226

In Google search results, in Firefox or Chrome, I get URLs that go through Google and not directly to the target site. For example, at

http://www.google.com/search?q=foo

the first result is

http://www.google.com/url?sa=t&rct=j&q=foo&source=web&cd=1&ved=0CDIQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFoobar&ei=gBj9TtDpAcXT8QPI_4GdAQ&usg=AFQjCNH1J2pXAETcCKA7T6svhOKIRNyojg

I don't really care that Google is tracking what I click, and I don't really care about the extra indirection when I click on a result (though both are concerns). But I find it annoying that I can't copy-paste a result by simply right-clicking on a link and choosing “copy link address” (I want to get the real result, not Google's redirection to it).

I want to have the direct URL http://en.wikipedia.org/wiki/Foobar, at least for copy-paste purposes, in Firefox and Chrome.

Google's behavior changed several times:

  • When I asked this question, in a browser without Javascript, you got direct URLs in results: http://en.wikipedia.org/wiki/Foobar. The indirection was added via Javascript.
  • Some time later, Google changed to provide indirect results in all browsers.
  • Since 2012-09-04, it seems that:

    • In a browser without JS, the HTML still contains indirect results.
    • In a browser with JS support (at least in recent Firefox and Chrome), the HTML contains a direct result in the href attribute, but there is an onmousedown attribute that invokes the rwt function which does rewrite the link. You see the direct link when you hover, but you get an indirect link like the one above when you click or copy-paste.

12 Answers12

104

Author's note (July 2016): The answer below was written in 2011, and still works in Google Search. I have since published new extensions that use a different method to remove the search result indirection and they work on even more Google sites as well as on mobile.

TL;DR: Don't track me Google is an extension I made that allows you to copy normal URLs, while hiding the referrer to the sites you're visiting.

Installation

  • "Don't track me Google" from the Internet Archive of Userscripts.org. (works in Google search only and is no longer updated).

Explanation

I have written a method that replaces the link-modifying rwt function with a bogus function that can't be touched by Google.

By preventing Google from overwriting the rwt function, the link can no longer be modified. This method depends on the Object.defineProperty method (Firefox 4+ and Chrome 5+). The fallback requires Firefox 2+ and Chrome 1+.

Firefox 2+

If you only want to remove the link-modifying behaviour, and don't mind showing your search queries through the referrer, this GreaseMonkey script can be used:
(very non-strict @include rules using wildcards and the Magic TLD)

// ==UserScript==
// @name           Don't track me Google
// @namespace      Rob W
// @include        http://*.google.tld/*
// @include        https://*.google.tld/*
// @version        1.2
// @grant          none
// ==/UserScript==

"use strict"; if (Object.defineProperty) { Object.defineProperty(unsafeWindow,"rwt", {value: function(){return !0;}, writable: false }); } else { unsafeWindow.defineGetter('rwt',function(){return function(){return !0}}); }

Google Chrome does not support Magic TLDs, so the closest you can get is *://*.google.com/* (repeat the rule, replace .com with other supported Google TLDs).

In Chrome, scripts have to be injected in the form of a <script> tag, because Content scripts are executed in an "isolated world".

Chrome & Firefox 2+ - Link to source code

On January 21st, 2012, I published an extended version, which includes a referrer-hiding method, so that others cannot see your search query. This greatly improves your privacy.

2016 Update: Referrer hiding is no longer needed in modern browsers because of the referrer policy, which only shows the domain in the Referer header)

Rubén - Volunteer Moderator -
  • 46,305
  • 18
  • 101
  • 297
Rob W
  • 1,436
  • 4
  • 14
  • 17
49

See if the userscript found here for Google search works for you. I have been using it for a while now, and it's been working more often than not for me. enter image description here

Edit: Here is an addon for Firefox: Google search link fix

John C
  • 9,378
  • 2
  • 36
  • 48
Leo
  • 809
  • 5
  • 4
24

Appears the rwt function is invoked upon onmousedown, and thereby rewriting the href. If we could override this behaviour, then we should be set.

In firefox I inserted the following JavaScript into a bookmarklet which can then be executed anytime I wish to prevent the (slighly annoying) link-rewriting on a given Google SERP:

javascript:function rwt(a,f,g,l,m,h,c,n,i){return a};

Edit: Great to see that the userscript @Rob has created and included in his reply takes advantage of this snippet, highly recommended!

wehal3001
  • 351
  • 1
  • 4
13

I use the Firefox Redirect Remover add-on.

After this is installed, right click on a redirected URL in the browser gives an option to copy cleaned URL.

Alex
  • 22,820
  • 12
  • 83
  • 106
Chaim Geretz
  • 131
  • 3
13

Solutions without any browser extension or JavaScript

If you want to keep Google's redirection and only selectively copy & paste some URLs here are other possibilities which do not require any change in the browser. Unfortunately while the solutions work in Firefox they do not seem to work in Chrome and Internet Explorer any more.

Solution with keyboard (tested in Linux and Windows):
Navigate to the desired search result link:

  • in Firefox: use Tab and Shift+Tab to navigate between links;
  • in Chrome: press Tab to move the focus into the page, then Up and Down to navigate between search results. (“Copy Link Address” not available if you reach the search result with Tab.)

Then press the context menu key or Shift+F10 and select “Copy Link Location” / “Copy Link Address” (hot key: A in English Firefox, E in English Chrome).

Making the keyboard navigation faster using a mouse:
For faster navigation in Firefox using the mouse, you can click a white-space or an non-link text before the link and then press Tab. You can also switch to the caret navigation using F7 and use cursor keys or Tab.

Solution with mouse only:
In some browsers and environments (e.g. Firefox on Windows) it is possible to press the right mouse button outside of the link, move the mouse cursor while keeping the button still pressed and then release the button on the link to invoke the context menu.

Explanation:
The described ways avoid clicking the mouse on the link and invoking the onmousedown event which causes the conversion of the original URL. Note that if you already clicked the link, you must reload the search results page (F5) to get the original URL back.

11

For short URLs, you can just copy the green text under the title as that's the same URL just without protocol lead.

For long URLs (those that have ellipsis in the green text), you either need a script or use a semi-complex workaround.

A script is necessary because Google modifies links with its own script on mouse click. If you hover over a results link, you'll notice in the status bar that it displays properly but it changes upon your interaction with it.

The workaround consists of opening Developer Tools in Chrome or FireBug in Firefox, selecting the link with element inspector, and copying the content of href attribute. This requires 2 windows to be open, so it's not the most convenient workflow on smaller screens.

You could've done it with View source but Google Instant sometimes results in strange source. Also, in order to find the link in the source you must remember its title as there's no visual selector as in Developer Tools & FireBug.

dnbrv
  • 3,900
  • 2
  • 20
  • 23
11

Extensions for Chrome and Firefox:

Sk8erPeter
  • 397
  • 1
  • 3
  • 10
10

Using Safari, it is easy to make your own extension to handle this. I used Develop > Show Extension Builder and added "www.google.com" as an Allowed Domain and then the following script as an End Script in the Injected Extension Content section:

if (window.top === window) {
    var els = document.getElementsByClassName("l");
    for (var i in els) {
        els[i].onmousedown = undefined;
    }
}
Alex
  • 22,820
  • 12
  • 83
  • 106
Flinn
  • 101
  • 2
8

I am also often annoyed by this. So my simple solution is to use the mobile version of Google's site:

http://www.google.com/pda
or
http://www.google.com/m (This link does not work in IE.)

These sites will give you the URLs that go directly to the target sites, no more redirection.

Please note that the search results from these sites will be a little different from the normal ones ( by using google.com ).

7

Just paste this in your URL bar and press enter:

javascript:alert(unescape(prompt("URL","").match("url=([^&]*)")[1]))
Alex
  • 22,820
  • 12
  • 83
  • 106
user22610
  • 171
  • 2
4

I have the same problem.

There's an online tool that I find useful here:

Online Tool - Convert google link to direct link for easier copying and pasting

Just bookmark that page and then paste 'horrific URLs' into the form to convert them into a normal links.

JW01
  • 157
  • 1
  • 5
1

For shorter links, selecting the green text is fine. For longer links with an ellipsis, I tend to just open the link and grab the URL from the address/awesome/omnibar.

AGMLego
  • 27
  • 1