最近实在忍受不了百度低劣的搜索结果,网上找了找没找到简洁又单一的好脚本(可能没看到),于是决定自己写一个
屏蔽关键词就是百度搜索结果的脚标,理论上是能把部分广告也能屏蔽的
可能已经有其他作者写过了,但目前认为我写的这个代码比较精简,保证了功能单一性
代码如下:
[mw_shl_code=javascript,true]// ==UserScript==
// @name 百度搜索结果过滤
// @namespace https://gitee.com/huelse/baidu-filter
// @version 0.2
// @description 在下方block_list中添加你想过滤的网站,世界都将清净了
// @AuThor THENDINGs
// @match https://www.baidu.com/s*
// @Icon https://www.baidu.com/favicon.ico
// @license GPL License
// ==/UserScript==
(function() {
'use strict';
// 屏蔽列表(默认为搜索结果的脚标)
const block_list = ['广告', 'CSDN', '脚本之家', '百度知道', '百度经验', '腾讯云', '阿里云'];
// 屏蔽函数
function block() {
const arr = $('#content_left a.c-showurl');
$.each(arr, function(idx, el) {
$.each(block_list, function(index, ele) {
if (el.innerText.indexOf(ele) != -1) {
console.log('屏蔽: '+el.innerText);
$(el).parents('.c-container').css('display', 'none');
}
});
});
}
// 监听页面搜索结果加载(适配AC-baidu插件)
$('#content_left').bind('DOMNodeInserted', function() {
block();
})
// 默认页面重载调用
$(document).ready(function () {
block();
});
})();[/mw_shl_code]
已经发布在了https://greasyfork.org/scripts/427392,务必通过此链接安装代码,上面的代码被论坛格式化可能会失效
有油猴插件的可以直接进入安装
可以自己添加屏蔽关键词,如果失效了,欢迎留言告知~
如果觉得好用,给个免费的评分哦 |