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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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...
})();