YouTube: Force Animated-Rolling-Number

To force YouTube use Animated-Rolling-Number for YouTube Live

目前为 2023-10-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube: Force Animated-Rolling-Number
  3. // @namespace UserScripts
  4. // @match https://www.youtube.com/*
  5. // @grant none
  6. // @version 0.1.5
  7. // @author CY Fung
  8. // @license MIT
  9. // @description To force YouTube use Animated-Rolling-Number for YouTube Live
  10. // @run-at document-start
  11. // @inject-into page
  12. // @unwrap
  13. // @require https://greasyfork.org/scripts/475632-ytconfighacks/code/ytConfigHacks.js?version=1252732
  14. // ==/UserScript==
  15.  
  16. (() => {
  17.  
  18. window._ytConfigHacks.add((config_) => {
  19.  
  20. const EXPERIMENT_FLAGS = config_.EXPERIMENT_FLAGS;
  21.  
  22. if (EXPERIMENT_FLAGS) {
  23.  
  24. EXPERIMENT_FLAGS.web_enable_dynamic_metadata = true;
  25. EXPERIMENT_FLAGS.dynamic_metadata_update_interaction_delay_period_sec = 8;
  26. EXPERIMENT_FLAGS.web_animated_like = true;
  27. EXPERIMENT_FLAGS.web_animated_like_lazy_load = true;
  28.  
  29.  
  30. }
  31.  
  32. });
  33.  
  34.  
  35. setInterval(()=>{
  36. // prevent animation number flicking due to change of video content (browse -> mini -> browse of another)
  37.  
  38. for(const an of document.querySelectorAll('[hidden] yt-animated-rolling-number:not([f9wm6="0"]), [hidden] yt-smartimation:not([f9wm6="0"])')){
  39. an.setAttribute('f9wm6','0');
  40. if(typeof an.disconnectedCallback ==='function') an.disconnectedCallback();
  41. }
  42.  
  43.  
  44. for(const an of document.querySelectorAll('yt-animated-rolling-number[f9wm6="0"], yt-smartimation[f9wm6="0"]')){
  45. if(an.closest('[hidden]')) continue;
  46. an.setAttribute('f9wm6','1');
  47. if(typeof an.connectedCallback ==='function') an.connectedCallback();
  48. }
  49.  
  50. }, 100);
  51.  
  52.  
  53. })();