Greasy Fork is available in English.

HiAnime Auto 1080p

Automatically sets your Quality & Speed to your desired values, Auto Fullscreen, Auto Pause/Unpause when switching tabs, Auto Unmute.

Instali tiun ĉi skripton?
Author's suggested script

You may also like Better HiAnime.

Instali tiun ĉi skripton
// ==UserScript==
// @name         HiAnime Auto 1080p
// @namespace    http://tampermonkey.net/
// @version      4.3
// @description  Automatically sets your Quality & Speed to your desired values, Auto Fullscreen, Auto Pause/Unpause when switching tabs, Auto Unmute.
// @icon         https://hianime.to/images/icons-192.png
// @author       Ghoste
// @match        https://megacloud.tv/*
// @grant        none
// @license      MIT
// ==/UserScript==


var PauseOnFocusLoss = false
// Set this to true if you want it to pause/unpause based on if you're looking at
// the HiAnime tab or not (minimizing the browser, switching to another tab.)
// Valid Values: true, false.


var AutoUnmute = true
// If this is true, automatically unmutes the player if it starts muted.
// Valid Values: true, false.

var AutoFullscreen = false
// Set this to true if you want the video to automatically go fullscreen.
// Valid Values: true, false.

var PlaybackQuality = "1080"
// Sets the Video Quality.
// Valid Values: 1080, 720, 360.

var PlaybackRate = 1
// Sets the Playback Speed.
// Valid Values: 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2. (higher might work)



if (PauseOnFocusLoss == true){
var LastPlayingState = false
document.addEventListener("visibilitychange", () => {
    if (document.visibilityState == "visible"){
        if (LastPlayingState){
        jwplayer().play(1)
        }
    }
    if (document.visibilityState == "hidden"){
        if (jwplayer().getState() == 'paused'){
            LastPlayingState = false
        } else {
            LastPlayingState = true
            jwplayer().pause(1)
        }
    }
});
}

(async () => {
    'use strict';

    function waitForElement(selector, baseElement = document.body) {
        return new Promise(resolve => {
            if (baseElement.querySelector(selector)) {
                return resolve(baseElement.querySelector(selector));
            }

            const observer = new MutationObserver(mutations => {
                if (baseElement.querySelector(selector)) {
                    resolve(baseElement.querySelector(selector));
                    observer.disconnect();
                }
            });

            observer.observe(baseElement, {
                childList: true,
                subtree: true
            });
        });
    }

    // Once the settings button is loaded, we know the player is loaded
    const settingsButtonSelector = 'div.jw-icon.jw-icon-inline.jw-button-color.jw-reset.jw-icon-settings.jw-settings-submenu-button';
    await waitForElement(settingsButtonSelector);

    const player = jwplayer();

    player.on('firstFrame', function(){
        player.setPlaybackRate(PlaybackRate)
        if (AutoUnmute){
            player.setMute(0)
        }
        if (PlaybackQuality == "1080"){
            player.setCurrentQuality(1)
        }
        if (PlaybackQuality == "720"){
            player.setCurrentQuality(2)
        }
        if (PlaybackQuality == "360"){
            player.setCurrentQuality(3)
        }
        if (AutoFullscreen == true){
            player.setFullscreen(1)
        }
    });
    player.on('visualQuality', function(){
        if (PlaybackQuality == "1080"){
            player.setCurrentQuality(1)
        }
        if (PlaybackQuality == "720"){
            player.setCurrentQuality(2)
        }
        if (PlaybackQuality == "360"){
            player.setCurrentQuality(3)
        }
    });
})();