NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name 网页广告清理 // @namespace https://openuserjs.org/users/rainbowcorn // @version 1.0.6 // @description 清理页面内的百度广告 // @match * // @grant none // @licence MIT // @copyright 2019, rainbowcorn (https://openuserjs.org/users/rainbowcorn) // @require http://code.jquery.com/jquery-3.4.1.min.js // ==/UserScript== (function() { 'use strict'; let randHex = function () { let chars = ['a', 'b', 'c', 'd', 'e', 'f', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str = 'random-interval-id-', i; for (i = 0; i < 32; i ++) { str += chars[Math.floor(Math.random() + chars.length)]; } return str; }; let interval = 1000, regex_rules = { id: [ /^\d{10,20}_\d{10,20}$/gi, /^(jm_DIV_)\w+/gi, /^(cs_DIV)\w+/gi, /^(tttb_)\w+/gi, /^(a960)\w+/gi, ], src: [ /^(https:\/\/adx)\w+/gi ] }; window.ADS_KILLER_INTERVAL_ID = setInterval(() => { for (let key in regex_rules) { let rules = regex_rules[key]; document.querySelectorAll('[' + key + ']').forEach(el => { let str = el.getAttribute(key), to_remove = false; rules.forEach(rule => { if (rule.test(str)) to_remove = true; }); if (to_remove) el.remove(); }); } }, interval); })();