Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Created November 8, 2012 12:40
Show Gist options
  • Save iambibhas/4038568 to your computer and use it in GitHub Desktop.
Save iambibhas/4038568 to your computer and use it in GitHub Desktop.
Google Image Search Direct Link to Image
// ==UserScript==
// @name Google Image Direct Link
// @namespace http://userscripts.org/users/192333
// @include http*://*.google.co.in/search*
// @version 1
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_info
// ==/UserScript==
si = window.setInterval(clearanchors, 2000);
function clearanchors(){
anchors = document.getElementsByClassName('rg_l')
for(i=0;i<anchors.length;i++){
url = anchors[i].getAttribute('href');
var patt = /imgurl\=[^&]*/g;
regstr = patt.exec(url);
if(regstr != null && regstr.length > 0){
str = regstr[0].replace("imgurl=", "");
anchors[i].setAttribute('href', str);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment