// ==UserScript==
// @name Google Images direct link fix
// @description Adds a direct button link for the image.
// @version 1.5.1b
// @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() {
$("#aTheIMG").remove();
Checker();
$(window).click(function(e) {
if ( $(e.target).prop("tagName") == 'IMG' ) {
$("#aTheIMG").remove();
setTimeout(function() {
Checker();
}, 500);
}
});
});
function Checker() { setTimeout(function() {
progressBar = $('html>body#gsr.srp.tbo.vasq>div#main>div#cnt>div#rcnt>div.col>div#center_col>div#res.med>div#search>div>div#rso>div#isr_mc.irc-vo>div>div#irc_bg.irc-unt>div#irc_cc>div#irc-ss.jKbJyf>div.irc_c.i8187.immersive-container>div.irc_t.i30052>div.irc_pgb.jfk-progressBar-blocking');
if ( $(progressBar).css('display') != 'none' ) {
Checker();
return true;
} else {
theWork();
}
}, 500); }
function theWork() { setTimeout(function() {
$('#irc-ss>div').each(function (index, value) {
if( $(value).css('display') != 'none' ) {
xIMG = $(value).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.endsWith('jpg') == false && xurl.endsWith('png') == false && xurl.endsWith('gif') == false ) {
$("#aTheIMG").remove();
xIMG = $('div.irc_c:nth-child(3) > div:nth-child(1) > div:nth-child(4) > div:nth-child(2) > a:nth-child(1) > img:nth-child(1)');
xurl = $(xIMG).attr("src")
$(xPlaceholder).append('View image');
}
if ( $("#aTheIMG").attr('href').endsWith('undefined') ) {
//alert('undefined ~ trying..');
$("#aTheIMG").remove();
xIMG = $('html>body#gsr.srp.tbo.vasq>div#main>div#cnt>div#rcnt>div.col>div#center_col>div#res.med>div#search>div>div#rso>div#isr_mc.irc-vo>div>div#irc_bg.irc-unt>div#irc_cc>div#irc-ss.jKbJyf>div.irc_c.i8187.immersive-container>div.irc_t.i30052>div.irc_mic>div.irc_mimg.irc_hic>a.irc_mil.i3597>div.KkFss>img.irc_mi');
xurl = $(xIMG).attr("src")
$(xPlaceholder).append('View image');
}
}
});
}, 500); }
$( '