News for hackers. Stuff that matters.

Ask HN: Is there a way to stop Google hijacking the URL?

On many pages I visit now, clicking on a search result from google takes me to

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.

( 6 comments | 9 points | on HN )
Re:Ask HN: Is there a way to stop Google hijacking the URL? by zzo38computer on Monday June 15, 2020 @07:04PM (#23534100)
I just use this:

  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+]*$/,""));
  }
Re:Ask HN: Is there a way to stop Google hijacking the URL? by oriettaxx on Monday June 15, 2020 @07:02PM (#23534086)
yes, it's well known, and I hate it!

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 :)

Re:Ask HN: Is there a way to stop Google hijacking the URL? by t21u on Monday June 15, 2020 @08:40PM (#23534731)
There are some addons for Firefox to clear the urls. My advice is to not use Google.
Re:Ask HN: Is there a way to stop Google hijacking the URL? by throwaway29303 on Monday June 15, 2020 @06:34PM (#23533867)
I don't believe it is, your best bet right now is to change to another browser.
Re:Ask HN: Is there a way to stop Google hijacking the URL? by thePunisher on Monday June 15, 2020 @05:05PM (#23532970)
Answer: install Firefox.
Re:Ask HN: Is there a way to stop Google hijacking the URL? by garlicGum on Monday June 15, 2020 @05:25PM (#23533147)
You could use another search engine. Though, if you really want to use google you can open the article in another tab. That should give you the correct url.