You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
4.3 KiB
1 lines
4.3 KiB
!function(n){var e,r,s;for(var t in s={API_SERVER:"//zhannei-dm.csdn.net/",API_BAIDU_SERVER:"https://gsp0.baidu.com/yrwHcjSl0MgCo2Kml5_Y_D3/",API_KEYWORD_GET_URL:"recommend/baidu_keyword",API_BAIDU_CACHE_URL:"recommend/baidu_zhannei_search",API_STATISTIC_SERVER:"//statistic.csdn.net/",SUB_DOMAIN:["blog.csdn.net","download.csdn.net","bbs.csdn.net","edu.csdn.net","geek.csdn.net"],keyword:"",autorun:!1,install:!0,baiduSearchAPPID:"10742016945123576423",debug:{active:!1,currentUrl:"http://blog.csdn.net/dqcfkyqdxym3f8rb0/article/details/66666666",API_SERVER:"http://devpassport.csdn.net/"}})"API_SERVER"!=t&&"API_STATISTIC_SERVER"!=t&&"API_BAIDU_SERVER"!=t&&-1<t.indexOf("API")&&(s.debug.active?s[t]=s.debug.API_SERVER+s[t]:s[t]=s.API_SERVER+s[t]);for(i in"http:"==window.location.protocol&&(s.API_BAIDU_SERVER="http://zhannei.baidu.com/"),r={getRequest:function(e,t){var a,n,c,r={};switch(t=t||"search"){case"hash":a=e.split("#")[1]||"";break;case"search":a=(a=e.split("?")[1]||"").split("#")[0]}for(c=a.split("&"),n=0;n<c.length;n++)r[c[n].split("=")[0]]=decodeURI(c[n].split("=")[1]);return r},parseCFG:function(){if(document.getElementsByTagName("meta")["csdn-baidu-search"]){var e=JSON.parse(document.getElementsByTagName("meta")["csdn-baidu-search"].content);s.keyword=e.keyword||s.keyword,s.autorun="true"==e.autorun,s.install="false"!=e.install,console.log("init cfg=",s)}},autorun:function(){console.log("abc:",s.keyword),""!=s.keyword?csdn.baiduSearch(s.keyword,function(e){csdn.baiduCacheBuild(s.keyword,e)}):csdn.baiduKeywordGet(function(t){csdn.baiduSearch(t,function(e){csdn.baiduCacheBuild(t,e)})})},trackByGraylog:function(e,t){},filterData:function(e){var t=[];for(var a in e){var n=e[a];if(!/^((https|http)?:\/\/)(.*)download.csdn.net[^\s]+/.test(n.linkUrl)||/^((https|http)?:\/\/)download.csdn.net\/download\/[^\s]+/.test(n.linkUrl)){var c=n.title;(c=(c=(c=(c=c.replace("-<em>CSDN</em>下载","")).replace("- <em>CSDN</em>下载","")).replace("-CSDN下载","")).replace(" - 下载频道 - CSDN.NET",""))!==n.title&&console.log("title update:",n.title,c),n.title=c,t.push(n)}else console.log("delete:",n.linkUrl)}return t},removeCurrent:function(e){var t=window.location.href.split("#")[0],a=[];for(var n in e){var c=e[n];c.linkUrl.split("?")[0]!=t&&a.push(c)}return a}},e={baiduSearchInstall:function(e){var t=document.createElement("script");t.type="text/javascript",t.charset="utf-8",t.src=s.API_BAIDU_SERVER+"api/customsearch/apiaccept?sid="+s.baiduSearchAPPID+"&v=2.0&callback=csdn.afterBaiduSearchInit",t.onerror=function(){r.trackByGraylog("baidu_search_error",{step:"install"}),console.error("baiduSearch install error!"),"function"==typeof csdn.baiduSearchInstallError&&csdn.baiduSearchInstallError()};var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(t,a)},afterBaiduSearchInit:function(){csdn.cse=new BCse.Search(s.baiduSearchAPPID),"function"!=typeof csdn.afterCasInit?s.autorun&&r.autorun():csdn.afterCasInit(s.keyword,csdn.cse)},baiduSearch:function(a,n,e,t){if(console.log("baiduSearch :",arguments),e)if(-1<e.indexOf("/"))console.log("二级域名搜索",e.split("/")[1]),csdn.cse.setSearchRange(3,[e.split("/")[1]]);else{var c=e.split(".csdn.net");1<c.length&&(e=c[0]),csdn.cse.setSearchRange(2,[e+".csdn.net"])}else csdn.cse.setSearchRange(2,s.SUB_DOMAIN);t||(t=1),csdn.cse.getResult(a,function(e){r.trackByGraylog("baidu_search_success"),e=r.filterData(e),console.log("上报数据:",e),csdn.baiduCacheBuild(a,e);var t=r.removeCurrent(e);console.log("展现数据:",t),n(t)},t)},baiduKeywordGet:function(t){n.ajax({url:s.API_KEYWORD_GET_URL,type:"GET",contentType:"text/plain;charset=UTF-8",data:{url:s.debug.active?s.debug.currentUrl:window.location.href,result_size:1},success:function(e){console.log("aaaaaaaaaaaa",e),0<e.length&&(s.debug.active&&(console.log("baiduKeywordGet()",e),console.log("nextStep:",t)),t(e[0].keyword))}})},baiduCacheBuild:function(e,t){var a="?keyword="+e;"2"==csdn.cse.param.ct&&-1==csdn.cse.param.cc.indexOf("%26")?a+="&domain_type="+csdn.cse.param.cc.split(".csdn.net")[0]:"3"==csdn.cse.param.ct&&(a+="&url_type="+csdn.cse.param.cc),n.ajax({url:s.API_BAIDU_CACHE_URL+a,type:"POST",dataType:"text",contentType:"text/plain;charset=UTF-8",data:JSON.stringify(t)})},baiduSearchCFG:s},void 0===window.csdn&&(window.csdn={}),e)window.csdn[i]=e[i];r.parseCFG(),s.install&&csdn.baiduSearchInstall()}(jQuery); |