🏠 Home 

Google Images direct links

Add direct links to the picture and the page link to the Google Image Search r###lts.


Install this script?
  1. // ==UserScript==
  2. ///////////////// In case it fails to update in TamperMonkey, visit https://github.com/svArtist/Google-Images-Direct-Links/raw/master/googleImagesDirectLinks.user.js directly ////////
  3. // @name Google Images direct links
  4. // @version 1.5
  5. // @description Add direct links to the picture and the page link to the Google Image Search r###lts.
  6. // @namespace Google
  7. // @author Benjamin Philipp <dev [at - please don't spam] benjamin-philipp.com>
  8. // @include /^https?:\/\/(www\.)*google\.[a-z\.]{2,5}\/search.*tbm=isch.*/
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
  10. // @run-at document-body
  11. // @grant GM_xmlhttpRequest
  12. // @connect *
  13. // ==/UserScript==
  14. var updateInterval = 1000;
  15. var maxtries = 10;
  16. var idle = true;
  17. function updatePage()
  18. {
  19. if($("#directLinkStyles").length<=0){
  20. $("head").append("\
  21. <style id='directLinkStyles'>\
  22. .linkToTarget{\
  23. box-shadow: 3px 5px 10px rgba(0,0,0,0.5); \
  24. cursor: default;\
  25. position: absolute; \
  26. right:0; top:0; \
  27. opacity: 0; \
  28. background-color: rgba(255,255,255,0.5);\
  29. transition: background-color 0.5s, opacity 0.5s \
  30. }\
  31. .failed .linkToTarget span{\
  32. color: rgba(230,100,100, 0.7)!important; \
  33. }\
  34. a:hover .linkToTarget{\
  35. opacity: 0.6; \
  36. }\
  37. .linksdone:hover .linkToTarget, .linkToTarget:hover{\
  38. opacity: 1; \
  39. background-color: rgba(255,255,255,1);\
  40. }\
  41. .linksdone:hover .linkToTarget{\
  42. cursor: pointer;\
  43. }\
  44. .linkToTargetLink, .linkToTarget>span{\
  45. color: rgba(200,200,200, 0.7)!important; \
  46. padding: 3px 10px; \
  47. font-size: 28pt; \
  48. display: block; \
  49. font-weight: bold; \
  50. text-decoration: none;\
  51. transition: color 0.5s, font-size 0.5s, padding 0.5s; \
  52. }\
  53. .linkToTargetLink:hover{\
  54. color: rgba(155,177,233, 1)!important; \
  55. padding:8px 20px; \
  56. font-size: 36pt; \
  57. } \
  58. </style>");
  59. }
  60. $(".rg_di.rg_bx a.rg_l:not(.linksdone)").each(function(){
  61. // console.log(this);
  62. var tp = this;
  63. var tppar = $(tp).parent();
  64. var imin = tp.href.indexOf("imgurl=");
  65. if(imin<0)
  66. {
  67. $(tp).attr("resTries", $(tp).attr("resTries")?$(tp).attr("resTries")*1+1:1);
  68. if($(tp).attr("resTries")*1>=maxtries){
  69. console.log("This Link won't come up with a good fragment: " + $(tp).find("img")[0].src);
  70. $(tp).addClass("linksdone");
  71. $(tp).addClass("failed");
  72. $(tp).find(".linkToTarget span").html("x");
  73. return true;
  74. }
  75. if(!$(tp).hasClass("linkswait")){
  76. $(tp).addClass("linkswait");
  77. $(tp).append("<div class='linkToTarget temp'><span>...</span></div>");
  78. }
  79. // console.log("Not ready");
  80. return true;
  81. }
  82. var linkconts = tp.href.substr(imin+7);
  83. var piclink = linkconts.substr(0,linkconts.indexOf("&"));
  84. var reflink = linkconts.substr(linkconts.indexOf("imgrefurl=")+10);
  85. reflink = decodeURIComponent(reflink.substr(0, reflink.indexOf("&")));
  86. piclink = decodeURIComponent(piclink);
  87. $(tp).find(".linkToTarget.temp").remove();
  88. $(tp).append("<div class='linkToTarget'><a class='linkToTargetLink' href='" + piclink + "'>+</a></div>");
  89. $(tp).removeClass("linkswait");
  90. $(tp).addClass("linksdone");
  91. var urilink = $(tppar).find(".rg_ilmbg")[0];
  92. $(urilink).html("<a style='display: block; color: #fff; text-decoration: none;' href='" + reflink + "'>" + urilink.innerHTML + "</a>");
  93. $(tp).find(".linkToTargetLink").add(urilink).click(function(e){
  94. e.stopImmediatePropagation();
  95. });
  96. });
  97. }
  98. setInterval(updatePage, updateInterval);
  99. updatePage();