9anime Best Resolution

Automatcially select the highest resolution on vidstream/mycloud streams

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         9anime Best Resolution
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Automatcially select the highest resolution on vidstream/mycloud streams
// @author       Discord: nvllptr
// @match        https://9animetv.lv/*
// @match        https://hianime.kim/*
// @match        https://zorotv.my/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=9animetv.lv
// @grant        none
// @license      MIT
// ==/UserScript==
 
(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);
 
    // Set the quality to the highest with the jwplayer api
    const player = jwplayer();
    // 0 = auto, 1 = highest
    player.on('firstFrame', () => player.setCurrentQuality(1));
})();