查看: 2875|回复: 0

链接提交-js代码推送进化版

[复制链接]

2万

主题

141

回帖

7万

积分

管理员

高级管理员

积分
70479
发表于 10-30 18:46 | 显示全部楼层 |阅读模式
这个改良的脚本长下面这样,如果你对js一窍不通,那么请用下图<script>...</script>部分(行6~30)替换原来百度官方的代码。


<script>
        (function(){
                var canonicalURL, curProtocol;
                //Get the <link> tag
                var x=document.getElementsByTagName("link");
                //Find the last canonical URL
                if(x.length > 0){
                        for (i=0;i<x.length;i++){
                                if(x.rel.toLowerCase() == 'canonical' && x.href){
                                        canonicalURL=x.href;
                                }
                        }
                }
                //E58免费提供分享
            if (!canonicalURL){
                    curProtocol = window.location.protocol.split(':')[0];
            }
            else{
                    curProtocol = canonicalURL.split(':')[0];
            }
            //Get current URL if the canonical URL does not exist
            if (!canonicalURL) canonicalURL = window.location.href;
            //Assign script content. Replace current URL with the canonical URL
            !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
</script>


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条