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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        KissAnime Anti-Adblock Blocker
// @namespace   userscripts.org/user/swyter
// @description Not even the people from Easylist seem to fight this site anymore, someone had to try as this looks popular enough. *sigh*
// @match       http://kissanime.com/*
// @version     3.3.1
// @grant       GM_addStyle
// @run-at      document-end
// @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=swyterzone%40gmail%2ecom&item_number=swydonations&currency_code=EUR
// ==/UserScript==

/* run this just on the parent page, not in sub-frames */
if (window.parent !== window)
  throw "stop execution";

/* get rid of timeouts right away, they aren't used for anything useful */
console.log("Started KissAnime Anti-Adblock Blocker, waiting for the DOM to load...");

/* chromium-based browsers compatibility/fallback */
unsafeWindow = (unsafeWindow ? unsafeWindow : window);

setTimeout_fn = unsafeWindow.setTimeout;

//unsafeWindow.setTimeout=undefined;
//      window.setTimeout=undefined;

   
function when_external_loaded()
{   
    console.log("DOM loaded, processing stuff...");

    /* remove the anti-adblock script */
    if(thing=document.querySelector("#adCheck3 + script"))
    {
        thing.parentElement.removeChild(thing);
    }
    
    /* get rid of the cruft */
    for(elem in cruft=document.querySelectorAll("iframe[src*='ad'], .divCloseBut, .clear2, div[style*='!important']"))
    {
        if(typeof cruft[elem]==="object")
        {
          console.log("removing cruft: ", cruft[elem]);
          cruft[elem].parentElement.removeChild(cruft[elem]);
        }
    }
    
    /* custom timeout override */
    (function(timeout_func)
    {
        window.setTimeout = function(arg, time)
        {
            if(//arguments.callee &&
               //arguments.callee.caller &&
               //arguments.callee.caller.toString().match(/(ad)check/i) != null ||
            (typeof arguments[0] === "string" && arguments[0].match(/detect/i) != null))
            {
                console.info("No timeout for you, AdBlock blocker!", arguments.callee.caller.toString().match(/(ad)check/i),arguments[0].match(/detect/i), arguments);
                return 0;
            }
            else
            {
                timeout_func.apply(this,arguments);
            }
        }
    }(window.setTimeout))
        
    /* let's hook the AJAX requests, just in case, and filter out the so-called 'ban'
       avoiding potential fake points loss and such, what a scummy move by the site owner */
    (function(xhr_proto_open)
    {
        XMLHttpRequest.prototype.open = function(method,url)
        {
            if(url.match(/ban|Banned|GotBanned/) != null)
            {
                console.info("Intercepted shitty 'ban' request!", arguments);
                this.abort();
            }
            else
            {
                xhr_proto_open.apply(this,arguments);
            }
        }
    }(XMLHttpRequest.prototype.open))
}


/* inject this cleaning function right in the page */
window.document.head.appendChild(
  inject_fn = document.createElement("script")
);

inject_fn.innerHTML = when_external_loaded.toString() + ";when_external_loaded()";


/* fix upper links positioning after removing the cruft and
   add styling rules for my custom lightsoff lampshade */
   
GM_addStyle("a#qualityChoose                    \
             {                                  \
               display: block;                  \
             }                                  \
                                                \
             div.swylightsoff                   \
             {                                  \
               right: 0;                        \
               width: 100%;                     \
               height: 100%;                    \
               top: 0;                          \
               left: 0;                         \
               position: fixed;                 \
               background: rgba(0,0,0,0.96);    \
             }                                  \
                                                \
             #divContentVideo                   \
             {                                  \
               z-index: 999;                    \
             }                                  \
                                                \
             #switch                            \
             {                                  \
               z-index: auto;                   \
             }");


/* make the *lights off* button work */
document.getElementById("switch").addEventListener("click",function(e)
{

    lights_off = document.querySelector('.swylightsoff');

    if(!lights_off)
    {
        console.log("Lights off");
    
        window.document.getElementById("switch").appendChild(
            inject_lo = document.createElement("div")
        );
        
        inject_lo.classList.add("swylightsoff");
    }
    else
    {
        console.log("Lights on");
        lights_off.parentElement.removeChild(lights_off);
    }
})