// ==UserScript== // @name 隐藏百度搜索结果中 CSDN&百度经验&百度知道 的垃圾内容 // @namespace http://tampermonkey.net/ // @version 0.3 // @description try to take over the world! // @author You // @include http*://www.baidu.com/* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; // Your code here... function cleanTheResult() { var list = Array.from(document.getElementsByClassName('c-showurl')) var rex = /CSDN|csdn|百度知道|百度经验|mamicode|bubuko|codercto|javascriptcn/; var num = 0; function findParent(item) { // console.log(item); if (item.classList.contains('c-container')) { item.style.display = 'none'; num++; } else { findParent(item.parentElement) } } list.map(item => { if (rex.test(item.innerText)) { findParent(item); } }) console.log("已屏蔽" + num + "条搜索结果") } document.addEventListener("click", () => { cleanTheResult(); }); })();