抢月饼 浏览器插件开发

该方案已失效。 user.js插件的形式已经被chrome封杀,建议使用油猴插件:https://www.cnblogs.com/CyLee/p/10095489.html

该方案已失效。 user.js插件的形式已经被chrome封杀,建议使用油猴插件:https://www.cnblogs.com/CyLee/p/10095489.html

该方案已失效。 user.js插件的形式已经被chrome封杀,建议使用油猴插件:https://www.cnblogs.com/CyLee/p/10095489.html


新建一个test.user.js文件

setInterval(function(){
    alert("test");
},1500)

  Chrome:

1. 打开chrome扩展程序页 – chrome://extensions

2. 将刚才的自定义脚本保存为以user.js为后缀的 .js文件,例如test.user.js,拖入扩展程序页。

3. 必须启动

4. 打开任意一个页面测试(不可以是本地html文件、浏览器的新建标签页),比如打开www.baidu.com、https://www.cnblogs.com/cylee、http://www.youku.com/

下面是根据网友的一个奇葩要求定制的一个插件。5秒跳转到百度,然后10秒跳转到新浪。

由于跳转到百度之后,页面刷新,插件会重新加载,插件的逻辑无法继续往下执行,所以需要通过判断网址来跳转到新浪,变相10秒跳转到新浪

setTimeout(function(){        
            console.log(window.location);
            // 如果已经是新浪,那么停止脚本
            if(window.location.hostname.indexOf("popladys") >= 0 || window.location.hostname.indexOf("fst360") >= 0 || window.location.hostname.indexOf("sina") >= 0 ||  window.location.hostname.indexOf("cnhksy") >= 0) return;
            
            // 5秒后跳转到百度
            if (window.location.hostname.indexOf("baidu") < 0) {
                alert("我要跳转百度了");
                window.location.href = "http://www.baidu.com"
            } else { // 10秒后跳转到新浪
                setTimeout(function(){
                        window.location.href = "http://www.sina.com.cn/";
                        alert("我要跳转新浪了");
                },5000) 
            }
},5000)

禅道bug列表中的a标签全部修改为target = "__blank"

var a_list = document.querySelectorAll('#bugList a')

a_list.forEach(function(ele, index){
    ele.setAttribute('target', '__blank');
})
原文地址:https://www.cnblogs.com/CyLee/p/6016266.html