<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


HOW TO make Google skip redirection step on clicking search result


There have been times when I wanted to just copy the URL of a site mentioned in a Google search result without having to go to the website & then copying it from the address bar.


However when I right click & copy the URL, this is how the address typically looks -
http://www.google.com/url?sa=t&rct=j&q=menu_elements_selector
&source=web&cd=5&cad=rja&ved=0CEIQFjAE
&url=http%3A%2F%2Fapi.jquery.com%2Fattribute-ends-with-selector%2F
&ei=LdQ8UKOkJYPTrQfn0IHIDA
&usg=AFQjCNFmICOvDtxuImTTeXY3pCDQNW6yVQ

(URL broken with new lines for readability & to preserve formatting)

Digging into the source code reveals that there is a mousedown event that fires up when the link is accessed & re-creates the HREF of that anchor tag so that you have to pass through a quick additional Google step before you can reach the search result site

I wished there was a bookmarklet that could stop Google from mangling the URL and skip the redirection step. Guess what, there is bookmarklet Zap Events that can remove all JavaScript events assigned to elements in a web page.

It only zaps the following 4 events - "mouseover","mouseout","unload","resize". I tweaked the code a bit to include the "mousedown" event as well -

javascript:(function(){var%20H=^
["mouseover","mouseout","unload","resize","mousedown"],^
o=window.opera;%20if(document.addEventListener/*MOZ*/&&!o)^
%20for(j%20in%20H)^
{document.addEventListener(H[j],function(e)^
{e.stopPropagation();},true);}^
%20else%20^
if(window.captureEvents/*NS4*/&&!o)%20{%20^
document.captureEvents(-1/*ALL*/);^
for(j%20in%20H)^
{window["on"+H[j]]=null;}}%20else/*IE*/%20{function%20R(N)^
{var%20i,x;for(j%20in%20H)^
if(N["on"+H[j]]/*NOT%20TEXTNODE*/)N["on"+H[j]]=null;^
for(i=0;x=N.childNodes[i];++i)R(x);}R(document);}})()

(remove  ^ & newline character when you're using this code)

With this modified bookmarklet, I can now copy the actual URL in a Google Search result.

Update 5/Sept/12: Found that this redirection feature bugs a lot of people. This thread on the StackExchange WebApps forum has simpler bookmarklet code to address this issue:

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

Related:


Labels: ,

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment