MCPcopy Create free account
hub / github.com/hoothin/UserScripts / searchBaidu

Function searchBaidu

Picviewer CE+/dist.user.js:28837–28864  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28835 function searchImgByImg(imgSrc, imgCon, callBack, onError, noneResult, searchFrom){
28836 let srcs=[];
28837 var searchBaidu=function(){
28838 setSearchState(i18n("beginSearchImg","百度"),imgCon);
28839 getUrl("http://image.baidu.com/n/same?queryImageUrl="+encodeURIComponent(imgSrc)+"&isguessword=1&rn=30&fr=pc&pn=0&sort=size", function(d){
28840 let baiduJson;
28841 try{
28842 baiduJson=JSON.parse(d.responseText);
28843 }catch(e){
28844 setSearchState(i18n("findNoPic"),imgCon);
28845 setTimeout(function(){
28846 setSearchState("",imgCon);
28847 },2000);
28848 searchNext();
28849 return;
28850 }
28851 if(baiduJson.data[0]){
28852 srcs=[];
28853 for(let imgData of baiduJson.data){
28854 if(srcs.length>2)break;
28855 srcs.push(imgData.objURL);
28856 }
28857 setSearchState(i18n("findOverBeginLoad",["百度",srcs.length]),imgCon);
28858 callBackFun(srcs);
28859 }else{
28860 searchNext();
28861 return;
28862 }
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){

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