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 line
3.9 KiB
1 line
3.9 KiB
5 years ago
|
!function(a){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 n,a,c,r={};switch(t=t||"search"){case"hash":n=e.split("#")[1]||"";break;case"search":n=(n=e.split("?")[1]||"").split("#")[0]}for(c=n.split("&"),a=0;a<c.length;a++)r[c[a].split("=")[0]]=decodeURI(c[a].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}},autorun:function(){""!=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 n in e){var a=e[n];if(!/^((https|http)?:\/\/)(.*)download.csdn.net[^\s]+/.test(a.linkUrl)||/^((https|http)?:\/\/)download.csdn.net\/download\/[^\s]+/.test(a.linkUrl)){var c=a.title;c=(c=(c=(c=c.replace("-<em>CSDN</em>下载","")).replace("- <em>CSDN</em>下载","")).replace("-CSDN下载","")).replace(" - 下载频道 - CSDN.NET",""),a.title,a.title=c,t.push(a)}}return t},removeCurrent:function(e){var t=window.location.href.split("#")[0],n=[];for(var a in e){var c=e[a];c.linkUrl.split("?")[0]!=t&&n.push(c)}return n}},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"}),"function"==typeof csdn.baiduSearchInstallError&&csdn.baiduSearchInstallError()};var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},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(n,a,e,t){if(e)if(-1<e.indexOf("/"))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(n,function(e){r.trackByGraylog("baidu_search_success"),e=r.filterData(e),csdn.baiduCacheBuild(n,e);var t=r.removeCurrent(e);a(t)},t)},baiduKeywordGet:function(t){a.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){0<e.length&&(s.debug.active,t(e[0].keyword))}})},baiduCacheBuild:function(e,t){var n="?keyword="+e;"2"==csdn.cse.param.ct&&-1==csdn.cse.param.cc.indexOf("%26")?n+="&domain_type="+csdn.cse.param.cc.split(".csdn.net")[0]:"3"==csdn.cse.param.ct&&(n+="&url_type="+csdn.cse.param.cc),a.ajax({url:s.API_BAIDU_CACHE_URL+n,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);
|