// ==UserScript== // @name 【屏蔽百度搜索结果中的广告】 // @namespace http://tampermonkey.net/ // @version 1.2 // @icon https://www.baidu.com/favicon.ico // @description 屏蔽百度搜索结果中烦人的广告 // @author wushx // @match *://*.baidu.com/* // @grant none // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js // @license MIT // @downloadURL none // ==/UserScript== let dom = {}; dom.query = jQuery.noConflict(true); dom.query(document).ready(function ($) { const cycletime = 400; if (location.href.indexOf('www.baidu.com') > 0) { // 右侧栏全部关闭(大部分是广告) $("#content_right").remove(); // top-ad也关闭 $("#top-ad").remove(); $(".ec-pl-container").remove(); $("#content_left > div").each(function () { if ($(this).attr('id') === undefined && $('> style', this).attr('id') !== undefined) { $(this).remove(); } }) setInterval(function () { // 右侧栏全部关闭(大部分是广告) $("#content_right").remove(); // 搜索结果中有的条目广告 $("#content_left > div").each(function () { if ($(this).attr('id') === undefined && $('> div', this).attr('data-placeid') !== undefined) { $(this).remove(); } }) // 有延时跳出的广告 $("a").each(function () { if ($(this)[0].innerHTML === '广告') {$(this).parents(".result").remove(); } }) $(".san-card").each(function () { if ($(this).attr("tpl") === 'feed-ad') { $(this).remove() } }) //搜索内容居中 $("#s_tab").css("padding-left","276px"); $("#container").css("margin-left","276px"); }, cycletime); } });