最讨厌工作时候百度的信息
如何去除百度的每日新闻提示:
1. 下载Greasemonkey 油猴脚本【这个插件】
2.本次处理对象是百度搜索,由于上班期间老是情不自禁看新闻,决定自宫,处理结果如下
完美解决百度的各种子内容,当然要定制的个位园友请发挥想象力自己去定制,个人的油猴脚本如下【本人不搞前端开发,简单实现如下】
// ==UserScript== // @name 百度 // @description 百度去广告 // @copyright 2020;陈-林-赵-魏 // @icon https://assets-cdn.github.com/pinned-octocat.svg // @version 0.0.1 // @author WK // @license MIT // @homepageURL https://github.com/ // @match http://*.baidu.com/* // @match https://*.baidu.com/* // @run-at document-end // @grant none // ==/UserScript== //搜索页:githubSvg var githubSvg = "<svg height=\"32\" class=\"octicon octicon-mark-github text-white\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"32\" aria-hidden=\"false\"><path fill-rule=\"evenodd\" d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z\"></path></svg>"; //主页换SVG var githubSvg2 = "<svg class=\"icon\" style=\"width: 100; height: 250;vertical-align: middle;fill: currentColor;overflow: hidden;\""+ " viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"2624\">"+ "<path fill=\"#7EB4DA\" d=\"M263.456 759.36c0 27.04 22.88 40.576 68.672 40.576 40.064 0 60.096-14.048 60.096-42.144 0-26.528-21.856-39.808-65.536-39.808C284.544 718.016 263.456 731.808 263.456 759.36zM853.344 0 170.688 0C76.8 0 0 76.8 0 170.688l0 682.624C0 947.264 76.8 1024 170.688 1024l682.656 0C947.232 1024 1024 947.264 1024 853.312L1024 170.688C1024 76.8 947.232 0 853.344 0zM475.744 408.992c-7.296 2.592-17.696 5.472-31.2 8.576 4.16 11.968 6.24 23.168 6.24 33.568 0 33.28-10.016 62.304-30.048 87.008-20.032 24.704-45.92 39.392-77.632 44.096-20.8 3.136-31.2 14.304-31.2 33.568 0 6.752 3.392 13.536 10.144 20.288 8.832 9.888 21.856 16.128 39.008 18.72 74.4 11.456 111.584 42.4 111.584 92.864 0 80.64-48.128 120.96-144.352 120.96-39.552 0-72.064-7.04-97.536-21.056-32.256-17.696-48.384-45.536-48.384-83.488 0-43.712 24.192-73.6 72.576-89.728l0-1.568c-17.696-10.912-26.528-27.584-26.528-49.952 0-29.12 8.32-47.36 24.96-54.624l0-1.568c-16.64-5.728-31.488-18.72-44.48-39.04-14.56-21.856-21.856-45.248-21.856-70.24 0-37.472 13.28-68.672 39.808-93.632 25.504-23.424 55.936-35.104 91.296-35.104 25.504 0 49.152 6.24 71.008 18.72 24.96 0 53.856-6.24 86.624-18.72L475.744 408.992 475.744 408.992zM602.176 679.008l-88.192 0c1.056-10.4 1.568-28.096 1.568-53.056L515.552 383.232c0-24.448-0.512-41.376-1.568-50.72l88.192 0c-1.056 9.888-1.568 26.272-1.568 49.152l0 239.552C600.608 647.776 601.152 667.04 602.176 679.008zM596.32 254.496c-10.656 11.456-23.296 17.152-37.856 17.152-15.072 0-27.968-5.728-38.624-17.152-10.656-11.456-16-24.96-16-40.576 0-16.128 5.344-29.92 16-41.376 10.656-11.456 23.552-17.152 38.624-17.152 14.56 0 27.2 5.728 37.856 17.152 10.656 11.456 16 25.216 16 41.376C612.32 229.504 606.976 243.04 596.32 254.496zM841.696 668.832c-19.264 10.4-42.4 15.616-69.472 15.616-37.984 0-64.256-13.504-78.816-40.576-10.944-20.288-16.384-52.288-16.384-95.968l0-139.68 0.768 0 0-1.568-11.712-0.768c-6.752 0-15.616 0.768-26.528 2.336L639.584 332.512l38.24 0 0-30.432c0-14.56-0.768-26.272-2.336-35.104l90.528 0c-1.536 9.888-2.336 21.056-2.336 33.536l0 32 67.872 0 0 75.68c-2.592 0-7.424-0.256-14.432-0.768-7.04-0.512-13.664-0.8-19.904-0.8l-33.568 0 0 145.152c0 34.848 11.456 52.288 34.336 52.288 16.128 0 30.688-4.416 43.712-13.248L841.696 668.832 841.696 668.832zM321.216 400.416c-32.768 0-49.152 19.264-49.152 57.76 0 35.904 16.384 53.856 49.152 53.856 31.744 0 47.616-18.208 47.616-54.624 0-15.104-3.648-28.096-10.912-39.008C349.056 406.4 336.832 400.416 321.216 400.416z\" p-id=\"2625\"></path></svg>"; //更改图标 function ChangeLogo() { //搜索页面换logo var logo = document.getElementById("result_logo"); if(logo!==null) { logo.innerHTML = githubSvg; } //主页换Logo var mainLogo = document.getElementById("lg"); if(mainLogo!==null) { mainLogo.innerHTML = githubSvg2; } } //移除广告 function RemoveGuangGao(node){ for(var i=node.childNodes.length - 1; i >= 0;i--){ var childNode = node.childNodes[i]; if(childNode.nodeName == "div" || childNode.nodeName == "Div" || childNode.nodeName == "DIV") { var textInNode = childNode.innerText; if(textInNode.indexOf("CSDN")!=-1) { node.removeChild(childNode); break; } var classAttrValue = childNode.className; // console.log("childNode_"+childNode); // console.log("class_" + classAttrValue); if(classAttrValue !== null && classAttrValue !== undefined && classAttrValue !== "" && classAttrValue.length > 0) { if(classAttrValue.toLowerCase() == "GSlQWV") { node.removeChild(childNode); } else if(classAttrValue.toLowerCase() == "_SOpbo HdSWRZ pPBNnR c-container new-pmd".toLowerCase()) { node.removeChild(childNode); } else if(classAttrValue != "result c-container new-pmd") { //删除医生 if(classAttrValue == "c-container result") { var tplValue = childNode.getAttribute("tpl"); if(tplValue == "ask_doctor") { node.removeChild(childNode); } } var object1 = childNode.getAttribute('data-ecimtimesign'); //debugger; //alert("Here!"); console.log("data-ecimtimesign_"+ object1); if(childNode.getAttribute("data-ecimtimesign") !== null)//移除广告 { node.removeChild(childNode); } else if(childNode.children.length == 3) {//移除广告 //alert('Here'); if(childNode.children[2].className=="f13") { node.removeChild(childNode); } } // else if(childNode.attributes.indexOf("data-ecimtimesign")>-1) // { // node.removeChild(childNode); // } } else { var links = childNode.getElementsByTagName('a'); var isHas = false; if(links !== undefined && links !== null && links.length>0) { for (var kkk = 0; kkk < links.length; kkk++){ if(links[kkk].innerText==="广告") { isHas = true; break; } } } if(isHas) { node.removeChild(childNode); } else { var link2 = childNode.getElementsByTagName('span'); if(link2 !== undefined && link2 !== null && link2.length>0) { for (var ggg = 0; ggg < link2.length; ggg++){ if(link2[ggg].innerText==="广告") { isHas = true; break; } } if(isHas) { node.removeChild(childNode); } } } //还是有奇怪的广告 } } else { //此时div没有Class的是广告 node.removeChild(childNode); } } } } //页面移除相应的搜索,新闻提示 function RemoveBaidu() { var mycustomerTitle = "Here Please Input You Cnblog Address Or github Address! Power by <strong>陈-林-赵-魏</strong>!"; //搜索页去除新闻 var findobj = document.getElementById("content_right"); if(findobj !== null) findobj.innerHTML=mycustomerTitle; //主页去除新闻top10 var findobj2 = document.getElementById("s-hotsearch-wrapper"); if(findobj2 !== null) findobj2.innerHTML=mycustomerTitle; //主页去除顶部其他标签 var mainPageThele =document.getElementById("s-top-left"); if(mainPageThele !== null) { mainPageThele.innerHTML= "不允许搜索其他的内容"; } //主页去除登陆 var u1 = document.getElementById("u1"); if(u1 !== null) { u1.innerHTML = "登陆会暴漏隐私"; } //去除搜索页中的查找连接 var finds_tab = document.querySelector("#s_tab>.s_tab_inner"); if(finds_tab !== null) { finds_tab.innerHTML = "不允许搜索其他的内容!"; } //搜索页面不要登陆 var findU = document.getElementById("u"); if(findU !== null) { findU.innerHTML = "登陆会暴漏隐私"; } } (function() { 'use strict'; var i = 5; RemoveBaidu();//永久去除 var timer= setInterval(function() //开启循环 暴力1秒去一次!呵呵哒 { document.title = 'Hello World!'; //搜索结果过滤 var content_left = document.getElementById("content_left"); if(content_left !== null) { RemoveGuangGao(content_left); } ChangeLogo();//更改图标 RemoveBaidu();//永久去除 //clearInterval(timer); },1000); })();
只需要复制到油猴脚本如下画面里编辑器的输入内容,保存即可,然后刷新百度画面,Enjoy!
转载保留源出处即可,商业使用请自行鉴别,使用本博客中公开内容做任何违法犯罪于本作者无关