YouTube: Force Animated-Rolling-Number

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        YouTube: Force Animated-Rolling-Number
// @namespace   UserScripts
// @match       https://www.youtube.com/*
// @grant       none
// @version     0.1.11
// @author      CY Fung
// @license     MIT
// @description To force YouTube use Animated-Rolling-Number for YouTube Live
// @run-at      document-start
// @inject-into page
// @unwrap
// @require     https://update.greasyfork.org/scripts/475632/1361351/ytConfigHacks.js
// ==/UserScript==

(() => {

  window._ytConfigHacks.add((config_) => {

    const EXPERIMENT_FLAGS = config_.EXPERIMENT_FLAGS;

    if (EXPERIMENT_FLAGS) {

      EXPERIMENT_FLAGS.web_enable_dynamic_metadata = true;
      EXPERIMENT_FLAGS.dynamic_metadata_update_interaction_delay_period_sec = 8;
      EXPERIMENT_FLAGS.web_animated_like = true;
      EXPERIMENT_FLAGS.web_animated_like_lazy_load = true;

    }

  });

  const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);

  setInterval(() => {
    // prevent animation number flicking due to change of video content (browse -> mini -> browse of another)

    for (const an of document.querySelectorAll('[hidden] yt-animated-rolling-number:not([f9wm6="0"]), [hidden] yt-smartimation:not([f9wm6="0"])')) {
      an.setAttribute('f9wm6', '0');
      const cnt = insp(an);
      const pnt = typeof cnt.disconnectedCallback === 'function' ? cnt : an;
      if (typeof pnt.disconnectedCallback === 'function') pnt.disconnectedCallback();
    }

    for (const an of document.querySelectorAll('yt-animated-rolling-number[f9wm6="0"], yt-smartimation[f9wm6="0"]')) {
      if (an.closest('[hidden]')) continue;
      an.setAttribute('f9wm6', '1');
      const cnt = insp(an);
      const pnt = typeof cnt.connectedCallback === 'function' ? cnt : an;
      if (typeof pnt.connectedCallback === 'function') pnt.connectedCallback();
    }

  }, 100);


})();