9 points · by anigbrowl · 6y ago · 6 comments
https://someurl.tld/page-I-want/#:~:text=Text%20I%20never%20asked%20for
where the appended portion is the text fragment that shows up in Google's search result under the URL. It's incredibly annoying as I'm having to suddenly hand-sanitize every URL if I get it from Google. I use other search engines like DDG where possible but it's not always possible or practical.
let p=document.evaluate("//a",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
var w,x;
for(var i=0;i<p.snapshotLength;i++) {
w=p.snapshotItem(i);
x=w.getAttribute("href");
x=x.replace(/^\/url\?q=([^&]*)&.*$/,(y,z)=>unescape(z));
w.setAttribute("href",x.replace(/[?&]?sa=[A-Z]&ved=[-A-Za-z/._0-9+]*$/,""));
}Get rid of that s... with https://github.com/palant/searchlinkfix or similar: every time I install it I have to search pretty hard for that plugin :)