// ==UserScript== // @name 贴吧页面强力去污 // @namespace https://coding.net/u/BackRunner/p/GreaseMonkey-JS/git // @version 2.0.1 // @description 强力去除各种扰眼模块、广告模块和触点推广等各类伪装广告 // @author BackRunner // @include *://tieba.baidu.com/f?* // @include *://tieba.baidu.com/p/* // @run-at document-body // @require https://code.jquery.com/jquery-3.1.1.min.js // @license MIT // @grant unsafeWindow // @downloadURL none // ==/UserScript== // ==== Tips ===== // 请根据需要根据下面代码的注释选择需要隐藏的模块,有不想隐藏的模块可以注释掉那一行代码 // === 更新日志 === // 2016.10.28 - 2.0.1 // 修复了@chenyuchen1995反馈的兼容性问题 // 2016.10.22 - 2.0 // 跳个大版本号 // 添加对用户签名档与右侧菜单的精简 // 添加对几个未精简到的模块的精简 // 整合贴吧触点推广专杀等功能,【不需要任何其它脚本了】 // 添加详细的控制台内容 // ================ // 2016.10.16 - 1.1 // 更新了一些内容,可以只配合ADBlock不配合推荐脚本使用 // 写了一个新的脚本用来杀贴吧触点推广,请配合使用 // ================ // 2016.10.3 - 1.0 // 基本扰眼的模块都隐藏了 // ================ (function() { //========================= // 变量定义 //========================= var sleepTime = 750; //如果对清理效果不满意可以尝试改大上面数值,不推荐超过1500 var sleepTimeWhenPageTurn = 50; var postprocess = true; //如果你配合使用了其他脚本,请将上面的值改为false var checkrate = 1; //如果你感觉到卡顿请更改上面的数值,该值为翻页后脚本执行频率倍数,推荐范围1-3 //===================== //以上内容可以修改,请勿修改以下内容 //===================== var startTime = new Date().getTime(); var finishTime = 0; //========================= // 主执行区 //========================= //控制台信息 console.warn('贴吧页面精简 by BackRunner: 启动'); //css修改 appendCSS(); if (postprocess){ //延迟执行 setTimeout(function(){ var interval = setInterval(check,100); var n=0; function check(){ console.warn('贴吧页面精简 by BackRunner: 开始执行延迟脚本'); //列表翻页监听 addListenerToList(); addListenerToPage(); adinListClean(); tpointADClean(); adinPageClean(); n++; if (n>2){ clearInterval(interval); } } },sleepTime); //惰性脚本执行 window.onload=function(){ finishTime = new Date().getTime() - startTime; console.log('贴吧页面精简 by BackRunner: 页面加载用时: ' + finishTime); console.warn('贴吧页面精简 by BackRunner: 开始执行惰性脚本'); //列表翻页监听 addListenerToList(); adinListClean(); tpointADClean(); adinPageClean(); }; } else { console.warning('贴吧页面精简 by BackRunner: 后处理脚本已跳过'); } //========================= //========================= //功能区 请勿修改下面的内容 //========================= //css修改 function appendCSS(){ var cssText = ""; //顶部直播栏 cssText += '#video_frs_head {display: none !important;}'; //右侧会员模块 cssText += '.celebrity {display: none !important;}'; //右侧我的应用模块 cssText += '.my_app {display: none !important;}'; //热议榜 cssText += '.topic_list_box {display: none !important;}'; //广告灰色label cssText += '.label_text {display: none !important;}'; //右边一排图标 cssText += '.j_icon_slot {display: none !important;}'; //会员图标(会造成用户名左移,一定程度上影响整体美观) //cssText += '.icon_tbworld {display: none !important;}'; //你可能感兴趣的吧 cssText += '.forum_recommend {display: none !important;}'; //右上角应用中心(会造成一段小空白) cssText += '.u_menu_wrap.u_appcenterEntrance_wrap {display: none !important;}'; //右上角会员官网(会造成一段小空白) cssText += '.u_joinvip_wrap.vip_red.j_btn_getmember {display: none !important;}'; //内页顶部banner cssText += '.l_banner {display: none !important;}'; //内页成就section cssText += '.achievement_medal_section {display: none !important;}'; //顶部游戏信息 cssText += '.game-head-game-info-wrapper {display: none !important;}'; //内页送礼物按钮 cssText += '.post-foot-send-gift-btn {display: none !important;}'; //会员挽尊按钮 cssText += '.save_face_bg {display: none !important;}'; cssText += '.save_face_bg_2 {display: none !important;}'; //底部游戏开测 cssText += '#duoku_servers_list {display: none !important;}'; //右侧热门卡包 cssText += '.u9_aside {display: none !important;}'; //右侧小说人气榜 cssText += '.novel-ranking-frs-body {display: none !important;}'; //头像下面的一排图标 cssText += '.icon_wrap {display: none !important;}'; //贴吧触点推广图片(触点推广只有这个图片是特殊的,别的东西和正常回帖一致,无法用我所用的方法剔除) cssText += '.tpoint-imgs {display: none !important;}'; //右下角炮筒 cssText += '.j-firework-sender {display: none !important;}'; //访谈直播 cssText += '.interview {display: none !important;}'; //贴内相关推荐 cssText += '.thread_recommend {display: none !important;}'; //贴内广告 cssText += '.iframe_wrapper {display: none !important;}'; //右侧贴吧作者认证 cssText += '.author-manager {display: none !important;}'; //输入框placeholder cssText += '.tb_poster_placeholder {display: none !important;}'; //图片签名档 cssText += '.j_user_sign {display: none !important;}'; //会员名牌 cssText += '.pb_nameplate {display: none !important;}'; //右侧菜单栏精简 cssText += '.tbui_fbar_props {display: none !important;}'; cssText += '.tbui_fbar_tsukkomi {display: none !important;}'; //右侧可点击广告 cssText += '.j_click_stats {display: none !important;}'; console.log('贴吧页面精简 by BackRunner: css创建完成'); var modStyle = document.querySelector('#modCSS'); if (modStyle === null) { modStyle = document.createElement('style'); modStyle.id = 'modCSS'; document.body.appendChild(modStyle); } modStyle.innerHTML = cssText; console.log('贴吧页面精简 by BackRunner: css已添加'); } //列表翻页监听 function addListenerToList(){ $('#frs_list_pager a').each(function(){ this.addEventListener('click',listPageTurnEvent); }); console.log('贴吧页面精简 by BackRunner: 列表翻页监听添加完毕'); } //列表翻页监听事件 function listPageTurnEvent(e){ console.warn('贴吧页面精简 by BackRunner: 列表翻页事件触发'); setTimeout(function(){ var interval = setInterval(check,50 * checkrate); function check(){ setTimeout(function(){ addListenerToList(); adinListClean(); },300); setTimeout(function(){ addListenerToList(); adinListClean(); },sleepTime); setTimeout(function(){ addListenerToList(); adinListClean(); clearInterval(interval); },finishTime/3); } },sleepTimeWhenPageTurn); } function addListenerToPage(){ $('.l_pager a').each(function(){ this.addEventListener('click',pageTurnEvent); }); console.log('贴吧页面精简 by BackRunner: 帖子翻页监听添加完毕'); } function pageTurnEvent(e){ console.warn('贴吧页面精简 by BackRunner: 帖子翻页事件触发'); setTimeout(function(){ var interval = setInterval(check,50 * checkrate); function check(){ setTimeout(function(){ addListenerToPage(); adinPageClean(); tpointADClean(); },200); setTimeout(function(){ addListenerToPage(); adinPageClean(); tpointADClean(); },sleepTime); setTimeout(function(){ addListenerToPage(); adinPageClean(); tpointADClean(); clearInterval(interval); },finishTime/3); } },sleepTimeWhenPageTurn); } //触点推广 function tpointADClean(){ console.log('贴吧页面精简 by BackRunner: 开始精简触点推广'); var pointad = document.getElementsByClassName('tpoint-imgs'); console.log('贴吧页面精简 by BackRunner: 抓取到的广告元素数量: '+pointad.length); for(var i=0;i