Advertisement
Cpt_mathix

Kissanime Anti-Adblocker

Apr 3rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        KissAnime Anti-Adblock Blocker
  3. // @author      Swyter
  4. // @namespace   userscripts.org/user/swyter
  5. // @description Not even the people from Easylist seem to fight this site anymore, someone had to try as this looks popular enough. *sigh*
  6. // @match       *://kissanime.com/*
  7. // @match       *://kisscartoon.me/*
  8. // @match       *://kissanime.to/*
  9. // @match       *://kissasian.com/*
  10. // @match       *://kissmanga.com/*
  11. // @match       *://readcomiconline.to/*
  12. // @match       *://kissanime.ru/*
  13. // @match       *://kisscartoon.se/*
  14. // @version     2017.04.01.3
  15. // @grant       none
  16. // @run-at      document-start
  17. // ==/UserScript==
  18.  
  19. console.log('Started KissAnime Anti-Adblock Blocker, waiting for the DOM to load...');
  20.  
  21. window.addEventListener('beforescriptexecute', function(e)
  22. {
  23.   /* typical js kludge, holy carp, that's convoluted! */
  24.   var element_host = ((tmp = document.createElement('a')).href = e.target.src) && tmp.host;
  25.  
  26.   if (e.target.src && element_host !== document.domain &&
  27.                       element_host !== document.domain.split('.')[0] + '.disqus.com') e.preventDefault();
  28.  
  29.   if (!e.target.src)
  30.     for (var i of ['charCodeAt', 'BB_', 'taboola', 'plusone', 'analytics'])
  31.       if (e.target.textContent.indexOf(i) != -1)
  32.         e.preventDefault();
  33.  
  34.   console.log('[i] blocking script element: ', e.defaultPrevented, e.target.src);
  35. });
  36.  
  37. /* let's hook the AJAX requests, just in case, and filter out the so-called 'ban'
  38.    avoiding potential fake points loss and such, what a scummy move by the site owner */
  39. (function (xhr_proto_open)
  40.  {
  41.     window.XMLHttpRequest.prototype.open = function(method, url)
  42.     {
  43.         var element_host = ((tmp = document.createElement('a')).href = url) && tmp.host;
  44.         console.log(element_host);
  45.  
  46.         if (url.match(/ban|Banned|GotBanned/gi) !== null)
  47.         {
  48.             console.info("[x] intercepted shitty 'ban' request!", arguments);
  49.             this.abort();
  50.         }
  51.         else if (url && element_host !== document.domain && element_host !== document.domain.split('.')[0] + '.disqus.com')
  52.         {
  53.             console.info("[x] intercepted cross-domain request!", arguments);
  54.             this.abort();
  55.         }
  56.         else
  57.         {
  58.             xhr_proto_open.apply(this, arguments);
  59.         }
  60.     };
  61. }(XMLHttpRequest.prototype.open));
  62.  
  63. /* override the check in Chrome and call it a day */
  64. try
  65. {
  66.   Object.defineProperty(window, 'DoDetect2',
  67.   {
  68.     configurable: false,
  69.     writable: false,
  70.     value: function()
  71.     {
  72.       console.info('[/] check overriden!');
  73.     }
  74.   });
  75. } catch(e) {}
  76.  
  77. window.addEventListener('DOMContentLoaded', function(e)
  78. {
  79.   console.log('DOM loaded, processing stuff...');
  80.  
  81.   /* get rid of the cruft */
  82.   for (var elem of document.querySelectorAll(`
  83.      iframe[src*='ad']:not([src*='openload']),
  84.     .divCloseBut,
  85.     .clear2,
  86.      div[style*='!important'],
  87.      div[id^='divFloat'],
  88.     .episodeList div[style$='float: left;'],
  89.     .episodeList .clear,
  90.      div[style$='height:80px'],
  91.      img[id^='adCheck'],
  92.      div[id^=adsFloat][style],
  93.      div[id^=btnClose],
  94.      div[style*='width:800px'],
  95.      div[id*=fl-ads].rf-container,
  96.      iframe[src*='Ads'],
  97.      iframe[src*='facebook'],
  98.      div[style*='300px'][style*='250px'],
  99.      div[style*='margin: 0px auto'],
  100.      div[style*='height: 600px'],
  101.      div[style*='820px'][style*='215px'],
  102.      div[style*='728px'][style*='200px'],
  103.      li#liFlappy, li#liReportError,
  104.      body > script[src],
  105.      script[data-cfasync],
  106.      iframe[src*='check.aspx']
  107.   `))
  108.   {
  109.     console.log('[-] removing cruft: ', elem);
  110.     elem.parentElement.removeChild(elem);
  111.   }
  112. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement