// ==UserScript== // @name 再见了百度知道和百家号搜索结果 // @namespace http://tampermonkey.net/ // @home-url https://greasyfork.org/zh-CN/scripts/371691 // @description 删除百度搜索结果的百度知道结果 // @version 0.2 // @include http://www.baidu.com/* // @include https://www.baidu.com/* // @author vessl // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... var hostname = window.location.hostname; // 移除百家号的搜索结果 if (hostname == 'www.baidu.com') { process(); document.addEventListener("DOMSubtreeModified", process); } function process() { var results = document.getElementsByClassName('result c-container'); //console.log(results) if (results && results.length > 0) { for (var i = results.length - 1; i >= 0; i--) { var links = results[i].getElementsByClassName('c-showurl'); if (links && links.length > 0) { var link = links[0]; var text = link.innerText; if (text && text.indexOf('zhidao.baidu') > -1){ results[i].parentNode.removeChild(results[i]); } } } } } })();