KissAnime Anti-Adblock Blocker

Not even the people from Easylist seem to fight this site anymore, someone had to try as this looks popular enough. *sigh*

当前为 2014-09-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name KissAnime Anti-Adblock Blocker
  3. // @namespace userscripts.org/user/swyter
  4. // @description Not even the people from Easylist seem to fight this site anymore, someone had to try as this looks popular enough. *sigh*
  5. // @match http://kissanime.com/*
  6. // @version 3.3.1
  7. // @grant GM_addStyle
  8. // @run-at document-end
  9. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=swyterzone%40gmail%2ecom&item_number=swydonations&currency_code=EUR
  10. // ==/UserScript==
  11.  
  12. /* run this just on the parent page, not in sub-frames */
  13. if (window.parent !== window)
  14. throw "stop execution";
  15.  
  16. /* get rid of timeouts right away, they aren't used for anything useful */
  17. console.log("Started KissAnime Anti-Adblock Blocker, waiting for the DOM to load...");
  18.  
  19. /* chromium-based browsers compatibility/fallback */
  20. unsafeWindow = (unsafeWindow ? unsafeWindow : window);
  21.  
  22. setTimeout_fn = unsafeWindow.setTimeout;
  23.  
  24. //unsafeWindow.setTimeout=undefined;
  25. // window.setTimeout=undefined;
  26.  
  27. function when_external_loaded()
  28. {
  29. console.log("DOM loaded, processing stuff...");
  30.  
  31. /* remove the anti-adblock script */
  32. if(thing=document.querySelector("#adCheck3 + script"))
  33. {
  34. thing.parentElement.removeChild(thing);
  35. }
  36. /* get rid of the cruft */
  37. for(elem in cruft=document.querySelectorAll("iframe[src*='ad'], .divCloseBut, .clear2, div[style*='!important']"))
  38. {
  39. if(typeof cruft[elem]==="object")
  40. {
  41. console.log("removing cruft: ", cruft[elem]);
  42. cruft[elem].parentElement.removeChild(cruft[elem]);
  43. }
  44. }
  45. /* custom timeout override */
  46. (function(timeout_func)
  47. {
  48. window.setTimeout = function(arg, time)
  49. {
  50. if(//arguments.callee &&
  51. //arguments.callee.caller &&
  52. //arguments.callee.caller.toString().match(/(ad)check/i) != null ||
  53. (typeof arguments[0] === "string" && arguments[0].match(/detect/i) != null))
  54. {
  55. console.info("No timeout for you, AdBlock blocker!", arguments.callee.caller.toString().match(/(ad)check/i),arguments[0].match(/detect/i), arguments);
  56. return 0;
  57. }
  58. else
  59. {
  60. timeout_func.apply(this,arguments);
  61. }
  62. }
  63. }(window.setTimeout))
  64. /* let's hook the AJAX requests, just in case, and filter out the so-called 'ban'
  65. avoiding potential fake points loss and such, what a scummy move by the site owner */
  66. (function(xhr_proto_open)
  67. {
  68. XMLHttpRequest.prototype.open = function(method,url)
  69. {
  70. if(url.match(/ban|Banned|GotBanned/) != null)
  71. {
  72. console.info("Intercepted shitty 'ban' request!", arguments);
  73. this.abort();
  74. }
  75. else
  76. {
  77. xhr_proto_open.apply(this,arguments);
  78. }
  79. }
  80. }(XMLHttpRequest.prototype.open))
  81. }
  82.  
  83.  
  84. /* inject this cleaning function right in the page */
  85. window.document.head.appendChild(
  86. inject_fn = document.createElement("script")
  87. );
  88.  
  89. inject_fn.innerHTML = when_external_loaded.toString() + ";when_external_loaded()";
  90.  
  91.  
  92. /* fix upper links positioning after removing the cruft and
  93. add styling rules for my custom lightsoff lampshade */
  94. GM_addStyle("a#qualityChoose \
  95. { \
  96. display: block; \
  97. } \
  98. \
  99. div.swylightsoff \
  100. { \
  101. right: 0; \
  102. width: 100%; \
  103. height: 100%; \
  104. top: 0; \
  105. left: 0; \
  106. position: fixed; \
  107. background: rgba(0,0,0,0.96); \
  108. } \
  109. \
  110. #divContentVideo \
  111. { \
  112. z-index: 999; \
  113. } \
  114. \
  115. #switch \
  116. { \
  117. z-index: auto; \
  118. }");
  119.  
  120.  
  121. /* make the *lights off* button work */
  122. document.getElementById("switch").addEventListener("click",function(e)
  123. {
  124.  
  125. lights_off = document.querySelector('.swylightsoff');
  126.  
  127. if(!lights_off)
  128. {
  129. console.log("Lights off");
  130. window.document.getElementById("switch").appendChild(
  131. inject_lo = document.createElement("div")
  132. );
  133. inject_lo.classList.add("swylightsoff");
  134. }
  135. else
  136. {
  137. console.log("Lights on");
  138. lights_off.parentElement.removeChild(lights_off);
  139. }
  140. })