百度搜索优化

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         百度搜索优化
// @namespace    https://greasyfork.org/zh-CN/scripts/377102
// @version      0.8
// @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 href = $a.attr("href")
                // 如果没有安装 直链 不修改链接
                if (href.indexOf("https://www.baidu.com/link?url")>-1 || href.indexOf("http://www.baidu.com/link?url")>-1) return;
                let url = href.match(/(?<=(http|https)\:\/\/)(.+?)(?=\/)/);
                if (url&& url[0] && $a.attr("baidu_url")!=url[0]){
                    $a.attr("baidu_url",url[0]);
                    $a.html(url[0]);
                }
            }
        })
    }
})();