// ==UserScript== // @name 百度搜索去顽固广告+百度页面样式美化 // @description 只有十几行代码!快速去除百度结果页的顽固广告和右边栏,适当放大了界面,美化了字体等样式,页面显示更加美观;为了精简代码以及提高性能,没有加任何定时器脚本,没有任何购物推荐啥的,最大程度减少系统资源消耗。 // @icon http://baidu.com/favicon.ico // @namespace https://greasyfork.org/zh-CN/users/393603-tsing // @version 1.0 // @author Tsing // @run-at document-start // @include *://ipv6.baidu.com/s?* // @include *://www.baidu.com/s?* // @include *://www.baidu.com/ // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @grant none // @downloadURL none // ==/UserScript== (function() { /* global $ */ 'use strict'; var style_tag = document.createElement('style'); style_tag.innerHTML = 'body{zoom:1.15} #content_right{display:none;} #content_left a, #rs a{color: #3C50B4; text-decoration: none !important; } .se_st_footer a{color:#008000;} .m{color:#666666 !important;} em{color: #FA3232; text-decoration: none !important;} .t a{font-size: 1.2em;} a.c-text{color:#ffffff !important; font-size:0.8em !important;} #kw{font-size: 1.6em !important;} .c-span18.c-span-last{width:488px;} .nums{width: 638px !important;} .c-container{width:628px !important; padding:10px 15px 15px 10px; border-radius: 10px; box-shadow:1px 1px 6px #eeeeff; transition:padding 0.5s ease, box-shadow 0.5s ease, border-radius 1s ease-out;} .c-container:hover{box-shadow:1px 1px 10px #cccccc; border-radius:0;} .c-span-last p a{font-size: 1.1em;} .c-border{box-shadow:none !important; width:600px;}'; document.head.appendChild(style_tag); document.addEventListener ("DOMContentLoaded", kill_baidu_ad); function kill_baidu_ad () { $(document).ajaxSuccess(function(e, xhr, opt) { // 点击百度一下按钮,采用的是ajax更新网页内容和url document.head.appendChild(style_tag); $('#content_left>div').has('span:contains("广告")').remove(); setTimeout(function () { $('.c-container').has('.f13>span:contains("广告")').remove(); }, 2100); // 去除顽固性的延迟加载广告,一般延迟2秒左右。例如搜索“淘宝”,当页面加载完毕之后在搜索结果最前或最后会再插入一个广告。 }); $("#s-usersetting-top").mouseover(function(){ // 由于body放大,导致首页上的设置弹出框位置错乱,百度的UI设计能不能走点心。。。 $("#s-user-setting-menu").css("right", "70px"); setTimeout(function () { document.getElementById("s-user-setting-menu").style.right = "70px"; }, 1); // 页面自动控制位置,因此必须等该元素出现后才可以移动位置。 }); } })();