Google Images direct link fix

adds a direct link for the image.

目前为 2019-11-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Google Images direct link fix
  3. // @description adds a direct link for the image.
  4. // @version 1
  5. // @grant none
  6. // @include https://www.google.com/search?q=*
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
  8. // @namespace https://greasyfork.org/users/11231
  9. // ==/UserScript==
  10.  
  11.  
  12. const srcX = 'https://www.shareicon.net/data/32x32/2016/02/13/718320_camera_512x512.png';
  13. const styleX = 'left: -167px;position: relative;filter: invert(100%);z-index: 1;top: 3px;';
  14. var tar, x;
  15.  
  16. $( window ).on( "load", function () {
  17. tar = $('div.tvh9oe:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > a:nth-child(1) > img:nth-child(1)');
  18. x = $(tar).attr('src');
  19. $('.fwCBrd').append('<a id="aTheIMG" href="'+x+'" title="Open image in new tab"> <img src="'+srcX+'" href="'+x+'" target="_blank" style="'+styleX+'" ></img></a>');
  20. $('.rg_i.Q4LuWd.tx8vtf').each( function ( i, obj )
  21. {
  22. $(obj).click( function () {
  23. theWork();
  24. });
  25. });
  26. });
  27.  
  28.  
  29. function theWork() {
  30. jQuery.ajaxSetup( { async: false } );
  31. $('#aTheIMG').remove();
  32. setTimeout( function ()
  33. {
  34. if (!$('div.tvh9oe:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > a:nth-child(1) > img:nth-child(1)').attr('src').match("^https://encrypted-tbn") ) {
  35. tar = $('div.tvh9oe:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > a:nth-child(1) > img:nth-child(1)');
  36. x = $(tar).attr('src');
  37. $('.fwCBrd').append('<a id="aTheIMG" href="'+x+'" title="Open image in new tab"> <img src="'+srcX+'" href="'+x+'" target="_blank" style="'+styleX+'" ></img></a>');
  38. }
  39. else{ }
  40. x = '';
  41. }, 2000 );
  42. }