屏蔽CSDN搜索结果 / Hide CSDN Search Results

在百度、Bing、谷歌中屏蔽CSDN搜索结果 / Hide CSDN results on search engines (Baidu, Bing, Google)

// ==UserScript==
// @name         屏蔽CSDN搜索结果 / Hide CSDN Search Results
// @namespace    https://github.com/uuhc
// @version      1.0
// @description  在百度、Bing、谷歌中屏蔽CSDN搜索结果 / Hide CSDN results on search engines (Baidu, Bing, Google)
// @author       uuhc
// @match        *://www.baidu.com/s*
// @match        *://www.google.com/search*
// @match        *://www.bing.com/search*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to hide results based on domain
    function hideCSDNResults() {
        const csdnKeywords = /csdn\.net/i;

        // Baidu
        if (location.host.includes("baidu.com")) {
            document.querySelectorAll('.c-container').forEach((result) => {
                if (result.innerText.match(csdnKeywords)) {
                    result.style.display = 'none';
                }
            });
        }

        // Google
        else if (location.host.includes("google.com")) {
            document.querySelectorAll('.g').forEach((result) => {
                if (result.innerText.match(csdnKeywords)) {
                    result.style.display = 'none';
                }
            });
        }

        // Bing
        else if (location.host.includes("bing.com")) {
            document.querySelectorAll('.b_algo').forEach((result) => {
                if (result.innerText.match(csdnKeywords)) {
                    result.style.display = 'none';
                }
            });
        }
    }

    // Run the function initially and on dynamically loaded content
    hideCSDNResults();
    document.addEventListener('scroll', hideCSDNResults);
})();

QingJ © 2025

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