MCPcopy
hub / github.com/hoothin/UserScripts / searchGoogle

Function searchGoogle

Picviewer CE+/Picviewer CE+.user.js:28865–28889  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28863 }, onError);
28864 };
28865 var searchGoogle=function(){
28866 setSearchState(i18n("beginSearchImg","Google"),imgCon);
28867 getUrl("https://www.google.com/searchbyimage?safe=off&image_url="+encodeURIComponent(imgSrc), function(d){
28868 let googleHtml=document.implementation.createHTMLDocument('');
28869 googleHtml.documentElement.innerHTML = d.responseText;
28870 let sizeUrl=googleHtml.querySelector("div.card-section>div>div>span.gl>a");
28871 if(sizeUrl){
28872 getUrl("https://www.google.com"+sizeUrl.getAttribute("href"), function(d){
28873 googleHtml.documentElement.innerHTML = d.responseText;
28874 let imgs=googleHtml.querySelectorAll("div.rg_meta");
28875 if(imgs.length==0){searchNext();return;}
28876 srcs=[];
28877 for(var i=0;i<imgs.length;i++){
28878 if(srcs.length>2)break;
28879 let jsonData=JSON.parse(imgs[i].innerHTML);
28880 srcs.push(jsonData.ou);
28881 }
28882 setSearchState(i18n("findOverBeginLoad",["Google",srcs.length]),imgCon);
28883 callBackFun(srcs);
28884 }, onError);
28885 }else{
28886 searchNext();
28887 }
28888 }, onError);
28889 };
28890 var searchTineye=function(){
28891 setSearchState(i18n("beginSearchImg","Tineye"),imgCon);
28892 getUrl("https://www.tineye.com/search?url="+encodeURIComponent(imgSrc)+"&sort=size", function(d){

Callers 1

switchSearchFunction · 0.70

Calls 5

setSearchStateFunction · 0.70
i18nFunction · 0.70
getUrlFunction · 0.70
searchNextFunction · 0.70
callBackFunFunction · 0.70

Tested by

no test coverage detected