综合去除或隐藏网页元素

去除网页元素,classname格式:.+classname,元素格式:#+元素名

目前为 2024-06-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         综合去除或隐藏网页元素
// @version      1.0
// @description  去除网页元素,classname格式:.+classname,元素格式:#+元素名
// @author       Geek
// @match        https://*.ghxi.com/*
// @match        https://*.bilibili.com/*
// @match        https://*.123pan.com/*
// @match        https://*.bing.com/*
// @match        https://yiyan.baidu.com/
// @license MIT
// @run-at       docunment-start
// @namespace https://gf.qytechs.cn/users/1318945
// ==/UserScript==

(function () {

    // 只需要在此处定义需要隐藏元素
    var clearElementArr = [
        {"ghxi.com":[".item-sticky",".wwads-cn",".wwads-vertical",".wpcom_ad_wrap","."]},
        {"bilibili.com":
        [".loc-entry",".left-loc-entry","跨年晚会",
         ".download-entry",".download-client-trigger",".desktop-download-tip","客户端下载",
         ".bili-dyn-version-control",
         ".adblock-tips",
         ".vip-wrap",
         ".slide-ad-exp",
         ".vip-entry-containter",
        ".inside-wrp",]},
        {"123pan.com":
        [".mfy-main-layout__head",
        ".sider-member-btn",
        ".vip-icon",
        ".banner_all_wrap",
         ".ant-menu-submenu-inline",
         ".ant-menu-submenu",]},
        {"https://yiyan.baidu.com":
        [".CWqnDmBt",".B1u21v2t",".Pek2kYSK",".PB57KCF0",".NQlBLxO4",".gLMZvZ80",".RxwtDmpH",

        ]}

        ]

 // 这是架子代码,不用改动
    console.log("准备隐藏以下元素 >>> " + clearElementArr);
    let style = document.createElement("style");
    window.location.href.includes("zhihu.com/question/") ? style.innerText += `html {overflow: auto}` : '';
    window.pageC = function (clearElements) {
        if (typeof (clearElements) === "object") {
            clearElementArr.forEach(o => {
                let key = Object.keys(o);
                if (window.location.href.includes(key)) {
                    o[key].forEach(el => {
                        style.innerText += `${el} {display: none !important;} `;
                    })
                }
            })
        } else {
            console.error("param error,require array!");
        }
        style.innerText != '' ? document.head.appendChild(style) : '';
    };
    pageC(clearElementArr);
   // console.log("清理完成!");
})();

QingJ © 2025

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