csdn,百度搜索,知乎网页去广告净化

写了一个小架子,不管你是编程老手还是小白,都可以根据这个架子定制自己的网站净化

目前為 2022-08-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         csdn,百度搜索,知乎网页去广告净化
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  写了一个小架子,不管你是编程老手还是小白,都可以根据这个架子定制自己的网站净化
// @author       王子周棋洛
// @match        https://blog.csdn.net/*/article/details/*
// @match        https://www.baidu.com/
// @match        https://www.zhihu.com/explore
// @match        https://www.zhihu.com/question/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
// @grant        none、
// @license      MIT
// ==/UserScript==

(function () {
    var clearElementArr = [
        'csdn', '.passport-container', 'passport-login-mark',
        '知乎', '.css-1izy64v', '.css-ysn1om', '.Modal-wrapper',
        '百度搜索', '#s-top-left', '#s_top_wrap', '.s-top-right', '#s_main', '.s-bottom-layer-content'
    ];

    window.sd = function (d, h) {
        var dom = document.querySelector(String(d));
        window.location.href.includes("zhihu.com/question/") ? document.documentElement.style.overflow = "auto" : '';
        h ? dom.style.display = "none" : '';
        return dom;
    };

    console.log("准备隐藏以下元素 >>> " + clearElementArr);

    window.pageC = function (clearElements) {
        if (typeof (clearElements) === "object") {
            clearElements.forEach(cE => {
                if (sd(cE) !== null && sd(cE).style.display !== "none") { sd(cE, 1); console.log(`已清理 ${cE}`); }
            });
        } else { console.error("param error,require array!"); }
    };

    pageC(clearElementArr);

    var observer = new MutationObserver(function () {
        pageC(clearElementArr);
    });

    observer.observe(document.body, {
        attributes: true,
        subtree: true,
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址