// ==UserScript== // @name Google Images direct link // @namespace http://lorentz // @description Add direct link to images and pages in google image search // @include http://images.google.*/images* // @include http://www.google.*/images* // @include http://www.google.*/search?* // @include http://www.google.*/imgres* // @version 3 // ==/UserScript== var parseUrl = function (url) { var qstr = url.split('?')[1]; var rawparams = qstr.split('&'); var par = new Array(); var i; for (i=0 ; i<rawparams.length ; i++){ var p = rawparams[i].split("="); par[p[0]] = p[1]; } return par; } if (parseUrl(window.location.href)["directLink"]){ var imglnk = document.getElementsByTagName('a')[2]; if (imglnk){ window.location.replace(imglnk.href) } } var getImageLinks = function (url){ var param = parseUrl(url); var links = new Object(); links.toImgHref = decodeURIComponent(param["imgurl"]); if (param["imgurl"] == undefined){ links.toImgHref = url+'&directLink=true'; } links.toPageHref = decodeURIComponent(param["imgrefurl"]); return links; } String.prototype.endsWith = function(str){ return ( this.lastIndexOf(str) + str.length ) == this.length; } var imgTable = document.getElementById('imgtb'); if (imgTable) { // legacy page (for Opera) var rows = imgTable.getElementsByTagName('tr'); for ( i=0 ; i < rows.length ; i+=2 ) { var imgCell = rows[i].getElementsByTagName('td'); var descCell = rows[i+1].getElementsByTagName('td'); for( j=0 ; j<imgCell.length ; j++ ) { var imageAnchor = imgCell[j].getElementsByTagName('a')[0]; var domainText = descCell[j].getElementsByTagName('cite')[0]; var links = getImageLinks(imageAnchor.href); if ( !domainText.innerHTML.endsWith('...') ){ domainText.innerHTML = '<a href="' + links.toPageHref + '">' + domainText.innerHTML + '/…<\a>'; } else { domainText.innerHTML = '<a href="' + links.toPageHref + '">' + domainText.innerHTML + '<\a>'; } imageAnchor.href = links.toImgHref; } } } else { // new page (for Firefox) var stopEvent = function(event){ event.stopPropagation() } var nodeHandler = function (event) { if(event.target.id!='rg_h')return ; var domain = document.getElementById('rg_hr'); var imageAnchor = document.getElementById('rg_hl'); var links = getImageLinks(imageAnchor.href); imageAnchor.href = links.toImgHref; imageAnchor.addEventListener("mousedown", stopEvent, false); if (domain.getElementsByTagName('a').length == 0) domain.innerHTML = '<a onmousedown="event.stopPropagation();" ' + 'style="color:green;" ' + 'href="' + links.toPageHref + '">' + domain.innerHTML + '/…</a>'; } document.addEventListener("DOMSubtreeModified", nodeHandler, false); }
Mozilla add on,User script,Grease Monkey Script, greasemonkey userscripts, updater userscripts mafia wars userscripts mafia wars autoplayer userscripts mafia wars wall userscripts scripts userscripts travian greasemonkey greasemonkey download greasemonkey facebook greasemonkey tutorial greasemonkey youtube greasemonkey travian greasemonkey chrome greasemonkey mafia wars greasemonkey mafia wars autoplayer
Saturday, October 29, 2011
Google Images direct link
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment