remove CSDN

在搜索结果中屏蔽 CSDN。支持 Google / Baidu / Bing / 360 搜索

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         remove CSDN
// @namespace    czqu
// @version      1.1
// @icon         https://www.google.com/s2/favicons?sz=64&domain=csdn.net
// @description  在搜索结果中屏蔽 CSDN。支持 Google / Baidu / Bing / 360 搜索
// @license      GNU-GPLv3
// @include      *://*.baidu.com/baidu?*
// @include      *://*.baidu.com/s?*
// @include      *://*.google.*/search*
// @include      *://*.bing.com/search*
// @include      *://*.so.com/s*
// @include      *://*.csdn.net/*
// @grant        none
// ==/UserScript==

function isSite(domain) {
    return window.location.href.match(new RegExp("^https?:\/\/[\\w.]+?" + domain))
}

function HideCSDN(){
    const filters = ".source_1Vdff, .iUh30, .b_attribution, .g-linkinfo-a,.c-showurl".split(", ")
    const Elements=document.querySelectorAll(".result.c-container, .g, .b_algo, .res-list");
    let num;
    Elements.forEach(function(Item,i){
        for (var filter in filters) {
            let selectedContent=Item.querySelector(filters[filter])
            if (selectedContent !== null) {
                console.log(selectedContent.innerText)
                if (selectedContent.innerText.toLowerCase().includes("csdn")) {
                    Item.parentNode.removeChild(Item);
                    num = i;
                    break;
                }
            }
        }
    });
    if (num !== undefined) {
        console.log(`[Fuck CSDN] 已去除 ${num} 条 CSDN 内容`)
    }
}

function bind() {
    document.querySelectorAll(".page-item_M4MDr, #form, #page, .ac_wrap").forEach(
        function(Item) {
            Item.addEventListener('mousedown',function () {
                setTimeout(function(){
                    HideCSDN();
                    if (isSite('so.com')) {
                        bind();
                    }
                },1000);
            })
        }
)}

// 绑定回车事件
document.querySelectorAll("input.gLFyf.gsfi, input#kw, input#keyword").forEach(
function(Item) {
    Item.addEventListener('keydown', function () {
    var evt = window.event || arguments.callee.caller.arguments[0];
    if (evt.keyCode == "13") {
        setTimeout(function(){HideCSDN();},1000);
    }
})})

if (isSite('csdn.net')) {
    document.body.innerHTML = "Blocked by Fuck CSDN.";
    window.history.go(-1);
}

HideCSDN();
bind();