Bookmarklet to remove text after ?
Posted: Sun Sep 08, 2019 3:00 pm
Bookmarklet to remove the text after a ? (question mark, or some character, for that matter) from links (rather then URL in URLbar) from a web page.
Becomes:
(The second, broken, understandably. But since you're the one causing it, you know it.)
For the URLbar, this looks to work:
But from "links" within a webpage?
A "remove redirects" bookmarklet already does something along those lines.
I had long known that remove redirects was "keying in" on certain items; like &, t.indexOf('&'), & I could have sworn I tried s/&/?/, & as I'm writing this, I'm thinking... let me try again, doing just that, & it partially does what I wanted.
And then if I simply append instead of replacing: ;%20j=t.indexOf('&');%20j=t.indexOf('?'); ...
Sometimes it just helps to walk away, then come back & write things out .
Code: Select all
https://addons.mozilla.org/firefox/downloads/file/3383315/noscript_security_suite-11.0.3-an+fx.xpi?src=featured
https://addons.palemoon.org/?component=download&id=AdvancedNightMode@Off.JustOff&version=1.0.9&hash=8659729bbf0142077b866646352b9198ea30d85dec811007b23b283f5b7fa236
Code: Select all
https://addons.mozilla.org/firefox/downloads/file/3383315/noscript_security_suite-11.0.3-an+fx.xpi
https://addons.palemoon.org/
For the URLbar, this looks to work:
Code: Select all
javascript:location.href = location.href.substring(0,location.href.indexOf("?"));
But from "links" within a webpage?
A "remove redirects" bookmarklet already does something along those lines.
Code: Select all
javascript:(function(){var%20k,x,t,i,j,p;%20for(k=0;x=document.links[k];k++){t=x.href.replace(/[%]3A/ig,':').replace(/[%]2f/ig,'/');i=t.lastIndexOf('http');if(i>0){%20t=t.substring(i);%20j=t.indexOf('&');;%20j=t.indexOf('?');%20if(j>0)t=t.substring(0,j);%20p=/https?\:\/\/[^\s]*[^.,;'">\s\)\]]/.exec(unescape(t));%20if(p)%20x.href=p[0];%20}%20else%20if%20(x.onmouseover&&x.onmouseout){x.onmouseover();%20if%20(window.status%20&&%20window.status.indexOf('://')!=-1)x.href=window.status;%20x.onmouseout();%20}%20x.onmouseover=null;%20x.onmouseout=null;%20}})();
And then if I simply append instead of replacing: ;%20j=t.indexOf('&');%20j=t.indexOf('?'); ...
Sometimes it just helps to walk away, then come back & write things out .