Disabling auto video quality with toast notification, original script -> https://greasyfork.org/en/users/226529
当前为
// ==UserScript==
// @name Youtube Video Quality
// @version 1.0
// @grant none
// @match https://www.youtube.com/*
// @run-at document-start
// @author Yamako - Tanuki
// @description Disabling auto video quality with toast notification, original script -> https://greasyfork.org/en/users/226529
// @no-frames
// @namespace
// ==/UserScript==
const QUALITIES = ['auto', 'highres', 'hd2880', 'hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small', 'tiny'];
const QUALITY_MEDIUM = QUALITIES[8]; //360p
const QUALITY_LARGE = QUALITIES[7]; //480p
const QUALITY_SMALL = QUALITIES[9]; //240p
const KUALITAS = QUALITY_MEDIUM;
var entut = 0;
var kntd = 0;
addCSS('https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css');
addScript('https://cdn.jsdelivr.net/npm/toastify-js');
function SetQuality() {
if (window.location.href.indexOf('watch?v=')>1){
if (document.getElementById("movie_player").getPlaybackQuality() != KUALITAS) {
Toastify({text: "Change "+document.getElementById("movie_player").getPlaybackQuality()+" to "+ KUALITAS + " Quality.",duration: 3000}).showToast();
document.getElementById("movie_player").setPlaybackQualityRange(KUALITAS);
}else{
if (entut == 0){
Toastify({text: "Video Quality Already "+ document.getElementById("movie_player").getPlaybackQuality(),duration: 3000}).showToast();
entut = 1;
}
}
}
}
setTimeout(SetQuality, 1000);
setInterval(SetQuality, 500);
// https://makitweb.com/dynamically-include-script-and-css-file-with-javascript/
// Include CSS file
function addCSS(filename){
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('link');
style.href = filename;
style.type = 'text/css';
style.rel = 'stylesheet';
head.append(style);
console.log(filename + " Loaded.")
}
// Include script file
function addScript(filename){
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
head.append(script);
console.log(filename + " Loaded.")
}