码迷,mamicode.com
首页 > 其他好文 > 详细

Google浏览器插件之闪存过滤器

时间:2019-07-04 20:16:07      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:val   定时   png   length   use   浏览器   inter   htm   http   

本文学习自:https://www.cnblogs.com/sunshine-wy/p/11133987.html
1.新建manifest.json文件,写入如下内容:

{
  "manifest_version": 2,
  "name" : "闪存过滤器",
  "description" : "不喜欢的人过滤掉就好啦~~",
  "version": "1.0.0.0",
  "content_scripts" :[
    {
      "matches" : ["*://ing.cnblogs.com/*"],
      "js" : ["jquery-3.3.1.min.js","main.js"]
    }
  ]
   
}

技术图片

//main.js
var Home = function () {
    var _this = this;
    this.Init = function () {
        console.log("插件启动成功!");
        //加载页面时清除一次
        _this.ChearUsers();
        //此后每两秒定时清除一次
        setInterval(_this.ChearUsers, 2000);
    }
    this.ChearUsers = function () {
        var filterNames = new Array("测试1", "测试2");
        $(".entry_a,.entry_b").each(function (i, e) {
            var currDomInfo = $(e).find(".ing-author").attr("title");
            $.each(filterNames, function (ii, ee) {
                if (ee.length > 0)//空字符串不做处理
                {
                    if (currDomInfo.indexOf(ee) > -1) {
                        $(e).remove();
                        console.log("已清除用户=>" + ee);
                    }
                }
            });
        });
    }
}
var home = new Home();
home.Init();

技术图片

Google浏览器插件之闪存过滤器

标签:val   定时   png   length   use   浏览器   inter   htm   http   

原文地址:https://www.cnblogs.com/smart-girl/p/11134592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!