Greasy Fork

Greasy Fork is available in English.

移除百家家号搜索结果

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

当前为 2018-12-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         移除百家家号搜索结果
// @namespace    http://tampermonkey.net/
// @home-url     http://greasyfork.icu/zh-CN/scripts/375240
// @description  删除百度搜索结果的百家号结果
// @version      0.14
// @include      http://www.baidu.com/*
// @include      https://www.baidu.com/*
// @require      http://code.jquery.com/jquery-1.8.2.js
// @author       mzcc
// @note         2018.12.19-0.14 根据百度界面变化,删除操作做新的变更逻辑
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    $(document).on('DOMSubtreeModified', process);

    function process() {
        // 第一项单独处理
        let $topOp = $('.c-offset');
        $topOp.children().each(function(i, v){
            let $this = $(this);
            if($this.find('.source-icon').length){
                let href = $this.find('a').attr('href');
                $topOp.find('a[href="'+href+'"]').parent().remove();
            }
        });
        
        
        // 移除第一项之外的百家号
        $('.c-showurl').each(function(i, v){
            let html = $(this).html();
            if(html.indexOf('baijia') > -1){
                $(this).parents('.c-container').remove();
            }
        });

        
        if(!$topOp.find('.c-offset').length){
            $topOp.parent().remove();
        }

        let $video = $('.op-short-video-pc');
        if($video.length){
            $video.parent().remove();
        }
    }
})();