Youtube Video Quality

Disabling auto video quality with toast notification, original script -> https://greasyfork.org/en/users/226529

当前为 2019-03-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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