Search with google image again cause fuck google lens, SHIFT + Left click to search
当前为
// ==UserScript==
// @name Search with google image fix
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Search with google image again cause fuck google lens, SHIFT + Left click to search
// @author You
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
(function() {
function srcHasHostInformation(url) {
var res = url.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
return (res !== null)
}
function addHostInformationIfNeeded(src) {
if (!srcHasHostInformation(src)) {
if (src[0] != "/") {
src = "/" + src ;
}
return window.location.hostname + src;
}
return src;
}
$(document).mousedown(function(event) {
if ($(event.target).prop("tagName").toUpperCase() == "IMG"){
if (window.event.shiftKey ){
var origSrc = addHostInformationIfNeeded($(event.target).attr("src"));
console.log("orig: " + origSrc);
var src = "https://www.google.com/searchbyimage?image_url=" + origSrc;
window.open(src);
}
}
});
})();