贴吧伪装广告清理

清理ADB或UBO等未能清理掉的百度贴吧列表伪装广告、帖内伪装广告与推荐应用广告

目前为 2016-11-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Kill TieBa AD
  3. // @name:zh-CN 贴吧伪装广告清理
  4. // @name:zh-TW 貼吧僞裝廣告清理
  5. // @namespace hoothin
  6. // @version 0.50
  7. // @description Just Kill TieBa AD
  8. // @description:zh-CN 清理ADB或UBO等未能清理掉的百度贴吧列表伪装广告、帖内伪装广告与推荐应用广告
  9. // @description:zh-TW 清理ADB或UBO等未能清理掉的百度貼吧列表偽裝廣告、帖內偽裝廣告與推薦應用廣告
  10. // @author hoothin
  11. // @include http*://tieba.baidu.com/*
  12. // @grant none
  13. // @run-at document-body
  14. // @supportURL http://www.hoothin.com
  15. // @license MIT License
  16. // @compatible chrome
  17. // @compatible firefox
  18. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=rixixi@sina.com&item_name=Greasy+Fork+donation
  19. // @contributionAmount 1
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24. var observer, option;
  25. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  26. var tcss = ".j_encourage_entry{display: none !important;} #encourage_entry{display: none !important;} .tpoint-skin{display: none !important;} #pb_adbanner{display: none !important;} .iframe_wrapper{display: none !important;} div.tpoint-skin{display: none !important;}";
  27. var snod = document.createElement('style');
  28. snod.innerHTML = tcss;
  29. document.getElementsByTagName("head")[0].appendChild(snod);
  30. var content = document.querySelector("#content");
  31. if(content){
  32. delAD("#thread_list","LI");
  33. observer = new MutationObserver(function(records){
  34. delAD("#thread_list","LI");
  35. });
  36. option = {
  37. 'childList': true,
  38. 'subtree': true
  39. };
  40. observer.observe(content, option);
  41. }else{
  42. content=document.querySelector(".content");
  43. if(!content)return;
  44. delAD("#j_p_postlist","DIV");
  45. observer = new MutationObserver(function(records){
  46. delAD("#j_p_postlist","DIV");
  47. });
  48. option = {
  49. 'childList': true,
  50. 'subtree': true
  51. };
  52. observer.observe(content, option);
  53. }
  54.  
  55. function delAD(a,b){
  56. var threadList = document.querySelector(a+">"+a),i;
  57. if(!threadList) threadList = document.querySelector(a);
  58. if(!threadList) return;
  59. var delList = [];
  60. for(i=0;i<threadList.childNodes.length;i++){
  61. let thread = threadList.childNodes[i];
  62. if(thread.tagName == "STYLE"){
  63. delList.push(thread);
  64. var previousSibling = thread.previousSibling;
  65. previousSibling = previousSibling.tagName == b?previousSibling:previousSibling.previousSibling;
  66. delList.push(previousSibling);
  67. }else{
  68. if(thread.getAttribute && thread.getAttribute("data-field")){
  69. let tdata=JSON.parse(thread.getAttribute("data-field"));
  70. if(tdata.content && tdata.content.pb_tpoint && tdata.content.pb_tpoint.is_tpoint==1)delList.push(thread);
  71. }
  72. }
  73. }
  74. for(i=0;i<delList.length;i++){
  75. let del = delList[i];
  76. threadList.removeChild(del);
  77. }
  78. var easyAD, easyADs=document.querySelectorAll("span.label_text");
  79. for(i=0;i<easyADs.length;i++){
  80. easyAD = easyADs[i];
  81. if(easyAD.innerHTML=="广告" && easyAD.parentNode && easyAD.parentNode.parentNode){
  82. easyAD.parentNode.parentNode.removeChild(easyAD.parentNode);
  83. }
  84. }
  85. }
  86. })();