28

When logged in to Google, Google search results are redirected (for tracking purposes etc.). This is annoying, as it's not easy to copy/paste the URL without visiting the site. If there would be no redirect, I would just right-click the link in the search results and select "Copy link address". Now it is altered by some Google JavaScript code which monitors for the right-click.

How can this be disabled on Chrome? I think there used to be a Chrome extension for it, but seems to not be working anymore.

6
  • What is the purpose of your right-click?
    – Beniamin
    Aug 26, 2011 at 11:10
  • 4
    @Beniamin: as said in my question: "copy [paste] the URL". I just want to get the URL (e.g. for pasting in a report etc.) Aug 26, 2011 at 11:45
  • 4
    FYI: Just selecting the text with the cursor and pressing ctrl-c is not always an option, because google concatenates long URLs Aug 26, 2011 at 11:50
  • Ok. But when you right-click on link, it changes to google tracking link. So you won't get that link unless you open page, google will redirect you to desired page and you will have what you want.
    – Beniamin
    Aug 26, 2011 at 12:18
  • 2
    The question is exactly on how to avoid that. (there was some chrome extension before (doesn't work anymore), and some greasemonkey script for firefox, but last time I checked I had some issues with that. So saying "you won't get that link unless you open the page" doesn't make sense). Aug 26, 2011 at 12:43

7 Answers 7

8

Now when I know what you wanted, I wrote a little script which deletes onmousedown attribute from link.

Here it is:

// ==UserScript==
// @name           Delete onmousedown
// @namespace      google
// @include        http://www.google.*/*
// ==/UserScript==
var runOnce = function(){
    var items = document.querySelectorAll('li.g h3.r a');
    for(var i = 0, len = items.length; i< len; i++){
        items[i].removeAttribute('onmousedown');
    }
}
document.body.appendChild(document.createElement("script")).innerHTML = "("+runOnce+")()";

Save it as some file which ends with .user.js and drop it on Google Chrome and let me know if it helped.

PS. English is not my spoken language so sorry for misunderstanding you.

Edit: I added extra logic so it should work with Google Instant. Tell me if it works for you.

Edit: I rolled back to version "without" Google Instant support.

12
  • Thanks for the effort. I tried something similar, however, when I drag the script file over Chrome, it is opened in the browser, displaying the source code instead of installing the script. Aug 26, 2011 at 13:35
  • Try Ctrl+O to open the file. And are you sure you named it something like: google.user.js?
    – Beniamin
    Aug 26, 2011 at 14:09
  • And I've read that chrome window need to be maximized.
    – Beniamin
    Aug 26, 2011 at 14:16
  • Or install some greasemonkey-like extension in chrome. It will help you install scripts and greasemonkey scripts should work. For example: chrome.google.com/webstore/detail/…
    – Beniamin
    Aug 26, 2011 at 14:21
  • 1
    @Rabarberski, then you’ll have to stop using Google Instant.
    – Synetech
    Aug 29, 2011 at 8:16
5

Try to use "Undirect" Chrome extension.

It removes this tracking and redirection from google search results. Supports using google over both HTTP and HTTPS.

4

If you are using Firefox, you are lucky as the following answer applies to you. If you are using Chrome, you are much less lucky, see the bottom of this answer.

Greasemonkey fires the user scripts once the DOM is loaded, thus you don't need to implement a "DOM ready" listener.

Also you are on Firefox, so you can use some modern candy: for...of, let.

Here is the resulting Greasemonkey script:

// ==UserScript==
// @name        Remove Google redirects
// @namespace   google
// @description Remove redirects from Google Search result links.
// @include     https://www.google.*/*
// @version     1
// @grant       none
// ==/UserScript==

for (let element of document.querySelectorAll('#res .r > a')) {
    element.removeAttribute('onmousedown');
}

Thanks to the let there are no local declarations, therefore you don't need to enclose the above code in an IIFE.


For the unfortunate Chrome (Tampermonkey) users:

Links are not found at the time the script is executed, even though document.readyState === 'complete'… as a result you have to implement some loop with timer.

Therefore, you end up with:

// ==UserScript==
// @name        Remove Google redirects
// @namespace   google
// @description Remove redirects from Google Search result links.
// @include     https://www.google.*/*
// @version     1
// @grant       none
// ==/UserScript==

(function removeGoogleRedirects() {

    var links = document.querySelectorAll('#res .r > a');

    if (links.length === 0) {
        setTimeout(removeGoogleRedirects, 100);
        return;
    }

    for (var link of links) {
        link.removeAttribute('onmousedown');
    }

})();

Update October 2018:
Because of a markup change in the Google page, the h3.r needed to be changed to div.r.
I went farther and replaced h3.r > a with #res .r > a (replaced "tag.class" with just ".class", and added a parent as a security so that the selector is not too generic).

1
  • Taking the text of the Firefox script, and appending 'javascript: ' to the start of it, and then making a bookmarklet of it (a la bobobobo's answer) worked great for me.
    – ojchase
    May 29, 2019 at 22:02
1

I like @bobobobo's answer but unfortunately, it didn't work for me on Chromium Edge.

However, the following bookmarklet did work just fine:

javascript: const items = document.getElementsByTagName('a'); for (const i of items) { if ( i.onmousedown || i.getAttribute('data-ved') ) {i.removeAttribute("onmousedown");i.removeAttribute("data-ved")} }

I also remove the data-ved attribute as I suspect that is also involved with tracking.

0

Benjamin's script works for me if I change the selector to: li.g div.vsc h3.r a

Actually this user script looks like it would do the job:

Google Tracking-B-Gone for Greasemonkey

0
0

I find this scriptlet easiest to run. Copy and drag it to your bookmarks bar and click it before right clicking on any of the search result links.

javascript: var items = document.getElementsByTagName('a');  for( var i = 0 ; i < items.length; i++ )  if( items[i].className=='l' )  items[i].onmousedown = null ;

God these people are satan but I updated the script Beniamin gave, works as of the date of this post. User this trick to lightweight make sure page has loaded before stripping a elements of their mousedown events. Must use TamperMonkey to make this work.

// ==UserScript==
// @name           Delete onmousedown
// @namespace      google
// @version        0.1
// @description    Allows you to right click links on Google search results without having them mangled on you.
// @include          http://www.google.*/*
// ==/UserScript==
var tid = setInterval( function () {
    if ( document.readyState !== 'complete' ) return;

    var items = document.getElementsByTagName('a');

    var succeeded=false;
    for( var i = 0 ; i < items.length; i++ )
    {
      if( items[i].className=='l' )
      {
        if( items[i].onmousedown ) { succeeded=true; } // we stripped the urls
        items[i].onmousedown = null ;
      }
    }

    if( succeeded )  clearInterval( tid ); // stop invoking this routine when we succeeded.
}, 100 );
1
  • That bookmarklet didn't work for me on Chromium Edge. Mar 21, 2021 at 21:45
0

The Chrome Web Store extension Don't Track Me Google works perfectly for me in Chromium Edge. There is no more funny business from google.com with the URL changing when you click on it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .