The script is to auto click the "全高清" Button for viu.com videos (only avaliable for paid member)
当前为
// ==UserScript==
// @name Auto Full HD Resolution for Viu.com Video Playing
// @version 0.2
// @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';
if (!document || !document.documentElement) return window.requestAnimationFrame($$);
var fn = function() {
this.setAttribute('__userscript_viu_force_selected', 'true')
};
var t = 0;
var cid = 0;
var mDate = 0;
const TIMEOUT = 8000;
var gn = function() {
mDate = +new Date + TIMEOUT;
if (cid > 0) clearInterval(cid);
cid = setInterval(function() {
if (mDate < +new Date) clearInterval(cid);
var btn1080 = document.querySelector('.vjs-menu-item[data-r="1080"]');
if (btn1080) {
clearInterval(cid);
if(btn1080.matches('[__userscript_viu_loaded]'))return;
btn1080.setAttribute('__userscript_viu_loaded', 'true');
const bool = btn1080.matches(':not([aria-disabled=""]):not([aria-disabled="true"]):not([aria-checked="true"]):not([aria-checked=""])');
if (bool) {
const menuBtns = btn1080.parentNode.querySelectorAll('.vjs-menu-item[data-r]');
queueMicrotask(() => {
btn1080.click();
queueMicrotask(() => {
for (const menuBtn of menuBtns) menuBtn.addEventListener("click", fn, true)
})
})
}
}
}, 33);
}
document.addEventListener('loadedmetadata', gn, true)
document.addEventListener('playing', gn, true)
document.addEventListener('pause', gn, true)
// Your code here...
})();