Anti-AdBlocker Fuckoff

Protects & Remove Anti-AdBlockers modal windows from web sites

  1. // ==UserScript==
  2. // @name Anti-AdBlocker Fuckoff
  3. // @name:es Anti-AdBlocker Fuckoff
  4. // @namespace Anti-AdBlocker-Fuckoff
  5. // @version 1.68
  6. // @description Protects & Remove Anti-AdBlockers modal windows from web sites
  7. // @description:es Protege y elimina las ventanas modales de Anti-AdBlockers de los sitios web
  8. // @author Elwyn
  9. // @license MIT
  10. // @homepage https://github.com/WakeupNeo33/Anti-AdBlocker-Fuckoff-userscript
  11. // @supportURL https://github.com/WakeupNeo33/Anti-AdBlocker-Fuckoff-userscript/issues
  12. // @iconURL https://github.com/WakeupNeo33/Anti-AdBlocker-Fuckoff-userscript/raw/main/icon.png
  13. // @include *
  14. // @exclude https://*aliexpress.com/*
  15. // @exclude https://*amazon.*/*
  16. // @exclude https://*anaconda.org/*
  17. // @exclude https://*apple.com/*
  18. // @exclude https://*ask.com/*
  19. // @exclude https://*baidu.com/*
  20. // @exclude https://*binance.com/*
  21. // @exclude https://*binance.us/*
  22. // @exclude https://*bing.com/*
  23. // @exclude https://*bitfinex.com/*
  24. // @exclude https://*bitflyer.com/*
  25. // @exclude https://*bitstamp.net/*
  26. // @exclude https://*blockchain.com/*
  27. // @exclude https://*blockchair.com/*
  28. // @exclude https://*blockcypher.com/*
  29. // @exclude https://*bscscan.com/*
  30. // @exclude https://*buffer.com/*
  31. // @exclude https://*bufferapp.com/*
  32. // @exclude https://*calm.com/*
  33. // @exclude https://*chatango.com/*
  34. // @exclude https://*coinbase.com/*
  35. // @exclude https://*coinmarketcap.com/*
  36. // @exclude https://*doctor-groups.com/*
  37. // @exclude https://*duckduckgo.com/*
  38. // @exclude https://*ebay.com/*
  39. // @exclude https://*etherscan.io/*
  40. // @exclude https://*facebook.com/*
  41. // @exclude https://*firefaucet.win/*
  42. // @exclude https://*flattr.com/*
  43. // @exclude https://*flickr.com/*
  44. // @exclude https://*fsf.org/*
  45. // @exclude https://*ftx.com/*
  46. // @exclude https://*ftx.us/*
  47. // @exclude https://*gate.io/*
  48. // @exclude https://*geeksforgeeks.org/*
  49. // @exclude https://*gemini.com/*
  50. // @exclude https://*github.com/*
  51. // @exclude https://*gitlab.com/*
  52. // @exclude https://*google.*
  53. // @exclude https://*greasyfork.org/*
  54. // @exclude https://*huobi.com/*
  55. // @exclude https://*imdb.com/*
  56. // @exclude https://*imgbox.com/*
  57. // @exclude https://*imgur.com/*
  58. // @exclude https://*instagram.com/*
  59. // @exclude https://*jsbin.com/*
  60. // @exclude https://*jsfiddle.net/*
  61. // @exclude https://*kucoin.com/*
  62. // @exclude https://*kraken.com/*
  63. // @exclude https://*linkedin.com/*
  64. // @exclude https://*liquid.com/*
  65. // @exclude https://*live.com/*
  66. // @exclude https://*mail.ru/*
  67. // @exclude https://*mega.nz/*
  68. // @exclude https://*minds.com/*
  69. // @exclude https://*microsoft.com/*
  70. // @exclude https://*msn.com/*
  71. // @exclude https://*netflix.com/*
  72. // @exclude https://*odysee.com/*
  73. // @exclude https://*openuserjs.org/*
  74. // @exclude https://*paypal.com/*
  75. // @exclude https://*pinterest.com/*
  76. // @exclude http*://*plnkr.co/*
  77. // @exclude http*://*poloniex.com/*
  78. // @exclude https://*primevideo.com/*
  79. // @exclude https://*protonmail.com/*
  80. // @exclude https://*qq.com/*
  81. // @exclude https://*raider.io/*
  82. // @exclude https://*reddit.com/*
  83. // @exclude https://*stackoverflow.com/*
  84. // @exclude https://*steampowered.com/*
  85. // @exclude https://*tampermonkey.net/*
  86. // @exclude https://*trello.com/*
  87. // @exclude https://*twitch.tv/*
  88. // @exclude https://*twitter.com/*
  89. // @exclude https://*userstyles.org/*
  90. // @exclude https://*viawallet.com/*
  91. // @exclude https://*vimeo.com/*
  92. // @exclude https://*whatsapp.com/*
  93. // @exclude https://*wikipedia.org/*
  94. // @exclude https://*w3schools.com/*
  95. // @exclude https://*x.com/*
  96. // @exclude https://*yahoo.*
  97. // @exclude https://*yandex.ru/*
  98. // @exclude https://*youtube.com/*
  99. // @exclude https://*vod.pl/*
  100. // @noframes
  101. // @run-at document-start
  102. // @grant unsafeWindow
  103. // ==/UserScript==
  104. (function() {
  105.  
  106. var enable_debug = false;
  107.  
  108. // Anti-AdBlocker Pattern to Search
  109. var adblock_pattern = /ad-block|adblock|ad block|blocking ads|bloqueur|bloqueador|Werbeblocker|آدبلوك بلس|блокировщиком/i;
  110. var disable_pattern = /kapat|disabl|désactiv|desactiv|desativ|deaktiv|detect|enabled|turned off|turn off|απενεργοποίηση|запрещать|állítsd le|publicités|рекламе|verhindert|advert|kapatınız/i;
  111.  
  112. var tagNames_pattern = /b|center|div|font|i|iframe|s|span|section|u/i;
  113.  
  114. var is_core_protected = false;
  115.  
  116. var classes = [];
  117.  
  118. // HELPER Functions
  119. //-----------------
  120. function debug( msg, val ) {
  121. if ( !enable_debug ) return;
  122. console.log( '%c ANTI-ADBLOCKER \n','color: white; background-color: red', msg );
  123. if ( val === undefined ) return;
  124. if ( val.nodeType === Node.ELEMENT_NODE )
  125. {
  126. console.log ( 'TagName: ' + val.nodeName + ' | Id: ' + val.id + ' | Class: ' + val.classList );
  127. console.log ( val );
  128. } else {
  129. console.log ( '%c' +val, 'color: grey;' );
  130. }
  131. }
  132.  
  133. function addStyle(str) {
  134. var style = document.createElement('style');
  135. style.innerHTML = str;
  136. document.body.appendChild( style );
  137. }
  138.  
  139. function randomInt( min, max )
  140. {
  141. // min and max included
  142. if ( max === undefined ) {
  143. max = min;
  144. min = 0;
  145. }
  146. return Math.floor(min + Math.random() * (max - min + 1));
  147. }
  148.  
  149. function getRandomName( size )
  150. {
  151. var charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  152. var name = '';
  153. for (var i = 0; i < (size||randomInt(10,20)); ++i)
  154. {
  155. name += charset.charAt( Math.floor( Math.random() * charset.length) );
  156. }
  157. return name;
  158. }
  159.  
  160. function addRandomClass( el ) {
  161. let name = getRandomName();
  162. el.classList.add( name );
  163. return name;
  164. }
  165.  
  166. function enableRightClick() {
  167. if (typeof jQuery !== 'undefined') {
  168. jQuery(function($) {
  169. $('img').removeAttr('onmousedown').removeAttr('onselectstart').removeAttr('ondragstart');
  170. $(document).off('contextmenu');
  171. $(document.body).off('contextmenu');
  172. $(document.body).off('selectstart');
  173. $(document.body).off('dragstart');
  174. });
  175. } else {
  176. const images = document.querySelectorAll('img');
  177. images.forEach(img => {
  178. img.removeAttribute('onmousedown');
  179. img.removeAttribute('onselectstart');
  180. img.removeAttribute('ondragstart');
  181. });
  182. }
  183. document.oncontextmenu=null;
  184. document.onmousedown=null;
  185. document.body.oncontextmenu=null;
  186. document.body.onselectstart=null;
  187. document.body.ondragstart=null;
  188. }
  189.  
  190.  
  191.  
  192. function isElementBlur( el )
  193. {
  194. if (el instanceof Element) {
  195. var style = window.getComputedStyle( el );
  196. var filter = style.getPropertyValue( 'filter' );
  197. return ( (/blur/i).test( filter ) );
  198. }
  199. }
  200.  
  201. function isElementFixed( el )
  202. {
  203. if (el instanceof Element) {
  204. var style = window.getComputedStyle( el );
  205. return ( style.getPropertyValue( 'position' ) == 'fixed' );
  206. }
  207. }
  208.  
  209. function isOverflowHidden( el )
  210. {
  211. if (el instanceof Element) {
  212. var style = window.getComputedStyle( el );
  213. return ( style.getPropertyValue( 'overflow' ) == 'hidden' );
  214. }
  215. }
  216. function isNotHidden( el )
  217. {
  218. if (el instanceof Element) {
  219. var style = window.getComputedStyle( el );
  220. return ( style.getPropertyValue( 'display' ) != 'none' );
  221. }
  222. }
  223.  
  224. function isBlackoutModal( el )
  225. {
  226. if (el instanceof Element) {
  227. var style = window.getComputedStyle( el );
  228. var position = style.getPropertyValue( 'position' );
  229. var top = parseInt( style.getPropertyValue( 'top' ) );
  230. var left = parseInt( style.getPropertyValue( 'left' ) );
  231. var right = parseInt( style.getPropertyValue( 'right' ) );
  232. var bottom = parseInt( style.getPropertyValue( 'bottom' ) );
  233. if (position == 'fixed') {
  234. debug ( "Possible Blackout",
  235. "position: " + position +
  236. "\n top: " + top + " left: " + left +
  237. "\n bottom: " + bottom + " right: " + right +
  238. "\n Height: " + (window.innerHeight / el.offsetHeight) +
  239. "\n Width: " + (window.innerWidth / el.offsetWidth)
  240. );
  241. }
  242. return position == 'fixed' && ( ( (window.innerHeight / el.offsetHeight) > 0.96 && (window.innerWidth / el.offsetWidth) > 0.96 ) && ((top <= 2 && left <= 2) || (right <= 2 && bottom <= 2)) );
  243. }
  244. }
  245.  
  246. function isAntiAdblockText( value )
  247. {
  248. return adblock_pattern.test( value ) && disable_pattern.test( value );
  249. }
  250.  
  251. function isModalWindows( el )
  252. {
  253. return isElementFixed ( el ) && ( isAntiAdblockText( el.textContent ) || isBlackoutModal( el ) );
  254. }
  255.  
  256. // Blocks the possibility of being able to remove the BODY or the HEAD
  257. function protectCore() {
  258. if ( is_core_protected ) return;
  259.  
  260. if (typeof unsafeWindow === 'undefined') {
  261. const unsafeWindow = window;
  262. }
  263.  
  264. // Protect RemoveChild
  265. const $_removeChild = unsafeWindow.Node.prototype.removeChild;
  266. unsafeWindow.Node.prototype.removeChild = function( node ) {
  267. if ( node.nodeName == 'HEAD' || (node.parentNode.nodeName == 'HEAD' && !(/META|SCRIPT|STYLE/.test(node.nodeName)) ) ){
  268. return debug( 'An attempt to DELETE the element ' + node.nodeName + ' was blocked', node );
  269. }
  270. else if ( node.nodeName == 'BODY' ){
  271. if ( node.parentNode == document.body.firstElementChild ) {
  272. return debug( 'An attempt to DELETE the element ' + node.nodeName + ' from ' + node.parentNode.nodeName + ' was blocked', node );
  273. }
  274. return debug( 'An attempt to DELETE the element ' + node.nodeName + ' was blocked', node );
  275. }
  276. $_removeChild.apply( this, arguments );
  277. };
  278.  
  279. // Protect innerHTML
  280.  
  281. const $_innerHTML = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
  282. Object.defineProperty(Element.prototype, 'innerHTML', {
  283. set: function (value) {
  284. if ( this.nodeName == 'BODY' || isAntiAdblockText( value ) ){
  285. return debug( 'An attempt to CHANGE the content of the element ' + this.nodeName + ' was blocked\n', value );
  286. }
  287. //Call the original setter
  288. return $_innerHTML.set.call(this, value);
  289. },
  290. get: function() {
  291. return $_innerHTML.get.call(this);
  292. },
  293. configurable: true
  294. });
  295.  
  296. debug( 'Core Protected');
  297. }
  298.  
  299.  
  300. function unblockScroll()
  301. {
  302. if ( isOverflowHidden( document.body ) )
  303. {
  304. document.body.setAttribute('style', (document.body.getAttribute('style')||'').replace('overflow: visible !important;','') + 'overflow: visible !important;');
  305. document.body.classList.add( 'scroll_on' );
  306. debug( 'Scroll Unblocked from BODY tag');
  307. }
  308. if ( isOverflowHidden( document.documentElement ) )
  309. {
  310. document.documentElement.setAttribute('style', (document.documentElement.getAttribute('style')||'').replace('overflow: visible !important;','') + 'overflow: visible !important;');
  311. document.documentElement.classList.add( 'scroll_on' );
  312. debug( 'Scroll Unblocked from HTML tag ');
  313. }
  314. }
  315.  
  316. // Main Functions
  317. function removeBackStuff()
  318. {
  319. document.querySelectorAll( 'b,center,div,font,i,iframe,s,span,section,u' ).forEach( ( el ) => {
  320. if ( isBlackoutModal( el ) )
  321. {
  322. debug( 'Blackout Modal Detected & Removed: ', el);
  323. el.removeAttribute('id');
  324. el.removeAttribute('class');
  325. el.setAttribute('style', (el.getAttribute('style')||'') + ';display: none !important;');
  326. el.classList.add( 'hide_modal' );
  327. }
  328. else if ( isElementBlur( el ) )
  329. {
  330. debug( 'Blur Element Detected & Deblurred: ', el);
  331. el.classList.add( 'un_blur' );
  332. }
  333. });
  334. setTimeout( unblockScroll, 500);
  335. }
  336.  
  337. function checkModals()
  338. {
  339. debug( 'Checking Modals' );
  340. var modalFound = false;
  341. // Only check common used html tag names
  342. document.querySelectorAll( 'b,center,div,font,i,iframe,s,span,section,u' ).forEach( ( el ) => {
  343. if ( isModalWindows( el ) && isNotHidden( el ) )
  344. {
  345. modalFound = true;
  346. removeModal( el );
  347. }
  348. });
  349.  
  350. if ( modalFound )
  351. {
  352. setTimeout( removeBackStuff, 150);
  353. }
  354. }
  355.  
  356. function removeModal( el, isNew )
  357. {
  358. // Skip the already processed elements
  359. if ( (new RegExp(classes.join('|'))).test( el.classList ) ) {
  360. //debug( 'Modal already added : ', el );
  361. return;
  362. }
  363.  
  364. el.removeAttribute('id');
  365. el.removeAttribute('class');
  366.  
  367. // Definde a random class name to hide the element
  368. // ( so that it is not so easy to detect the class name )
  369. var class_name = '';
  370. class_name = addRandomClass( el );
  371. classes.push( class_name );
  372.  
  373. // Hide the element through a high priority incorporating the sentence in the style parameter
  374. el.setAttribute('style', (el.getAttribute('style')||'') + ';display: none !important;');
  375.  
  376. // Also, add the random class name to the element
  377. // (in case there is a script that eliminates the previous statement)
  378. addStyle( '.' + class_name + '{ display: none !important; }' );
  379.  
  380. debug( 'Modal Detected & Removed: ', el);
  381.  
  382. if ( isNew )
  383. {
  384. setTimeout( removeBackStuff, 150);
  385. }
  386. }
  387.  
  388. window.addEventListener('DOMContentLoaded', (event) => {
  389.  
  390.  
  391. classes.push( getRandomName() );
  392.  
  393. //document.html = document.getElementsByTagName('html')[0];
  394.  
  395. // Mutation Observer
  396. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  397.  
  398. // Create an observer instance
  399. var observer = new MutationObserver( (mutations) => {
  400. mutations.forEach( (mutation) => {
  401. if ( mutation.addedNodes.length ) {
  402. Array.prototype.forEach.call( mutation.addedNodes, ( el ) => {
  403. // skip unusual html tag names
  404. if ( !tagNames_pattern.test ( el.tagName ) ) return;
  405.  
  406. // Check if element is an Anti-Adblock Modal Windows
  407. if ( isModalWindows( el ) && isNotHidden( el ) )
  408. {
  409. debug( 'OnMutationObserver: ', el );
  410. removeModal( el, true );
  411. }
  412. });
  413. }
  414. });
  415. });
  416. // Observer
  417. // Observe only the body and its direct descendants
  418. observer.observe(document.body, {
  419. childList : true,
  420. subtree : true
  421. });
  422.  
  423.  
  424. // First check with a little delay
  425. setTimeout( function() {
  426. // check Modals
  427. checkModals();
  428. }, 150 );
  429.  
  430. addStyle( 'body { user-select: auto !important; } body.scroll_on, html.scroll_on { overflow: visible !important; } .hide_modal { display: none !important; } .un_blur { -webkit-filter: blur(0px) !important; filter: blur(0px) !important; }' );
  431.  
  432. });
  433.  
  434. window.addEventListener('load', (event) => {
  435. // Second check, when page is complete loaded ( just in case )
  436. setTimeout( function() {
  437. // enable RightClick again
  438. enableRightClick();
  439. // check Modals
  440. checkModals();
  441. }, 1500 );
  442. });
  443.  
  444.  
  445. // Protect Core Functions
  446. protectCore();
  447.  
  448. })();