百度主动推送代码 批量改进版

百度主动推送代码,批量推送页面所有URL。说明:改进修复推送undefined错误问题。
<script type="text/javascript">
//by https://www.jiansouti.com/
var list = document.getElementsByTagName("a");
var n = "http//api.share.baidu.com/s.gif";
var ns = "https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif"; 
var r = window.location.href;
var url = [];
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
for(var i=0;i<list.length;++i){if (typeof(list[i].href) != "undefined"){ url.push(ns+'?l='+encodeURIComponent(list[i].href));}
}
} else {
for(var i=0;i<list.length;++i){if (typeof(list[i].href) != "undefined"){ url.push(n+'?r='+r+'&l='+encodeURIComponent(list[i].href));}
}
}
for(var i=0;i<list.length;++i){var t = new Image;t.src = url[Math.round(Math.random() * list.length)];
}; 
</script>

 

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注