Assassinate Ad Block Blockers

You know those annoying content blockers that popup demanding you remove your AdBlock so you can read the content? This script removes them by force. Please note, this is not UNIVERSAL like AdBlock Plus. It operates at a per-site basis.

当前为 2020-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Assassinate Ad Block Blockers
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.22
  5. // @description You know those annoying content blockers that popup demanding you remove your AdBlock so you can read the content? This script removes them by force. Please note, this is not UNIVERSAL like AdBlock Plus. It operates at a per-site basis.
  6. // @author Kxmode
  7. // @run-at document-idle
  8. // @match *://www.vg247.com/*
  9. // @match *://www.eurogamer.net/*
  10. // @match *://www.makeuseof.com/*
  11. // @match *://www.gamesradar.com/*
  12. // @match *://www.usatoday.com/*
  13. // @match *://www.cnn.com/*
  14. // @match *://www.businessinsider.com/*
  15. // @match *://www.thedailybeast.com/*
  16. // @match *://www.forbes.com/*
  17. // @match *://*.nytimes.com/*
  18. // @match *://*.dailymail.co.uk/*
  19. // @match *://*.washingtonpost.com/*
  20. // @match *://*.insider.com/*
  21.  
  22. // ==/UserScript==
  23.  
  24. // Loads jQuery and triggers a callback function when jQuery has finished loading
  25. function addJQuery(callback) {
  26. var script = document.createElement("script");
  27. script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js");
  28. script.addEventListener('load', function() { callback(); }, false);
  29. document.body.appendChild(script);
  30. }
  31.  
  32. // The main script
  33. function main() {
  34.  
  35. const $ = (unsafeWindow || window).$;
  36.  
  37. // For domains that follow the standard way of blocking AdBlockers typically with a full-page block and overlay.
  38. var arrayStandardBlockerDomains = [ "www.vg247.com",
  39. "www.eurogamer.net",
  40. "www.gamesradar.com",
  41. "www.usatoday.com",
  42. "www.cnn.com"].map(String);
  43.  
  44. // For domains that follow a nonstandard way of blocking AdBlockers by typically blocking the content area only, or some other unique way.
  45. var arrayAbnormalBlockerDomains = [ "www.makeuseof.com",
  46. "www.businessinsider.com",
  47. "www.thedailybeast.com",
  48. "www.nytimes.com",
  49. "cooking.nytimes.com",
  50. "www.forbes.com",
  51. "www.dailymail.co.uk",
  52. "www.washingtonpost.com",
  53. "www.insider.com"].map(String);
  54.  
  55. // For domains that typically launch third-party modals for random stuff like sign-ups.
  56. var arrayAuxiliaryBlockerDomains = [ "www.gamesradar.com"].map(String);
  57.  
  58. /*
  59. // keeping for future use
  60. function DomainCheck() {
  61. var i, domain = window.location.hostname;
  62. for (i = 0; i < arrayStandardBlockerDomains.length; i++)
  63. {
  64. if (domain == arrayStandardBlockerDomains[i])
  65. {
  66. return arrayStandardBlockerDomains[i];
  67. break;
  68. }
  69. }
  70. for (i = 0; i < arrayAbnormalBlockerDomains.length; i++)
  71. {
  72. if (domain == arrayAbnormalBlockerDomains[i])
  73. {
  74. return arrayAbnormalBlockerDomains[i];
  75. break;
  76. }
  77. }
  78. for (i = 0; i < arrayAuxiliaryBlockerDomains.length; i++)
  79. {
  80. if (domain == arrayAuxiliaryBlockerDomains[i])
  81. {
  82. return arrayAuxiliaryBlockerDomains[i];
  83. break;
  84. }
  85. }
  86. }
  87. var domain = DomainCheck();
  88. */
  89.  
  90. // Use to display the loading animation
  91.  
  92. $("body").prepend('<div id="Injected-By-Assassinate-Ad-Block-Blockers" style="background-color: #D8070E; font-weight: bold; color: white; text-align: center; margin: auto; padding: 10px; position: relative; z-index: 9999999999 !important; top: 220px;"><style>#Injected-By-Assassinate-Ad-Block-Blockers img { width: unset; }</style><img src="//i.imgur.com/velCxDX.gif" style="display: inline-block; vertical-align: middle;" /> <span>Assassinate Ad Block Blockers is doing its jobs. Please wait a few seconds.</span></div>');
  93.  
  94. function DOMStatusCheck() {
  95. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1)
  96. {
  97. var isHTMLBlocked = $("html").attr("style");
  98. var isBodyBlocked = $("body").attr("style");
  99. var isHTMLClassBlocked = $("html").hasClass("sp-message-open");
  100.  
  101. if (isHTMLBlocked !== undefined || isBodyBlocked !== undefined || isHTMLClassBlocked)
  102. {
  103. clearInterval(currentStatus1);
  104. // We're on a page that is blocked
  105.  
  106. $("html").removeAttr("style");
  107. $("body").removeAttr("style");
  108. $("html").removeClass("sp-message-open");
  109.  
  110. switch(window.location.hostname)
  111. {
  112. case arrayStandardBlockerDomains[0]: // vg247
  113. case arrayStandardBlockerDomains[1]: // eurogamer
  114. case arrayStandardBlockerDomains[2]: // gamesradar
  115. case arrayStandardBlockerDomains[3]: // usatoday
  116. case arrayStandardBlockerDomains[4]: // cnn
  117. $("[class*='sp_veil']").remove();
  118. $("[id*='sp_message_id']").remove();
  119. break;
  120. }
  121. }
  122.  
  123. console.clear();
  124. }
  125.  
  126. if (arrayAuxiliaryBlockerDomains.indexOf(window.location.hostname) > -1)
  127. {
  128. switch(window.location.hostname)
  129. {
  130. case arrayAuxiliaryBlockerDomains[0]: // gamesradar
  131. if ($(".raleigh-optin-visible").is(":visible"))
  132. {
  133. $("[class*='raleigh-optin-']").remove();
  134. }
  135. clearInterval(currentStatus2);
  136. break;
  137. }
  138. }
  139.  
  140. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1)
  141. {
  142. switch(window.location.hostname)
  143. {
  144. case arrayAbnormalBlockerDomains[0]: // makeuseof
  145. $("[class*='unblockplease-overlay']").remove();
  146. $(".unblockplease").removeAttr("style");
  147. break;
  148. case arrayAbnormalBlockerDomains[1]: // businessinsider
  149. $(".tp-modal").remove();
  150. $(".tp-backdrop").remove();
  151. $("body").removeClass("tp-modal-open");
  152. break;
  153. case arrayAbnormalBlockerDomains[3]: // nytimes
  154. case arrayAbnormalBlockerDomains[4]: // nytimes cooking
  155. // nytimes
  156. $("#standalone-footer").remove();
  157. $("#gateway-content").remove();
  158. $("body").attr("style", "overflow: unset;");
  159. $("#site-content").attr("style","position: unset;");
  160. $("[id*='lire-ui-'").remove();
  161. $("[class*='css-1bd']").remove();
  162.  
  163. // nytimes' cooking
  164. $(".nytc---modal-window---windowContainer").parents("#appContainer").remove(); // a modal with no close button. wtf nyt?!
  165. $("#container").attr("style","overflow: unset;");
  166. $(".nytc---modal-window---noScroll").attr("style","overflow: unset;");
  167. $("#site-content").attr("style","position: unset;");
  168.  
  169. // nytimes' magazine and site-wide
  170. $("[class*='css-mcm']").attr("style","position: unset;");
  171. break;
  172. case arrayAbnormalBlockerDomains[5]: // forbes
  173. $(".page-loaded").remove();
  174. $(".article-fixed[_nghost-c11]").attr("style", "position: unset;");
  175. // abnormal situation. these appear on certain pages.
  176. $("#lightboxjs-lightboxlib").remove();
  177. $("#aax_prefetch_frame").remove();
  178. $("#cok_aax").remove();
  179. $("body > iframe:nth-of-type(1)").remove(); // these run in sequence. we want to remove the first 7-9 iframes since iframes typically contain ABB-related injection code or advertisements.
  180. $("body > iframe:nth-of-type(1)").remove();
  181. $("body > iframe:nth-of-type(1)").remove();
  182. $("body > iframe:nth-of-type(1)").remove();
  183. $("body > iframe:nth-of-type(1)").remove();
  184. $("body > iframe:nth-of-type(1)").remove();
  185. $(".fbs-auth__container").remove();
  186. $(".fbs-ad--ntv-contentd-wrapper").remove();
  187. $(".body--no-scroll").attr("style", "overflow: unset;");
  188. $.each($("script"), function() { // scans all scripts for a very specific paywall script
  189. var selector = $(this).attr("src");
  190. var target = String(selector).match(/(paywall)+.(unlock-protocol)+./g); // the script is found
  191. if (target !== null)
  192. {
  193. $(this).remove(); // and removed so that it can't re-inject itself
  194. }
  195. });
  196. $("#article-container-0").attr("style","position: unset;");
  197. break;
  198. case arrayAbnormalBlockerDomains[6]: // www.dailymail.co.uk
  199. $("#mol-ads-cmp-iframe").next().remove();
  200. $("html").removeAttr("class");
  201. $("body").removeAttr("class");
  202. break;
  203. case arrayAbnormalBlockerDomains[7]: // washingtonpost
  204. $("html").removeAttr("style");
  205. $("[data-qa*='paywall']").remove();
  206. $("[rel*='apple-touch-icon']").last().next().next().remove(); // removes the blocker html
  207. $("[rel*='apple-touch-icon']").last().next().next().remove(); // removes the blocker styles
  208. break;
  209. case arrayAbnormalBlockerDomains[8]: // insider
  210. $(".tp-modal").remove();
  211. $(".tp-backdrop.tp-active").remove();
  212. $("body").removeAttr("class");
  213. break;
  214. }
  215. }
  216.  
  217. }
  218.  
  219. function SledgehammerRemoval() {
  220. if (window.location.hostname == arrayAbnormalBlockerDomains[2]) // dailybeast
  221. {
  222. $("#Injected-By-Assassinate-Ad-Block-Blockers").attr("style","background-color: green; font-weight: bold; color: white; text-align: center; margin: auto; padding: 10px; position: relative; z-index: 9999999999 !important; transition: .5s; top: 220px;");
  223. $("#Injected-By-Assassinate-Ad-Block-Blockers").find("img").attr("src","https://i.imgur.com/i5e5xp0.gif");
  224. $("#Injected-By-Assassinate-Ad-Block-Blockers").find("span").text("Success. Enjoy!");
  225.  
  226. // Wait 1.5 seconds
  227. setTimeout(function()
  228. {
  229. $(".tp-modal").remove();
  230. $(".tp-backdrop").remove();
  231. $("body").removeClass("tp-modal-open");
  232. $("[id*='offer-0-']").remove();
  233. $("[displayname*='PianoTag']").remove();
  234. $("[src*='tinypass.min.js']").remove();
  235. $("#piano_bottom_ribbon_wrapper").remove();
  236. console.clear();
  237. console.log("blocker code removed");
  238. $("#Injected-By-Assassinate-Ad-Block-Blockers").remove();
  239. }, 1500);
  240. }
  241. }
  242.  
  243. SledgehammerRemoval();
  244.  
  245. function ClearAllIntervals()
  246. {
  247. $("#Injected-By-Assassinate-Ad-Block-Blockers").attr("style","background-color: green; font-weight: bold; color: white; text-align: center; margin: auto; padding: 10px; position: relative; z-index: 9999999999 !important; transition: .5s; top: 220px;");
  248. $("#Injected-By-Assassinate-Ad-Block-Blockers").find("img").attr("src","https://i.imgur.com/i5e5xp0.gif");
  249. $("#Injected-By-Assassinate-Ad-Block-Blockers").find("span").text("Success. Enjoy!");
  250.  
  251. // Wait 1.5 seconds
  252. setTimeout(function()
  253. {
  254. console.clear();
  255. var totalTimeouts = 10;
  256.  
  257. if (window.location.hostname != arrayAbnormalBlockerDomains[2]) // dailybeast
  258. {
  259. if (window.location.hostname == arrayAbnormalBlockerDomains[3] || window.location.hostname == arrayAbnormalBlockerDomains[4]) // nytimes and nytimes cooking
  260. {
  261. console.log("Final pass for nytimes");
  262. $("[class*='css-1bd']").remove();
  263. }
  264. if (window.location.hostname == arrayAbnormalBlockerDomains[5]) // forbes
  265. {
  266. console.log("Final pass for forbes");
  267. $(".unlock.start").remove();
  268. $("#article-container-0").attr("style","position: unset;");
  269. }
  270. if (window.location.hostname == arrayAbnormalBlockerDomains[6]) // www.dailymail.co.uk
  271. {
  272. $("#mol-ads-cmp-iframe").next().remove();
  273. $("html").removeAttr("class");
  274. $("body").removeAttr("class");
  275. }
  276. if (window.location.hostname == arrayAbnormalBlockerDomains[7]) // washingtonpost
  277. {
  278. $("html").removeAttr("style");
  279. $("[data-qa*='paywall']").remove();
  280. $("[rel*='apple-touch-icon']").last().next().next().remove(); // removes the blocker html
  281. $("[rel*='apple-touch-icon']").last().next().next().remove(); // removes the blocker styles
  282. }
  283. if (window.location.hostname == arrayAbnormalBlockerDomains[8]) // washingtonpost
  284. {
  285. $(".tp-modal").remove();
  286. $(".tp-backdrop.tp-active").remove();
  287. $("body").removeAttr("class");
  288. }
  289.  
  290. clearInterval("SledgehammerRemoval");
  291. console.log("Sledgehammer interval cleared");
  292. }
  293. for (var i = 1; i <= totalTimeouts; i++)
  294. {
  295. var intervalName = "currentStatus" + i;
  296. clearInterval(intervalName);
  297. }
  298. clearInterval(ci);
  299. console.log("all intervals cleared");
  300.  
  301. $("#Injected-By-Assassinate-Ad-Block-Blockers").remove();
  302. }, 1500);
  303. }
  304.  
  305. // Sets up listeners to supercede any blocker shenanigans
  306. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus1 = setInterval(DOMStatusCheck, 50); }
  307. if (arrayAuxiliaryBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus2 = setInterval(DOMStatusCheck, 50); }
  308.  
  309. // Second pass after 1.5 seconds
  310. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus3 = setTimeout(DOMStatusCheck, 1500); }
  311. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus4 = setTimeout(DOMStatusCheck, 1500); }
  312.  
  313. // Third pass after 2.5 seconds
  314. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus5 = setTimeout(DOMStatusCheck, 2500); }
  315. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus6 = setTimeout(DOMStatusCheck, 2500); }
  316.  
  317. // Fourth pass after 5.5 seconds
  318. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus7 = setTimeout(DOMStatusCheck, 5500); }
  319. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus8 = setTimeout(DOMStatusCheck, 5500); }
  320.  
  321. // Fifth pass after 7 seconds
  322. if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus9 = setTimeout(DOMStatusCheck, 7000); }
  323. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus10 = setTimeout(DOMStatusCheck, 7000); }
  324.  
  325. // Last-pass guarantee after 7.05 seconds (We want this to fire immediately after the fifth pass)
  326. var ci = setTimeout(ClearAllIntervals, 7050);
  327.  
  328. // Perpetual check and removal every 2.5 seconds - The Peter Gabriel Sledgehammer Special
  329. if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var ABStatus = setInterval(SledgehammerRemoval, 2500); }
  330.  
  331.  
  332. console.clear();
  333. }
  334.  
  335. // Load jQuery and then execute the main function
  336. addJQuery(main);