Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/40acc2fa0a41477dd5b6259b7a632dfd.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name Auto Full HD Resolution for Viu.com Video Playing
// @version 0.4
// @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
// @downloadURL none
// ==/UserScript==
(function $$() {
'use strict';
if (!document || !document.documentElement) return window.requestAnimationFrame($$);
var fn = function() {
this.setAttribute('__userscript_viu_force_selected', 'true')
};
var cid = 0;
var mDate = 0;
const TIMEOUT = 8000; // just in case DOM is not found
var gn = function() {
mDate = +new Date + TIMEOUT;
var jn=function(btn1080){
//button is found
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]');
btn1080.click();
queueMicrotask(() => {
for (const menuBtn of menuBtns) menuBtn.addEventListener("click", fn, true)
})
}
}
var zn=function() {
//query when the video is loading/loaded/ready...
if (cid>0 && mDate < +new Date) {
cid=clearInterval(cid);
return;
}
var btn1080 = document.querySelector('.vjs-menu-item[data-r="1080"]');
if (!btn1080) return;
if(cid>0) cid=clearInterval(cid);
if(btn1080.matches('[__userscript_viu_loaded]'))return true;
btn1080.setAttribute('__userscript_viu_loaded', 'true');
window.requestAnimationFrame(()=>jn(btn1080)); // prevent too fast
}
if (cid > 0) cid=clearInterval(cid);
if(!zn()) cid = setInterval(zn, 33);
}
document.addEventListener('loadstart', gn, true)
document.addEventListener('durationchange', gn, true)
document.addEventListener('loadedmetadata', gn, true)
document.addEventListener('loadeddata', gn, true)
document.addEventListener('progress', gn, true)
document.addEventListener('canplay', gn, true)
document.addEventListener('canplaythrough', gn, true)
// Your code here...
})();