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-07 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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.1
// @grant       none
// @run-at      document-end
// ==/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...");
window.setTimeout=undefined;
    
function when_external_loaded()
{   
    console.log("DOM loaded, processing stuff...");
    window.setTimeout=undefined;
    
    /* 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]);
        }
    }
}


/* 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 styling rules for my custom lightsoff lampshade */
window.document.head.appendChild(
  inject_st = document.createElement("style")
);

inject_st.innerHTML = "a#qualityChoose{display:block;} .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);
    }
})