Greasy Fork

Greasy Fork is available in English.

9anime Bingewatcher+

Auto-fullscreen, skip intros, jump to next episode 9anime on Vidstream and MyCloud videos

当前为 2022-01-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         9anime Bingewatcher+
// @namespace    http://greasyfork.icu/en/users/10118-drhouse
// @version      3.0
// @description  Auto-fullscreen, skip intros, jump to next episode 9anime on Vidstream and MyCloud videos
// @include      https://www*.9anime.*/*
// @include      https://9anime.*/*
// @include      https://*.9anime.*/*
// @match        *.9anime.to/watch/*
// @include      https://vidstream.pro/*
// @include      https://vidstreamz.online/*
// @include      https://mcloud.to/*
// @include      https://mcloud2.to/*
// @include      https://storage.googleapis.com/*
// @include      https://movies7.to/*
// @include      https://*.mp4upload.com:*/*
// @include      https://*.mp4upload.com*/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @require      http://greasyfork.icu/scripts/395037-monkeyconfig-modern/code/MonkeyConfig%20Modern.js?version=764968
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @grant        GM_notification
// @author       drhouse
// @license      CC-BY-NC-SA-4.0
// @icon         https://s2.bunnycdn.ru/assets/9anime/favicons/favicon.png?v1
// ==/UserScript==
 
(function($){
 
    var cfg = new MonkeyConfig({
        title: 'Configure',
        menuCommand: true,
        params: {
            'Automatic Highest Quality': {
                type: 'checkbox',
                default: true,
                enable: true
            },
            'More Info': {
            type: 'text',
                default: 'http://greasyfork.icu/en/scripts/438731-9anime-auto-1080p-select-vidstream-mcloud'
            }
        }
    })

    if (cfg.get('Automatic Highest Quality')) {
        const myInterval = setInterval(myTimer, 1000);
        
        function myTimer() {
            var $highest_check = $('#jw-settings-submenu-quality > div:nth-child(1) > button:nth-child(2)').attr('aria-checked')
            var $auto_check = $('#jw-settings-submenu-quality > div:nth-child(1) > button:nth-child(1)').text()
            $('div.jw-icon:nth-child(14)')[0].click()

            if ($auto_check === 'Auto'){
                if ($highest_check === "true"){
                    $('div.jw-icon:nth-child(14)')[0].click()
                    clearInterval(myInterval);
                } else {
                    $('#jw-settings-submenu-quality > div:nth-child(1) > button:nth-child(2)').click()
                }
            } else {
                $('div.jw-icon:nth-child(14)')[0].click()
                clearInterval(myInterval);
            }
        }

    } else {
        // AHQ off
    }
    
    function openFullscreen(elem) {
        if (elem.requestFullscreen) {
            elem.requestFullscreen();
        } else if (elem.mozRequestFullScreen) { /* Firefox */
            elem.mozRequestFullScreen();
        } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
            elem.webkitRequestFullscreen();
        } else if (elem.msRequestFullscreen) { /* IE / Edge */
            elem.msRequestFullscreen();
        }
    }
 
    function waitForElementToDisplay(selector, time) {
        if($(selector)!=null) {
            setTimeout(function(){
                var elem = $('video').parent().parent().parent().get(0);
                openFullscreen(elem);
                $(elem).focus();
            }, 1000);
 
 
            var newYearCountdown = setInterval(function(){
 
                var player = $('video').get(0);
 
                var duration = player.duration;
                var current = player.currentTime;
 
                //console.log('duration='+duration)
                //console.log('current='+current)
 
                var link = $("body");
                link.addEventListener("keydown", function(event) {
 
                    var x = event.key;
                    var z = event.keyCode;
 
                    if (x == '0') { // 0 key skip 89s
                        player.currentTime = current + 89;
                    }
 
                    if (x == '6') { // 0 key skip end
                        player.currentTime = player.duration;
                    }
 
                    if (x == 'v') { // V key skip 89s
                        player.currentTime = current + 89;
                    }
 
                    if (x == 'n') { // V key skip end
                        player.currentTime = player.duration;
                    }
                }) 
            }, 1000);
        }
        else {
            setTimeout(function() {
                waitForElementToDisplay(selector, time);
            }, time);
        }
    }
 
    waitForElementToDisplay('#player', 1000);
 
})(jQuery);