Greasy Fork is available in English.
Adds a direct button link for the image.
当前为
// ==UserScript==
// @name Google Images direct link fix
// @description Adds a direct button link for the image.
// @version 1.6.3b
// @grant none
// @include https://www.google.tld/*tbm=isch*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @namespace http://greasyfork.icu/users/11231
// ==/UserScript==
var xurl, progressBar, xIMG, xPlaceholder, xCurrentClass, xPos;
$(window).on("load", function() {
setTimeout(function() { Checker(); }, 900);
$(window).click(function(e) {
if ( $(e.target).prop("tagName") == 'IMG' ) {
//alert('IMG clicked');
setTimeout(function() {
Checker();
}, 550);
}
});
$(document).unbind("keypress.key37");
$(document).unbind("keypress.key39");
document.onkeydown = function(e) {
if ( $('body').attr('style').includes('overscroll-behavior-y: none;') ) {
switch (e.keyCode) {
case 37:
//alert('left');
Checker();
break;
case 39:
//alert('right');
Checker();
break;
}
}
}
});
function Checker() { setTimeout(function() {
$("#aTheIMG").remove();
$( '.tvh9oe' ).each(function (index, obj) {
if ( $( obj ).css('display') != 'none' ) {
progressBar = $( obj ).find('.k7O2sd');
if ( $(progressBar).css('display') != 'none' )
{
Checker();
return true;
} else {
theWork(obj);
}
}
})
}, 500); }
function theWork(obj) {
xIMG = $(obj).find('img');
xurl = $(xIMG).attr("src");
xPlaceholder = $(obj).find('.fwCBrd'); //$('div.irc_c.immersive-container>div.irc_mmc > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)');
xCurrentClass = 'dJcyOc';
xPos = '130px;';
if (!$("#aTheIMG").length) {
$(xPlaceholder).append('<a class="'+xCurrentClass+'" id="aTheIMG" role="button" style="right:'+xPos+'" href="'+xurl+'" title="Open image in new tab" target="_blank" ><span>View image</span></a>');
}
if ( $(xurl).attr("href").startsWith('data:image/') ) {
$("#aTheIMG").attr("href") = $("#aTheIMG").parent().parent().parent().parent().parent().find('.i30052').find('img').attr('src');
}
}
$( '<style>' ).text(' \
#aTheIMG { \
position: relative; \
z-index: 1; \
top: 0px; \
margin-left: -91px; \
text-decoration: none !important; \
} \
#aTheIMG > span {padding-left: 3px;} \
#aTheIMG:hover { \
filter: brightness(1.3); \
} \
div.tvh9oe:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(1) > a:nth-child(1) {pointer-events: none !important;} \
div.tvh9oe:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(1) {pointer-events: all !important;} \
' ).appendTo( document.head );