屏蔽csdn

csdn有目共睹的越来越恶心人,不得不采取措施。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         屏蔽csdn
// @namespace    wang-zhixin
// @version      20211125
// @description  csdn有目共睹的越来越恶心人,不得不采取措施。
// @match        https://www.baidu.com/s?*
// @grant        none
// ==/UserScript==
let timer;
function HideCSDN(){
    const Elements=document.querySelectorAll(".result.c-container ");
    let num;
    Elements.forEach(function(Item,i){
        let Content=Item.querySelector(".f13 a:first-child").innerText;
        if(Content.includes("CSDN技术社区")){
            Item.parentNode.removeChild(Item);
            num = i
            clearInterval(timer)
        }
    });
    console.log(`共去除${num}条csdn内容`)
}
HideCSDN();

/*绑定键盘回车事件*/
document.querySelector("body").addEventListener('keydown',function () {
    //谷歌能识别event,火狐识别不了,所以增加了这一句,chrome浏览器可以直接支持event.keyCode
    var theEvent = window.event || arguments.callee.caller.arguments[0];
    if (theEvent.keyCode == "13") {//keyCode=13是回车键
        clearInterval(timer)
        timer = setInterval(function(){
            HideCSDN()
            console.log(`123`)
        },1000)
    }
})
/*绑定单机事件*/
document.querySelector("body").addEventListener('click',function () {
    clearInterval(timer)
    timer = setInterval(function(){
        HideCSDN()
        console.log(`123`)
    },1000)
})