chrome 插件学习笔记(一)

主要是屏蔽cnbeta中屏蔽广告之后的弹出层

manifest.json文件

    {
        "js": ["jquery-1.7.2.min.js","cnbeta.js"],
        "matches": ["http://www.cnbeta.com/*","https://www.cnbeta.com/*" ],//满足什么条件执行该插件  
        "run_at": "document_end"//在document加载时执行该脚本 
    }

cnbeta.js文件

window.addEventListener ("load", myMain, false);

function myMain (evt) {
    var jsInitChecktimer = setInterval (checkForJS_Finish, 50);

    function checkForJS_Finish () {
        $("body>div").each(function(){
            //console.log($(this).attr("style"));
            if( $(this).attr("style")&&$(this).attr("style")=="display:block !important;position:fixed;bottom:0;margin-top:10px;width:100%;background:#c44;color:#fff;font-size:15px;z-index:99999" ){
                //console.log($(this).text());
                if($(this).text()=="帮助cnBeta.COM更好地生产内容,请将我们加入广告屏蔽插件的白名单,非常感谢。具体方法X"){
                    $(this).hide();
                            
                    if (document.readyState == "complete") {
                        window.clearInterval(jsInitChecktimer);
                    }
                }
            }
        });
    }
}

猜你喜欢

转载自www.cnblogs.com/q20686321/p/9182835.html