油猴插件(隐藏知乎标题,屏蔽百度搜索广告) |
您所在的位置:网站首页 › 脚本标题有哪些 › 油猴插件(隐藏知乎标题,屏蔽百度搜索广告) |
1.隐藏知乎标题
先下载安装一个浏览器插件"油猴插件"(Tampermonkey): https://www.aliyundrive.com/s/4rTXeq7R8bx 提取码: iz36 安装好后可以在浏览器上面查看这个插件,黑色这个,然后点击2这里,添加新脚本,会出来一个代码的页面: 然后将如下代码全部复制到这里,如下图,代码已经单独以文本方式给出: 代码: // ==UserScript== // @name remove the zhihu title // @namespace https://github.com/woodongwong/ // @version 0.1 // @description 将知乎的醒目标题移除掉! // @author woodong wong // @match https://www.zhihu.com/question/* // @grant none // ==/UserScript== (function() { var pageHeader = window.document.getElementsByClassName('PageHeader'); if (pageHeader.length > 0) { pageHeader[0].getElementsByClassName('QuestionHeader-title')[0].innerHTML = ''; } })();然后点击保存即可: 再到知乎文章界面,刷新界面,向下滚动页面,标题头就不会出现了: 2.隐藏百度知道标题百度知道的页面也是和知乎一样的,滚动后标题就出来了,需要隐藏的话,步骤和上面的知乎那个差不多,主要是需要的代码不一样: 同样是到这里添加新脚本: 自动会出现一个代码界面,需要替换代码: 替换为如下图的代码: 代码文本如下: // ==UserScript== // @name 百度知道隐藏标题 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://zhidao.baidu.com/question/* // @grant none // ==/UserScript== (function() { var pageHeader = window.document.getElementsByClassName('wgt-header-title'); if (pageHeader.length > 0) { pageHeader[0].getElementsByClassName('wgt-header-title-text')[0].innerHTML = ''; } })();然后点击保存: 回到百度知道页面,刷新页面,发现已经启动脚本,标题不会出现: 其实细心的朋友可能会发现,这两段部分代码(知乎和百度知道)有相似部分和不同部分,如果其他社区网站标题也是这样的,是不是也可以按照这个方式来隐藏标题。答案是可以的,因为百度知道这个就是我按照隐藏知乎标题代码改了一下就可以隐藏百度知道的标题了。 知乎的网页代码: 注意有小数点哦,小数点前面的就是标题头类的名字 百度知道的网页代码: 注意有小数点哦,小数点前面的就是标题头的类名字: 标题头的名字: 通过上面找到的"标题类名称"和"标题名称"替换到插件里的代码红框里即可: 只要定位到标题的代码,找到标题头的类名字("wgt-header-title")和标题头的名字("wgt-header-title-text")就行了。 4.百度搜索出广告,屏蔽百度出来的广告代码: // ==UserScript== // @name 屏蔽广告 网站(百度、csdn、凤凰网、百度文库、凤凰网等) // @namespace http://tampermonkey.net/ // @version v0.307 // @description 广告去除脚本 // @author Skity666 // @match https://*.baidu.com/* // @match http://*.baidu.com/* // @match https://*csdn.net* // @match https://www.zhihu.com/* // @match https://www.ifeng.com/* // @include https://*.baidu.com/* // @include https://*csdn.net* // @include https://www.zhihu.com/* // @grant none // @require https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js // ==/UserScript== //百度首页广告去除,csdn博客广告去除,csdn论坛广告去除、凤凰网广告去除 ,知乎登录页面自动关闭 // jQuery.noConflict(); (function($) { '屏蔽百度广告,csdn全网广告'; setInterval(function(){ filter() }, 1000); $(document).ready(function() { if(location.href.indexOf('www.zhihu.com')>0){ closeZhiHu(); } }); function filter(){ //csdn首页 if(location.href.indexOf('blog.csdn.net')>0){ //推荐位第一广告 $("[data-type='ad']") //左下角的广告 $("#footerRightAds").remove(); //博客评论上方的广告 $("#dmp_ad_58").remove() //博客评论下方的广告 $("#recommend-item-box-tow").remove(); $(".adsbygoogle").remove(); } //csdn论坛 if(location.href.indexOf('bbs.csdn.net')>0){ //本周牛人上方的广告 $(".ad_top.bbs_left_box").remove() //右下方的广告 $(".ad_1.bbs_left_box").remove(); //中部的广告 $(".bbs_left_box .ad_1").remove(); } //百度 if(location.href.indexOf('www.baidu.com')>0){ //右边栏的广告 $("#zsyx_im0").remove() $("#m3423525928_canvas").remove() $("#m3424514202_canvas").remove() $("div").each(function(){ if($(this).attr("id")!='undefined'& $(this).attr("id")>3000){ $(this).remove() } }) //百度右边栏 if(localStorage.getItem("right-setting")!=null){ //console.log(localStorage.getItem("right-setting")) $("#content_right").remove() } //$("#content_right").remove() //第一层广告去除掉后出现的广告 setTimeout(function(){ $("div.result.c-container").each(function(){ //console.log($("span:contains('广告')",this).length) if($("span:contains('广告')",this).length>0||$("a:contains('广告')",this).length>0){ $(this).remove() } }) //$("div.result.c-container>.f13").parent().remove() }, 2000); //百度首页 $("span:contains('广告')").parent().parent().parent().remove() } //百度文库 if(location.href.indexOf('wenku.baidu.com')>0){ //中间内容栏的广告 $(".hx-warp").remove() } //凤凰网 if(location.href.indexOf('www.ifeng.com')>0){ $("#couplet3_left").remove() $("[c]").remove() } } function closeZhiHu(){ setTimeout(function(){ //知乎登录页面 $(".Button.Modal-closeButton.Button--plain").click(); },100); } // Your code here... })(jQuery);![]() |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |