Auto Full HD Resolution for Viu.com Video Playing

The script is to auto click the "全高清" Button for viu.com videos (only avaliable for paid member)

目前為 2021-06-16 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Auto Full HD Resolution for Viu.com Video Playing
// @version      0.1
// @description  The script is to auto click the "全高清" Button for viu.com videos (only avaliable for paid member)
// @match        https://www.viu.com/ott/*/vod/*
// @icon         https://www.google.com/s2/favicons?domain=viu.com
// @grant        none
// @namespace https://greasyfork.org/users/371179
// ==/UserScript==
(function() {
    'use strict';

    let p = 0;
    var fn = function() {
        if (p == 5) return;
        this.setAttribute('__userscript_viu_force_selected', 'true')
    };
    setInterval(function() {

        let s = document.querySelector('.vjs-menu-item[data-r="1080"]:not([aria-disabled=""]):not([aria-disabled="true"]):not([aria-checked="true"]):not([aria-checked=""]):not([__userscript_viu_loaded])');
        if (s) {
            s.setAttribute('__userscript_viu_loaded', 'true')
            for (const menuBtn of s.parentNode.querySelectorAll('.vjs-menu-item[data-r]')) {
                menuBtn.addEventListener("click", fn, true)
            }
            window.requestAnimationFrame(() => {

                if (s.parentNode.querySelector('[__userscript_viu_force_selected]')) return;

                p = 5;
                s.click();
                setTimeout(() => (p = 0), 300)

            })
        }

    }, 33)

    // Your code here...
})();