移除搜索关键词

去你妈的傻逼高亮搜索关键词。

目前为 2024-07-20 提交的版本。查看 最新版本

// ==UserScript==
// @name         No Keywords
// @name:zh-CN   移除搜索关键词
// @namespace    http://tampermonkey.net/
// @version      0.3.0
// @description  Get rid of fucking highlighted search keywords.
// @description:zh-CN 去你妈的傻逼高亮搜索关键词。
// @author       PRO
// @match        https://zhidao.baidu.com/question/*
// @match        https://www.bilibili.com/*
// @match        https://blog.csdn.net/*
// @icon         https://cors.cdn.bcebos.com/amis/namespaces/m-activity/iknow-duck/2022-12/1671625780490/%E6%90%9C%E7%B4%A2wap.png
// @grant        none
// @license      gpl-3.0
// ==/UserScript==

(function () {
    'use strict';
    const log = console.log.bind(console, "[No Keywords]");
    // Adapted from https://www.abeautifulsite.net/posts/querying-through-shadow-roots/
    function shadowQueryAll(selector, rootNode = document) {
        const selectors = String(selector).split('>>>');
        let currentNodes = [rootNode];
        selectors.forEach((selector) => {
            let nextNodes = [];
            currentNodes.forEach(node => {
                if (node instanceof Element && node.shadowRoot) {
                    nextNodes.push(...node.shadowRoot.querySelectorAll(selector));
                } else if (node === rootNode) {
                    nextNodes.push(...rootNode.querySelectorAll(selector));
                }
            });
            currentNodes = nextNodes;
        });
        return currentNodes;
    }
    function fuck(kw) { // `kw` is the element to be fixed
        const txt = kw.textContent;
        const tn = document.createTextNode(txt);
        kw.parentElement.replaceChild(tn, kw);
        log(`Removed keyword "${txt}"`);
    }
    function purify(config) {
        shadowQueryAll(config.keyword).forEach(fuck);
        if (config.icon) {
            const icons = shadowQueryAll(config.icon);
            icons.forEach(icon => icon.remove());
        }
    }
    const allConfig = {
        "zhidao.baidu.com": {
            keyword: ".rich-content-container a[highlight='true']",
            icon: null,
            persistent: false
        },
        "www.bilibili.com": {
            keyword: "bili-comments >>> bili-comment-thread-renderer >>> bili-comment-renderer >>> bili-rich-text >>> a[data-keyword]",
            icon: "bili-comments >>> bili-comment-thread-renderer >>> bili-comment-renderer >>> bili-rich-text >>> a[data-keyword] > img",
            persistent: true
        },
        "blog.csdn.net": {
            keyword: "a.hl-1",
            icon: null,
            persistent: false
        }
    }
    if (!(window.location.hostname in allConfig)) return;
    const config = allConfig[window.location.hostname];
    if (config.persistent) {
        window.setInterval(() => {
            purify(config);
        }, 1000);
    } else {
        purify(config);
    }
})();

QingJ © 2025

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