再见了百家号搜索结果

删除百度搜索结果的百家号的结果

目前为 2018-04-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         再见了百家号搜索结果
// @namespace    http://tampermonkey.net/
// @description  删除百度搜索结果的百家号的结果
// @version      0.1
// @include      http://www.baidu.com/*
// @include      https://www.baidu.com/*
// @author       依然菜刀
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    var hostname = window.location.hostname;
    // 移除百家号的搜索结果
    if (hostname == 'www.baidu.com') {
        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('baijia') > -1){
                        results[i].parentNode.removeChild(results[i]);
                    }
                }
            }
        }
    }
})();