// ==UserScript== // @name Google Images direct link fix // @description Adds a direct button link for the image. // @version 1.6.0b // @grant none // @include https://www.google.com/search?* // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js // @namespace https://greasyfork.org/users/11231 // @downloadURL none // ==/UserScript== var xurl, progressBar, xIMG, xPlaceholder, xCurrentClass, xPos; $(window).on("load", function() { setTimeout(function() { Checker(); }, 1000); $(window).click(function(e) { if ( $(e.target).prop("tagName") == 'IMG' ) { $("#aTheIMG").remove(); setTimeout(function() { Checker(); }, 500); } }); }); function Checker() { setTimeout(function() { $("#aTheIMG").remove(); $( '#irc-ss>div' ).each(function (index, obj) { if ( $( obj ).css('display') != 'none' ) { progressBar = $( obj ).find('.jfk-progressBar-blocking'); if ( $(progressBar).css('display') != 'none' ) { Checker(); return true; } else { theWork(obj); } } }); }, 300); } function theWork(obj) { xIMG = $(obj).find('img'); xurl = $(xIMG).attr("src"); xPlaceholder = $('.hZC4Sd > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)'); xCurrentClass = $('.hZC4Sd > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > a:nth-child(2)').attr('class'); xPos = '130px;'; if (!$("#aTheIMG").length) { $(xPlaceholder).append('View image'); } if ( $(xurl).attr("href").startsWith('data:image/') ) { $("#aTheIMG").attr("href") = $("#aTheIMG").parent().parent().parent().parent().parent().find('.i30052').find('img').attr('src'); } } $( '