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

In a browser without Javascript, this doesn't happen: the result URL is good old http://www.google.com/search?q=foo. How can I arrange to have these URLs (at least for copy-paste purposes) in Firefox and Chrome?

link|improve this question
3  
Didn't realise this doesn't happen in Opera – Eight Days of Malaise Dec 30 '11 at 3:17
This doesn't happen in my Firefox too – Manuel Bitto Dec 30 '11 at 12:10
6  
@Barfieldmv it's like you don't care about the other, valid reasons to turn it off. – kojiro Dec 30 '11 at 14:58
1  
I didn't see any reason posted why google uses this redirection. (my tone might be a bit off though since I'm a non native english speaker) I was trying to add an argument to keep it turned on. – Barfieldmv Dec 30 '11 at 15:07
3  
What they need to do is detect which mouse button triggered the mousedown event and only change the link to the redirect if event.button !== 2 (2 is right click). – David Murdoch Dec 30 '11 at 17:08
show 7 more comments
feedback

9 Answers

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

link|improve this answer
1  
The twitter one is working beautifully for me. Neither Facebook nor Google seem to work though... Using the latest version of Chrome. – Jeffrey Blake Dec 30 '11 at 15:01
This will always disable the rewriting, which means that sensitive information will not be removed from the referrer (see e.g. facebook.com/notes/facebook-engineering/…). Is there a way to copy the original URL to the clipboard when needed, but still rewrite it when the link is followed normally? – mark4o Jan 2 at 2:54
feedback

I have written a method which replaces the link-modifying rwt function with untouchable bogus.

By preventing Google from overwriting the rwt function, the link cannot be modified any more. 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 not care about 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.1
// ==/UserScript==

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

Google Chrome does not support Magic TLDs[source], 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"[source].

Chrome & Firefox 2+ - Link to source code / installation.

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

  • The mechanism is explained at this answer on Stack Overflow.
  • Additional details are available at the source code and description of Don't track me Google, a User script which fixes the URIs and hides the referrer.
link|improve this answer
1  
TL;DR Don't track me Google allows you to copy normal URLs, while hiding the referrer to the sites you're visiting :) – Rob W Jan 25 at 13:45
Don't track me google worked for me on Chrome! – drozzy Apr 3 at 3:29
feedback

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!

link|improve this answer
2  
As an aside, you can knock out all of the parameters for rwt except a in this case, because JavaScript doesn't care if the arguments to a function match the parameters or not. – Reid Dec 31 '11 at 3:41
good point. and FWIW, I suspect javascript:function rwt(){0}; might produce a similar result, even without the 0 -- perhaps worthy of asking over at codereview.stackexchange.com since this is both untested and slightly offtopic. – wehal3001 Dec 31 '11 at 10:07
feedback

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.

link|improve this answer
1  
That's an annoyingly twisty workaround, more complicated than doing the search in w3m. Is there a way to disable the redirection once and for all through a user script? – Gilles Dec 30 '11 at 2:46
1  
I just tried the only 2 scripts on www.userscripts.org that claim to do just that (the most recent one is dated Feb 2011). Neither of them works in Chrome or Firefox/Greasemonkey. – dnbrv Dec 30 '11 at 3:14
feedback

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;
    }
}
link|improve this answer
feedback

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.

link|improve this answer
feedback

Just paste this in your URL bar and press enter:

javascript:alert(unescape(prompt("URL","").match("url=([^&]*)")[1]))
link|improve this answer
feedback

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

link|improve this answer
1  
doesn't work. they give the same redirects to me – bizso09 Dec 30 '11 at 21:53
2  
The link google.com/m worked for me in IE8 but it still redirects. google.com/pda gives direct links when opened in Firefox 6 & IE 8 (versions I tested on) but not Chrome 16 – mvark Jan 1 at 5:08
feedback

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.

link|improve this answer
8  
yes, but clicking through the link and loading the entire website just so we can copy the darn URL is slow and .. unwieldy. – Jeff Atwood Dec 30 '11 at 10:34
3  
This does not work if the linked document is one that the browser opens in another application (e.g. PDF). – Complicated see bio Jan 1 at 12:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.