贴吧伪装广告清理

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

当前为 2016-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Kill TieBa AD
  3. // @name:zh-CN 贴吧伪装广告清理
  4. // @name:zh-TW 貼吧僞裝廣告清理
  5. // @namespace hoothin
  6. // @version 0.49
  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. console.log(222);
  32. if(content){
  33. delAD("#thread_list","LI");
  34. observer = new MutationObserver(function(records){
  35. delAD("#thread_list","LI");
  36. });
  37. option = {
  38. 'childList': true,
  39. 'subtree': true
  40. };
  41. observer.observe(content, option);
  42. }else{
  43. content=document.querySelector(".content");
  44. if(!content)return;
  45. delAD("#j_p_postlist","DIV");
  46. observer = new MutationObserver(function(records){
  47. delAD("#j_p_postlist","DIV");
  48. console.log(111);
  49. });
  50. option = {
  51. 'childList': true,
  52. 'subtree': true
  53. };
  54. observer.observe(content, option);
  55. }
  56.  
  57. function delAD(a,b){
  58. var threadList = document.querySelector(a+">"+a),i;
  59. if(!threadList) threadList = document.querySelector(a);
  60. if(!threadList) return;
  61. var delList = [];
  62. for(i=0;i<threadList.childNodes.length;i++){
  63. let thread = threadList.childNodes[i];
  64. if(thread.tagName == "STYLE"){
  65. delList.push(thread);
  66. var previousSibling = thread.previousSibling;
  67. previousSibling = previousSibling.tagName == b?previousSibling:previousSibling.previousSibling;
  68. delList.push(previousSibling);
  69. }
  70. }
  71. for(i=0;i<delList.length;i++){
  72. let del = delList[i];
  73. threadList.removeChild(del);
  74. }
  75. var easyAD, easyADs=document.querySelectorAll("span.label_text");
  76. for(i=0;i<easyADs.length;i++){
  77. easyAD = easyADs[i];
  78. if(easyAD.innerHTML=="广告" && easyAD.parentNode && easyAD.parentNode.parentNode){
  79. easyAD.parentNode.parentNode.removeChild(easyAD.parentNode);
  80. }
  81. }
  82. }
  83. })();