Youtube Video Quality

Disabling auto video quality with toast notification, original script -> https://gf.qytechs.cn/en/users/226529

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

  1. // ==UserScript==
  2. // @name Youtube Video Quality
  3. // @version 1.0
  4. // @grant none
  5. // @match https://www.youtube.com/*
  6. // @run-at document-start
  7. // @author Yamako - Tanuki
  8. // @description Disabling auto video quality with toast notification, original script -> https://gf.qytechs.cn/en/users/226529
  9. // @no-frames
  10. // @namespace
  11. // ==/UserScript==
  12.  
  13. const QUALITIES = ['auto', 'highres', 'hd2880', 'hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small', 'tiny'];
  14. const QUALITY_MEDIUM = QUALITIES[8]; //360p
  15. const QUALITY_LARGE = QUALITIES[7]; //480p
  16. const QUALITY_SMALL = QUALITIES[9]; //240p
  17. const KUALITAS = QUALITY_MEDIUM;
  18. var entut = 0;
  19. var kntd = 0;
  20.  
  21. addCSS('https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css');
  22. addScript('https://cdn.jsdelivr.net/npm/toastify-js');
  23.  
  24. function SetQuality() {
  25. if (window.location.href.indexOf('watch?v=')>1){
  26. if (document.getElementById("movie_player").getPlaybackQuality() != KUALITAS) {
  27. Toastify({text: "Change "+document.getElementById("movie_player").getPlaybackQuality()+" to "+ KUALITAS + " Quality.",duration: 3000}).showToast();
  28. document.getElementById("movie_player").setPlaybackQualityRange(KUALITAS);
  29. }else{
  30. if (entut == 0){
  31. Toastify({text: "Video Quality Already "+ document.getElementById("movie_player").getPlaybackQuality(),duration: 3000}).showToast();
  32. entut = 1;
  33. }
  34. }
  35. }
  36. }
  37.  
  38. setTimeout(SetQuality, 1000);
  39. setInterval(SetQuality, 500);
  40.  
  41.  
  42. // https://makitweb.com/dynamically-include-script-and-css-file-with-javascript/
  43. // Include CSS file
  44. function addCSS(filename){
  45. var head = document.getElementsByTagName('head')[0];
  46.  
  47. var style = document.createElement('link');
  48. style.href = filename;
  49. style.type = 'text/css';
  50. style.rel = 'stylesheet';
  51. head.append(style);
  52. console.log(filename + " Loaded.")
  53. }
  54.  
  55. // Include script file
  56. function addScript(filename){
  57. var head = document.getElementsByTagName('head')[0];
  58.  
  59. var script = document.createElement('script');
  60. script.src = filename;
  61. script.type = 'text/javascript';
  62.  
  63. head.append(script);
  64. console.log(filename + " Loaded.")
  65. }
  66.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址