通过ajax查询文章页百度收录判断,优化加载白屏时间!
我用的是杨小杰API的接口,如果不喜欢可以自己做!
同样还是有js自动推送功能,可省去已被收录的文章进行反复推送的加载时间。
JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| $(function () { $.getJSON(‘https://api.yum6.cn/baidu/query.php?url='+window.location.href, function(json, textStatus) { if (json.state == 1) { $(‘#ae\_bdcx’).html(‘本文已被百度收录!’); $(“#ae\_bdcx”).attr(‘href’,’https://www.baidu.com/s?wd='+window.location.href); }else{ $(‘#ae\_bdcx’).html(‘坐等收录’); $(‘#ae\_bdcx’).css(‘color’,’#ff0000’); $(‘#ae\_bdcx’).attr(‘href’,’http://zhanzhang.baidu.com/sitesubmit/index?sitename='+window.location.href); var bp = document.createElement(‘script’); var curProtocol = window.location.protocol.split(‘:’)\[0\]; if (curProtocol === ‘https’) {bp.src = ‘https://zz.bdstatic.com/linksubmit/push.js';} else {bp.src = ‘http://push.zhanzhang.baidu.com/push.js';} var s = document.getElementsByTagName(‘script’)\[0\]; s.parentNode.insertBefore(bp, s); } });
|
HTML
1
| <a id=”ae\_bdcx” rel=”external nofollow” target=”\_blank”></a>
|