Greasy Fork

Greasy Fork is available in English.

KissAnime Auto Hide

Automatically hide ads on KissAnime pages. Also automatically hides the beta player ad.

当前为 2018-07-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         KissAnime Auto Hide
// @version      1.1.1
// @description  Automatically hide ads on KissAnime pages.  Also automatically hides the beta player ad.
// @author       G-Rex
// @match        http://kissanime.ru/*
// @match        https://kissanime.ru/*
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at       document-idle
//
// @namespace http://greasyfork.icu/users/154522
// ==/UserScript==

var observer;
var hidAds = false;
var closedVidAd = false;

(function() {
    'use strict';

    let date = new Date();
    let sec = date.getSeconds();
    let ms = date.getMilliseconds();

    let content = document.querySelector('.barContent');
    if(!content) {
        return;
    }

    observer = new MutationObserver(removeAds);
    observer.observe(content, {
        'childList': true,
        'subtree': true
    });
})();

function removeAds() {
    hideAds();
    closeVideoAd();

    if(hidAds && closedVidAd) {
        console.log('disconnecting');
        observer.disconnect();
    }
}

function hideAds() {
    let hideAnchors = document.querySelectorAll('.divCloseBut a');

    if(hideAnchors.length === 0) {
        return;
    }

    for(let i = 0; i < hideAnchors.length; i++) {
        hideAnchors[i].onclick();
    }

    hidAds = true;
}

function closeVideoAd() {
    let videoAdClose = document.querySelector('.videoAdClose');


    if(!videoAdClose) {
        return;
    }

    videoAdClose.onclick();

    closedVidAd = true;
}

function videoadclosetemp() {
    let videoAd = document.getElementById('videoAd');
    if(videoAd) {
        videoAd.parentNode.removeChild(videoAd);
    }

    let videoAdClose = document.getElementsByClassName('videoAdClose');

    for(let i = 0; i < videoAdClose.length; i++) {
        if(videoAdClose[i]) {
            videoAdClose[i].parentNode.removeChild(videoAdClose[i]);
        }
    }
}