-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto Best Resolution.user.js
54 lines (48 loc) · 1.99 KB
/
Auto Best Resolution.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ==UserScript==
// @name Auto Best Resolution
// @namespace http://github.com/
// @version 1.9
// @description Automatcially select the highest resolution
// @author Loidauk / TellerMoose
// @match https://mcloud.bz/*
// @match https://vid2a41.site/*
// @match https://megacloud.tv/*
// @match https://1azayf9w.xyz/*
// @match https://vidco.pro/*
// @match https://embtaku.pro/*
// @match https://embtaku.com/*
// @match https://awish.pro/*
// @match https://megaf.cc/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=aniwave.to
// @grant none
// @license MIT
// @downloadURL https://update.greasyfork.org/scripts/487541/Aniwave%20Auto%20Best%20Resolution.user.js
// @updateURL https://update.greasyfork.org/scripts/487541/Aniwave%20Auto%20Best%20Resolution.meta.js
// ==/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));
})();