Greasy Fork

来自缓存

Greasy Fork is available in English.

KimCartoon AutoPlay by ImFalling

Autoplay and auto-fullscreen next episode on kimcartoon.to

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         KimCartoon AutoPlay by ImFalling
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Autoplay and auto-fullscreen next episode on kimcartoon.to
// @author       ImFalling @ GitHub
// @match        https://kimcartoon.to/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    //Get the video player
    var video = document.querySelector("#my_video_1_html5_api");
    //Set time variables
    var durationValue = video.duration;
    var currentValue = video.currentTime;
    //Variable to ensure the script will not spam the "next" link. KimCartoon detects bots through this type of request spam.
    var clicked = false;

    //Define margin of video end in seconds
    var margin = 3;
    //Define interval of script trigger in milliseconds
    var interval = 4000;

    //Make the video player cover the entire page, since actual auto-fullscreen is disabled in browsers due to security issues.
    video.style.position = "fixed";
    video.play();
    video.controls = true;

    document.body.style.overflowY = "hidden";

    function disableScript(){
        video.style.position= "relative";
        document.body.style.overflowY = "scroll";
        clearInterval(checkOver);
        video.controls = false;
    }

    function checkOver(){
        //Update time values
        currentValue = video.currentTime;
        durationValue = video.duration;

        //DEBUG STUFF
        /*console.log("Right time: " + currentValue + " >= " + durationValue + "?");
        console.log(currentValue >= durationValue);
        console.log("Has clicked: ");
        console.log(clicked);*/

        //Check if episode is over, and if the next link has not yet been clicked.
        if(currentValue >= durationValue - margin && !clicked){
            var next = document.querySelector("#myContainer > div:nth-child(2) > a:nth-child(2)");
            if(next != null){
                next.click()
            }
            else{
                if(confirm("Could not find 'Next' button on page. Perhaps this was the last episode?\nDisable the script for this page?")){
                    disableScript();
                }
            }
            clicked = true;

        }
    }

    setInterval(checkOver, interval);

    video.addEventListener("pause", function(e){
        if(confirm("Press OK to disable the script. Otherwise, press cancel.")){
           disableScript();
        }
    }, false);
})();