Ads DOM Remover

Removes Ad Containers from DOM (doesn't replace adblocker extension, but blocks dynamic content which the adblocker fails to block by removing whole sections from the HTML DOM.)

当前为 2016-07-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Ads DOM Remover
  3. // @namespace sagiegurari
  4. // @version 0.74
  5. // @author Sagie Gur-Ari
  6. // @description Removes Ad Containers from DOM (doesn't replace adblocker extension, but blocks dynamic content which the adblocker fails to block by removing whole sections from the HTML DOM.)
  7. // @homepage https://github.com/sagiegurari/userscripts-ads-dom-remover
  8. // @supportURL https://github.com/sagiegurari/userscripts-ads-dom-remover/issues
  9. // @match http://www.ynet.co.il/home/*
  10. // @match http://www.ynet.co.il/articles/*
  11. // @match http://www.mynet.co.il/articles/*
  12. // @match http://www.calcalist.co.il/*
  13. // @match http://www.globes.co.il/*
  14. // @match https://sourceforge.net/projects/*/download*
  15. // @match http://subscenter.cinemast.com/*
  16. // @match https://*.wikipedia.org/*
  17. // @require https://code.jquery.com/jquery-2.2.2.min.js
  18. // @require https://greasyfork.org/scripts/18490-ads-dom-remover-runner/code/Ads%20DOM%20Remover%20Runner.js?version=123541
  19. // @grant none
  20. // @license MIT License
  21. // ==/UserScript==
  22.  
  23. (function run($, runner) {
  24. 'use strict';
  25.  
  26. var ynetHelper = {
  27. getArticleBlock: function ($element) {
  28. return !$element.parent('.block.B4');
  29. }
  30. };
  31.  
  32. var selectorDefinitions = {
  33. ynet: [
  34. '#colorbox',
  35. '#cboxOverlay',
  36. '#ads.premium',
  37. '#articleLayoutrightsidtable',
  38. 'img[src*="dynamicyield"]',
  39. 'div.MSCmainContent',
  40. '[id*="arketingCarouse"]',
  41. '[id*="arketingRecommended"]',
  42. '.mainVerticalArticleSharingLinks',
  43. '.OUTBRAIN',
  44. '.topBannerWrap',
  45. '.block.B3 .B3.ghcite.dyother.dyMonitor div',
  46. '.bigdealhomepage',
  47. '#ww6s_Main',
  48. '.buyandsavedy',
  49. '.area.footer.ghcite',
  50. '.hdr_set_homepage',
  51. '#c1_Hor',
  52. '#c2_Hor',
  53. '#c3_Hor',
  54. '#c4_Hor',
  55. '#c5_Hor',
  56. '#c6_Hor',
  57. '.homepagevideo-x6',
  58. '.buyandsave',
  59. '.general-image',
  60. '.PhotoArticlesTalkbacks',
  61. '[name="ExternalWebpageIframe"]',
  62. '#PROCOIL_SearchForm',
  63. '#magazines1024',
  64. '[id^="promo_"]',
  65. 'tr td [id^="ads."]',
  66. {
  67. selector: '#multiarticles-12',
  68. fineTuneSelector: ynetHelper.getArticleBlock
  69. },
  70. {
  71. selector: '#multiarticles-14',
  72. fineTuneSelector: ynetHelper.getArticleBlock
  73. },
  74. {
  75. selector: '#multiarticles-16',
  76. fineTuneSelector: ynetHelper.getArticleBlock
  77. },
  78. {
  79. selector: 'iframe',
  80. filter: function ($element) {
  81. return !$element.parent().hasClass('news_ticker_iframe');
  82. }
  83. },
  84. {
  85. selector: 'div.B2b.block div',
  86. pre: function ($element) {
  87. $element.parent().css({
  88. height: '1px'
  89. });
  90. }
  91. },
  92. {
  93. selector: '#dcPremiumRightImg',
  94. fineTuneSelector: function ($element) {
  95. return $element.parent();
  96. }
  97. }
  98. ],
  99. globes: [
  100. '#chromeWindow',
  101. {
  102. selector: 'iframe',
  103. filter: function ($element) {
  104. var id = $element.attr('id');
  105. var src = $element.attr('src') || '';
  106.  
  107. return (id !== 'GlobalFinanceData_home') && (src.indexOf('/news/') !== -1);
  108. }
  109. }
  110. ],
  111. sourceforge: [
  112. '#content-for-adblock'
  113. ],
  114. subscenter: [
  115. '.weekBottom',
  116. '.reviewsWindow',
  117. '#banner_cinemast',
  118. '.bottomMenu',
  119. 'footer',
  120. '#paypal',
  121. '#aboveSite'
  122. ],
  123. wikipedia: [
  124. '#frbanner',
  125. '.frbanner'
  126. ]
  127. };
  128.  
  129. Object.keys(selectorDefinitions).forEach(function (id) {
  130. selectorDefinitions[id] = {
  131. id: id,
  132. selectors: selectorDefinitions[id]
  133. };
  134. });
  135.  
  136. runner($, {
  137. getSelectors: function (hostName) {
  138. var selectors;
  139. if (hostName.indexOf('globes') !== -1) {
  140. selectors = selectorDefinitions.globes;
  141. } else if (hostName.indexOf('sourceforge.net') !== -1) {
  142. selectors = selectorDefinitions.sourceforge;
  143. } else if (hostName.indexOf('subscenter.cinemast.com') !== -1) {
  144. selectors = selectorDefinitions.subscenter;
  145. } else if (hostName.indexOf('wikipedia.org') !== -1) {
  146. selectors = selectorDefinitions.wikipedia;
  147. } else { //ynet/calcalist
  148. selectors = selectorDefinitions.ynet;
  149. }
  150.  
  151. return selectors;
  152. }
  153. });
  154. }(window.jQuery.noConflict(true), window.adrRunner));