贴吧伪装广告清理

清理ADB与ADP未能清理掉的百度贴吧(tieba.baidu.com)列表伪装广告、帖内伪装广告与推荐应用广告

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

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