{"id":27995577,"url":"https://github.com/chokcoco/del_ad_chrome_ext","last_synced_at":"2025-08-21T20:24:34.418Z","repository":{"id":36177315,"uuid":"40481438","full_name":"chokcoco/del_ad_chrome_ext","owner":"chokcoco","description":"一款简易的chrome拓展程序，可清除页面中的广告。","archived":false,"fork":false,"pushed_at":"2015-11-11T10:07:34.000Z","size":181,"stargazers_count":37,"open_issues_count":0,"forks_count":28,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-08T20:44:22.432Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chokcoco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-10T12:31:02.000Z","updated_at":"2024-02-05T02:30:19.000Z","dependencies_parsed_at":"2022-08-18T14:21:44.917Z","dependency_job_id":null,"html_url":"https://github.com/chokcoco/del_ad_chrome_ext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chokcoco/del_ad_chrome_ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Fdel_ad_chrome_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Fdel_ad_chrome_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Fdel_ad_chrome_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Fdel_ad_chrome_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chokcoco","download_url":"https://codeload.github.com/chokcoco/del_ad_chrome_ext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Fdel_ad_chrome_ext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267372482,"owners_count":24076781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-08T20:33:43.716Z","updated_at":"2025-07-27T14:45:14.131Z","avatar_url":"https://github.com/chokcoco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A chrome extension for removing ads on the web page.\n\n一款简易的chrome拓展程序，可清除页面中的广告。\n\n仓库里是整个插件包，下载安装chrome拓展可以直接使用，chrome插件安装及配置参考：\nhttp://open.chrome.360.cn/extension_dev/getstarted.html\n\n通过在匹配的页面注入js脚本文件，通过找到页面中的广告框然后将其隐藏（通过JQ hide()方法）达到清除广告的效果。\n\n通过寻找页面中广告的特性，通过算法可以得到广告框的外层id或者类名。\n\n简单的算法如下：\n```Javascript\n//简单的智能算法\nfindSomeAdPossible: function() {\n\t//找到可能的广告wrapper\n\tvar sap = $('div iframe'),\n\t    ad_img = $('div script').parent().find('img,embed'),\n\t    float_img = $('div object').parent().find('img,embed');\n\n\t    this.arrayDel(sap,360,200);\n\t    this.arrayDel(ad_img,350,150);\n\t    this.arrayDel(float_img,350,150);\n},\narrayDel : function(arr,conWidth,conHeight){\n\tvar len = arr.length;\n\n\tfor(var i = 0 ; i\u003clen ; i++){\n\t\tvar self = arr.eq(i);\n\n\t\tif(self.width() \u003c= conWidth || self.height() \u003c= conHeight) {\n\t\t\tself.hide();\n\t\t}\n\n\t}\n}\n```\n\n另外设置了一个id数组和class数组用于存放那些没有特性的广告框容器名，缺点是需要手动收集\n```Javascript\nclear: function() {\n\t//此处可手动添加广告框id名，去除顽疾ad必备\n\tvar ad_id_name = [\n\t\t\"cproIframe2001holder\",\n\t\t\"cproIframe2002holder\",\n\t\t\"cproIframe2003holder\",\n\t\t\"cproIframe2004holder\",\n\t\t\"cproIframe2005holder\",\n\t\t\"cproIframe2006holder\",\n\t\t\"cproIframe2007holder\",\n\t\t\"cproIframe2008holder\",\n\t\t\"id_300x250_banner_top\",\n\t\t\"ads\",\n\t\t\"google_image_div\",\n\t\t\"mx_cs_71603_1261456\",\n\t\t\"AC_TR86_71603\",\n\t\t\"cproIframe_u2060917_1\",\n\t\t\"google_image_div\",\n\t\t\"content_right\"\n\t];\n\n\t//此处添加广告框类名\n\tvar ad_css_name = [\n\t\t\"cproIframe_u410704_3\",\n\t\t\"img_ad\",\n\t\t\"hover_btn\"\n\t];\n\n\tfor (var i = 0; i \u003c ad_id_name.length; i++) {\n\t\t$('#' + ad_id_name[i]).hide();\n\t}\n\n\tfor (var i = 0; i \u003c ad_css_name.length; i++) {\n\t\t$('.' + ad_css_name[i]).hide();\n\t}\n}\n```\n\n由于manifest文件匹配规则只有通配没有非功能，所以可在此方法可以设置不想删除广告的页面\n```javascript\ncheckUrl: function() {\n\tvar Checkflag = 0,\n\t\turl = window.location.href;\n\n\t//手动添加不需要清除广告的域\n\tvar notDel = [\n\t\t\"www.baidu.com\",\n\t\t\"taobao.com\",\n\t\t\"tmall.com\",\n\t\t\"jd.com\"\n\t];\n\n\t//正则匹配\n\tfor (var i = 0; i \u003c notDel.length; i++) {\n\t\tvar reg = new RegExp(notDel[i], \"g\");\n\n\t\tif (reg.test(url)) {\n\t\t\tconsole.log('This page does not clear ads.');\n\t\t\tbreak;\n\t\t} else {\n\t\t\tif (i == notDel.length - 1) {\n\t\t\t\tCheckflag = 1;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (Checkflag == 1) {\n\t\tthis.clear();\n\t\tthis.findSomeAdPossible();\n\t}\n}\n```\n\n如果安装了无法正常使用，需要进行如下配置，打开chrome浏览器，输入框输入\n```\nchrome://flags/#enable-npapi\n```\n然后，然后启用 NPAPI 、启用 实验性扩展程序 API\n\nblog介绍地址：http://www.cnblogs.com/coco1s/p/4725477.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchokcoco%2Fdel_ad_chrome_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchokcoco%2Fdel_ad_chrome_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchokcoco%2Fdel_ad_chrome_ext/lists"}