Greasy Fork

Greasy Fork is available in English.

百度 百家号删除 来源显示域名

删除百度搜索中百家号的结果, 搜索结果来源显示域名 更短的代码 更好的性能

当前为 2019-01-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         百度 百家号删除 来源显示域名
// @namespace    http://greasyfork.icu/zh-CN/scripts/377102
// @version      0.4
// @description  删除百度搜索中百家号的结果, 搜索结果来源显示域名 更短的代码 更好的性能
// @author       lqzh
// @copyright    lqzh
// @include       http*://www.baidu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $(document).on('DOMSubtreeModified', limitBjh);
    window._bjher = 0;

    function limitBjh(){
         clearTimeout(window._bjher);
         window._bjher = setTimeout(function(){
             removeBJH();
         },150)
    }

    function removeBJH(){
        $(".result").each(function(i,v){
            let flag = v.innerHTML.match(/href\=\"(http|https)\:\/\/baijiahao.baidu.com/);
            if (flag){
                 v.remove();
            }else{
                // 域名处理
                let $a = $(v).find(".c-showurl");
                let url = $a.attr("href").match(/(?<=(http|https)\:\/\/)(.+?)(?=\/)/);
                if (url&& url[0] && $a.attr("baidu_url")!=url[0]){
                    $a.attr("baidu_url",url[0]);
                    $a.html(url[0]);
                }
            }
        })
    }
})();