Filter CSDN Content from Bing and Baidu

Filter out CSDN content from Bing and Baidu search results

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Filter CSDN Content from Bing and Baidu
// @namespace    http://tampermonkey.net/
// @version      2024-12-05
// @description  Filter out CSDN content from Bing and Baidu search results
// @author       You
// @match        https://www.bing.com/search?q=*
// @match        https://www.baidu.com/s?wd=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove CSDN results
    function removeCSDNResults() {
        const results = document.querySelectorAll('.b_algo, .b_sideBleed, .b_footnote, .result');
        results.forEach(result => {
            const link = result.querySelector('a');
            // Filter for Bing results
            if (link && link.href.includes('csdn.net')) {
                result.style.display = 'none';
            }
            // Filter for Baidu results
            const muAttr = result.getAttribute('mu');
            if (muAttr && muAttr.includes('csdn.net')) {
                result.style.display = 'none';
            }
        });
    }

    // Run the function after the page loads
    window.addEventListener('load', removeCSDNResults);
})();