YouTube 超快聊天

YouTube直播聊天的终极性能提升

目前为 2023-08-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Super Fast Chat
  3. // @version 0.30.5
  4. // @license MIT
  5. // @name:ja YouTube スーパーファーストチャット
  6. // @name:zh-TW YouTube 超快聊天
  7. // @name:zh-CN YouTube 超快聊天
  8. // @icon https://github.com/cyfung1031/userscript-supports/raw/main/icons/super-fast-chat.png
  9. // @namespace UserScript
  10. // @match https://www.youtube.com/live_chat*
  11. // @match https://www.youtube.com/live_chat_replay*
  12. // @author CY Fung
  13. // @run-at document-start
  14. // @grant none
  15. // @unwrap
  16. // @allFrames true
  17. // @inject-into page
  18. //
  19. // @compatible firefox Violentmonkey
  20. // @compatible firefox Tampermonkey
  21. // @compatible firefox FireMonkey
  22. // @compatible chrome Violentmonkey
  23. // @compatible chrome Tampermonkey
  24. // @compatible opera Violentmonkey
  25. // @compatible opera Tampermonkey
  26. // @compatible safari Stay
  27. // @compatible edge Violentmonkey
  28. // @compatible edge Tampermonkey
  29. // @compatible brave Violentmonkey
  30. // @compatible brave Tampermonkey
  31. //
  32. // @description Ultimate Performance Boost for YouTube Live Chats
  33. // @description:ja YouTubeのライブチャットの究極のパフォーマンスブースト
  34. // @description:zh-TW YouTube直播聊天的終極性能提升
  35. // @description:zh-CN YouTube直播聊天的终极性能提升
  36. //
  37. // ==/UserScript==
  38.  
  39. ((__CONTEXT__) => {
  40. 'use strict';
  41.  
  42. const ENABLE_REDUCED_MAXITEMS_FOR_FLUSH = true; // TRUE to enable trimming down to MAX_ITEMS_FOR_FULL_FLUSH (25) messages when there are too many unrendered messages
  43. const MAX_ITEMS_FOR_TOTAL_DISPLAY = 90; // By default, 250 latest messages will be displayed, but displaying MAX_ITEMS_FOR_TOTAL_DISPLAY (90) messages is already sufficient.
  44. const MAX_ITEMS_FOR_FULL_FLUSH = 25; // If there are too many new (stacked) messages not yet rendered, clean all and flush MAX_ITEMS_FOR_FULL_FLUSH (25) latest messages then incrementally added back to MAX_ITEMS_FOR_TOTAL_DISPLAY (90) messages
  45.  
  46. const ENABLE_NO_SMOOTH_TRANSFORM = true; // Depends on whether you want the animation effect for new chat messages
  47. const USE_OPTIMIZED_ON_SCROLL_ITEMS = true; // TRUE for the majority
  48. const USE_WILL_CHANGE_CONTROLLER = false; // FALSE for the majority
  49. const ENABLE_DELAYED_CHAT_OCCURRENCE_PREFERRED = true; // In Chrome, the rendering of new chat messages could be too fast for no smooth transform. 80ms delay of displaying new messages should be sufficient for element rendering.
  50. const ENABLE_OVERFLOW_ANCHOR_PREFERRED = true; // Enable `overflow-anchor: auto` to lock the scroll list at the bottom for no smooth transform.
  51.  
  52. const FIX_SHOW_MORE_BUTTON_LOCATION = true; // When there are voting options (bottom panel), move the "show more" button to the top.
  53. const FIX_INPUT_PANEL_OVERFLOW_ISSUE = true; // When the super chat button is flicking with color, the scrollbar might come out.
  54. const FIX_INPUT_PANEL_BORDER_ISSUE = true; // No border should be allowed if there is an empty input panel.
  55. const SET_CONTAIN_FOR_CHATROOM = true; // Rendering hacks (`contain`) for chatroom elements. [ General ]
  56.  
  57. const FORCE_CONTENT_VISIBILITY_UNSET = true; // Content-visibility should be always VISIBLE for high performance and great rendering.
  58. const FORCE_WILL_CHANGE_UNSET = true; // Will-change should be always UNSET (auto) for high performance and low energy impact.
  59.  
  60. // Replace requestAnimationFrame timers with custom implementation
  61. const ENABLE_RAF_HACK_TICKERS = true; // When there is a ticker
  62. const ENABLE_RAF_HACK_DOCKED_MESSAGE = true; // To be confirmed
  63. const ENABLE_RAF_HACK_INPUT_RENDERER = true; // To be confirmed
  64. const ENABLE_RAF_HACK_EMOJI_PICKER = true; // When changing the page of the emoji picker
  65.  
  66. // Force rendering all the character subsets of the designated font(s) before messages come (Pre-Rendering of Text)
  67. const ENABLE_FONT_PRE_RENDERING_PREFERRED = 1 | 2 | 4 | 8 | 16;
  68.  
  69. // Backdrop `filter: blur(4px)` inside the iframe can extend to the whole page, causing a negative visual impact on the video you are watching.
  70. const NO_BACKDROP_FILTER_WHEN_MENU_SHOWN = true;
  71.  
  72. // Data Manipulation for Participants (Participant List)
  73. // << if DO_PARTICIPANT_LIST_HACKS >>
  74. const DO_PARTICIPANT_LIST_HACKS = true; // TRUE for the majority
  75. const SHOW_PARTICIPANT_CHANGES_IN_CONSOLE = false; // Just too annoying to show them all in popular chat
  76. const CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = true; // Only consider changes in renderable content (not concerned with the last chat message of the participants)
  77. const PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED = true;
  78. // << end >>
  79.  
  80. // show more button
  81. const ENABLE_SHOW_MORE_BLINKER = true; // BLINK WHEN NEW MESSAGES COME
  82.  
  83. // faster stampDomArray_ for participants list creation
  84. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL = 1; // 0 - OFF; 1 - ON; 2 - ON(PARTICIPANTS_LIST ONLY)
  85. const USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET = false;
  86.  
  87. // reuse yt components
  88. const ENABLE_FLAGS_REUSE_COMPONENTS = true;
  89.  
  90. // images <Group#I01>
  91. const AUTHOR_PHOTO_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  92. const EMOJI_IMAGE_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  93. const LEAST_IMAGE_SIZE = 48; // minium size = 48px
  94.  
  95. const DO_LINK_PREFETCH = true; // DO NOT CHANGE
  96. // << if DO_LINK_PREFETCH >>
  97. const ENABLE_BASE_PREFETCHING = true; // (SUB-)DOMAIN | dns-prefetch & preconnect
  98. const ENABLE_PRELOAD_THUMBNAIL = true; // subresource (prefetch) [LINK for Images]
  99. const PREFETCH_LIMITED_SIZE_EMOJI = 512; // DO NOT CHANGE THIS
  100. const PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO = 68; // DO NOT CHANGE THIS
  101. // << end >>
  102.  
  103. const FIX_SETSRC_AND_THUMBNAILCHANGE_ = true; // Function Replacement for yt-img-shadow....
  104. const FIX_THUMBNAIL_DATACHANGED = true; // Function Replacement for yt-live-chat-author-badge-renderer..dataChanged
  105. // const REMOVE_PRELOADAVATARFORADDACTION = false; // Function Replacement for yt-live-chat-renderer..preloadAvatarForAddAction
  106.  
  107. const FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION = true; // important [depends on <Group#I01>]
  108. const FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT = true; // [depends on <Group#I01>]
  109.  
  110. const ATTEMPT_ANIMATED_TICKER_BACKGROUND = 'steps' // false OR '' for disabled, 'linear', 'steps' for easing-function
  111. // << if ATTEMPT_ANIMATED_TICKER_BACKGROUND >>
  112. // BROWSER SUPPORT: Chrome 75+, Edge 79+, Safari 13.1+, Firefox 63+, Opera 62+
  113. const TICKER_MAX_STEPS_LIMIT = 500; // NOT LESS THAN 5 STEPS!!
  114. // [limiting 500 max steps] is recommended for "confortable visual change"
  115. // min. step increment 0.2% => max steps: 500 => 800ms per each update
  116. // min. step increment 0.5% => max steps: 200 => 1000ms per each update
  117. // min. step increment 1.0% => max steps: 100 => 1000ms per each update
  118. // min. step increment 2.5% => max steps: 40 => 1000ms per each update
  119. // min. step increment 5.0% => max steps: 20 => 1250ms per each update
  120. const ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX = true; // for video playback's ticker issue. [ Playback Replay - Pause at Middle - Backwards Seeking ]
  121. // << end >>
  122.  
  123. const FIX_TOOLTIP_DISPLAY = true;
  124. const FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK = true;
  125. const USE_VANILLA_DEREF = true;
  126. const FIX_DROPDOWN_DERAF = true; // DONT CHANGE
  127. const FIX_MENU_REOPEN_RENDER_PERFORMANCE = true; // to be checked. showContextMenu_ delayed due to request of parameter.
  128. // const FIX_MENU_CAPTURE_SCROLL = true;
  129. const CHAT_MENU_REFIT_ALONG_SCROLLING = 0; // 0 for locking / default; 1 for unlocking only; 2 for unlocking and refit
  130.  
  131. const RAF_FIX_keepScrollClamped = true;
  132. const RAF_FIX_scrollIncrementally = true;
  133.  
  134. const FIX_MENU_POSITION_N_SIZING_ON_SHOWN = 1; // correct size and position when the menu dropdown opens
  135.  
  136. // ========= EXPLANTION FOR 0.2% @ step timing [min. 0.2%] ===========
  137. /*
  138.  
  139. ### Time Approach
  140.  
  141. // all below values can make the time interval > 250ms
  142. // 250ms (practical value) refers to the minimum frequency for timeupdate in most browsers (typically, shorter timeupdate interval in modern browsers)
  143. if (totalDuration > 400000) stepInterval = 0.2; // 400000ms with 0.2% increment => 800ms
  144. else if (totalDuration > 200000) stepInterval = 0.5; // 200000ms with 0.5% increment => 1000ms
  145. else if (totalDuration > 100000) stepInterval = 1; // 100000ms with 1% increment => 1000ms
  146. else if (totalDuration > 50000) stepInterval = 2; // 50000ms with 2% increment => 1000ms
  147. else if (totalDuration > 25000) stepInterval = 5; // 25000ms with 5% increment => 1250ms
  148.  
  149. ### Pixel Check
  150. // Target Max Pixel Increment < 5px for Short Period Ticker (Rapid Background Change)
  151. // Assume total width <= 99px for short period ticker, like small donation & member welcome
  152. 99px * 5% = 4.95px < 5px [Condition Fulfilled]
  153.  
  154. ### Example - totalDuration = 280000
  155. totalDuration 280000
  156. stepInterval 0.5
  157. numOfSteps = Math.round(100 / stepInterval) = 200
  158. time interval = 280000 / 200 = 1400ms <acceptable>
  159.  
  160. ### Example - totalDuration = 18000
  161. totalDuration 18000
  162. stepInterval 5
  163. numOfSteps = Math.round(100 / stepInterval) = 20
  164. time interval = 18000 / 20 = 900ms <acceptable>
  165.  
  166. ### Example - totalDuration = 5000
  167. totalDuration 5000
  168. stepInterval 5
  169. numOfSteps = Math.round(100 / stepInterval) = 20
  170. time interval = 5000 / 20 = 250ms <threshold value>
  171.  
  172. ### Example - totalDuration = 3600
  173. totalDuration 3600
  174. stepInterval 5
  175. numOfSteps = Math.round(100 / stepInterval) = 20
  176. time interval = 3600 / 20 = 180ms <reasonable for 3600ms ticker>
  177.  
  178. */
  179.  
  180. // =======================================================================================================
  181.  
  182. // AUTOMAICALLY DETERMINED
  183. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL === 1;
  184. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL >= 1;
  185. const CHAT_MENU_SCROLL_UNLOCKING = CHAT_MENU_REFIT_ALONG_SCROLLING >= 1;
  186. const FIX_MENU_REOPEN_RENDER_PERFORMANCE_1 = FIX_MENU_REOPEN_RENDER_PERFORMANCE;
  187. const FIX_MENU_REOPEN_RENDER_PERFORMANCE_2 = FIX_MENU_REOPEN_RENDER_PERFORMANCE;
  188. let runTickerClassName = 'run-ticker';
  189.  
  190. const dummyImgURL = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  191. /*
  192. WebP: data:image/webp;base64,UklGRjAB
  193. PNG: data:image/png;base64,iVBORw0KGg==
  194. JPEG: data:image/jpeg;base64,/9j/4AA=
  195. GIF: data:image/gif;base64,R0lGODlhAQABAIA=
  196. BMP: data:image/bmp;base64,Qk1oAAAA
  197. SVG: data:image/svg+xml;base64,PHN2Zy8+Cg==
  198.  
  199. WebP: data:image/webp;base64,AAAAAAA=
  200. PNG: data:image/png;base64,AAAAAAA=
  201. JPEG: data:image/jpeg;base64,AAAAAAA=
  202. GIF: data:image/gif;base64,AAAAAAA=
  203. BMP: data:image/bmp;base64,AAAAAAA=
  204.  
  205. data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  206.  
  207.  
  208. */
  209.  
  210. // image sizing code
  211. // (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null)
  212.  
  213.  
  214. // function KC(a, b, c, d) {
  215. // d = void 0 === d ? "width" : d;
  216. // if (!a || !a.length)
  217. // return null;
  218. // if (z("kevlar_tuner_should_always_use_device_pixel_ratio")) {
  219. // var e = window.devicePixelRatio;
  220. // z("kevlar_tuner_should_clamp_device_pixel_ratio") ? e = Math.min(e, zl("kevlar_tuner_clamp_device_pixel_ratio")) : z("kevlar_tuner_should_use_thumbnail_factor") && (e = zl("kevlar_tuner_thumbnail_factor"));
  221. // HC = e
  222. // } else
  223. // HC || (HC = window.devicePixelRatio);
  224. // e = HC;
  225. // z("kevlar_tuner_should_always_use_device_pixel_ratio") ? b *= e : 1 < e && (b *= e);
  226. // if (z("kevlar_tuner_min_thumbnail_quality"))
  227. // return a[0].url || null;
  228. // e = a.length;
  229. // if (z("kevlar_tuner_max_thumbnail_quality"))
  230. // return a[e - 1].url || null;
  231. // if (c)
  232. // for (var h = 0; h < e; h++)
  233. // if (0 <= a[h].url.indexOf(c))
  234. // return a[h].url || null;
  235. // for (c = 0; c < e; c++)
  236. // if (a[c][d] >= b)
  237. // return a[c].url || null;
  238. // for (b = e - 1; 0 < b; b--)
  239. // if (a[b][d])
  240. // return a[b].url || null;
  241. // return a[0].url || null
  242. // }
  243.  
  244. const { IntersectionObserver } = __CONTEXT__;
  245.  
  246. /** @type {globalThis.PromiseConstructor} */
  247. const Promise = (async () => { })().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  248.  
  249. if (!IntersectionObserver) return console.warn("Your browser does not support IntersectionObserver.\nPlease upgrade to the latest version.");
  250. if (typeof WebAssembly !== 'object') return console.warn("Your browser is too old.\nPlease upgrade to the latest version."); // for passive and once
  251.  
  252. // necessity of cssText3_smooth_transform_position to be checked.
  253. const cssText3_smooth_transform_position = ENABLE_NO_SMOOTH_TRANSFORM ? `
  254.  
  255. #item-offset.style-scope.yt-live-chat-item-list-renderer > #items.style-scope.yt-live-chat-item-list-renderer {
  256. position: static !important;
  257. }
  258.  
  259. `: '';
  260.  
  261. // fallback if dummy style fn fails
  262. const cssText4_smooth_transform_forced_props = ENABLE_NO_SMOOTH_TRANSFORM ? `
  263.  
  264. /* optional */
  265. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  266. height: auto !important;
  267. min-height: unset !important;
  268. }
  269.  
  270. #items.style-scope.yt-live-chat-item-list-renderer {
  271. transform: translateY(0px) !important;
  272. }
  273.  
  274. /* optional */
  275.  
  276. `: '';
  277.  
  278. const cssText5 = SET_CONTAIN_FOR_CHATROOM ? `
  279.  
  280. /* ------------------------------------------------------------------------------------------------------------- */
  281.  
  282. yt-live-chat-author-chip #chat-badges.yt-live-chat-author-chip, yt-live-chat-author-chip #chat-badges.yt-live-chat-author-chip yt-live-chat-author-badge-renderer, yt-live-chat-author-chip #chat-badges.yt-live-chat-author-chip yt-live-chat-author-badge-renderer #image, yt-live-chat-author-chip #chat-badges.yt-live-chat-author-chip yt-live-chat-author-badge-renderer #image img {
  283. contain: layout style;
  284. }
  285.  
  286. #items.style-scope.yt-live-chat-item-list-renderer {
  287. contain: layout paint style;
  288. }
  289.  
  290. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  291. contain: style;
  292. }
  293.  
  294. #item-scroller.style-scope.yt-live-chat-item-list-renderer {
  295. contain: size style;
  296. }
  297.  
  298. #contents.style-scope.yt-live-chat-item-list-renderer, #chat.style-scope.yt-live-chat-renderer, img.style-scope.yt-img-shadow[width][height] {
  299. contain: size layout paint style;
  300. }
  301.  
  302. .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label], .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label] > #container {
  303. contain: layout paint style;
  304. }
  305.  
  306. yt-live-chat-text-message-renderer.style-scope.yt-live-chat-item-list-renderer, yt-live-chat-membership-item-renderer.style-scope.yt-live-chat-item-list-renderer, yt-live-chat-paid-message-renderer.style-scope.yt-live-chat-item-list-renderer, yt-live-chat-banner-manager.style-scope.yt-live-chat-item-list-renderer {
  307. contain: layout style;
  308. }
  309.  
  310. tp-yt-paper-tooltip[style*="inset"][role="tooltip"] {
  311. contain: layout paint style;
  312. }
  313.  
  314. /* ------------------------------------------------------------------------------------------------------------- */
  315.  
  316. ` : '';
  317.  
  318. const cssText6b_show_more_button = FIX_SHOW_MORE_BUTTON_LOCATION ? `
  319.  
  320. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer{
  321. top: 4px;
  322. transition-property: top;
  323. bottom: unset;
  324. }
  325.  
  326. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer[disabled]{
  327. top: -42px;
  328. }
  329.  
  330. `: '';
  331.  
  332. const cssText6c_input_panel_overflow = FIX_INPUT_PANEL_OVERFLOW_ISSUE ? `
  333.  
  334. #input-panel #picker-buttons yt-live-chat-icon-toggle-button-renderer#product-picker {
  335. contain: layout style;
  336. }
  337.  
  338. #chat.yt-live-chat-renderer ~ #panel-pages.yt-live-chat-renderer {
  339. overflow: visible;
  340. }
  341.  
  342. `: '';
  343.  
  344. const cssText6d_input_panel_border = FIX_INPUT_PANEL_BORDER_ISSUE ? `
  345.  
  346. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer:not(:empty) {
  347. --yt-live-chat-action-panel-top-border: none;
  348. }
  349.  
  350. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer.iron-selected > *:first-child {
  351. border-top: 1px solid var(--yt-live-chat-panel-pages-border-color);
  352. }
  353.  
  354. html #panel-pages.yt-live-chat-renderer {
  355. border-top: 0;
  356. border-bottom: 0;
  357. }
  358.  
  359. `: '';
  360.  
  361. const cssText7b_content_visibility_unset = FORCE_CONTENT_VISIBILITY_UNSET ? `
  362.  
  363. img,
  364. yt-img-shadow[height][width],
  365. yt-img-shadow {
  366. content-visibility: visible !important;
  367. }
  368.  
  369. ` : '';
  370.  
  371. const cssText7c_will_change_unset = FORCE_WILL_CHANGE_UNSET ? `
  372.  
  373. /* remove YouTube constant will-change */
  374. /* constant value will slow down the performance; default auto */
  375.  
  376. /* www-player.css */
  377. html .ytp-contextmenu,
  378. html .ytp-settings-menu {
  379. will-change: unset;
  380. }
  381.  
  382. /* frequently matched elements */
  383. html .fill.yt-interaction,
  384. html .stroke.yt-interaction,
  385. html .yt-spec-touch-feedback-shape__fill,
  386. html .yt-spec-touch-feedback-shape__stroke {
  387. will-change: unset;
  388. }
  389.  
  390. /* live_chat_polymer.js */
  391. /*
  392. html .toggle-button.tp-yt-paper-toggle-button,
  393. html #primaryProgress.tp-yt-paper-progress,
  394. html #secondaryProgress.tp-yt-paper-progress,
  395. html #onRadio.tp-yt-paper-radio-button,
  396. html .fill.yt-interaction,
  397. html .stroke.yt-interaction,
  398. html .yt-spec-touch-feedback-shape__fill,
  399. html .yt-spec-touch-feedback-shape__stroke {
  400. will-change: unset;
  401. }
  402. */
  403.  
  404. /* desktop_polymer_enable_wil_icons.js */
  405. /* html .fill.yt-interaction,
  406. html .stroke.yt-interaction, */
  407. html tp-yt-app-header::before,
  408. html tp-yt-iron-list,
  409. html #items.tp-yt-iron-list > *,
  410. html #onRadio.tp-yt-paper-radio-button,
  411. html .toggle-button.tp-yt-paper-toggle-button,
  412. html ytd-thumbnail-overlay-toggle-button-renderer[use-expandable-tooltip] #label.ytd-thumbnail-overlay-toggle-button-renderer,
  413. html #items.ytd-post-multi-image-renderer,
  414. html #items.ytd-horizontal-card-list-renderer,
  415. html #items.yt-horizontal-list-renderer,
  416. html #left-arrow.yt-horizontal-list-renderer,
  417. html #right-arrow.yt-horizontal-list-renderer,
  418. html #items.ytd-video-description-infocards-section-renderer,
  419. html #items.ytd-video-description-music-section-renderer,
  420. html #chips.ytd-feed-filter-chip-bar-renderer,
  421. html #chips.yt-chip-cloud-renderer,
  422. html #items.ytd-merch-shelf-renderer,
  423. html #items.ytd-product-details-image-carousel-renderer,
  424. html ytd-video-preview,
  425. html #player-container.ytd-video-preview,
  426. html #primaryProgress.tp-yt-paper-progress,
  427. html #secondaryProgress.tp-yt-paper-progress,
  428. html ytd-miniplayer[enabled] /* ,
  429. html .yt-spec-touch-feedback-shape__fill,
  430. html .yt-spec-touch-feedback-shape__stroke */ {
  431. will-change: unset;
  432. }
  433.  
  434. /* other */
  435. .ytp-videowall-still-info-content[class],
  436. .ytp-suggestion-image[class] {
  437. will-change: unset !important;
  438. }
  439.  
  440. ` : '';
  441.  
  442. const ENABLE_FONT_PRE_RENDERING = typeof HTMLElement.prototype.append === 'function' ? (ENABLE_FONT_PRE_RENDERING_PREFERRED || 0) : 0;
  443. const cssText8_fonts_pre_render = ENABLE_FONT_PRE_RENDERING ? `
  444.  
  445. elzm-fonts {
  446. visibility: collapse;
  447. position: fixed;
  448. top: -10px;
  449. left: -10px;
  450. font-size: 10pt;
  451. line-height: 100%;
  452. width: 100px;
  453. height: 100px;
  454. transform: scale(0.1);
  455. transform: scale(0.01);
  456. transform: scale(0.001);
  457. transform-origin: 0 0;
  458. contain: strict;
  459. display: block;
  460.  
  461. pointer-events: none !important;
  462. user-select: none !important;
  463. }
  464.  
  465. elzm-fonts[id]#elzm-fonts-yk75g {
  466. user-select: none !important;
  467. pointer-events: none !important;
  468. }
  469.  
  470. elzm-font {
  471. visibility: collapse;
  472. position: absolute;
  473. line-height: 100%;
  474. width: 100px;
  475. height: 100px;
  476. contain: strict;
  477. display: block;
  478.  
  479. user-select: none !important;
  480. pointer-events: none !important;
  481. }
  482.  
  483. elzm-font::before {
  484. visibility: collapse;
  485. position: absolute;
  486. line-height: 100%;
  487. width: 100px;
  488. height: 100px;
  489. contain: strict;
  490. display: block;
  491.  
  492. content: '0aZ!@#$~^&*()_-+[]{}|;:><?\\0460\\0301\\0900\\1F00\\0370\\0102\\0100\\28EB2\\28189\\26DA0\\25A9C\\249BB\\23F61\\22E8B\\21927\\21076\\2048E\\1F6F5\\FF37\\F94F\\F0B2\\9F27\\9D9A\\9BEA\\9A6B\\98EC\\9798\\9602\\949D\\9370\\926B\\913A\\8FA9\\8E39\\8CC1\\8B26\\8983\\8804\\8696\\8511\\83BC\\828D\\8115\\7F9A\\7E5B\\7D07\\7B91\\7A2C\\78D2\\776C\\7601\\74AA\\73B9\\7265\\70FE\\6FBC\\6E88\\6D64\\6C3F\\6A9C\\6957\\67FE\\66B3\\6535\\63F2\\628E\\612F\\5FE7\\5E6C\\5CEE\\5B6D\\5A33\\58BC\\575B\\5611\\54BF\\536E\\51D0\\505D\\4F22\\4AD1\\41DB\\3B95\\3572\\2F3F\\26FD\\25A1\\2477\\208D\\1D0A\\1FB\\A1\\A3\\B4\\2CB\\60\\10C\\E22\\A5\\4E08\\B0\\627\\2500\\5E\\201C\\3C\\B7\\23\\26\\3E\\D\\20\\25EE8\\1F235\\FFD7\\FA10\\F92D\\9E8B\\9C3E\\9AE5\\98EB\\971D\\944A\\92BC\\9143\\8F52\\8DC0\\8B2D\\8973\\87E2\\8655\\84B4\\82E8\\814A\\7F77\\7D57\\7BC8\\7A17\\7851\\768C\\7511\\736C\\7166\\6F58\\6D7C\\6B85\\69DD\\6855\\667E\\64D2\\62CF\\6117\\5F6C\\5D9B\\5BBC\\598B\\57B3\\5616\\543F\\528D\\50DD\\4F57\\4093\\3395\\32B5\\31C8\\3028\\2F14\\25E4\\24D1\\2105\\2227\\A8\\2D9\\2CA\\2467\\B1\\2020\\2466\\251C\\266B\\AF\\4E91\\221E\\2464\\2266\\2207\\4E32\\25B3\\2463\\2010\\2103\\3014\\25C7\\24\\25BD\\4E18\\2460\\21D2\\2015\\2193\\4E03\\7E\\25CB\\2191\\25BC\\3D\\500D\\4E01\\25\\30F6\\2605\\266A\\40\\2B\\4E16\\7C\\A9\\4E\\21\\1F1E9\\FEE3\\F0A7\\9F3D\\9DFA\\9C3B\\9A5F\\98C8\\972A\\95B9\\94E7\\9410\\92B7\\914C\\8FE2\\8E2D\\8CAF\\8B5E\\8A02\\8869\\86E4\\8532\\83B4\\82A9\\814D\\7FFA\\7ED7\\7DC4\\7CCC\\7BC3\\7ACA\\797C\\783E\\770F\\760A\\74EF\\73E7\\72DD\\719C\\7005\\6ED8\\6DC3\\6CB2\\6A01\\68E1\\6792\\663A\\64F8\\63BC\\623B\\60FA\\5FD1\\5EA3\\5D32\\5BF5\\5AB2\\5981\\5831\\570A\\5605\\5519\\53FB\\52A2\\5110\\4FE3\\4EB8\\3127\\279C\\2650\\254B\\23E9\\207B\\1D34\\2AE\\176\\221A\\161\\200B\\300C\\4E4C\\1F921\\FF78\\FA0A\\F78A\\9EB9\\9D34\\9BD3\\9A6F\\9912\\97C6\\964E\\950C\\93E4\\92E5\\91F0\\90BB\\8F68\\8E18\\8B6C\\89F6\\889B\\874C\\8602\\84B1\\8378\\826E\\8113\\7FB1\\7EAF\\7D89\\7C20\\7AFB\\7988\\7840\\7705\\75CC\\749A\\73B3\\727F\\7113\\6FE8\\6ED6\\6DD3\\6CDA\\6BBB\\6A31\\6900\\67D9\\66A7\\655D\\6427\\630D\\61C6\\60AC\\5F78\\5E34\\5CE0\\5B80\\5A51\\590B\\57A1\\566F\\5551\\543D\\52DB\\518F\\5032\\3A17\\305C\\2749\\264A\\2567\\2476\\2139\\1EC0\\11AF\\2C8\\1AF\\E17\\2190\\2022\\2502\\2312\\2025\\50';
  493.  
  494. user-select: none !important;
  495. pointer-events: none !important;
  496. }
  497.  
  498. `: '';
  499.  
  500. const cssText9_no_backdrop_filter_when_menu_shown = NO_BACKDROP_FILTER_WHEN_MENU_SHOWN ? `
  501. tp-yt-iron-dropdown.yt-live-chat-app ytd-menu-popup-renderer {
  502. -webkit-backdrop-filter: none;
  503. backdrop-filter: none;
  504. }
  505. `: '';
  506.  
  507. const cssText10_show_more_blinker = ENABLE_SHOW_MORE_BLINKER ? `
  508.  
  509. @keyframes blinker-miuzp {
  510. 0%, 60%, 100% {
  511. opacity: 1;
  512. }
  513. 30% {
  514. opacity: 0.6;
  515. }
  516. }
  517.  
  518. yt-icon-button#show-more.has-new-messages-miuzp {
  519. animation: blinker-miuzp 1.74s linear infinite;
  520. }
  521.  
  522. `: '';
  523.  
  524.  
  525. const addCss = () => `
  526.  
  527. @property --ticker-rtime {
  528. syntax: "<percentage>";
  529. inherits: false;
  530. initial-value: 0%;
  531. }
  532.  
  533. /*
  534. .run-ticker {
  535. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  536. }
  537.  
  538. .run-ticker-test {
  539. background: #00000001;
  540. }
  541.  
  542. .run-ticker-forced,
  543. yt-live-chat-ticker-renderer #items > * > #container.run-ticker-forced,
  544. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker-forced[class]
  545. {
  546. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2)) !important;
  547. }
  548. */
  549.  
  550. .run-ticker {
  551. --ticker-bg:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  552. }
  553.  
  554. .run-ticker,
  555. yt-live-chat-ticker-renderer #items > * > #container.run-ticker,
  556. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker[class]
  557. {
  558. background: var(--ticker-bg) !important;
  559. }
  560.  
  561. yt-live-chat-ticker-dummy777-item-renderer {
  562. background: #00000001;
  563. }
  564.  
  565. yt-live-chat-ticker-dummy777-item-renderer[dummy777] {
  566. position: fixed !important;
  567. top: -1000px !important;
  568. left: -1000px !important;
  569. font-size: 1px !important;
  570. color: transparent !important;
  571. pointer-events: none !important;
  572. z-index: -1 !important;
  573. contain: strict !important;
  574. box-sizing: border-box !important;
  575. pointer-events: none !important;
  576. user-select: none !important;
  577. max-width: 1px !important;
  578. max-height: 1px !important;
  579. overflow: hidden !important;
  580. visibility: collapse !important;
  581. display: none !important;
  582. }
  583.  
  584. yt-live-chat-ticker-dummy777-item-renderer #container {
  585. background: inherit;
  586. }
  587.  
  588.  
  589. ${cssText8_fonts_pre_render}
  590.  
  591. ${cssText9_no_backdrop_filter_when_menu_shown}
  592.  
  593. @supports (contain: layout paint style) {
  594.  
  595. ${cssText5}
  596.  
  597. }
  598.  
  599. @supports (color: var(--general)) {
  600.  
  601. html {
  602. --yt-live-chat-item-list-renderer-padding: 0px 0px;
  603. }
  604.  
  605. ${cssText3_smooth_transform_position}
  606.  
  607. ${cssText7c_will_change_unset}
  608.  
  609. ${cssText7b_content_visibility_unset}
  610.  
  611. yt-live-chat-item-list-renderer:not([allow-scroll]) #item-scroller.yt-live-chat-item-list-renderer {
  612. overflow-y: scroll;
  613. padding-right: 0;
  614. }
  615.  
  616. ${cssText4_smooth_transform_forced_props}
  617.  
  618. yt-icon[icon="down_arrow"] > *, yt-icon-button#show-more > * {
  619. pointer-events: none !important;
  620. }
  621.  
  622. #continuations, #continuations * {
  623. contain: strict;
  624. position: fixed;
  625. top: 2px;
  626. height: 1px;
  627. width: 2px;
  628. height: 1px;
  629. visibility: collapse;
  630. }
  631.  
  632. ${cssText6b_show_more_button}
  633.  
  634. ${cssText6d_input_panel_border}
  635.  
  636. ${cssText6c_input_panel_overflow}
  637.  
  638. }
  639.  
  640.  
  641. @supports (overflow-anchor: auto) {
  642.  
  643. .no-anchor * {
  644. overflow-anchor: none;
  645. }
  646. .no-anchor > item-anchor {
  647. overflow-anchor: auto;
  648. }
  649.  
  650. item-anchor {
  651.  
  652. height:1px;
  653. width: 100%;
  654. transform: scaleY(0.00001);
  655. transform-origin:0 0;
  656. contain: strict;
  657. opacity:0;
  658. display:flex;
  659. position:relative;
  660. flex-shrink:0;
  661. flex-grow:0;
  662. margin-bottom:0;
  663. overflow:hidden;
  664. box-sizing:border-box;
  665. visibility: visible;
  666. content-visibility: visible;
  667. contain-intrinsic-size: auto 1px;
  668. pointer-events:none !important;
  669.  
  670. }
  671.  
  672. #item-scroller.style-scope.yt-live-chat-item-list-renderer[class] {
  673. overflow-anchor: initial !important; /* whenever ENABLE_OVERFLOW_ANCHOR or not */
  674. }
  675.  
  676. html item-anchor {
  677.  
  678. height: 1px;
  679. width: 1px;
  680. top: auto;
  681. left: auto;
  682. right: auto;
  683. bottom: auto;
  684. transform: translateY(-1px);
  685. position: absolute;
  686. z-index: -1;
  687.  
  688. }
  689.  
  690. }
  691.  
  692. @supports (color: var(--pre-rendering)) {
  693.  
  694. @keyframes dontRenderAnimation {
  695. 0% {
  696. background-position-x: 3px;
  697. }
  698. 100% {
  699. background-position-x: 4px;
  700. }
  701. }
  702.  
  703. .dont-render[class] {
  704. /* visibility: collapse !important; */
  705. /* visibility: collapse will make innerText become "" which conflicts with BetterStreamChat; see https://greasyfork.org/scripts/469878/discussions/197267 */
  706.  
  707. transform: scale(0.01) !important;
  708. transform: scale(0.00001) !important;
  709. transform: scale(0.0000001) !important;
  710. transform-origin: 0 0 !important;
  711. z-index: -1 !important;
  712. contain: strict !important;
  713. box-sizing: border-box !important;
  714.  
  715. height: 1px !important;
  716. height: 0.1px !important;
  717. height: 0.01px !important;
  718. height: 0.0001px !important;
  719. height: 0.000001px !important;
  720.  
  721. animation: dontRenderAnimation 1ms linear 80ms 1 normal forwards !important;
  722.  
  723. pointer-events: none !important;
  724. user-select: none !important;
  725.  
  726. }
  727.  
  728. #sk35z {
  729. display: block !important;
  730.  
  731. visibility: collapse !important;
  732.  
  733. transform: scale(0.01) !important;
  734. transform: scale(0.00001) !important;
  735. transform: scale(0.0000001) !important;
  736. transform-origin: 0 0 !important;
  737. z-index: -1 !important;
  738. contain: strict !important;
  739. box-sizing: border-box !important;
  740.  
  741. height: 1px !important;
  742. height: 0.1px !important;
  743. height: 0.01px !important;
  744. height: 0.0001px !important;
  745. height: 0.000001px !important;
  746.  
  747. position: absolute !important;
  748. top: -1000px !important;
  749. left: -1000px !important;
  750.  
  751. }
  752.  
  753. }
  754.  
  755. [rNgzQ] {
  756. opacity: 0.1 !important;
  757. opacity: 0.01 !important;
  758. opacity: 0.001 !important;
  759. opacity: 0.0001 !important;
  760. opacity: 0.00001 !important;
  761. opacity: 0.00000001 !important;
  762.  
  763. pointer-events: none !important;
  764. }
  765.  
  766. ${cssText10_show_more_blinker}
  767.  
  768. `;
  769.  
  770.  
  771. const win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : (this instanceof Window ? this : window);
  772.  
  773. // Create a unique key for the script and check if it is already running
  774. const hkey_script = 'mchbwnoasqph';
  775. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  776. win[hkey_script] = true;
  777.  
  778. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  779.  
  780. let te4 = setTimeout(() => { }); // dummy; skip timerId only;
  781. if (te4 < 3) {
  782. setTimeout(() => { });
  783. setTimeout(() => { });
  784. }
  785.  
  786. }
  787.  
  788. class Mutex {
  789.  
  790. constructor() {
  791. this.p = Promise.resolve()
  792. }
  793.  
  794. /**
  795. * @param {(lockResolve: () => void)} f
  796. */
  797. lockWith(f) {
  798. this.p = this.p.then(() => new Promise(f).catch(console.warn))
  799. }
  800.  
  801. }
  802.  
  803. function dr(s) {
  804. // reserved for future use
  805. return s;
  806. // return window.deWeakJS ? window.deWeakJS(s) : s;
  807. }
  808.  
  809. const getProto = (element) => {
  810. if (element) {
  811. const cnt = element.inst || element;
  812. return cnt.constructor.prototype || null;
  813. }
  814. return null;
  815. }
  816.  
  817. const assertor = (f) => f() || console.assert(false, f + "");
  818.  
  819. const fnIntegrity = (f, d) => {
  820. if (!f || typeof f !== 'function') {
  821. console.warn('f is not a function', f);
  822. return;
  823. }
  824. let p = f + "", s = 0, j = -1, w = 0;
  825. for (let i = 0, l = p.length; i < l; i++) {
  826. const t = p[i];
  827. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  828. if (j < i - 1) w++;
  829. j = i;
  830. } else {
  831. s++;
  832. }
  833. }
  834. let itz = `${f.length}.${s}.${w}`;
  835. if (!d) {
  836. return itz;
  837. } else {
  838. return itz === d;
  839. }
  840. }
  841.  
  842.  
  843. console.assert(MAX_ITEMS_FOR_TOTAL_DISPLAY > 0 && MAX_ITEMS_FOR_FULL_FLUSH > 0 && MAX_ITEMS_FOR_TOTAL_DISPLAY > MAX_ITEMS_FOR_FULL_FLUSH)
  844.  
  845. let ENABLE_DELAYED_CHAT_OCCURRENCE_CAPABLE = false;
  846. const isContainSupport = CSS.supports('contain', 'layout paint style');
  847. if (!isContainSupport) {
  848. console.warn("Your browser does not support css property 'contain'.\nPlease upgrade to the latest version.".trim());
  849. } else {
  850. ENABLE_DELAYED_CHAT_OCCURRENCE_CAPABLE = true;
  851. }
  852.  
  853. let ENABLE_OVERFLOW_ANCHOR_CAPABLE = false;
  854. const isOverflowAnchorSupport = CSS.supports('overflow-anchor', 'auto');
  855. if (!isOverflowAnchorSupport) {
  856. console.warn("Your browser does not support css property 'overflow-anchor'.\nPlease upgrade to the latest version.".trim());
  857. } else {
  858. ENABLE_OVERFLOW_ANCHOR_CAPABLE = true;
  859. }
  860.  
  861. const NOT_FIREFOX = !CSS.supports('-moz-appearance', 'none'); // 1. Firefox does not have the flicking issue; 2. Firefox's OVERFLOW_ANCHOR is less effective than Chromium's.
  862.  
  863. const ENABLE_OVERFLOW_ANCHOR = ENABLE_OVERFLOW_ANCHOR_PREFERRED && ENABLE_OVERFLOW_ANCHOR_CAPABLE && ENABLE_NO_SMOOTH_TRANSFORM;
  864. const ENABLE_DELAYED_CHAT_OCCURRENCE = ENABLE_DELAYED_CHAT_OCCURRENCE_PREFERRED && ENABLE_DELAYED_CHAT_OCCURRENCE_CAPABLE && ENABLE_OVERFLOW_ANCHOR && ENABLE_NO_SMOOTH_TRANSFORM && NOT_FIREFOX;
  865.  
  866. let hasTimerModified = null;
  867. const DO_CHECK_TICKER_BACKGROUND_OVERRIDED = !!ATTEMPT_ANIMATED_TICKER_BACKGROUND || ENABLE_RAF_HACK_TICKERS;
  868.  
  869. const fxOperator = (proto, propertyName) => {
  870. let propertyDescriptorGetter = null;
  871. try {
  872. propertyDescriptorGetter = Object.getOwnPropertyDescriptor(proto, propertyName).get;
  873. } catch (e) { }
  874. return typeof propertyDescriptorGetter === 'function' ? (e) => {
  875. try {
  876.  
  877. return propertyDescriptorGetter.call(dr(e));
  878. } catch (e) { }
  879. return e[propertyName];
  880. } : (e) => e[propertyName];
  881. };
  882.  
  883. const nodeParent = fxOperator(Node.prototype, 'parentNode');
  884. // const nFirstElem = fxOperator(HTMLElement.prototype, 'firstElementChild');
  885. const nPrevElem = fxOperator(HTMLElement.prototype, 'previousElementSibling');
  886. const nNextElem = fxOperator(HTMLElement.prototype, 'nextElementSibling');
  887. const nLastElem = fxOperator(HTMLElement.prototype, 'lastElementChild');
  888.  
  889. const groupCollapsed = (text1, text2) => {
  890.  
  891. console.groupCollapsed(`%c${text1}%c${text2}`,
  892. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;",
  893. "background-color: #010502; color: #6ad9fe; font-weight: 300; padding: 2px;"
  894. );
  895. }
  896.  
  897.  
  898. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  899. const onRegistryReady = (callback) => {
  900. if (typeof customElements === 'undefined') {
  901. if (!('__CE_registry' in document)) {
  902. // https://github.com/webcomponents/polyfills/
  903. Object.defineProperty(document, '__CE_registry', {
  904. get() {
  905. // return undefined
  906. },
  907. set(nv) {
  908. if (typeof nv == 'object') {
  909. delete this.__CE_registry;
  910. this.__CE_registry = nv;
  911. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  912. }
  913. return true;
  914. },
  915. enumerable: false,
  916. configurable: true
  917. })
  918. }
  919. let eventHandler = (evt) => {
  920. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  921. const f = callback;
  922. callback = null;
  923. eventHandler = null;
  924. f();
  925. };
  926. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  927. } else {
  928. callback();
  929. }
  930. };
  931.  
  932. const promiseForCustomYtElementsReady = new Promise(onRegistryReady);
  933.  
  934. const renderReadyPn = typeof ResizeObserver !== 'undefined' ? (sizingTarget) => {
  935.  
  936. return new Promise(resolve => {
  937.  
  938. let ro = new ResizeObserver(entries => {
  939. if (entries && entries.length >= 1) {
  940. resolve();
  941. ro.disconnect();
  942. ro = null;
  943. }
  944. });
  945. ro.observe(sizingTarget);
  946.  
  947.  
  948.  
  949. });
  950.  
  951. } : (sizingTarget) => {
  952.  
  953.  
  954. return new Promise(resolve => {
  955.  
  956. let io = new IntersectionObserver(entries => {
  957. if (entries && entries.length >= 1) {
  958. resolve();
  959. io.disconnect();
  960. io = null;
  961. }
  962. });
  963. io.observe(sizingTarget);
  964.  
  965.  
  966.  
  967. });
  968.  
  969. };
  970.  
  971. /* globals WeakRef:false */
  972.  
  973. /** @type {(o: Object | null) => WeakRef | null} */
  974. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  975.  
  976. /** @type {(wr: Object | null) => Object | null} */
  977. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  978.  
  979. const { addCssManaged } = (() => {
  980.  
  981. const addFontPreRendering = () => {
  982.  
  983. groupCollapsed("YouTube Super Fast Chat", " | Fonts Pre-Rendering");
  984.  
  985. let efsContainer = document.createElement('elzm-fonts');
  986. efsContainer.id = 'elzm-fonts-yk75g'
  987.  
  988. const arr = [];
  989. let p = document.createElement('elzm-font');
  990. arr.push(p);
  991.  
  992. if (ENABLE_FONT_PRE_RENDERING & 1) {
  993. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  994.  
  995. p = document.createElement('elzm-font');
  996. p.style.fontWeight = size;
  997. arr.push(p);
  998. }
  999. }
  1000.  
  1001. if (ENABLE_FONT_PRE_RENDERING & 2) {
  1002. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1003.  
  1004. p = document.createElement('elzm-font');
  1005. p.style.fontFamily = 'Roboto';
  1006. p.style.fontWeight = size;
  1007. arr.push(p);
  1008. }
  1009. }
  1010.  
  1011. if (ENABLE_FONT_PRE_RENDERING & 4) {
  1012. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1013.  
  1014. p = document.createElement('elzm-font');
  1015. p.style.fontFamily = '"YouTube Noto",Roboto,Arial,Helvetica,sans-serif';
  1016. p.style.fontWeight = size;
  1017. arr.push(p);
  1018. }
  1019. }
  1020.  
  1021.  
  1022. if (ENABLE_FONT_PRE_RENDERING & 8) {
  1023. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1024.  
  1025. p = document.createElement('elzm-font');
  1026. p.style.fontFamily = '"Noto",Roboto,Arial,Helvetica,sans-serif';
  1027. p.style.fontWeight = size;
  1028. arr.push(p);
  1029. }
  1030. }
  1031.  
  1032.  
  1033. if (ENABLE_FONT_PRE_RENDERING & 16) {
  1034. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1035.  
  1036. p = document.createElement('elzm-font');
  1037. p.style.fontFamily = 'sans-serif';
  1038. p.style.fontWeight = size;
  1039. arr.push(p);
  1040. }
  1041. }
  1042.  
  1043. console.log('number of elzm-font elements', arr.length);
  1044.  
  1045. HTMLElement.prototype.append.apply(efsContainer, arr);
  1046.  
  1047. (document.body || document.documentElement).appendChild(efsContainer);
  1048.  
  1049.  
  1050. console.log('elzm-font elements have been added to the page for rendering.');
  1051.  
  1052. console.groupEnd();
  1053.  
  1054. }
  1055.  
  1056. let isCssAdded = false;
  1057.  
  1058. function addCssElement() {
  1059. let s = document.createElement('style');
  1060. s.id = 'ewRvC';
  1061. return s;
  1062. }
  1063.  
  1064. const addCssManaged = () => {
  1065. if (!isCssAdded && document.documentElement && document.head) {
  1066. isCssAdded = true;
  1067. document.head.appendChild(dr(addCssElement())).textContent = addCss();
  1068. if (ENABLE_FONT_PRE_RENDERING) {
  1069. Promise.resolve().then(addFontPreRendering)
  1070. }
  1071. }
  1072. }
  1073.  
  1074. return { addCssManaged };
  1075. })();
  1076.  
  1077.  
  1078. const { setupStyle } = (() => {
  1079.  
  1080. const sp7 = Symbol();
  1081.  
  1082. const proxyHelperFn = (dummy) => ({
  1083.  
  1084. get(target, prop) {
  1085. return (prop in dummy) ? dummy[prop] : prop === sp7 ? target : target[prop];
  1086. },
  1087. set(target, prop, value) {
  1088. if (!(prop in dummy)) {
  1089. target[prop] = value;
  1090. }
  1091. return true;
  1092. },
  1093. has(target, prop) {
  1094. return (prop in target);
  1095. },
  1096. deleteProperty(target, prop) {
  1097. return true;
  1098. },
  1099. ownKeys(target) {
  1100. return Object.keys(target);
  1101. },
  1102. defineProperty(target, key, descriptor) {
  1103. return Object.defineProperty(target, key, descriptor);
  1104. },
  1105. getOwnPropertyDescriptor(target, key) {
  1106. return Object.getOwnPropertyDescriptor(target, key);
  1107. },
  1108.  
  1109. });
  1110.  
  1111. const setupStyle = (m1, m2) => {
  1112. if (!ENABLE_NO_SMOOTH_TRANSFORM) return;
  1113.  
  1114. const dummy1v = {
  1115. transform: '',
  1116. height: '',
  1117. minHeight: '',
  1118. paddingBottom: '',
  1119. paddingTop: ''
  1120. };
  1121.  
  1122. const dummyStyleFn = (k) => (function () { const style = this[sp7]; return style[k](...arguments); });
  1123. for (const k of ['toString', 'getPropertyPriority', 'getPropertyValue', 'item', 'removeProperty', 'setProperty']) {
  1124. dummy1v[k] = dummyStyleFn(k);
  1125. }
  1126.  
  1127. const dummy1p = proxyHelperFn(dummy1v);
  1128. const sp1v = new Proxy(m1.style, dummy1p);
  1129. const sp2v = new Proxy(m2.style, dummy1p);
  1130. Object.defineProperty(m1, 'style', { get() { return sp1v }, set() { }, enumerable: true, configurable: true });
  1131. Object.defineProperty(m2, 'style', { get() { return sp2v }, set() { }, enumerable: true, configurable: true });
  1132. m1.removeAttribute("style");
  1133. m2.removeAttribute("style");
  1134.  
  1135. }
  1136.  
  1137. return { setupStyle };
  1138.  
  1139. })();
  1140.  
  1141.  
  1142.  
  1143. function setThumbnails(config) {
  1144.  
  1145. const { baseObject, thumbnails, flag0, imageLinks } = config;
  1146.  
  1147. if (flag0 || (ENABLE_PRELOAD_THUMBNAIL && imageLinks)) {
  1148.  
  1149.  
  1150. if (thumbnails && thumbnails.length > 0) {
  1151. if (flag0 > 0 && thumbnails.length > 1) {
  1152. let pSize = 0;
  1153. let newThumbnails = [];
  1154. for (const thumbnail of thumbnails) {
  1155. if (!thumbnail || !thumbnail.url) continue;
  1156. const squarePhoto = thumbnail.width === thumbnail.height && typeof thumbnail.width === 'number';
  1157. const condSize = pSize <= 0 || (flag0 === 1 ? pSize > thumbnail.width : pSize < thumbnail.width);
  1158. const leastSizeFulfilled = squarePhoto ? thumbnail.width >= LEAST_IMAGE_SIZE : true;
  1159. if ((!squarePhoto || condSize) && leastSizeFulfilled) {
  1160. newThumbnails.push(thumbnail);
  1161. if (imageLinks) imageLinks.add(thumbnail.url);
  1162. }
  1163. if (squarePhoto && condSize && leastSizeFulfilled) {
  1164. pSize = thumbnail.width;
  1165. }
  1166. }
  1167. if (thumbnails.length !== newThumbnails.length && thumbnails === baseObject.thumbnails && newThumbnails.length > 0) {
  1168. baseObject.thumbnails = newThumbnails;
  1169. } else {
  1170. newThumbnails.length = 0;
  1171. }
  1172. newThumbnails = null;
  1173. } else {
  1174. for (const thumbnail of thumbnails) {
  1175. if (thumbnail && thumbnail.url) {
  1176. if (imageLinks) imageLinks.add(thumbnail.url);
  1177. }
  1178. }
  1179. }
  1180. }
  1181.  
  1182. }
  1183. }
  1184.  
  1185. function fixLiveChatItem(item, imageLinks) {
  1186. const liveChatTextMessageRenderer = (item || 0).liveChatTextMessageRenderer || 0;
  1187. if (liveChatTextMessageRenderer) {
  1188. const messageRuns = (liveChatTextMessageRenderer.message || 0).runs || 0;
  1189. if (messageRuns && messageRuns.length > 0) {
  1190. for (const run of messageRuns) {
  1191. const emojiImage = (((run || 0).emoji || 0).image || 0);
  1192. setThumbnails({
  1193. baseObject: emojiImage,
  1194. thumbnails: emojiImage.thumbnails,
  1195. flag0: EMOJI_IMAGE_SINGLE_THUMBNAIL,
  1196. imageLinks
  1197. });
  1198. }
  1199. }
  1200. const authorPhoto = liveChatTextMessageRenderer.authorPhoto || 0;
  1201. setThumbnails({
  1202. baseObject: authorPhoto,
  1203. thumbnails: authorPhoto.thumbnails,
  1204. flag0: AUTHOR_PHOTO_SINGLE_THUMBNAIL,
  1205. imageLinks
  1206. });
  1207. }
  1208. }
  1209.  
  1210.  
  1211. const flagsFnOnInterval = (ENABLE_FLAGS_MAINTAIN_STABLE_LIST || ENABLE_FLAGS_REUSE_COMPONENTS) ? (() => {
  1212.  
  1213. const flags = () => {
  1214. try {
  1215. return ytcfg.data_.EXPERIMENT_FLAGS;
  1216. } catch (e) { }
  1217. return null;
  1218. };
  1219.  
  1220. const flagsForced = () => {
  1221. try {
  1222. return ytcfg.data_.EXPERIMENTS_FORCED_FLAGS;
  1223. } catch (e) { }
  1224. return null;
  1225. };
  1226.  
  1227. const flagsFn = (EXPERIMENT_FLAGS) => {
  1228.  
  1229. if (!EXPERIMENT_FLAGS) return;
  1230.  
  1231. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST) {
  1232. if (USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true : true) {
  1233. EXPERIMENT_FLAGS.kevlar_tuner_should_test_maintain_stable_list = true;
  1234. EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list = true;
  1235. }
  1236. }
  1237.  
  1238. if (ENABLE_FLAGS_REUSE_COMPONENTS) {
  1239. EXPERIMENT_FLAGS.kevlar_tuner_should_test_reuse_components = true;
  1240. EXPERIMENT_FLAGS.kevlar_tuner_should_reuse_components = true;
  1241. }
  1242.  
  1243. };
  1244.  
  1245. const uf = (EXPERIMENT_FLAGS) => {
  1246. if (EXPERIMENT_FLAGS === undefined) EXPERIMENT_FLAGS = flags();
  1247. if (EXPERIMENT_FLAGS) {
  1248. flagsFn(EXPERIMENT_FLAGS);
  1249. flagsFn(flagsForced());
  1250. }
  1251. }
  1252.  
  1253. uf();
  1254.  
  1255. const flagsFnOnInterval = (setInterval, clearInterval) => {
  1256.  
  1257. uf();
  1258. let cidFlags = 0;
  1259. let kd = 0;
  1260. new Promise(flagResolve => {
  1261.  
  1262. const flagTimer = () => {
  1263. const EXPERIMENT_FLAGS = flags();
  1264. if (!EXPERIMENT_FLAGS) return;
  1265. uf(EXPERIMENT_FLAGS);
  1266. if (kd > 0) return;
  1267. kd = 1;
  1268. const delay1000 = new Promise(resolve => setTimeout(resolve, 1000));
  1269. const moDeferred = new Promise(resolve => {
  1270. let mo = new MutationObserver(() => {
  1271. if (mo) {
  1272. mo.disconnect();
  1273. mo.takeRecords();
  1274. mo = null;
  1275. resolve();
  1276. }
  1277. });
  1278. mo.observe(document, { subtree: true, childList: true });
  1279. });
  1280. Promise.race([delay1000, moDeferred]).then(flagResolve);
  1281. };
  1282.  
  1283. uf();
  1284. cidFlags = setInterval(flagTimer, 1);
  1285. }).then(() => {
  1286. if (cidFlags > 0) clearInterval(cidFlags);
  1287. cidFlags = 0;
  1288. uf();
  1289. });
  1290.  
  1291. }
  1292.  
  1293. return flagsFnOnInterval;
  1294.  
  1295. })() : null;
  1296.  
  1297. let kptPF = null;
  1298. const emojiPrefetched = new Set();
  1299. const authorPhotoPrefetched = new Set();
  1300.  
  1301. function linker(link, rel, href, _as) {
  1302. return new Promise(resolve => {
  1303. if (!link) link = document.createElement('link');
  1304. link.rel = rel;
  1305. if (_as) link.setAttribute('as', _as);
  1306. link.onload = function () {
  1307. resolve({
  1308. link: this,
  1309. success: true
  1310. })
  1311. this.remove();
  1312. };
  1313. link.onerror = function () {
  1314. resolve({
  1315. link: this,
  1316. success: false
  1317. });
  1318. this.remove();
  1319. };
  1320. link.href = href;
  1321. document.head.appendChild(link);
  1322. link = null;
  1323. });
  1324. }
  1325.  
  1326.  
  1327. const cleanContext = async (win) => {
  1328. const waitFn = requestAnimationFrame; // shall have been binded to window
  1329. try {
  1330. let mx = 16; // MAX TRIAL
  1331. const frameId = 'vanillajs-iframe-v1';
  1332. /** @type {HTMLIFrameElement | null} */
  1333. let frame = document.getElementById(frameId);
  1334. let removeIframeFn = null;
  1335. if (!frame) {
  1336. frame = document.createElement('iframe');
  1337. frame.id = 'vanillajs-iframe-v1';
  1338. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  1339. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  1340. n.appendChild(frame);
  1341. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  1342. const root = document.documentElement;
  1343. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  1344. removeIframeFn = (setTimeout) => {
  1345. const removeIframeOnDocumentReady = (e) => {
  1346. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  1347. win = null;
  1348. setTimeout(() => {
  1349. n.remove();
  1350. n = null;
  1351. }, 200);
  1352. }
  1353. if (document.readyState !== 'loading') {
  1354. removeIframeOnDocumentReady();
  1355. } else {
  1356. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  1357. }
  1358. }
  1359. }
  1360. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  1361. const fc = frame.contentWindow;
  1362. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  1363. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval } = fc;
  1364. const res = { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval };
  1365. for (let k in res) res[k] = res[k].bind(win); // necessary
  1366. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  1367. res.animate = HTMLElement.prototype.animate;
  1368. return res;
  1369. } catch (e) {
  1370. console.warn(e);
  1371. return null;
  1372. }
  1373. };
  1374.  
  1375. cleanContext(win).then(__CONTEXT__ => {
  1376. if (!__CONTEXT__) return null;
  1377.  
  1378. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, animate } = __CONTEXT__;
  1379.  
  1380. let aeConstructor = null;
  1381.  
  1382. // << if ENABLE_VIDEO_PROGRESS_STATE_FIX >>
  1383. let pairForPauseResume = 0; // each increasion = number of ticker
  1384. let pairForPauseResumeM = 0;
  1385. // << end >>
  1386.  
  1387. // << __openedChanged82 >>
  1388. let currentMenuPivotWR = null;
  1389.  
  1390. // << if DO_PARTICIPANT_LIST_HACKS >>
  1391. const beforeParticipantsMap = new WeakMap();
  1392. // << end >>
  1393.  
  1394.  
  1395.  
  1396. // << if onRegistryReadyForDOMOperations >>
  1397.  
  1398. let dt0 = Date.now() - 2000;
  1399. const dateNow = () => Date.now() - dt0;
  1400. // let lastScroll = 0;
  1401. // let lastLShow = 0;
  1402. let lastWheel = 0;
  1403. let lastMouseDown = 0;
  1404. let lastMouseUp = 0;
  1405. let currentMouseDown = false;
  1406. let lastTouchDown = 0;
  1407. let lastTouchUp = 0;
  1408. let currentTouchDown = false;
  1409. let lastUserInteraction = 0;
  1410.  
  1411. let scrollChatFn = null;
  1412.  
  1413. let skipDontRender = true; // true first; false by flushActiveItems_
  1414. let allowDontRender = null;
  1415.  
  1416. // ---- #items mutation ----
  1417. let sk35zResolveFn = null;
  1418. let firstList = true;
  1419.  
  1420. // << end >>
  1421.  
  1422. class RAFHub {
  1423. constructor() {
  1424. /** @type {number} */
  1425. this.startAt = 8170;
  1426. /** @type {number} */
  1427. this.counter = 0;
  1428. /** @type {number} */
  1429. this.rid = 0;
  1430. /** @type {Map<number, FrameRequestCallback>} */
  1431. this.funcs = new Map();
  1432. const funcs = this.funcs;
  1433. /** @type {FrameRequestCallback} */
  1434. this.bCallback = this.mCallback.bind(this);
  1435. this.pClear = () => funcs.clear();
  1436. }
  1437. /** @param {DOMHighResTimeStamp} highResTime */
  1438. mCallback(highResTime) {
  1439. this.rid = 0;
  1440. Promise.resolve().then(this.pClear);
  1441. this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  1442. }
  1443. /** @param {FrameRequestCallback} f */
  1444. request(f) {
  1445. if (this.counter > 1e9) this.counter = 9;
  1446. let cid = this.startAt + (++this.counter);
  1447. this.funcs.set(cid, f);
  1448. if (this.rid === 0) this.rid = requestAnimationFrame(this.bCallback);
  1449. return cid;
  1450. }
  1451. /** @param {number} cid */
  1452. cancel(cid) {
  1453. cid = +cid;
  1454. if (cid > 0) {
  1455. if (cid <= this.startAt) {
  1456. return cancelAnimationFrame(cid);
  1457. }
  1458. if (this.rid > 0) {
  1459. this.funcs.delete(cid);
  1460. if (this.funcs.size === 0) {
  1461. cancelAnimationFrame(this.rid);
  1462. this.rid = 0;
  1463. }
  1464. }
  1465. }
  1466. }
  1467. }
  1468.  
  1469. function basePrefetching() {
  1470.  
  1471. new Promise(resolve => {
  1472.  
  1473. if (document.readyState !== 'loading') {
  1474. resolve();
  1475. } else {
  1476. win.addEventListener("DOMContentLoaded", resolve, false);
  1477. }
  1478.  
  1479. }).then(() => {
  1480. const hostL1 = [
  1481. 'https://www.youtube.com', 'https://googlevideo.com',
  1482. 'https://googleapis.com', 'https://accounts.youtube.com',
  1483. 'https://www.gstatic.com', 'https://ggpht.com',
  1484. 'https://yt3.ggpht.com', 'https://yt4.ggpht.com'
  1485. ];
  1486.  
  1487. const hostL2 = [
  1488. 'https://youtube.com',
  1489. 'https://fonts.googleapis.com', 'https://fonts.gstatic.com'
  1490. ];
  1491.  
  1492. let link = null;
  1493.  
  1494. function kn() {
  1495.  
  1496. link = document.createElement('link');
  1497. if (link.relList && link.relList.supports) {
  1498. kptPF = (link.relList.supports('dns-prefetch') ? 1 : 0) + (link.relList.supports('preconnect') ? 2 : 0) + (link.relList.supports('prefetch') ? 4 : 0) + (link.relList.supports('subresource') ? 8 : 0) + (link.relList.supports('preload') ? 16 : 0)
  1499. } else {
  1500. kptPF = 0;
  1501. }
  1502.  
  1503. groupCollapsed("YouTube Super Fast Chat", " | PREFETCH SUPPORTS");
  1504. if (ENABLE_BASE_PREFETCHING) console.log('dns-prefetch', (kptPF & 1) ? 'OK' : 'NG');
  1505. if (ENABLE_BASE_PREFETCHING) console.log('preconnect', (kptPF & 2) ? 'OK' : 'NG');
  1506. if (ENABLE_PRELOAD_THUMBNAIL) console.log('prefetch', (kptPF & 4) ? 'OK' : 'NG');
  1507. // console.log('subresource', (kptPF & 8) ? 'OK' : 'NG');
  1508. if (ENABLE_PRELOAD_THUMBNAIL) console.log('preload', (kptPF & 16) ? 'OK' : 'NG');
  1509. console.groupEnd();
  1510.  
  1511. }
  1512.  
  1513. for (const h of hostL1) {
  1514.  
  1515. if (kptPF === null) kn();
  1516. if (ENABLE_BASE_PREFETCHING) {
  1517. // if (kptPF & 1) {
  1518. // linker(link, 'dns-prefetch', h);
  1519. // link = null;
  1520. // }
  1521. if (kptPF & 2) {
  1522. linker(link, 'preconnect', h);
  1523. link = null;
  1524. }
  1525. }
  1526. }
  1527.  
  1528. for (const h of hostL2) {
  1529. if (kptPF === null) kn();
  1530. if (ENABLE_BASE_PREFETCHING) {
  1531. if (kptPF & 1) {
  1532. linker(link, 'dns-prefetch', h);
  1533. link = null;
  1534. }
  1535. }
  1536. }
  1537.  
  1538. })
  1539.  
  1540.  
  1541. }
  1542.  
  1543. if (flagsFnOnInterval) flagsFnOnInterval(setInterval, clearInterval);
  1544.  
  1545. if (DO_LINK_PREFETCH) basePrefetching();
  1546.  
  1547. const { notifyPath7081 } = (() => {
  1548. // DO_PARTICIPANT_LIST_HACKS
  1549.  
  1550. const mutexParticipants = new Mutex();
  1551.  
  1552. let uvid = 0;
  1553. let r95dm = 0;
  1554. let c95dm = -1;
  1555.  
  1556. const foundMap = (base, content) => {
  1557. /*
  1558. let lastSearch = 0;
  1559. let founds = base.map(baseEntry => {
  1560. let search = content.indexOf(baseEntry, lastSearch);
  1561. if (search < 0) return false;
  1562. lastSearch = search + 1;
  1563. return true;
  1564. });
  1565. return founds;
  1566. */
  1567. const contentSet = new Set(content);
  1568. return base.map(baseEntry => contentSet.has(baseEntry));
  1569.  
  1570. }
  1571.  
  1572.  
  1573.  
  1574. const spliceIndicesFunc = (beforeParticipants, participants, idsBefore, idsAfter) => {
  1575.  
  1576. const handler1 = {
  1577. get(target, prop, receiver) {
  1578. if (prop === 'object') {
  1579. return participants; // avoid memory leakage
  1580. }
  1581. if (prop === 'type') {
  1582. return 'splice';
  1583. }
  1584. return target[prop];
  1585. }
  1586. };
  1587. const releaser = () => {
  1588. participants = null;
  1589. }
  1590.  
  1591. let foundsForAfter = foundMap(idsAfter, idsBefore);
  1592. let foundsForBefore = foundMap(idsBefore, idsAfter);
  1593.  
  1594. let indexSplices = [];
  1595. let contentUpdates = [];
  1596. for (let i = 0, j = 0; i < foundsForBefore.length || j < foundsForAfter.length;) {
  1597. if (beforeParticipants[i] === participants[j]) {
  1598. i++; j++;
  1599. } else if (idsBefore[i] === idsAfter[j]) {
  1600. // content changed
  1601. contentUpdates.push({ indexI: i, indexJ: j })
  1602. i++; j++;
  1603. } else {
  1604. let addedCount = 0;
  1605. for (let q = j; q < foundsForAfter.length; q++) {
  1606. if (foundsForAfter[q] === false) addedCount++;
  1607. else break;
  1608. }
  1609. let removedCount = 0;
  1610. for (let q = i; q < foundsForBefore.length; q++) {
  1611. if (foundsForBefore[q] === false) removedCount++;
  1612. else break;
  1613. }
  1614. if (!addedCount && !removedCount) {
  1615. throw 'ERROR(0xFF32): spliceIndicesFunc';
  1616. }
  1617. indexSplices.push(new Proxy({
  1618. index: j,
  1619. addedCount: addedCount,
  1620. removed: removedCount >= 1 ? beforeParticipants.slice(i, i + removedCount) : []
  1621. }, handler1));
  1622. i += removedCount;
  1623. j += addedCount;
  1624. }
  1625. }
  1626. foundsForBefore = null;
  1627. foundsForAfter = null;
  1628. idsBefore = null;
  1629. idsAfter = null;
  1630. beforeParticipants = null;
  1631. return { indexSplices, contentUpdates, releaser };
  1632.  
  1633. }
  1634.  
  1635. /*
  1636.  
  1637. customElements.get("yt-live-chat-participant-renderer").prototype.notifyPath=function(){ console.log(123); console.log(new Error().stack)}
  1638.  
  1639. VM63631:1 Error
  1640. at customElements.get.notifyPath (<anonymous>:1:122)
  1641. at e.forwardRendererStamperChanges_ (live_chat_polymer.js:4453:35)
  1642. at e.rendererStamperApplyChangeRecord_ (live_chat_polymer.js:4451:12)
  1643. at e.rendererStamperObserver_ (live_chat_polymer.js:4448:149)
  1644. at Object.pu [as fn] (live_chat_polymer.js:1692:118)
  1645. at ju (live_chat_polymer.js:1674:217)
  1646. at a._propertiesChanged (live_chat_polymer.js:1726:122)
  1647. at b._flushProperties (live_chat_polymer.js:1597:200)
  1648. at a._invalidateProperties (live_chat_polymer.js:1718:69)
  1649. at a.notifyPath (live_chat_polymer.js:1741:182)
  1650.  
  1651. */
  1652.  
  1653. function convertToIds(participants) {
  1654. return participants.map(participant => {
  1655. if (!participant || typeof participant !== 'object') {
  1656. console.warn('Error(0xFA41): convertToIds', participant);
  1657. return participant; // just in case
  1658. }
  1659. let keys = Object.keys(participant);
  1660. // liveChatTextMessageRenderer
  1661. // liveChatParticipantRenderer - livestream channel owner [no authorExternalChannelId]
  1662. // liveChatPaidMessageRenderer
  1663. /*
  1664.  
  1665. 'yt-live-chat-participant-renderer' utilizes the following:
  1666. authorName.simpleText: string
  1667. authorPhoto.thumbnails: Object{url:string, width:int, height:int} []
  1668. authorBadges[].liveChatAuthorBadgeRenderer.icon.iconType: string
  1669. authorBadges[].liveChatAuthorBadgeRenderer.tooltip: string
  1670. authorBadges[].liveChatAuthorBadgeRenderer.accessibility.accessibilityData: Object{label:string}
  1671.  
  1672. */
  1673. if (keys.length !== 1) {
  1674. console.warn('Error(0xFA42): convertToIds', participant);
  1675. return participant; // just in case
  1676. }
  1677. let key = keys[0];
  1678. let renderer = (participant[key] || 0);
  1679. let authorName = (renderer.authorName || 0);
  1680. let text = `${authorName.simpleText || authorName.text}`
  1681. let res = participant; // fallback if it is not a vaild entry
  1682. if (typeof text !== 'string') {
  1683. console.warn('Error(0xFA53): convertToIds', participant);
  1684. } else {
  1685. text = `${renderer.authorExternalChannelId || 'null'}|${text || ''}`;
  1686. if (text.length > 1) res = text;
  1687. }
  1688. return res;
  1689. // return renderer?`${renderer.id}|${renderer.authorExternalChannelId}`: '';
  1690. // note: renderer.id will be changed if the user typed something to trigger the update of the participants' record.
  1691. });
  1692. }
  1693.  
  1694. const checkChangeToParticipantRendererContent = CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT ? (p1, p2) => {
  1695. // just update when content is changed.
  1696. if (p1.authorName !== p2.authorName) return true;
  1697. if (p1.authorPhoto !== p2.authorPhoto) return true;
  1698. if (p1.authorBadges !== p2.authorBadges) return true;
  1699. return false;
  1700. } : (p1, p2) => {
  1701. // keep integrity all the time.
  1702. return p1 !== p2; // always true
  1703. }
  1704.  
  1705. function notifyPath7081(path) { // cnt "yt-live-chat-participant-list-renderer"
  1706.  
  1707. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  1708. if (path !== "participantsManager.participants") {
  1709. return this.__notifyPath5036__.apply(this, arguments);
  1710. }
  1711. if (c95dm === r95dm) return;
  1712. } else {
  1713. const stack = new Error().stack;
  1714. if (path !== "participantsManager.participants" || stack.indexOf('.onParticipantsChanged') < 0) {
  1715. return this.__notifyPath5036__.apply(this, arguments);
  1716. }
  1717. }
  1718.  
  1719. if (uvid > 1e8) uvid = uvid % 100;
  1720. let tid = ++uvid;
  1721.  
  1722. const cnt = this; // "yt-live-chat-participant-list-renderer"
  1723. mutexParticipants.lockWith(lockResolve => {
  1724.  
  1725. const participants00 = cnt.participantsManager.participants;
  1726.  
  1727. if (tid !== uvid || typeof (participants00 || 0).splice !== 'function') {
  1728. lockResolve();
  1729. return;
  1730. }
  1731.  
  1732. let doUpdate = false;
  1733.  
  1734. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  1735.  
  1736. if (!participants00.r94dm) {
  1737. participants00.r94dm = 1;
  1738. if (++r95dm > 1e9) r95dm = 9;
  1739. participants00.push = function () {
  1740. if (++r95dm > 1e9) r95dm = 9;
  1741. return Array.prototype.push.apply(this, arguments);
  1742. }
  1743. participants00.pop = function () {
  1744. if (++r95dm > 1e9) r95dm = 9;
  1745. return Array.prototype.pop.apply(this, arguments);
  1746. }
  1747. participants00.shift = function () {
  1748. if (++r95dm > 1e9) r95dm = 9;
  1749. return Array.prototype.shift.apply(this, arguments);
  1750. }
  1751. participants00.unshift = function () {
  1752. if (++r95dm > 1e9) r95dm = 9;
  1753. return Array.prototype.unshift.apply(this, arguments);
  1754. }
  1755. participants00.splice = function () {
  1756. if (++r95dm > 1e9) r95dm = 9;
  1757. return Array.prototype.splice.apply(this, arguments);
  1758. }
  1759. participants00.sort = function () {
  1760. if (++r95dm > 1e9) r95dm = 9;
  1761. return Array.prototype.sort.apply(this, arguments);
  1762. }
  1763. participants00.reverse = function () {
  1764. if (++r95dm > 1e9) r95dm = 9;
  1765. return Array.prototype.reverse.apply(this, arguments);
  1766. }
  1767. }
  1768.  
  1769. if (c95dm !== r95dm) {
  1770. c95dm = r95dm;
  1771. doUpdate = true;
  1772. }
  1773.  
  1774. } else {
  1775. doUpdate = true;
  1776. }
  1777.  
  1778. if (!doUpdate) {
  1779. lockResolve();
  1780. return;
  1781. }
  1782.  
  1783. const participants = participants00.slice(0);
  1784. const beforeParticipants = beforeParticipantsMap.get(cnt) || [];
  1785. beforeParticipantsMap.set(cnt, participants);
  1786.  
  1787. const resPromise = (async () => {
  1788.  
  1789. if (beforeParticipants.length === 0) {
  1790. // not error
  1791. return 0;
  1792. }
  1793.  
  1794. let countOfElements = cnt.__getAllParticipantsDOMRenderedLength__()
  1795.  
  1796. // console.log(participants.length, doms.length) // different if no requestAnimationFrame
  1797. if (beforeParticipants.length !== countOfElements) {
  1798. // there is somewrong for the cache. - sometimes happen
  1799. return 0;
  1800. }
  1801.  
  1802. const idsBefore = convertToIds(beforeParticipants);
  1803. const idsAfter = convertToIds(participants);
  1804.  
  1805. let { indexSplices, contentUpdates, releaser } = spliceIndicesFunc(beforeParticipants, participants, idsBefore, idsAfter);
  1806.  
  1807. let res = 1; // default 1 for no update
  1808.  
  1809. if (indexSplices.length >= 1) {
  1810.  
  1811.  
  1812. // let p2 = participants.slice(indexSplices[0].index, indexSplices[0].index+indexSplices[0].addedCount);
  1813. // let p1 = indexSplices[0].removed;
  1814. // console.log(indexSplices.length, indexSplices ,p1,p2, convertToIds(p1),convertToIds(p2))
  1815.  
  1816. /* folllow
  1817. a.notifyPath(c + ".splices", d);
  1818. a.notifyPath(c + ".length", b.length);
  1819. */
  1820. // stampDomArraySplices_
  1821.  
  1822.  
  1823. await new Promise(resolve => {
  1824. cnt.resolveForDOMRendering781 = resolve;
  1825.  
  1826. cnt.__notifyPath5036__("participantsManager.participants.splices", {
  1827. indexSplices
  1828. });
  1829. indexSplices = null;
  1830. releaser();
  1831. releaser = null;
  1832. cnt.__notifyPath5036__("participantsManager.participants.length",
  1833. participants.length
  1834. );
  1835.  
  1836. });
  1837.  
  1838. await Promise.resolve(0); // play safe for the change of 'length'
  1839. countOfElements = cnt.__getAllParticipantsDOMRenderedLength__();
  1840.  
  1841. let wrongSize = participants.length !== countOfElements
  1842. if (wrongSize) {
  1843. console.warn("ERROR(0xE2C3): notifyPath7081", beforeParticipants.length, participants.length, doms.length)
  1844. return 0;
  1845. }
  1846.  
  1847. res = 2 | 4;
  1848.  
  1849. } else {
  1850.  
  1851. indexSplices = null;
  1852. releaser();
  1853. releaser = null;
  1854.  
  1855. if (participants.length !== countOfElements) {
  1856. // other unhandled cases
  1857. return 0;
  1858. }
  1859.  
  1860. }
  1861.  
  1862. // participants.length === countOfElements before contentUpdates
  1863. if (contentUpdates.length >= 1) {
  1864. for (const contentUpdate of contentUpdates) {
  1865. let isChanged = checkChangeToParticipantRendererContent(beforeParticipants[contentUpdate.indexI], participants[contentUpdate.indexJ]);
  1866. if (isChanged) {
  1867. cnt.__notifyPath5036__(`participantsManager.participants[${contentUpdate.indexJ}]`);
  1868. res |= 4 | 8;
  1869. }
  1870. }
  1871. }
  1872. contentUpdates = null;
  1873.  
  1874. return res;
  1875.  
  1876.  
  1877. })();
  1878.  
  1879.  
  1880. resPromise.then(resValue => {
  1881.  
  1882. const isLogRequired = SHOW_PARTICIPANT_CHANGES_IN_CONSOLE && ((resValue === 0) || ((resValue & 4) === 4));
  1883. isLogRequired && groupCollapsed("Participant List Change", `tid = ${tid}; res = ${resValue}`);
  1884. if (resValue === 0) {
  1885. new Promise(resolve => {
  1886. cnt.resolveForDOMRendering781 = resolve;
  1887. isLogRequired && console.log("Full Refresh begins");
  1888. cnt.__notifyPath5036__("participantsManager.participants"); // full refresh
  1889. }).then(() => {
  1890. isLogRequired && console.log("Full Refresh ends");
  1891. console.groupEnd();
  1892. }).then(lockResolve);
  1893. return;
  1894. }
  1895.  
  1896. const delayLockResolve = (resValue & 4) === 4;
  1897.  
  1898. if (delayLockResolve) {
  1899. isLogRequired && console.log(`Number of participants (before): ${beforeParticipants.length}`);
  1900. isLogRequired && console.log(`Number of participants (after): ${participants.length}`);
  1901. isLogRequired && console.log(`Total number of rendered participants: ${cnt.__getAllParticipantsDOMRenderedLength__()}`);
  1902. isLogRequired && console.log(`Participant Renderer Content Updated: ${(resValue & 8) === 8}`);
  1903. isLogRequired && console.groupEnd();
  1904. // requestAnimationFrame is required to avoid particiant update during DOM changing (stampDomArraySplices_)
  1905. // mutex lock with requestAnimationFrame can also disable participants update in background
  1906. requestAnimationFrame(lockResolve);
  1907. } else {
  1908. lockResolve();
  1909. }
  1910.  
  1911. });
  1912.  
  1913. });
  1914.  
  1915. }
  1916.  
  1917. return { notifyPath7081 };
  1918.  
  1919. })();
  1920.  
  1921.  
  1922. const onRegistryReadyForDataManipulation = () => {
  1923.  
  1924. function dummy5035(a, b, c) { }
  1925. function dummy411(a, b, c) { }
  1926.  
  1927. customElements.whenDefined("yt-live-chat-participant-list-renderer").then(() => {
  1928.  
  1929. if (!DO_PARTICIPANT_LIST_HACKS) return;
  1930.  
  1931. const tag = "yt-live-chat-participant-list-renderer";
  1932. const cProto = getProto(document.createElement(tag));
  1933. if (!cProto || typeof cProto.attached !== 'function') {
  1934. // for _registered, proto.attached shall exist when the element is defined.
  1935. // for controller extraction, attached shall exist when instance creates.
  1936. console.warn(`proto.attached for ${tag} is unavailable.`);
  1937. return;
  1938. }
  1939.  
  1940.  
  1941. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-participant-list-renderer hacks");
  1942.  
  1943. const fgsArr = ['kevlar_tuner_should_test_maintain_stable_list', 'kevlar_should_maintain_stable_list', 'kevlar_tuner_should_test_reuse_components', 'kevlar_tuner_should_reuse_components'];
  1944. const fgs = {};
  1945. for (const key of fgsArr) fgs[key] = undefined;
  1946.  
  1947. try {
  1948. const EXPERIMENT_FLAGS = ytcfg.data_.EXPERIMENT_FLAGS;
  1949. for (const key of fgsArr) fgs[key] = EXPERIMENT_FLAGS[key];
  1950. } catch (e) { }
  1951. console.log(`EXPERIMENT_FLAGS: ${JSON.stringify(fgs, null, 2)}`);
  1952.  
  1953. const canDoReplacement = (() => {
  1954. if (typeof cProto.__notifyPath5035__ === 'function' && cProto.__notifyPath5035__.name !== 'dummy5035') {
  1955. console.warn('YouTube Live Chat Tamer is running.');
  1956. return;
  1957. }
  1958.  
  1959. if (typeof cProto.__attached411__ === 'function' && cProto.__attached411__.name !== 'dummy411') {
  1960. console.warn('YouTube Live Chat Tamer is running.');
  1961. return;
  1962. }
  1963.  
  1964. cProto.__notifyPath5035__ = dummy5035 // just to against Live Chat Tamer
  1965. cProto.__attached411__ = dummy411 // just to against Live Chat Tamer
  1966.  
  1967. if (typeof cProto.flushRenderStamperComponentBindings_ !== 'function' || cProto.flushRenderStamperComponentBindings_.length !== 0) {
  1968. console.warn("ERROR(0xE355): cProto.flushRenderStamperComponentBindings_ not found");
  1969. return;
  1970. }
  1971.  
  1972. if (typeof cProto.flushRenderStamperComponentBindings66_ === 'function') {
  1973. console.warn("ERROR(0xE356): cProto.flushRenderStamperComponentBindings66_");
  1974. return;
  1975. }
  1976.  
  1977. if (typeof cProto.__getAllParticipantsDOMRenderedLength__ === 'function') {
  1978. console.warn("ERROR(0xE357): cProto.__getAllParticipantsDOMRenderedLength__");
  1979. return;
  1980. }
  1981. return true;
  1982. })();
  1983.  
  1984. console.log(`Data Manipulation Boost = ${canDoReplacement}`);
  1985.  
  1986. assertor(() => fnIntegrity(cProto.attached, '0.32.22')) // just warning
  1987. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  1988. const fiRSCB = fnIntegrity(cProto.flushRenderStamperComponentBindings_);
  1989. const s = fiRSCB.split('.');
  1990. if (s[0] === '0' && +s[1] > 381 && +s[1] < 391 && +s[2] > 228 && +s[2] < 238) {
  1991. console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - OK`);
  1992. } else {
  1993. console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - Failed`);
  1994. }
  1995. } else {
  1996. console.log("flushRenderStamperComponentBindings_ - not found");
  1997. }
  1998. // assertor(() => fnIntegrity(cProto.flushRenderStamperComponentBindings_, '0.386.233')) // just warning
  1999.  
  2000. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  2001. cProto.flushRenderStamperComponentBindings66_ = cProto.flushRenderStamperComponentBindings_;
  2002. cProto.flushRenderStamperComponentBindings_ = function () {
  2003. // console.log('flushRenderStamperComponentBindings_')
  2004. this.flushRenderStamperComponentBindings66_();
  2005. if (this.resolveForDOMRendering781) {
  2006. this.resolveForDOMRendering781();
  2007. this.resolveForDOMRendering781 = null;
  2008. }
  2009. };
  2010. }
  2011.  
  2012. cProto.__getAllParticipantsDOMRenderedLength__ = function () {
  2013. const container = ((this || 0).$ || 0).participants;
  2014. if (!container) return 0;
  2015. return HTMLElement.prototype.querySelectorAll.call(container, 'yt-live-chat-participant-renderer').length;
  2016. }
  2017.  
  2018. const onPageElements = [...document.querySelectorAll('yt-live-chat-participant-list-renderer:not(.n9fJ3)')];
  2019.  
  2020. cProto.__attached412__ = cProto.attached;
  2021. const fpPList = function (hostElement) {
  2022. const cnt = hostElement.inst || hostElement;
  2023. if (beforeParticipantsMap.has(cnt)) return;
  2024. hostElement.classList.add('n9fJ3');
  2025.  
  2026. assertor(() => (cnt.__dataEnabled === true && cnt.__dataReady === true));
  2027. if (typeof cnt.notifyPath !== 'function' || typeof cnt.__notifyPath5036__ !== 'undefined') {
  2028. console.warn("ERROR(0xE318): yt-live-chat-participant-list-renderer")
  2029. return;
  2030. }
  2031.  
  2032. groupCollapsed("Participant List attached", "");
  2033. // cnt.$.participants.appendChild = cnt.$.participants.__shady_native_appendChild = function(){
  2034. // console.log(123, 'appendChild');
  2035. // return HTMLElement.prototype.appendChild.apply(this, arguments)
  2036. // }
  2037.  
  2038. // cnt.$.participants.insertBefore =cnt.$.participants.__shady_native_insertBefore = function(){
  2039. // console.log(123, 'insertBefore');
  2040. // return HTMLElement.prototype.insertBefore.apply(this, arguments)
  2041. // }
  2042.  
  2043. cnt.__notifyPath5036__ = cnt.notifyPath
  2044. const participants = ((cnt.participantsManager || 0).participants || 0);
  2045. assertor(() => (participants.length > -1 && typeof participants.slice === 'function'));
  2046. console.log(`initial number of participants: ${participants.length}`);
  2047. const newParticipants = (participants.length >= 1 && typeof participants.slice === 'function') ? participants.slice(0) : [];
  2048. beforeParticipantsMap.set(cnt, newParticipants);
  2049. cnt.notifyPath = notifyPath7081;
  2050. console.log(`CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = ${CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT}`);
  2051. console.groupEnd();
  2052. }
  2053. cProto.attached = function () {
  2054. fpPList(this.hostElement || this);
  2055. this.__attached412__.apply(this, arguments);
  2056. };
  2057.  
  2058.  
  2059. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST) {
  2060.  
  2061. /** @type {boolean | (()=>boolean)} */
  2062. let toUseMaintainStableList = USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? (() => ytcfg.data_.EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true) : true;
  2063. if (typeof cProto.stampDomArray_ === 'function' && cProto.stampDomArray_.length === 6 && !cProto.stampDomArray_.nIegT && !cProto.stampDomArray66_) {
  2064.  
  2065. let lastMessageDate = 0;
  2066. cProto.stampDomArray66_ = cProto.stampDomArray_;
  2067.  
  2068. cProto.stampDomArray_ = function (...args) {
  2069. if (args[0] && args[0].length > 0 && args[1] === "participants" && args[2] && args[3] === true && !args[5]) {
  2070. if (typeof toUseMaintainStableList === 'function') {
  2071. toUseMaintainStableList = toUseMaintainStableList();
  2072. }
  2073. args[5] = toUseMaintainStableList;
  2074. let currentDate = Date.now();
  2075. if (currentDate - lastMessageDate > 440) {
  2076. lastMessageDate = currentDate;
  2077. console.log('maintain_stable_list for participants list', toUseMaintainStableList);
  2078. }
  2079. }
  2080. return this.stampDomArray66_.apply(this, args);
  2081. }
  2082.  
  2083. cProto.stampDomArray_.nIegT = 1;
  2084.  
  2085. }
  2086. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - YES`);
  2087. } else {
  2088. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - NO`);
  2089. }
  2090.  
  2091. console.groupEnd();
  2092.  
  2093. if (onPageElements.length >= 1) {
  2094. for (const s of onPageElements) {
  2095. if ((s.inst || s).isAttached === true) {
  2096. fpPList(s);
  2097. }
  2098. }
  2099. }
  2100.  
  2101. }).catch(console.warn);
  2102.  
  2103. };
  2104.  
  2105. if (DO_PARTICIPANT_LIST_HACKS) {
  2106. promiseForCustomYtElementsReady.then(onRegistryReadyForDataManipulation);
  2107. }
  2108.  
  2109.  
  2110.  
  2111. const rafHub = (ENABLE_RAF_HACK_TICKERS || ENABLE_RAF_HACK_DOCKED_MESSAGE || ENABLE_RAF_HACK_INPUT_RENDERER || ENABLE_RAF_HACK_EMOJI_PICKER) ? new RAFHub() : null;
  2112.  
  2113.  
  2114.  
  2115.  
  2116. const bnForDelayChatOccurrence = () => {
  2117.  
  2118. document.addEventListener('animationstart', (evt) => {
  2119.  
  2120. if (evt.animationName === 'dontRenderAnimation') {
  2121. evt.target.classList.remove('dont-render');
  2122. if (scrollChatFn) scrollChatFn();
  2123. }
  2124.  
  2125. }, true);
  2126.  
  2127. const f = (elm) => {
  2128. if (elm && elm.nodeType === 1) {
  2129. if (!skipDontRender && allowDontRender === true) {
  2130. // innerTextFixFn();
  2131. elm.classList.add('dont-render');
  2132. }
  2133. }
  2134. }
  2135.  
  2136. Node.prototype.__appendChild931__ = function (a) {
  2137. a = dr(a);
  2138. if (this.id === 'items' && this.classList.contains('yt-live-chat-item-list-renderer')) {
  2139. if (a && a.nodeType === 1) f(a);
  2140. else if (a instanceof DocumentFragment) {
  2141. for (let n = a.firstChild; n; n = n.nextSibling) {
  2142. f(n);
  2143. }
  2144. }
  2145. }
  2146. }
  2147.  
  2148. Node.prototype.__appendChild932__ = function () {
  2149. this.__appendChild931__.apply(this, arguments);
  2150. return Node.prototype.appendChild.apply(this, arguments);
  2151. }
  2152.  
  2153.  
  2154. };
  2155.  
  2156. const watchUserCSS = () => {
  2157.  
  2158. // if (!CSS.supports('contain-intrinsic-size', 'auto var(--wsr94)')) return;
  2159.  
  2160. const getElemFromWR = (nr) => {
  2161. const n = kRef(nr);
  2162. if (n && n.isConnected) return n;
  2163. return null;
  2164. }
  2165.  
  2166. const clearContentVisibilitySizing = () => {
  2167. Promise.resolve().then(() => {
  2168.  
  2169. const e = document.querySelector('#show-more[disabled]');
  2170. let btnShowMoreWR = e ? mWeakRef(e) : null;
  2171.  
  2172. let lastVisibleItemWR = null;
  2173. for (const elm of document.querySelectorAll('[wSr93]')) {
  2174. if (elm.getAttribute('wSr93') === 'visible') lastVisibleItemWR = mWeakRef(elm);
  2175. elm.setAttribute('wSr93', '');
  2176. // custom CSS property --wsr94 not working when attribute wSr93 removed
  2177. }
  2178. requestAnimationFrame(() => {
  2179. const btnShowMore = getElemFromWR(btnShowMoreWR); btnShowMoreWR = null;
  2180. if (btnShowMore) btnShowMore.click();
  2181. else {
  2182. // would not work if switch it frequently
  2183. const lastVisibleItem = getElemFromWR(lastVisibleItemWR); lastVisibleItemWR = null;
  2184. if (lastVisibleItem) {
  2185.  
  2186. Promise.resolve()
  2187. .then(() => lastVisibleItem.scrollIntoView())
  2188. .then(() => lastVisibleItem.scrollIntoView(false))
  2189. .then(() => lastVisibleItem.scrollIntoView({ behavior: "instant", block: "end", inline: "nearest" }))
  2190. .catch(e => { }) // break the chain when method not callable
  2191.  
  2192. }
  2193. }
  2194. });
  2195.  
  2196. });
  2197.  
  2198. }
  2199.  
  2200. const mutObserver = new MutationObserver((mutations) => {
  2201. for (const mutation of mutations) {
  2202. if ((mutation.addedNodes || 0).length >= 1) {
  2203. for (const addedNode of mutation.addedNodes) {
  2204. if (addedNode.nodeName === 'STYLE') {
  2205. clearContentVisibilitySizing();
  2206. return;
  2207. }
  2208. }
  2209. }
  2210. if ((mutation.removedNodes || 0).length >= 1) {
  2211. for (const removedNode of mutation.removedNodes) {
  2212. if (removedNode.nodeName === 'STYLE') {
  2213. clearContentVisibilitySizing();
  2214. return;
  2215. }
  2216. }
  2217. }
  2218. }
  2219. });
  2220.  
  2221. mutObserver.observe(document.documentElement, {
  2222. childList: true,
  2223. subtree: false
  2224. });
  2225. mutObserver.observe(document.head, {
  2226. childList: true,
  2227. subtree: false
  2228. });
  2229. mutObserver.observe(document.body, {
  2230. childList: true,
  2231. subtree: false
  2232. });
  2233.  
  2234. }
  2235.  
  2236.  
  2237. class WillChangeController {
  2238. constructor(itemScroller, willChangeValue) {
  2239. this.element = itemScroller;
  2240. this.counter = 0;
  2241. this.active = false;
  2242. this.willChangeValue = willChangeValue;
  2243. }
  2244.  
  2245. beforeOper() {
  2246. if (!this.active) {
  2247. this.active = true;
  2248. this.element.style.willChange = this.willChangeValue;
  2249. }
  2250. this.counter++;
  2251. }
  2252.  
  2253. afterOper() {
  2254. const c = this.counter;
  2255. requestAnimationFrame(() => {
  2256. if (c === this.counter) {
  2257. this.active = false;
  2258. this.element.style.willChange = '';
  2259. }
  2260. });
  2261. }
  2262.  
  2263. release() {
  2264. const element = this.element;
  2265. this.element = null;
  2266. this.counter = 1e16;
  2267. this.active = false;
  2268. try {
  2269. element.style.willChange = '';
  2270. } catch (e) { }
  2271. }
  2272.  
  2273. }
  2274.  
  2275.  
  2276. const skzData = (skz) => skz.data = {
  2277. "message": {
  2278. "runs": [
  2279. {
  2280. "text": "em2o"
  2281. },
  2282. {
  2283. "emoji": {
  2284. "emojiId": "cm35z",
  2285. "shortcuts": [
  2286. ":_s:",
  2287. ":s:"
  2288. ],
  2289. "searchTerms": [
  2290. "_s",
  2291. "s"
  2292. ],
  2293. "image": {
  2294. "thumbnails": [
  2295. {
  2296. "url": dummyImgURL,
  2297. "width": 48,
  2298. "height": 48
  2299. }
  2300. ],
  2301. "accessibility": {
  2302. "accessibilityData": {
  2303. "label": "s"
  2304. }
  2305. }
  2306. },
  2307. "isCustomEmoji": true
  2308. }
  2309. },
  2310. {
  2311. "text": "ji"
  2312. }
  2313. ]
  2314. },
  2315. "authorName": {
  2316. "simpleText": "N"
  2317. },
  2318. "authorPhoto": {
  2319. "thumbnails": [
  2320. {
  2321. "url": dummyImgURL,
  2322. "width": 64,
  2323. "height": 64
  2324. }
  2325. ]
  2326. },
  2327. "contextMenuEndpoint": {
  2328. "commandMetadata": {
  2329. "webCommandMetadata": {
  2330. "ignoreNavigation": true
  2331. }
  2332. },
  2333. "liveChatItemContextMenuEndpoint": {
  2334. "params": "123=="
  2335. }
  2336. },
  2337. "id": "sk35z",
  2338. "timestampUsec": "1232302352350000",
  2339. "authorBadges": [
  2340. {
  2341. "liveChatAuthorBadgeRenderer": {
  2342. "customThumbnail": {
  2343. "thumbnails": [
  2344. {
  2345. "url": dummyImgURL,
  2346. "width": 16,
  2347. "height": 16
  2348. },
  2349. {
  2350. "url": dummyImgURL,
  2351. "width": 32,
  2352. "height": 32
  2353. }
  2354. ]
  2355. },
  2356. "tooltip": "T",
  2357. "accessibility": {
  2358. "accessibilityData": {
  2359. "label": "E"
  2360. }
  2361. }
  2362. }
  2363. }
  2364. ],
  2365. "authorExternalChannelId": "A",
  2366. "contextMenuAccessibility": {
  2367. "accessibilityData": {
  2368. "label": "E"
  2369. }
  2370. },
  2371. "timestampText": {
  2372. "simpleText": "0:43"
  2373. }
  2374. };
  2375.  
  2376.  
  2377.  
  2378. const { lcRendererElm, visObserver } = (() => {
  2379.  
  2380.  
  2381.  
  2382. let lcRendererWR = null;
  2383.  
  2384. const lcRendererElm = () => {
  2385. let lcRenderer = kRef(lcRendererWR);
  2386. if (!lcRenderer || !lcRenderer.isConnected) {
  2387. lcRenderer = document.querySelector('yt-live-chat-item-list-renderer.yt-live-chat-renderer');
  2388. lcRendererWR = lcRenderer ? mWeakRef(lcRenderer) : null;
  2389. }
  2390. return lcRenderer;
  2391. };
  2392.  
  2393.  
  2394. let hasFirstShowMore = false;
  2395.  
  2396. const visObserverFn = (entry) => {
  2397.  
  2398. const target = entry.target;
  2399. if (!target) return;
  2400. // if(target.classList.contains('dont-render')) return;
  2401. let isVisible = entry.isIntersecting === true && entry.intersectionRatio > 0.5;
  2402. // const h = entry.boundingClientRect.height;
  2403. /*
  2404. if (h < 16) { // wrong: 8 (padding/margin); standard: 32; test: 16 or 20
  2405. // e.g. under fullscreen. the element created but not rendered.
  2406. target.setAttribute('wSr93', '');
  2407. return;
  2408. }
  2409. */
  2410. if (isVisible) {
  2411. // target.style.setProperty('--wsr94', h + 'px');
  2412. target.setAttribute('wSr93', 'visible');
  2413. if (nNextElem(target) === null) {
  2414.  
  2415. // firstVisibleItemDetected = true;
  2416. /*
  2417. if (dateNow() - lastScroll < 80) {
  2418. lastLShow = 0;
  2419. lastScroll = 0;
  2420. Promise.resolve().then(clickShowMore);
  2421. } else {
  2422. lastLShow = dateNow();
  2423. }
  2424. */
  2425. // lastLShow = dateNow();
  2426. } else if (!hasFirstShowMore) { // should more than one item being visible
  2427. // implement inside visObserver to ensure there is sufficient delay
  2428. hasFirstShowMore = true;
  2429. requestAnimationFrame(() => {
  2430. // foreground page
  2431. // page visibly ready -> load the latest comments at initial loading
  2432. const lcRenderer = lcRendererElm();
  2433. if (lcRenderer) {
  2434. (lcRenderer.inst || lcRenderer).scrollToBottom_();
  2435. }
  2436. });
  2437. }
  2438. }
  2439. else if (target.getAttribute('wSr93') === 'visible') { // ignore target.getAttribute('wSr93') === '' to avoid wrong sizing
  2440.  
  2441. // target.style.setProperty('--wsr94', h + 'px');
  2442. target.setAttribute('wSr93', 'hidden');
  2443. } // note: might consider 0 < entry.intersectionRatio < 0.5 and target.getAttribute('wSr93') === '' <new last item>
  2444.  
  2445. }
  2446.  
  2447.  
  2448.  
  2449. const visObserver = new IntersectionObserver((entries) => {
  2450.  
  2451. for (const entry of entries) {
  2452.  
  2453. Promise.resolve(entry).then(visObserverFn);
  2454.  
  2455. }
  2456.  
  2457. }, {
  2458. // root: HTMLElement.prototype.closest.call(m2, '#item-scroller.yt-live-chat-item-list-renderer'), // nullable
  2459. rootMargin: "0px",
  2460. threshold: [0.05, 0.95],
  2461. });
  2462.  
  2463.  
  2464. return { lcRendererElm, visObserver }
  2465.  
  2466.  
  2467. })();
  2468.  
  2469. const { setupMutObserver } = (() => {
  2470.  
  2471. const mutFn = (items) => {
  2472. for (let node = nLastElem(items); node !== null; node = nPrevElem(node)) {
  2473. if (node.hasAttribute('wSr93')) break;
  2474. node.setAttribute('wSr93', '');
  2475. visObserver.observe(node);
  2476. }
  2477. }
  2478.  
  2479. const mutObserver = new MutationObserver((mutations) => {
  2480. const items = (mutations[0] || 0).target;
  2481. if (!items) return;
  2482. if (sk35zResolveFn) {
  2483. sk35zResolveFn();
  2484. sk35zResolveFn = null;
  2485. }
  2486. mutFn(items);
  2487. });
  2488.  
  2489. const setupMutObserver = (m2) => {
  2490. scrollChatFn = null;
  2491. mutObserver.disconnect();
  2492. mutObserver.takeRecords();
  2493. if (m2) {
  2494. ENABLE_DELAYED_CHAT_OCCURRENCE && bnForDelayChatOccurrence();
  2495. if (typeof m2.__appendChild932__ === 'function') {
  2496. if (typeof m2.appendChild === 'function') m2.appendChild = m2.__appendChild932__;
  2497. if (typeof m2.__shady_native_appendChild === 'function') m2.__shady_native_appendChild = m2.__appendChild932__;
  2498. }
  2499. mutObserver.observe(m2, {
  2500. childList: true,
  2501. subtree: false
  2502. });
  2503. mutFn(m2);
  2504.  
  2505. const isFirstList = firstList;
  2506. firstList = false;
  2507.  
  2508. if (ENABLE_OVERFLOW_ANCHOR) {
  2509.  
  2510. let items = m2;
  2511. let addedAnchor = false;
  2512. if (items) {
  2513. if (items.nextElementSibling === null) {
  2514. items.classList.add('no-anchor');
  2515. addedAnchor = true;
  2516. items.parentNode.appendChild(dr(document.createElement('item-anchor')));
  2517. }
  2518. }
  2519.  
  2520.  
  2521.  
  2522. if (addedAnchor) {
  2523. nodeParent(m2).classList.add('no-anchor'); // required
  2524. }
  2525.  
  2526. }
  2527.  
  2528. // let div = document.createElement('div');
  2529. // div.id = 'qwcc';
  2530. // HTMLElement.prototype.appendChild.call(document.querySelector('yt-live-chat-item-list-renderer'), div )
  2531. // bufferRegion =div;
  2532.  
  2533. // buffObserver.takeRecords();
  2534. // buffObserver.disconnect();
  2535. // buffObserver.observe(div, {
  2536. // childList: true,
  2537. // subtree: false
  2538. // })
  2539.  
  2540. if (ENABLE_DELAYED_CHAT_OCCURRENCE && isFirstList) {
  2541.  
  2542. promiseForCustomYtElementsReady.then(() => {
  2543.  
  2544. customElements.whenDefined('yt-live-chat-text-message-renderer').then(() => {
  2545.  
  2546.  
  2547.  
  2548.  
  2549. setTimeout(() => {
  2550.  
  2551. /** @type {HTMLTemplateElement} */
  2552. let skz = document.createElement('yt-live-chat-text-message-renderer');
  2553.  
  2554. let cz1 = null;
  2555.  
  2556. if (skz && 'data' in skz && 'attached' in skz) {
  2557.  
  2558. const deferredZy1 = new Promise(resolve => {
  2559.  
  2560. skz.attached = function () {
  2561. cz1 = HTMLElement.prototype.querySelector.call(skz, '#message img') !== null;
  2562. resolve(skz.textContent);
  2563. }
  2564. skz.detached = function () {
  2565.  
  2566. }
  2567.  
  2568. });
  2569. skz.id = 'sk35z';
  2570. skzData(skz);
  2571.  
  2572.  
  2573. sk35zResolveFn = null;
  2574. const deferredMutation = new Promise(resolve => {
  2575. sk35zResolveFn = resolve;
  2576. HTMLElement.prototype.appendChild.call(m2, skz);
  2577. });
  2578.  
  2579. Promise.all([deferredZy1, deferredMutation]).then(async (res) => {
  2580. const [zy1, _] = res;
  2581. function fn() {
  2582. const zy2 = skz.textContent;
  2583. const cz2 = HTMLElement.prototype.querySelector.call(skz, '#message img') !== null;
  2584. if (typeof zy1 === 'string' && typeof zy2 === 'string') {
  2585. allowDontRender = zy1 === zy2 && cz1 === cz2; // '0:43N​em2oji'
  2586. }
  2587. if (allowDontRender === false) {
  2588.  
  2589. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  2590. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  2591. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  2592. );
  2593.  
  2594. console.warn(`%cWarning:\n\tYou might have added a userscript or extension that stops YouTube Super Fast Chat's quick loading.\n\tTo figure out which one affects the script, turn them off one by one and let the author know.`, 'color: #bada55');
  2595.  
  2596. console.groupEnd();
  2597. } else if (allowDontRender === true) {
  2598. return true;
  2599. }
  2600. }
  2601. await new Promise(r => setTimeout(r, 1));
  2602. if (fn()) {
  2603. await new Promise(r => requestAnimationFrame(r));
  2604. if (fn()) {
  2605. skz.remove();
  2606. skz.textContent = '';
  2607. console.log('%cALLOW_DELAYED_CHAT_OCCURRENCE', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  2608. }
  2609. }
  2610. });
  2611.  
  2612. }
  2613.  
  2614. }, 1);
  2615.  
  2616. }).catch(console.warn);
  2617.  
  2618. })
  2619.  
  2620. }
  2621.  
  2622.  
  2623. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  2624.  
  2625. (() => {
  2626.  
  2627. const tag = 'yt-iframed-player-events-relay'
  2628. const dummy = document.createElement(tag);
  2629.  
  2630. const cProto = getProto(dummy);
  2631. if (!cProto || !cProto.handlePostMessage_) {
  2632. console.warn(`proto.handlePostMessage_ for ${tag} is unavailable.`);
  2633. return;
  2634. }
  2635.  
  2636. if (typeof cProto.handlePostMessage_ === 'function' && !cProto.handlePostMessage66_) {
  2637.  
  2638. cProto.handlePostMessage66_ = cProto.handlePostMessage_;
  2639.  
  2640. cProto.handlePostMessage_ = function (a) {
  2641.  
  2642. const da = (a || 0).data || 0;
  2643. if (typeof da === 'object') {
  2644.  
  2645. // console.log('handlePostMessage_', da)
  2646. const qc = da['yt-player-state-change'];
  2647. if (qc === 3) { // pause
  2648. pairForPauseResume++;
  2649. pairForPauseResumeM++;
  2650. } else if (qc === 1) { // pause
  2651. pairForPauseResume++;
  2652. pairForPauseResumeM++;
  2653. } else if (qc === 2) {
  2654. pairForPauseResume++;
  2655. pairForPauseResumeM++;
  2656. }
  2657. if (pairForPauseResume > 1e9) pairForPauseResume = pairForPauseResume % 1e4;
  2658. if (pairForPauseResumeM > 1e9) pairForPauseResumeM = pairForPauseResumeM % 1e4;
  2659. return this.handlePostMessage66_(a);
  2660.  
  2661. }
  2662.  
  2663.  
  2664. }
  2665.  
  2666. }
  2667.  
  2668.  
  2669. })();
  2670.  
  2671. }
  2672.  
  2673. if (isFirstList && DO_CHECK_TICKER_BACKGROUND_OVERRIDED) {
  2674. setTimeout(() => {
  2675. if (!hasTimerModified) return;
  2676. const tickerRenderer = document.querySelector('#ticker yt-live-chat-ticker-renderer.style-scope.yt-live-chat-renderer');
  2677. if (!tickerRenderer) return;
  2678.  
  2679. const items = (tickerRenderer.$ || 0).items || 0;
  2680. if (!items) return;
  2681. const template = document.createElement('template');
  2682. template.innerHTML = `<yt-live-chat-ticker-dummy777-item-renderer class="style-scope yt-live-chat-ticker-renderer" whole-message-clickable=""
  2683. modern="" aria-label="¥1,000" role="button" tabindex="0" id="Chw777" style="width: 94px; overflow: hidden;"
  2684. dimmed="" [dummy777]>
  2685. <div id="container" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"
  2686. style="--background:linear-gradient(90deg, rgba(1,2,3,1),rgba(1,2,3,1) 7%,rgba(4,0,0,1) 7%,rgba(4,0,0,1));">
  2687. <div id="content" class="style-scope yt-live-chat-ticker-dummy777-item-renderer" style="color: rgb(255, 255, 255);">
  2688. <yt-img-shadow777 id="author-photo" height="24" width="24"
  2689. class="style-scope yt-live-chat-ticker-dummy777-item-renderer no-transition"
  2690. style="background-color: transparent;" loaded=""><img id="img"
  2691. draggable="false" class="style-scope yt-img-shadow" alt="I" height="24" width="24"
  2692. src="${dummyImgURL}"></yt-img-shadow777>
  2693.  
  2694. <span id="text" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"1,000</span>
  2695. </div>
  2696. </div>
  2697. </yt-live-chat-ticker-dummy777-item-renderer>`;
  2698. const dummy777 = template.content.firstElementChild;
  2699. items.appendChild(dummy777);
  2700. Promise.resolve(dummy777).then((dummy777) => {
  2701. let container = HTMLElement.prototype.querySelector.call(dummy777, '#container') || 0;
  2702. if (container.isConnected === true) {
  2703.  
  2704. const evaluated = `${window.getComputedStyle(container).background}`;
  2705.  
  2706. container = null;
  2707. dummy777.remove();
  2708. dummy777.textContent = '';
  2709. dummy777 = null;
  2710.  
  2711. if (evaluated.indexOf('0.') < 4) {
  2712.  
  2713. // not fulfilling
  2714. // rgba(0, 0, 0, 0.004) none repeat scroll 0% 0% / auto padding-box border-box
  2715.  
  2716. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  2717. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  2718. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  2719. );
  2720. console.warn(`%cWarning:\n\tYou might have added a userscript or extension that also modifies the ticker background.\n\tYouTube Super Fast Chat is taking over.`, 'color: #bada55');
  2721. console.groupEnd();
  2722.  
  2723. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND (Overriding other scripting)', 'background-color: #7eb32b; color: #102624; padding: 2px 4px');
  2724.  
  2725. } else {
  2726.  
  2727. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  2728. }
  2729. }
  2730. });
  2731.  
  2732. }, 800);
  2733. }
  2734.  
  2735. }
  2736. }
  2737.  
  2738. return { setupMutObserver };
  2739.  
  2740.  
  2741.  
  2742. })();
  2743.  
  2744. const setupEvents = () => {
  2745.  
  2746.  
  2747. let scrollCount = 0;
  2748.  
  2749. const passiveCapture = typeof IntersectionObserver === 'function' ? { capture: true, passive: true } : true;
  2750.  
  2751.  
  2752. const delayFlushActiveItemsAfterUserActionK_ = () => {
  2753.  
  2754. const lcRenderer = lcRendererElm();
  2755. if (lcRenderer) {
  2756. const cnt = (lcRenderer.inst || lcRenderer);
  2757. if (!cnt.hasUserJustInteracted11_) return;
  2758. if (cnt.atBottom && cnt.allowScroll && cnt.activeItems_.length >= 1 && cnt.hasUserJustInteracted11_()) {
  2759. cnt.delayFlushActiveItemsAfterUserAction11_ && cnt.delayFlushActiveItemsAfterUserAction11_();
  2760. }
  2761. }
  2762.  
  2763. }
  2764.  
  2765. document.addEventListener('scroll', (evt) => {
  2766. if (!evt || !evt.isTrusted) return;
  2767. // lastScroll = dateNow();
  2768. if (++scrollCount > 1e9) scrollCount = 9;
  2769. }, passiveCapture); // support contain => support passive
  2770.  
  2771. let lastScrollCount = -1;
  2772. document.addEventListener('wheel', (evt) => {
  2773. if (!evt || !evt.isTrusted) return;
  2774. if (lastScrollCount === scrollCount) return;
  2775. lastScrollCount = scrollCount;
  2776. lastWheel = dateNow();
  2777. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2778. }, passiveCapture); // support contain => support passive
  2779.  
  2780. document.addEventListener('mousedown', (evt) => {
  2781. if (!evt || !evt.isTrusted) return;
  2782. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  2783. lastMouseDown = dateNow();
  2784. currentMouseDown = true;
  2785. lastUserInteraction = lastMouseDown;
  2786. }, passiveCapture);
  2787.  
  2788. document.addEventListener('pointerdown', (evt) => {
  2789. if (!evt || !evt.isTrusted) return;
  2790. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  2791. lastMouseDown = dateNow();
  2792. currentMouseDown = true;
  2793. lastUserInteraction = lastMouseDown;
  2794. }, passiveCapture);
  2795.  
  2796. document.addEventListener('click', (evt) => {
  2797. if (!evt || !evt.isTrusted) return;
  2798. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  2799. lastMouseDown = lastMouseUp = dateNow();
  2800. currentMouseDown = false;
  2801. lastUserInteraction = lastMouseDown;
  2802. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2803. }, passiveCapture);
  2804.  
  2805. document.addEventListener('tap', (evt) => {
  2806. if (!evt || !evt.isTrusted) return;
  2807. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  2808. lastMouseDown = lastMouseUp = dateNow();
  2809. currentMouseDown = false;
  2810. lastUserInteraction = lastMouseDown;
  2811. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2812. }, passiveCapture);
  2813.  
  2814.  
  2815. document.addEventListener('mouseup', (evt) => {
  2816. if (!evt || !evt.isTrusted) return;
  2817. if (currentMouseDown) {
  2818. lastMouseUp = dateNow();
  2819. currentMouseDown = false;
  2820. lastUserInteraction = lastMouseUp;
  2821. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2822. }
  2823. }, passiveCapture);
  2824.  
  2825.  
  2826. document.addEventListener('pointerup', (evt) => {
  2827. if (!evt || !evt.isTrusted) return;
  2828. if (currentMouseDown) {
  2829. lastMouseUp = dateNow();
  2830. currentMouseDown = false;
  2831. lastUserInteraction = lastMouseUp;
  2832. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2833. }
  2834. }, passiveCapture);
  2835.  
  2836. document.addEventListener('touchstart', (evt) => {
  2837. if (!evt || !evt.isTrusted) return;
  2838. lastTouchDown = dateNow();
  2839. currentTouchDown = true;
  2840. lastUserInteraction = lastTouchDown;
  2841. }, passiveCapture);
  2842.  
  2843. document.addEventListener('touchmove', (evt) => {
  2844. if (!evt || !evt.isTrusted) return;
  2845. lastTouchDown = dateNow();
  2846. currentTouchDown = true;
  2847. lastUserInteraction = lastTouchDown;
  2848. }, passiveCapture);
  2849.  
  2850. document.addEventListener('touchend', (evt) => {
  2851. if (!evt || !evt.isTrusted) return;
  2852. if (currentTouchDown) {
  2853. lastTouchUp = dateNow();
  2854. currentTouchDown = false;
  2855. lastUserInteraction = lastTouchUp;
  2856. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2857. }
  2858. }, passiveCapture);
  2859.  
  2860. document.addEventListener('touchcancel', (evt) => {
  2861. if (!evt || !evt.isTrusted) return;
  2862. if (currentTouchDown) {
  2863. lastTouchUp = dateNow();
  2864. currentTouchDown = false;
  2865. lastUserInteraction = lastTouchUp;
  2866. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  2867. }
  2868. }, passiveCapture);
  2869.  
  2870.  
  2871. }
  2872.  
  2873.  
  2874. const onRegistryReadyForDOMOperations = () => {
  2875.  
  2876. let firstCheckedOnYtInit = false;
  2877.  
  2878. const assertorURL = () => assertor(() => location.pathname.startsWith('/live_chat') && (location.search.indexOf('continuation=') > 0 || location.search.indexOf('v=') > 0));
  2879.  
  2880. const mightFirstCheckOnYtInit = () => {
  2881. if (firstCheckedOnYtInit) return;
  2882. firstCheckedOnYtInit = true;
  2883.  
  2884. if (!document.body || !document.head) return;
  2885. if (!assertorURL()) return;
  2886.  
  2887. addCssManaged();
  2888.  
  2889. let efsContainer = document.getElementById('elzm-fonts-yk75g');
  2890. if (efsContainer && efsContainer.parentNode !== document.body) {
  2891. document.body.appendChild(efsContainer);
  2892. }
  2893.  
  2894. };
  2895.  
  2896. if (!assertorURL()) return;
  2897. // if (!assertor(() => document.getElementById('yt-masthead') === null)) return;
  2898.  
  2899. if (document.documentElement && document.head) {
  2900. addCssManaged();
  2901. }
  2902. // console.log(document.body===null)
  2903.  
  2904. customElements.whenDefined('yt-live-chat-item-list-renderer').then(() => {
  2905.  
  2906. const tag = "yt-live-chat-item-list-renderer"
  2907. const dummy = document.createElement(tag);
  2908.  
  2909. const cProto = getProto(dummy);
  2910. if (!cProto || !cProto.attached) {
  2911. console.warn(`proto.attached for ${tag} is unavailable.`);
  2912. return;
  2913. }
  2914.  
  2915. mightFirstCheckOnYtInit();
  2916. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-item-list-renderer hacks");
  2917. console.log("[Begin]");
  2918.  
  2919. const mclp = cProto;
  2920. try {
  2921. assertor(() => typeof mclp.scrollToBottom_ === 'function');
  2922. assertor(() => typeof mclp.flushActiveItems_ === 'function');
  2923. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  2924. assertor(() => typeof mclp.setAtBottom === 'function');
  2925. assertor(() => typeof mclp.scrollToBottom66_ === 'undefined');
  2926. assertor(() => typeof mclp.flushActiveItems66_ === 'undefined');
  2927. } catch (e) { }
  2928.  
  2929.  
  2930. try {
  2931. assertor(() => typeof mclp.attached === 'function');
  2932. assertor(() => typeof mclp.detached === 'function');
  2933. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  2934. assertor(() => typeof mclp.isSmoothScrollEnabled_ === 'function');
  2935. assertor(() => typeof mclp.maybeResizeScrollContainer_ === 'function');
  2936. assertor(() => typeof mclp.refreshOffsetContainerHeight_ === 'function');
  2937. assertor(() => typeof mclp.smoothScroll_ === 'function');
  2938. assertor(() => typeof mclp.resetSmoothScroll_ === 'function');
  2939. } catch (e) { }
  2940.  
  2941. mclp.__intermediate_delay__ = null;
  2942.  
  2943. let mzk = 0;
  2944. let myk = 0;
  2945. let mlf = 0;
  2946. let myw = 0;
  2947. let mzt = 0;
  2948. let zarr = null;
  2949. let mlg = 0;
  2950.  
  2951. if ((mclp.clearList || 0).length === 0) {
  2952. assertor(() => fnIntegrity(mclp.clearList, '0.106.50'));
  2953. mclp.clearList66 = mclp.clearList;
  2954. mclp.clearList = function () {
  2955. mzk++;
  2956. myk++;
  2957. mlf++;
  2958. myw++;
  2959. mzt++;
  2960. mlg++;
  2961. zarr = null;
  2962. this.__intermediate_delay__ = null;
  2963. this.clearList66();
  2964. };
  2965. console.log("clearList", "OK");
  2966. } else {
  2967. console.log("clearList", "NG");
  2968. }
  2969.  
  2970.  
  2971. let onListRendererAttachedDone = false;
  2972.  
  2973. function setList(itemOffset, items) {
  2974.  
  2975. const isFirstTime = onListRendererAttachedDone === false;
  2976.  
  2977. if (isFirstTime) {
  2978. onListRendererAttachedDone = true;
  2979. Promise.resolve().then(watchUserCSS);
  2980. addCssManaged();
  2981. setupEvents();
  2982. }
  2983.  
  2984. setupStyle(itemOffset, items);
  2985.  
  2986. setupMutObserver(items);
  2987. }
  2988.  
  2989. mclp.attached419 = async function () {
  2990.  
  2991. if (!this.isAttached) return;
  2992.  
  2993. let maxTrial = 16;
  2994. while (!this.$ || !this.$['item-scroller'] || !this.$['item-offset'] || !this.$['items']) {
  2995. if (--maxTrial < 0 || !this.isAttached) return;
  2996. await new Promise(requestAnimationFrame);
  2997. }
  2998.  
  2999. if (this.isAttached !== true) return;
  3000.  
  3001. if (!this.$) {
  3002. console.warn("!this.$");
  3003. return;
  3004. }
  3005. if (!this.$) return;
  3006. /** @type {HTMLElement | null} */
  3007. const itemScroller = this.$['item-scroller'];
  3008. /** @type {HTMLElement | null} */
  3009. const itemOffset = this.$['item-offset'];
  3010. /** @type {HTMLElement | null} */
  3011. const items = this.$['items'];
  3012.  
  3013. if (!itemScroller || !itemOffset || !items) {
  3014. console.warn("items.parentNode !== itemOffset");
  3015. return;
  3016. }
  3017.  
  3018. if (nodeParent(items) !== itemOffset) {
  3019.  
  3020. console.warn("items.parentNode !== itemOffset");
  3021. return;
  3022. }
  3023.  
  3024.  
  3025. if (items.id !== 'items' || itemOffset.id !== "item-offset") {
  3026.  
  3027. console.warn("id incorrect");
  3028. return;
  3029. }
  3030.  
  3031. const isTargetItems = HTMLElement.prototype.matches.call(items, '#item-offset.style-scope.yt-live-chat-item-list-renderer > #items.style-scope.yt-live-chat-item-list-renderer')
  3032.  
  3033. if (!isTargetItems) {
  3034. console.warn("!isTargetItems");
  3035. return;
  3036. }
  3037.  
  3038. setList(itemOffset, items);
  3039.  
  3040. }
  3041.  
  3042. mclp.attached331 = mclp.attached;
  3043. mclp.attached = function () {
  3044. this.attached419 && this.attached419();
  3045. return this.attached331();
  3046. }
  3047.  
  3048. mclp.detached331 = mclp.detached;
  3049.  
  3050. mclp.detached = function () {
  3051. setupMutObserver();
  3052. return this.detached331();
  3053. }
  3054.  
  3055. const t29s = document.querySelectorAll("yt-live-chat-item-list-renderer");
  3056. for (const t29 of t29s) {
  3057. if ((t29.inst || t29).isAttached === true) {
  3058. t29.attached419();
  3059. }
  3060. }
  3061.  
  3062. if ((mclp.async || 0).length === 2 && (mclp.cancelAsync || 0).length === 1) {
  3063.  
  3064. assertor(() => fnIntegrity(mclp.async, '2.24.15'));
  3065. assertor(() => fnIntegrity(mclp.cancelAsync, '1.15.8'));
  3066.  
  3067. /** @type {Map<number, any>} */
  3068. const aMap = new Map();
  3069. let count = 6150;
  3070. mclp.async66 = mclp.async;
  3071. mclp.async = function (e, f) {
  3072. // ensure the previous operation is done
  3073. // .async is usually after the time consuming functions like flushActiveItems_ and scrollToBottom_
  3074. const hasF = arguments.length === 2;
  3075. const stack = new Error().stack;
  3076. const isFlushAsync = stack.indexOf('flushActiveItems_') >= 0;
  3077. if (count > 1e9) count = 6159;
  3078. const resId = ++count;
  3079. aMap.set(resId, e);
  3080. (this.__intermediate_delay__ || Promise.resolve()).then(rk => {
  3081. const rp = aMap.get(resId);
  3082. if (typeof rp !== 'function') {
  3083. return;
  3084. }
  3085. let cancelCall = false;
  3086. if (isFlushAsync) {
  3087. if (rk < 0) {
  3088. cancelCall = true;
  3089. } else if (rk === 2 && arguments[0] === this.maybeScrollToBottom_) {
  3090. cancelCall = true;
  3091. }
  3092. }
  3093. if (cancelCall) {
  3094. aMap.delete(resId);
  3095. } else {
  3096. const asyncEn = function () {
  3097. aMap.delete(resId);
  3098. return rp.apply(this, arguments);
  3099. };
  3100. aMap.set(resId, hasF ? this.async66(asyncEn, f) : this.async66(asyncEn));
  3101. }
  3102. });
  3103.  
  3104. return resId;
  3105. }
  3106.  
  3107. mclp.cancelAsync66 = mclp.cancelAsync;
  3108. mclp.cancelAsync = function (resId) {
  3109. if (resId <= 6150) {
  3110. this.cancelAsync66(resId);
  3111. } else if (aMap.has(resId)) {
  3112. const rp = aMap.get(resId);
  3113. aMap.delete(resId);
  3114. if (typeof rp !== 'function') {
  3115. this.cancelAsync66(rp);
  3116. }
  3117. }
  3118. }
  3119.  
  3120. console.log("async", "OK");
  3121. } else {
  3122. console.log("async", "NG");
  3123. }
  3124.  
  3125.  
  3126. if ((mclp.showNewItems_ || 0).length === 0 && ENABLE_NO_SMOOTH_TRANSFORM) {
  3127.  
  3128. assertor(() => fnIntegrity(mclp.showNewItems_, '0.170.79'));
  3129. mclp.showNewItems66_ = mclp.showNewItems_;
  3130.  
  3131. mclp.showNewItems77_ = async function () {
  3132. if (myk > 1e9) myk = 9;
  3133. let tid = ++myk;
  3134.  
  3135. await new Promise(requestAnimationFrame);
  3136.  
  3137. if (tid !== myk) {
  3138. return;
  3139. }
  3140.  
  3141. const cnt = this;
  3142.  
  3143. await Promise.resolve();
  3144. cnt.showNewItems66_();
  3145.  
  3146. await Promise.resolve();
  3147.  
  3148. }
  3149.  
  3150. mclp.showNewItems_ = function () {
  3151.  
  3152. const cnt = this;
  3153. cnt.__intermediate_delay__ = new Promise(resolve => {
  3154. cnt.showNewItems77_().then(() => {
  3155. resolve();
  3156. });
  3157. });
  3158. }
  3159.  
  3160. console.log("showNewItems_", "OK");
  3161. } else {
  3162. console.log("showNewItems_", "NG");
  3163. }
  3164.  
  3165.  
  3166. if ((mclp.flushActiveItems_ || 0).length === 0) {
  3167.  
  3168. assertor(() => fnIntegrity(mclp.flushActiveItems_, '0.137.81'));
  3169.  
  3170. let hasMoreMessageState = !ENABLE_SHOW_MORE_BLINKER ? -1 : 0;
  3171.  
  3172. let contensWillChangeController = null;
  3173.  
  3174. mclp.flushActiveItems66_ = mclp.flushActiveItems_;
  3175.  
  3176. mclp.flushActiveItems78_ = async function (tid) {
  3177. try {
  3178. if (tid !== mlf) return;
  3179. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  3180. let logger = false;
  3181. const cnt = this;
  3182. let immd = cnt.__intermediate_delay__;
  3183. await new Promise(requestAnimationFrame);
  3184.  
  3185. if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3186. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return;
  3187.  
  3188. mlf++;
  3189. if (mlg > 1e9) mlg = 9;
  3190. ++mlg;
  3191.  
  3192. const tmpMaxItemsCount = this.data.maxItemsToDisplay;
  3193. const reducedMaxItemsToDisplay = MAX_ITEMS_FOR_FULL_FLUSH;
  3194. let changeMaxItemsToDisplay = false;
  3195. const activeItemsLen = this.activeItems_.length;
  3196. if (activeItemsLen > tmpMaxItemsCount && tmpMaxItemsCount > 0) {
  3197. logger = true;
  3198.  
  3199. groupCollapsed("YouTube Super Fast Chat", " | flushActiveItems78_");
  3200.  
  3201. logger && console.log('[Begin]')
  3202.  
  3203. console.log('this.activeItems_.length > N', activeItemsLen, tmpMaxItemsCount);
  3204. if (ENABLE_REDUCED_MAXITEMS_FOR_FLUSH && lockedMaxItemsToDisplay === tmpMaxItemsCount && lockedMaxItemsToDisplay !== reducedMaxItemsToDisplay) {
  3205. console.log('reduce maxitems');
  3206. if (tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  3207. // as all the rendered chats are already "outdated"
  3208. // all old chats shall remove and reduced number of few chats will be rendered
  3209. // then restore to the original number
  3210. changeMaxItemsToDisplay = true;
  3211. this.data.maxItemsToDisplay = reducedMaxItemsToDisplay;
  3212. console.log(`'maxItemsToDisplay' is reduced from ${tmpMaxItemsCount} to ${reducedMaxItemsToDisplay}.`)
  3213. }
  3214. this.activeItems_.splice(0, activeItemsLen - this.data.maxItemsToDisplay);
  3215. // console.log('changeMaxItemsToDisplay 01', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  3216.  
  3217. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  3218. } else {
  3219. this.activeItems_.splice(0, activeItemsLen - (tmpMaxItemsCount < 900 ? tmpMaxItemsCount : 900));
  3220.  
  3221. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  3222. }
  3223. }
  3224. // it is found that it will render all stacked chats after switching back from background
  3225. // to avoid lagging in popular livestream with massive chats, trim first before rendering.
  3226. // this.activeItems_.length > this.data.maxItemsToDisplay && this.activeItems_.splice(0, this.activeItems_.length - this.data.maxItemsToDisplay);
  3227.  
  3228.  
  3229. const items = (cnt.$ || 0).items;
  3230.  
  3231. if (USE_WILL_CHANGE_CONTROLLER) {
  3232. if (contensWillChangeController && contensWillChangeController.element !== items) {
  3233. contensWillChangeController.release();
  3234. contensWillChangeController = null;
  3235. }
  3236. if (!contensWillChangeController) contensWillChangeController = new WillChangeController(items, 'contents');
  3237. }
  3238. const wcController = contensWillChangeController;
  3239. cnt.__intermediate_delay__ = Promise.all([cnt.__intermediate_delay__ || null, immd || null]);
  3240. wcController && wcController.beforeOper();
  3241. await Promise.resolve();
  3242. const acItems = cnt.activeItems_;
  3243. const len1 = acItems.length;
  3244. if (!len1) console.warn('cnt.activeItems_.length = 0');
  3245. let waitFor = [];
  3246.  
  3247.  
  3248. /** @type {Set<string>} */
  3249. const imageLinks = new Set();
  3250.  
  3251. if (ENABLE_PRELOAD_THUMBNAIL || EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL) {
  3252. for (const item of acItems) {
  3253. fixLiveChatItem(item, imageLinks);
  3254. }
  3255. }
  3256. if (ENABLE_PRELOAD_THUMBNAIL && kptPF !== null && (kptPF & (8 | 4)) && imageLinks.size > 0) {
  3257. if (emojiPrefetched.size > PREFETCH_LIMITED_SIZE_EMOJI) emojiPrefetched.clear();
  3258. if (authorPhotoPrefetched.size > PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO) authorPhotoPrefetched.clear();
  3259.  
  3260. // reference: https://github.com/Yuanfang-fe/Blog-X/issues/34
  3261. const rel = kptPF & 8 ? 'subresource' : kptPF & 16 ? 'preload' : kptPF & 4 ? 'prefetch' : '';
  3262. // preload performs the high priority fetching.
  3263. // prefetch delays the chat display if the video resoruce is demanding.
  3264.  
  3265. if (rel) {
  3266.  
  3267. imageLinks.forEach(imageLink => {
  3268. let d = false;
  3269. const isEmoji = imageLink.includes('/emoji/');
  3270. const pretechedSet = isEmoji ? emojiPrefetched : authorPhotoPrefetched;
  3271. if (!pretechedSet.has(imageLink)) {
  3272. pretechedSet.add(imageLink);
  3273. d = true;
  3274. }
  3275. if (d) {
  3276. waitFor.push(linker(null, rel, imageLink, 'image'));
  3277.  
  3278. }
  3279. })
  3280.  
  3281. }
  3282.  
  3283. }
  3284.  
  3285. skipDontRender = ((cnt.visibleItems || 0).length || 0) === 0;
  3286. // console.log('ss1', Date.now())
  3287. if (waitFor.length > 0) {
  3288. await Promise.race([new Promise(r => setTimeout(r, 250)), Promise.all(waitFor)]);
  3289. }
  3290. waitFor.length = 0;
  3291. waitFor = null;
  3292. // console.log('ss2', Date.now())
  3293. cnt.flushActiveItems66_();
  3294. skipDontRender = ((cnt.visibleItems || 0).length || 0) === 0;
  3295. const len2 = cnt.activeItems_.length;
  3296. const bAsync = len1 !== len2;
  3297. await Promise.resolve();
  3298. if (wcController) {
  3299. if (bAsync) {
  3300. cnt.async(() => {
  3301. wcController.afterOper();
  3302. });
  3303. } else {
  3304. wcController.afterOper();
  3305. }
  3306. }
  3307. if (changeMaxItemsToDisplay && this.data.maxItemsToDisplay === reducedMaxItemsToDisplay && tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  3308. this.data.maxItemsToDisplay = tmpMaxItemsCount;
  3309.  
  3310. logger && console.log(`'maxItemsToDisplay' is restored from ${reducedMaxItemsToDisplay} to ${tmpMaxItemsCount}.`);
  3311. // console.log('changeMaxItemsToDisplay 02', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  3312. } else if (changeMaxItemsToDisplay) {
  3313.  
  3314. logger && console.log(`'maxItemsToDisplay' cannot be restored`, {
  3315. maxItemsToDisplay: this.data.maxItemsToDisplay,
  3316. reducedMaxItemsToDisplay,
  3317. originalMaxItemsToDisplay: tmpMaxItemsCount
  3318. });
  3319. }
  3320. logger && console.log('[End]')
  3321.  
  3322. logger && console.groupEnd();
  3323.  
  3324. if (!ENABLE_NO_SMOOTH_TRANSFORM) {
  3325.  
  3326.  
  3327. const ff = () => {
  3328.  
  3329. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3330. // if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3331. if (!cnt.atBottom && cnt.allowScroll && cnt.hasUserJustInteracted11_ && !cnt.hasUserJustInteracted11_()) {
  3332. cnt.scrollToBottom_();
  3333.  
  3334. Promise.resolve().then(() => {
  3335.  
  3336. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3337. if (!cnt.canScrollToBottom_()) cnt.scrollToBottom_();
  3338. });
  3339.  
  3340.  
  3341. }
  3342. }
  3343.  
  3344. ff();
  3345.  
  3346.  
  3347. Promise.resolve().then(ff);
  3348.  
  3349. // requestAnimationFrame(ff);
  3350. } else if (true) { // it might not be sticky to bottom when there is a full refresh.
  3351.  
  3352. const knt = cnt;
  3353. if (!scrollChatFn) {
  3354. const cnt = knt;
  3355. const f = () => {
  3356. const itemScroller = cnt.itemScroller;
  3357. if (!itemScroller || itemScroller.isConnected === false || cnt.isAttached === false) return;
  3358. if (!cnt.atBottom) {
  3359. cnt.scrollToBottom_();
  3360. } else if (itemScroller.scrollTop === 0) { // not yet interacted by user; cannot stick to bottom
  3361. itemScroller.scrollTop = itemScroller.scrollHeight;
  3362. }
  3363. };
  3364. scrollChatFn = () => Promise.resolve().then(f).then(f);
  3365. }
  3366.  
  3367. if (!ENABLE_DELAYED_CHAT_OCCURRENCE) scrollChatFn();
  3368. }
  3369.  
  3370. return 1;
  3371.  
  3372.  
  3373. } catch (e) {
  3374. console.warn(e);
  3375. }
  3376. }
  3377.  
  3378. mclp.flushActiveItems77_ = function () {
  3379.  
  3380. return new Promise(resResolve => {
  3381. try {
  3382. const cnt = this;
  3383. if (mlf > 1e9) mlf = 9;
  3384. let tid = ++mlf;
  3385. const hostElement = cnt.hostElement || cnt;
  3386. if (tid !== mlf || cnt.isAttached === false || hostElement.isConnected === false) return resResolve();
  3387. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return resResolve();
  3388.  
  3389. // 4 times to maxItems to avoid frequent trimming.
  3390. // 1 ... 10 ... 20 ... 30 ... 40 ... 50 ... 60 => 16 ... 20 ... 30 ..... 60 ... => 16
  3391.  
  3392. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  3393. this.activeItems_.length > lockedMaxItemsToDisplay * 4 && lockedMaxItemsToDisplay > 4 && this.activeItems_.splice(0, this.activeItems_.length - lockedMaxItemsToDisplay - 1);
  3394. if (cnt.canScrollToBottom_()) {
  3395. cnt.mutexPromiseFA78 = (cnt.mutexPromiseFA78 || Promise.resolve())
  3396. .then(() => cnt.flushActiveItems78_(tid)) // async function
  3397. .then((asyncResult) => {
  3398. resResolve(asyncResult); // either undefined or 1
  3399. resResolve = null;
  3400. }).catch((e) => {
  3401. console.warn(e);
  3402. if (resResolve) resResolve();
  3403. });
  3404. } else {
  3405. resResolve(2);
  3406. resResolve = null;
  3407. }
  3408. } catch (e) {
  3409. console.warn(e);
  3410. if (resResolve) resResolve();
  3411. }
  3412.  
  3413.  
  3414. });
  3415.  
  3416. }
  3417.  
  3418. mclp.flushActiveItems_ = function () {
  3419. const cnt = this;
  3420.  
  3421. if (arguments.length !== 0 || !cnt.activeItems_ || !cnt.canScrollToBottom_) return cnt.flushActiveItems66_.apply(this, arguments);
  3422.  
  3423. if (cnt.activeItems_.length === 0) {
  3424. cnt.__intermediate_delay__ = null;
  3425. return;
  3426. }
  3427.  
  3428. const cntData = ((cnt || 0).data || 0);
  3429. if (cntData.maxItemsToDisplay944 === undefined) {
  3430. cntData.maxItemsToDisplay944 = null;
  3431. if (cntData.maxItemsToDisplay > MAX_ITEMS_FOR_TOTAL_DISPLAY) cntData.maxItemsToDisplay = MAX_ITEMS_FOR_TOTAL_DISPLAY;
  3432. cntData.maxItemsToDisplay944 = cntData.maxItemsToDisplay || null;
  3433. }
  3434.  
  3435. // ignore previous __intermediate_delay__ and create a new one
  3436. cnt.__intermediate_delay__ = new Promise(resolve => {
  3437. cnt.flushActiveItems77_().then(rt => { // either undefined or 1 or 2
  3438. if (rt === 1) {
  3439. resolve(1); // success, scroll to bottom
  3440. if (hasMoreMessageState === 1) {
  3441. hasMoreMessageState = 0;
  3442. const showMore = (cnt.$ || 0)['show-more'];
  3443. if (showMore) {
  3444. showMore.classList.remove('has-new-messages-miuzp');
  3445. }
  3446. }
  3447. }
  3448. else if (rt === 2) {
  3449. resolve(2); // success, trim
  3450. if (hasMoreMessageState === 0) {
  3451. hasMoreMessageState = 1;
  3452. const showMore = cnt.$['show-more'];
  3453. if (showMore) {
  3454. showMore.classList.add('has-new-messages-miuzp');
  3455. }
  3456. }
  3457. }
  3458. else resolve(-1); // skip
  3459. }).catch(e => {
  3460. console.warn(e);
  3461. });
  3462. });
  3463.  
  3464. }
  3465. console.log("flushActiveItems_", "OK");
  3466. } else {
  3467. console.log("flushActiveItems_", "NG");
  3468. }
  3469.  
  3470. mclp.delayFlushActiveItemsAfterUserAction11_ = async function () {
  3471. try {
  3472. if (mlg > 1e9) mlg = 9;
  3473. const tid = ++mlg;
  3474. const keepTrialCond = () => this.atBottom && this.allowScroll && (tid === mlg) && this.isAttached === true && this.activeItems_.length >= 1 && (this.hostElement || 0).isConnected === true;
  3475. const runCond = () => this.canScrollToBottom_();
  3476. if (!keepTrialCond()) return;
  3477. if (runCond()) return this.flushActiveItems_() | 1; // avoid return promise
  3478. await new Promise(r => setTimeout(r, 80));
  3479. if (!keepTrialCond()) return;
  3480. if (runCond()) return this.flushActiveItems_() | 1;
  3481. await new Promise(requestAnimationFrame);
  3482. if (runCond()) return this.flushActiveItems_() | 1;
  3483. } catch (e) {
  3484. console.warn(e);
  3485. }
  3486. }
  3487.  
  3488. if ((mclp.atBottomChanged_ || 0).length === 1) {
  3489. // note: if the scrolling is too frequent, the show more visibility might get wrong.
  3490. assertor(() => fnIntegrity(mclp.atBottomChanged_, '1.75.39'));
  3491.  
  3492. const querySelector = HTMLElement.prototype.querySelector;
  3493. const U = (element) => ({
  3494. querySelector: (selector) => querySelector.call(element, selector)
  3495. });
  3496.  
  3497. let qid = 0;
  3498. mclp.atBottomChanged_ = function (a) {
  3499. let tid = ++qid;
  3500. let b = this;
  3501. a ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = this.async(function () {
  3502. if (tid !== qid) return;
  3503. U(b.hostElement).querySelector("#show-more").style.visibility = "hidden"
  3504. }, 200)) : (this.hideShowMoreAsync_ && this.cancelAsync(this.hideShowMoreAsync_),
  3505. this.hideShowMoreAsync_ = null,
  3506. U(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  3507. }
  3508.  
  3509. console.log("atBottomChanged_", "OK");
  3510. } else {
  3511. console.log("atBottomChanged_", "NG");
  3512. }
  3513.  
  3514. if ((mclp.onScrollItems_ || 0).length === 1) {
  3515.  
  3516. assertor(() => fnIntegrity(mclp.onScrollItems_, '1.17.9'));
  3517. mclp.onScrollItems66_ = mclp.onScrollItems_;
  3518. mclp.onScrollItems77_ = async function (evt) {
  3519. if (myw > 1e9) myw = 9;
  3520. let tid = ++myw;
  3521.  
  3522. await new Promise(requestAnimationFrame);
  3523.  
  3524. if (tid !== myw) {
  3525. return;
  3526. }
  3527.  
  3528. const cnt = this;
  3529.  
  3530. await Promise.resolve();
  3531. if (USE_OPTIMIZED_ON_SCROLL_ITEMS) {
  3532. await Promise.resolve().then(() => {
  3533. this.ytRendererBehavior.onScroll(evt);
  3534. }).then(() => {
  3535. if (this.canScrollToBottom_()) {
  3536. const hasUserJustInteracted = this.hasUserJustInteracted11_ ? this.hasUserJustInteracted11_() : true;
  3537. if (hasUserJustInteracted) {
  3538. // only when there is an user action
  3539. this.setAtBottom();
  3540. return 1;
  3541. }
  3542. } else {
  3543. // no message inserting
  3544. this.setAtBottom();
  3545. return 1;
  3546. }
  3547. }).then((r) => {
  3548.  
  3549. if (this.activeItems_.length) {
  3550.  
  3551. if (this.canScrollToBottom_()) {
  3552. this.flushActiveItems_();
  3553. return 1 && r;
  3554. } else if (this.atBottom && this.allowScroll && (this.hasUserJustInteracted11_ && this.hasUserJustInteracted11_())) {
  3555. // delayed due to user action
  3556. this.delayFlushActiveItemsAfterUserAction11_ && this.delayFlushActiveItemsAfterUserAction11_();
  3557. return 0;
  3558. }
  3559. }
  3560. }).then((r) => {
  3561. if (r) {
  3562. // ensure setAtBottom is correctly set
  3563. this.setAtBottom();
  3564. }
  3565. });
  3566. } else {
  3567. cnt.onScrollItems66_(evt);
  3568. }
  3569.  
  3570. await Promise.resolve();
  3571.  
  3572. }
  3573.  
  3574. mclp.onScrollItems_ = function (evt) {
  3575.  
  3576. const cnt = this;
  3577. cnt.__intermediate_delay__ = new Promise(resolve => {
  3578. cnt.onScrollItems77_(evt).then(() => {
  3579. resolve();
  3580. });
  3581. });
  3582. }
  3583. console.log("onScrollItems_", "OK");
  3584. } else {
  3585. console.log("onScrollItems_", "NG");
  3586. }
  3587.  
  3588. if ((mclp.handleLiveChatActions_ || 0).length === 1) {
  3589.  
  3590. assertor(() => fnIntegrity(mclp.handleLiveChatActions_, '1.31.17'));
  3591. mclp.handleLiveChatActions66_ = mclp.handleLiveChatActions_;
  3592.  
  3593. mclp.handleLiveChatActions77_ = async function (arr) {
  3594. if (typeof (arr || 0).length !== 'number') {
  3595. this.handleLiveChatActions66_(arr);
  3596. return;
  3597. }
  3598. if (mzt > 1e9) mzt = 9;
  3599. let tid = ++mzt;
  3600.  
  3601. if (zarr === null) zarr = arr;
  3602. else Array.prototype.push.apply(zarr, arr);
  3603. arr = null;
  3604.  
  3605. await new Promise(requestAnimationFrame);
  3606.  
  3607. if (tid !== mzt || zarr === null) {
  3608. return;
  3609. }
  3610.  
  3611. const carr = zarr;
  3612. zarr = null;
  3613.  
  3614. await Promise.resolve();
  3615. this.handleLiveChatActions66_(carr);
  3616. await Promise.resolve();
  3617.  
  3618. }
  3619.  
  3620. mclp.handleLiveChatActions_ = function (arr) {
  3621.  
  3622. const cnt = this;
  3623. cnt.__intermediate_delay__ = new Promise(resolve => {
  3624. cnt.handleLiveChatActions77_(arr).then(() => {
  3625. resolve();
  3626. });
  3627. });
  3628. }
  3629. console.log("handleLiveChatActions_", "OK");
  3630. } else {
  3631. console.log("handleLiveChatActions_", "NG");
  3632. }
  3633.  
  3634. mclp.hasUserJustInteracted11_ = () => {
  3635. const t = dateNow();
  3636. return (t - lastWheel < 80) || currentMouseDown || currentTouchDown || (t - lastUserInteraction < 80);
  3637. }
  3638.  
  3639. if ((mclp.canScrollToBottom_ || 0).length === 0) {
  3640.  
  3641. assertor(() => fnIntegrity(mclp.canScrollToBottom_, '0.9.5'));
  3642.  
  3643. mclp.canScrollToBottom_ = function () {
  3644. return this.atBottom && this.allowScroll && !this.hasUserJustInteracted11_();
  3645. }
  3646.  
  3647. console.log("canScrollToBottom_", "OK");
  3648. } else {
  3649. console.log("canScrollToBottom_", "NG");
  3650. }
  3651.  
  3652. if (ENABLE_NO_SMOOTH_TRANSFORM) {
  3653.  
  3654. mclp.isSmoothScrollEnabled_ = function () {
  3655. return false;
  3656. }
  3657.  
  3658. mclp.maybeResizeScrollContainer_ = function () {
  3659. //
  3660. }
  3661.  
  3662. mclp.refreshOffsetContainerHeight_ = function () {
  3663. //
  3664. }
  3665.  
  3666. mclp.smoothScroll_ = function () {
  3667. //
  3668. }
  3669.  
  3670. mclp.resetSmoothScroll_ = function () {
  3671. //
  3672. }
  3673. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "OK");
  3674. } else {
  3675. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "NG");
  3676. }
  3677.  
  3678. if (typeof mclp.handleAddChatItemAction_ === 'function' && !mclp.handleAddChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  3679.  
  3680. mclp.handleAddChatItemAction66_ = mclp.handleAddChatItemAction_;
  3681. mclp.handleAddChatItemAction_ = function (a) {
  3682. try {
  3683. if (a && typeof a === 'object' && !('length' in a)) {
  3684. fixLiveChatItem(a.item, null);
  3685. console.assert(arguments[0] === a);
  3686. }
  3687. } catch (e) { console.warn(e) }
  3688. return this.handleAddChatItemAction66_.apply(this, arguments);
  3689. }
  3690.  
  3691. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  3692. } else {
  3693.  
  3694. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  3695. }
  3696.  
  3697.  
  3698. if (typeof mclp.handleReplaceChatItemAction_ === 'function' && !mclp.handleReplaceChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  3699.  
  3700. mclp.handleReplaceChatItemAction66_ = mclp.handleReplaceChatItemAction_;
  3701. mclp.handleReplaceChatItemAction_ = function (a) {
  3702. try {
  3703. if (a && typeof a === 'object' && !('length' in a)) {
  3704. fixLiveChatItem(a.replacementItem, null);
  3705. console.assert(arguments[0] === a);
  3706. }
  3707. } catch (e) { console.warn(e) }
  3708. return this.handleReplaceChatItemAction66_.apply(this, arguments);
  3709. }
  3710.  
  3711. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  3712. } else {
  3713.  
  3714. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  3715. }
  3716.  
  3717. console.log("[End]");
  3718. console.groupEnd();
  3719.  
  3720. }).catch(console.warn);
  3721.  
  3722.  
  3723. const tickerContainerSetAttribute = function (attrName, attrValue) { // ensure '14.30000001%'.toFixed(1)
  3724.  
  3725. let yd = (this.__dataHost || (this.inst || 0).__dataHost || 0).__data;
  3726.  
  3727. if (arguments.length === 2 && attrName === 'style' && yd && attrValue) {
  3728.  
  3729. // let v = yd.containerStyle.privateDoNotAccessOrElseSafeStyleWrappedValue_;
  3730. let v = `${attrValue}`;
  3731. // conside a ticker is 101px width
  3732. // 1% = 1.01px
  3733. // 0.2% = 0.202px
  3734.  
  3735.  
  3736. const ratio1 = (yd.ratio * 100);
  3737. if (ratio1 > -1) { // avoid NaN
  3738.  
  3739. // countdownDurationMs
  3740. // 600000 - 0.2% <1% = 6s> <0.2% = 1.2s>
  3741. // 300000 - 0.5% <1% = 3s> <0.5% = 1.5s>
  3742. // 150000 - 1% <1% = 1.5s>
  3743. // 75000 - 2% <1% =0.75s > <2% = 1.5s>
  3744. // 30000 - 5% <1% =0.3s > <5% = 1.5s>
  3745.  
  3746. // 99px * 5% = 4.95px
  3747.  
  3748. // 15000 - 10% <1% =0.15s > <10% = 1.5s>
  3749.  
  3750.  
  3751. // 1% Duration
  3752.  
  3753. let ratio2 = ratio1;
  3754.  
  3755. const ydd = yd.data;
  3756. if (ydd) {
  3757.  
  3758. const d1 = ydd.durationSec;
  3759. const d2 = ydd.fullDurationSec;
  3760.  
  3761. // @ step timing [min. 0.2%]
  3762. let numOfSteps = 500;
  3763. if ((d1 === d2 || (d1 + 1 === d2)) && d1 > 1) {
  3764. if (d2 > 400) numOfSteps = 500; // 0.2%
  3765. else if (d2 > 200) numOfSteps = 200; // 0.5%
  3766. else if (d2 > 100) numOfSteps = 100; // 1%
  3767. else if (d2 > 50) numOfSteps = 50; // 2%
  3768. else if (d2 > 25) numOfSteps = 20; // 5% (max => 99px * 5% = 4.95px)
  3769. else numOfSteps = 20;
  3770. }
  3771. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  3772. if (numOfSteps < 5) numOfSteps = 5;
  3773.  
  3774. const rd = numOfSteps / 100.0;
  3775.  
  3776. ratio2 = Math.round(ratio2 * rd) / rd;
  3777.  
  3778. // ratio2 = Math.round(ratio2 * 5) / 5;
  3779. ratio2 = ratio2.toFixed(1);
  3780. v = v.replace(`${ratio1}%`, `${ratio2}%`).replace(`${ratio1}%`, `${ratio2}%`);
  3781.  
  3782. if (yd.__style_last__ === v) return;
  3783. yd.__style_last__ = v;
  3784. // do not consider any delay here.
  3785. // it shall be inside the looping for all properties changes. all the css background ops are in the same microtask.
  3786.  
  3787. }
  3788. }
  3789.  
  3790. HTMLElement.prototype.setAttribute.call(dr(this), attrName, v);
  3791.  
  3792.  
  3793. } else {
  3794. HTMLElement.prototype.setAttribute.apply(dr(this), arguments);
  3795. }
  3796.  
  3797. };
  3798.  
  3799.  
  3800. const fpTicker = (renderer) => {
  3801. const cnt = renderer.inst || renderer;
  3802. assertor(() => typeof (cnt || 0).is === 'string');
  3803. assertor(() => ((cnt || 0).hostElement || 0).nodeType === 1);
  3804. const container = (cnt.$ || 0).container;
  3805. if (container) {
  3806. assertor(() => (container || 0).nodeType === 1);
  3807. assertor(() => typeof container.setAttribute === 'function');
  3808. container.setAttribute = tickerContainerSetAttribute;
  3809. } else {
  3810. console.warn(`"container" does not exist in ${cnt.is}`);
  3811. }
  3812. };
  3813.  
  3814.  
  3815. const tags = ["yt-live-chat-ticker-paid-message-item-renderer", "yt-live-chat-ticker-paid-sticker-item-renderer",
  3816. "yt-live-chat-ticker-renderer", "yt-live-chat-ticker-sponsor-item-renderer"];
  3817.  
  3818.  
  3819. Promise.all(tags.map(tag => customElements.whenDefined(tag))).then(() => {
  3820.  
  3821. mightFirstCheckOnYtInit();
  3822. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-... hacks");
  3823. console.log("[Begin]");
  3824.  
  3825. // << if ENABLE_VIDEO_PROGRESS_STATE_FIX >>
  3826. let isMainVideoOngoing = null;
  3827. let mainVideoLastProgress = null;
  3828. // << end >>
  3829.  
  3830. for (const tag of tags) {
  3831. const dummy = document.createElement(tag);
  3832.  
  3833. const cProto = getProto(dummy);
  3834. if (!cProto || !cProto.attached) {
  3835. console.warn(`proto.attached for ${tag} is unavailable.`);
  3836. continue;
  3837. }
  3838.  
  3839. cProto.attached77 = cProto.attached;
  3840.  
  3841. cProto.attached = function () {
  3842. fpTicker(this.hostElement || this);
  3843. return this.attached77();
  3844. }
  3845.  
  3846. for (const elm of document.getElementsByTagName(tag)) {
  3847. if ((elm || elm.inst).isAttached === true) {
  3848. fpTicker(elm);
  3849. }
  3850. }
  3851.  
  3852.  
  3853. let rafHackState = 0;
  3854.  
  3855. let isTimingFunctionHackable = false;
  3856.  
  3857. let urt = 0;
  3858.  
  3859. if (typeof cProto.startCountdown === 'function' && typeof cProto.updateTimeout === 'function' && typeof cProto.isAnimationPausedChanged === 'function') {
  3860.  
  3861. // console.log('startCountdown', typeof cProto.startCountdown)
  3862. // console.log('updateTimeout', typeof cProto.updateTimeout)
  3863. // console.log('isAnimationPausedChanged', typeof cProto.isAnimationPausedChanged)
  3864.  
  3865. isTimingFunctionHackable = fnIntegrity(cProto.startCountdown, '2.66.37') && fnIntegrity(cProto.updateTimeout, '1.76.45') && fnIntegrity(cProto.isAnimationPausedChanged, '2.56.30')
  3866.  
  3867. } else {
  3868. console.log(`Skip Timing Function Modification for ${tag}`);
  3869. continue;
  3870. }
  3871.  
  3872.  
  3873. if (ENABLE_RAF_HACK_TICKERS && rafHub !== null) {
  3874.  
  3875. // cancelable - this.rafId < isAnimationPausedChanged >
  3876. rafHackState = 1;
  3877.  
  3878. if (isTimingFunctionHackable) {
  3879. rafHackState = 2;
  3880.  
  3881. } else {
  3882. rafHackState = 4;
  3883. }
  3884.  
  3885. }
  3886.  
  3887. const isCSSPropertySupported = () => {
  3888.  
  3889. if (typeof CSS !== 'object' || typeof (CSS || 0).registerProperty !== 'function') return;
  3890. const documentElement = document.documentElement;
  3891. if (!documentElement) {
  3892. console.warn('document.documentElement is not found');
  3893. return false;
  3894. }
  3895. if (`${window.getComputedStyle(documentElement).getPropertyValue('--ticker-rtime')}`.length === 0) {
  3896. return false;
  3897. }
  3898. return true;
  3899.  
  3900. };
  3901.  
  3902. const doAnimator = !!ATTEMPT_ANIMATED_TICKER_BACKGROUND && isTimingFunctionHackable && typeof KeyframeEffect === 'function' && typeof animate === 'function' && typeof cProto.computeContainerStyle === 'function' && typeof cProto.colorFromDecimal === 'function' && isCSSPropertySupported();
  3903.  
  3904. const doRAFHack = rafHackState === 2;
  3905.  
  3906. cProto._throwOut = function () {
  3907. this._r782 = 1;
  3908. Promise.resolve().then(() => {
  3909. this.detached();
  3910. this.data = null;
  3911. this.countdownMs = 0;
  3912. this.lastCountdownTimeMs = null;
  3913. if (this.__dataClientsReady === true) this.__dataClientsReady = false;
  3914. if (this.__dataEnabled === true) this.__dataEnabled = false;
  3915. if (this.__dataReady === true) this.__dataReady = false;
  3916. const hm = this.hostElement || this;
  3917. if (hm.parentNode) hm.remove();
  3918. if (hm.firstChild) hm.textContent = '';
  3919. }).catch(e => {
  3920. console.warn(e);
  3921. });
  3922. };
  3923.  
  3924. // cProto._checkTickerBackgroundChanged = doAnimator ? function () {
  3925. // if (runTickerClassName === 'run-ticker') {
  3926. // const container = (this.$ || 0).container || 0;
  3927. // if (!container) return;
  3928. // container.classList.add('run-ticker-test');
  3929. // const evaluated = `${window.getComputedStyle(container).background}`;
  3930. // container.classList.remove('run-ticker-test');
  3931. // if (evaluated.indexOf('0.') < 4) {
  3932. // // not fulfilling
  3933. // // rgba(0, 0, 0, 0.004) none repeat scroll 0% 0% / auto padding-box border-box
  3934. // runTickerClassName = 'run-ticker-forced';
  3935. // console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  3936. // "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  3937. // "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  3938. // );
  3939. // console.warn(`%cWarning:\n\tYou might have added a userscript or extension that hacks ticker background too.\n\tYouTube Super Fast Chat will override it for you.`, 'color: #bada55');
  3940. // console.groupEnd();
  3941. // }
  3942. // }
  3943. // } : null;
  3944.  
  3945. cProto._makeAnimator = doAnimator ? function () {
  3946. if (this._r782) return;
  3947. // if (!this.isAttached) return;
  3948. if (!this._runnerAE) {
  3949. const aElement = (this.$ || 0).container;
  3950. if (!aElement) return console.warn("this.$.container is undefined");
  3951. const da = this.data;
  3952. if (!da || !da.startBackgroundColor || !da.endBackgroundColor) return console.warn("this.data is undefined or incorrect");
  3953. const c1 = this.colorFromDecimal(da.startBackgroundColor);
  3954. const c2 = this.colorFromDecimal(da.endBackgroundColor);
  3955. if (typeof c1 !== 'string' || typeof c2 !== 'string') return console.warn('c1, c2 is not a string');
  3956.  
  3957. // if (!this.__tickerBackgroundInitialChecked__) {
  3958. // this.constructor.prototype.__tickerBackgroundInitialChecked__ = true;
  3959. // console.log('__tickerBackgroundInitialChecked__')
  3960. // this._checkTickerBackgroundChanged();
  3961. // }
  3962.  
  3963. aElement.style.setProperty('--ticker-c1', c1);
  3964. aElement.style.setProperty('--ticker-c2', c2);
  3965. aElement.classList.add(runTickerClassName);
  3966. const p = (this.countdownMs / this.countdownDurationMs) * 100;
  3967. // this._aeStartV = this.countdownMs;
  3968. // this._aeStartT = this.countdownDurationMs;
  3969. if (!(p >= 0 && p <= 100)) {
  3970. console.warn('incorrect time ratio', p);
  3971. } else {
  3972. /*
  3973. const u0 = p.toFixed(4) + '%';
  3974. this._runnerAE = animate.call(aElement,
  3975. [
  3976. { '--ticker-rtime': u0 },
  3977. { '--ticker-rtime': '0%' }
  3978. ]
  3979. ,
  3980. {
  3981. fill: "forwards",
  3982. duration: this.countdownMs,
  3983. easing: "linear"
  3984. }
  3985. );
  3986. */
  3987.  
  3988. let timingFn = 'linear';
  3989.  
  3990. const totalDuration = this.countdownDurationMs;
  3991.  
  3992. if (ATTEMPT_ANIMATED_TICKER_BACKGROUND === 'steps') {
  3993.  
  3994. // @ step timing [min. 0.2%]
  3995. let stepInterval = 0.2; // unit: %
  3996. if (totalDuration > 400000) stepInterval = 0.2;
  3997. else if (totalDuration > 200000) stepInterval = 0.5;
  3998. else if (totalDuration > 100000) stepInterval = 1;
  3999. else if (totalDuration > 50000) stepInterval = 2;
  4000. else if (totalDuration > 25000) stepInterval = 5;
  4001. else stepInterval = 5;
  4002.  
  4003. let numOfSteps = Math.round(100 / stepInterval);
  4004.  
  4005. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  4006. if (numOfSteps < 5) numOfSteps = 5;
  4007.  
  4008. timingFn = `steps(${numOfSteps}, end)`;
  4009.  
  4010. }
  4011.  
  4012.  
  4013.  
  4014. this._runnerAE = animate.call(aElement,
  4015. [
  4016. { '--ticker-rtime': '100%' },
  4017. { '--ticker-rtime': '0%' }
  4018. ]
  4019. ,
  4020. {
  4021. fill: "forwards",
  4022. duration: totalDuration,
  4023. easing: timingFn
  4024. }
  4025. );
  4026.  
  4027. this._runnerAE.onfinish = () => {
  4028. if (this.isAttached === true && !this._r782 && ((this.$ || 0).container || 0).isConnected === true) {
  4029. this._aeFinished();
  4030. }
  4031. }
  4032.  
  4033. let bq = (1.0 - (this.countdownMs / totalDuration)) * totalDuration;
  4034. if (bq >= 0 && bq <= totalDuration) {
  4035.  
  4036. this._runnerAE.currentTime = bq
  4037. } else {
  4038. console.warn('Error on setting _runnerAE.currentTime!');
  4039. }
  4040.  
  4041.  
  4042. aeConstructor = this._runnerAE.constructor; // constructor is from iframe
  4043. return this._runnerAE;
  4044. }
  4045. } else {
  4046. if (!aeConstructor) return console.warn('aeConstructor is undefined');
  4047. // assume just time update
  4048. const ae = this._runnerAE;
  4049. if (!(ae instanceof aeConstructor)) return console.warn('this._runnerAE is not Animation');
  4050. if (ae.playState !== 'paused') console.warn('ae.playState !== paused');
  4051. let p = (this.countdownMs / this.countdownDurationMs) * 100;
  4052. if (!(p >= 0 && p <= 100)) {
  4053. console.warn('incorrect time ratio', p);
  4054. } else {
  4055. // let u0 = p.toFixed(4) + '%'
  4056. /*
  4057. ae.effect.setKeyframes([
  4058. { '--ticker-rtime': u0 },
  4059. { '--ticker-rtime': '0%' }
  4060. ]);
  4061. ae.effect.updateTiming({ duration: this.countdownMs });
  4062. */
  4063. // ae.currentTime = 0;
  4064.  
  4065.  
  4066.  
  4067. let bq = (1.0 - (this.countdownMs / this.countdownDurationMs)) * this.countdownDurationMs;
  4068. if (bq >= 0 && bq <= this.countdownDurationMs) {
  4069.  
  4070. this._runnerAE.currentTime = bq
  4071. } else {
  4072. console.warn('Error on setting _runnerAE.currentTime!');
  4073. }
  4074.  
  4075.  
  4076. ae.play();
  4077. return ae;
  4078. }
  4079. }
  4080. } : null;
  4081.  
  4082. cProto._aeFinished = doAnimator ? function () {
  4083.  
  4084. if (this._r782) return;
  4085.  
  4086. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  4087. this._throwOut();
  4088. return;
  4089. }
  4090.  
  4091. if (doAnimator) {
  4092. if (!this._runnerAE) console.warn('Error in .updateTimeout; this._runnerAE is undefined');
  4093.  
  4094. let lc = window.performance.now();
  4095. this.countdownMs = Math.max(0, this.countdownMs - (lc - this.lastCountdownTimeMs));
  4096. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  4097. this.lastCountdownTimeMs = lc;
  4098. if (this.countdownMs > 10) console.warn('Warning: this.countdownMs is not zero when finished!', this.countdownMs); // just warning.
  4099.  
  4100. this.countdownMs = 0;
  4101. this.lastCountdownTimeMs = null;
  4102.  
  4103. if (this.isAttached) {
  4104. if (Date.now() - windowShownAt < 80) {
  4105. // no animation if the video page is switched from background to foreground
  4106. this.hostElement.style.display = 'none';
  4107. } else {
  4108. "auto" === this.hostElement.style.width && this.setContainerWidth();
  4109. this.slideDown();
  4110. }
  4111. }
  4112.  
  4113.  
  4114. } else {
  4115. console.warn('unexpected issue')
  4116. }
  4117. } : null;
  4118.  
  4119.  
  4120. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  4121.  
  4122. if (typeof cProto.handlePauseReplay === 'function' && !cProto.handlePauseReplay66 && cProto.handlePauseReplay.length === 0) {
  4123. urt++;
  4124. assertor(() => fnIntegrity(cProto.handlePauseReplay, '0.12.4'));
  4125. cProto.handlePauseReplay66 = cProto.handlePauseReplay;
  4126. cProto.handlePauseReplay = function () {
  4127. if (this.isAttached) {
  4128.  
  4129. if (pairForPauseResumeM === 0) {
  4130. pairForPauseResume++;
  4131. if (pairForPauseResume > 1e9) pairForPauseResume = pairForPauseResume % 1e4;
  4132. }
  4133. // console.log('handlePauseReplay');
  4134. // console.log('handlePauseReplay', pairForPauseResume);
  4135. const r = this.handlePauseReplay66.apply(this, arguments);
  4136. isMainVideoOngoing = false;
  4137. return r;
  4138. }
  4139. };
  4140. } else {
  4141. console.log('Error for setting cProto.handlePauseReplay', tag)
  4142. }
  4143.  
  4144. if (typeof cProto.handleResumeReplay === 'function' && !cProto.handleResumeReplay66 && cProto.handlePauseReplay.length === 0) {
  4145. urt++;
  4146. assertor(() => fnIntegrity(cProto.handleResumeReplay, '0.8.2'));
  4147. cProto.handleResumeReplay66 = cProto.handleResumeReplay;
  4148. cProto.handleResumeReplay = function () {
  4149. if (this.isAttached) {
  4150.  
  4151. if (pairForPauseResumeM === 0) {
  4152. pairForPauseResume++;
  4153. if (pairForPauseResume > 1e9) pairForPauseResume = pairForPauseResume % 1e4;
  4154. }
  4155. // console.log('handleResumeReplay');
  4156. // console.log('handleResumeReplay', pairForPauseResume);
  4157. const r = this.handleResumeReplay66.apply(this, arguments);
  4158. isMainVideoOngoing = true;
  4159. return r;
  4160.  
  4161. }
  4162. };
  4163. } else {
  4164. console.log('Error for setting cProto.handleResumeReplay', tag)
  4165. }
  4166.  
  4167. if (typeof cProto.handleReplayProgress === 'function' && !cProto.handleReplayProgress66 && cProto.handleReplayProgress.length === 1) {
  4168. urt++;
  4169. assertor(() => fnIntegrity(cProto.handleReplayProgress, '1.16.13'));
  4170. cProto.handleReplayProgress66 = cProto.handleReplayProgress;
  4171. cProto.handleReplayProgress = function (a) {
  4172. if (this.isAttached) {
  4173. const p = mainVideoLastProgress;
  4174. mainVideoLastProgress = a;
  4175. if (isMainVideoOngoing === false) { // ignore isMainVideoOngoing === null ?
  4176. const d = a - p;
  4177. if (d > 0 && d < 0.28) isMainVideoOngoing = true; // timeupdate
  4178. // 0.28 is due to
  4179. // - most browsers will fire the timeupdate event between 4 to 60 times per second
  4180. // - i.e. timeupdate roughly every 15-250 milliseconds
  4181. }
  4182. let promiseResult = null;
  4183. if (this.isAnimationPaused) {
  4184. // unstable state for isMainVideoOngoing; delay required
  4185. // all the tickers' handleReplayProgress are executed in the same microtask
  4186. // execute after result returned
  4187. const lz1 = pairForPauseResume;
  4188. Promise.resolve().then(() => {
  4189. return promiseResult
  4190. }).then(() => {
  4191.  
  4192.  
  4193. if (isMainVideoOngoing === true && this.isAnimationPaused) {
  4194. const lz2 = pairForPauseResume;
  4195. // console.log( 10044000, lz1, lz2 , mainVideoLastProgress - a, isMainVideoOngoing )
  4196. if (lz1 === lz2 && mainVideoLastProgress !== null && mainVideoLastProgress - a >= -1e-5) this.isAnimationPaused = false; // trigger isAnimationPausedChanged
  4197. }
  4198.  
  4199. });
  4200. }
  4201.  
  4202. const lq1 = pairForPauseResume;
  4203. promiseResult = Promise.resolve().then(() => {
  4204. const lq2 = pairForPauseResume;
  4205.  
  4206. if (lq1 === lq2) {
  4207. this.handleReplayProgress66(a);
  4208. }
  4209.  
  4210.  
  4211. })
  4212.  
  4213. }
  4214. };
  4215. } else {
  4216. console.log('Error for setting cProto.handleReplayProgress', tag)
  4217. }
  4218.  
  4219. }
  4220.  
  4221. const ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED = ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX && urt === 3;
  4222.  
  4223. const doTimerFnModification = (doRAFHack || doAnimator);
  4224.  
  4225. let windowShownAt = 0;
  4226. if (doTimerFnModification) {
  4227.  
  4228. window.addEventListener('visibilitychange', () => {
  4229. if (document.visibilityState === 'visible') windowShownAt = Date.now();
  4230. else windowShownAt = 0;
  4231. }, false);
  4232.  
  4233. }
  4234.  
  4235. cProto.startCountdown = doTimerFnModification ? function (a, b) { // .startCountdown(a.durationSec, a.fullDurationSec)
  4236.  
  4237. // a.durationSec [s] => countdownMs [ms]
  4238. // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  4239. // lastCountdownTimeMs => raf ongoing
  4240. // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  4241.  
  4242. if (this._r782) return;
  4243.  
  4244. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  4245. this._throwOut();
  4246. return;
  4247. }
  4248.  
  4249. if (doAnimator) {
  4250. b = void 0 === b ? 0 : b;
  4251. if (void 0 !== a) {
  4252. this.countdownMs = 1E3 * a; // decreasing from durationSec[s] to zero
  4253. this.countdownDurationMs = b ? 1E3 * b : this.countdownMs; // constant throughout the animation
  4254. if (!(this.lastCountdownTimeMs || this.isAnimationPaused)) {
  4255. this.lastCountdownTimeMs = performance.now()
  4256. this.rafId = 1
  4257. if (this._runnerAE) console.warn('Error in .startCountdown; this._runnerAE already created.')
  4258. this.detlaSincePausedSecs = 0;
  4259. const ae = this._makeAnimator();
  4260. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  4261.  
  4262. // console.log(539, isMainVideoOngoing)
  4263. if (this.isAnimationPaused === void 0 && ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED && isMainVideoOngoing === false && mainVideoLastProgress !== null) {
  4264. // << This is mainly for [PlayBack Replay] backwards >>
  4265. // fix the case when the main video is paused but due to seeking the tickers are added
  4266. // play first then pause immediately to allow the visual effect of initial state
  4267. // don't forget to set the "playerProgressSec"
  4268. // otherwise when it resumes from paused state, the detlaSincePausedSecs will be huge
  4269. this.playerProgressSec = mainVideoLastProgress; // save the progress first
  4270. this.isAnimationPaused = true; // trigger isAnimationPausedChanged
  4271. this.detlaSincePausedSecs = 0;
  4272. this._forceNoDetlaSincePausedSecs783 = 1; // reset this.detlaSincePausedSecs = 0 when resumed
  4273. }
  4274. }
  4275. }
  4276. } else {
  4277. // console.log('cProto.startCountdown', tag) // yt-live-chat-ticker-sponsor-item-renderer
  4278. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  4279. b = void 0 === b ? 0 : b;
  4280. void 0 !== a && (this.countdownMs = 1E3 * a,
  4281. this.countdownDurationMs = b ? 1E3 * b : this.countdownMs,
  4282. this.ratio = 1,
  4283. this.lastCountdownTimeMs || this.isAnimationPaused || (this.lastCountdownTimeMs = performance.now(),
  4284. this.rafId = rafHub.request(this.boundUpdateTimeout37_)))
  4285. }
  4286.  
  4287. } : cProto.startCountdown;
  4288.  
  4289. cProto.updateTimeout = doTimerFnModification ? function (a) {
  4290.  
  4291. if (this._r782) return;
  4292.  
  4293. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  4294. this._throwOut();
  4295. return;
  4296. }
  4297.  
  4298. if (doAnimator) {
  4299. if (!this._runnerAE) console.warn('Error in .updateTimeout; this._runnerAE is undefined');
  4300. this.countdownMs = Math.max(0, this.countdownMs - (a - (this.lastCountdownTimeMs || 0)));
  4301. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  4302. if (this.isAttached && this.countdownMs) {
  4303. this.lastCountdownTimeMs = a
  4304. const ae = this._makeAnimator(); // request raf
  4305. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  4306. } else {
  4307. (this.lastCountdownTimeMs = null,
  4308. this.isAttached && ("auto" === this.hostElement.style.width && this.setContainerWidth(),
  4309. this.slideDown()));
  4310. }
  4311. } else {
  4312. // console.log('cProto.updateTimeout', tag) // yt-live-chat-ticker-sponsor-item-renderer
  4313. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  4314. this.countdownMs = Math.max(0, this.countdownMs - (a - (this.lastCountdownTimeMs || 0)));
  4315. this.ratio = this.countdownMs / this.countdownDurationMs;
  4316. this.isAttached && this.countdownMs ? (this.lastCountdownTimeMs = a,
  4317. this.rafId = rafHub.request(this.boundUpdateTimeout37_)) : (this.lastCountdownTimeMs = null,
  4318. this.isAttached && ("auto" === this.hostElement.style.width && this.setContainerWidth(),
  4319. this.slideDown()))
  4320. }
  4321.  
  4322. } : cProto.updateTimeout;
  4323.  
  4324. // let ez = 0;
  4325. cProto.isAnimationPausedChanged = doTimerFnModification ? function (a, b) {
  4326.  
  4327. if (this._r782) return;
  4328.  
  4329. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  4330. this._throwOut();
  4331. return;
  4332. }
  4333. let forceNoDetlaSincePausedSecs783 = this._forceNoDetlaSincePausedSecs783;
  4334. this._forceNoDetlaSincePausedSecs783 = 0;
  4335.  
  4336. Promise.resolve().then(() => {
  4337.  
  4338. if (doAnimator) {
  4339.  
  4340. const playState = (this._runnerAE || 0).playState;
  4341. if (a && playState === 'running') {
  4342.  
  4343. } else if (!a && playState !== 'running' && b) {
  4344.  
  4345. } else {
  4346. return;
  4347. }
  4348. }
  4349.  
  4350. // if (Math.abs(this.detlaSincePausedSecs) < 0.01) this.detlaSincePausedSecs = 0;
  4351. if (doAnimator) {
  4352. const pu = () => { // running -> pause
  4353. this._runnerAE.pause()
  4354. let lc = window.performance.now();
  4355. this.countdownMs = Math.max(0, this.countdownMs - (lc - this.lastCountdownTimeMs));
  4356. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  4357. this.lastCountdownTimeMs = lc;
  4358. };
  4359. const wa = () => { // pause -> running
  4360. if (forceNoDetlaSincePausedSecs783) this.detlaSincePausedSecs = 0;
  4361. a = this.detlaSincePausedSecs ? (this.lastCountdownTimeMs || 0) + 1000 * this.detlaSincePausedSecs : (this.lastCountdownTimeMs || 0);
  4362. this.detlaSincePausedSecs = 0;
  4363. this.updateTimeout(a);
  4364. this.lastCountdownTimeMs = window.performance.now();
  4365. };
  4366. a ? (this._runnerAE && pu()) : (!a && b && wa());
  4367. } else {
  4368. // ez++;
  4369. // if(ez> 1e9) ez=9;
  4370. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  4371. a ? rafHub.cancel(this.rafId) : !a && b && (a = this.lastCountdownTimeMs || 0,
  4372. this.detlaSincePausedSecs && (a = (this.lastCountdownTimeMs || 0) + 1E3 * this.detlaSincePausedSecs,
  4373. this.detlaSincePausedSecs = 0),
  4374. this.boundUpdateTimeout37_(a),
  4375. this.lastCountdownTimeMs = window.performance.now())
  4376. }
  4377.  
  4378. }).catch(e => {
  4379. console.log(e);
  4380. });
  4381.  
  4382.  
  4383.  
  4384. } : cProto.isAnimationPausedChanged;
  4385.  
  4386.  
  4387. if (doAnimator) {
  4388.  
  4389. assertor(() => fnIntegrity(cProto.computeContainerStyle, '2.81.31'));
  4390.  
  4391. let dummyValueForStyleReturn = null;
  4392.  
  4393. cProto.computeContainerStyle66 = cProto.computeContainerStyle;
  4394. cProto.computeContainerStyle = function (a, b) {
  4395.  
  4396. if (this._r782) return;
  4397.  
  4398. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  4399. this._throwOut();
  4400. return;
  4401. }
  4402.  
  4403. const fullDurationSec = a ? a.fullDurationSec : 0;
  4404. if (fullDurationSec > 0 && typeof b === 'number') {
  4405.  
  4406. // usually zero
  4407.  
  4408. // let currentDuationSrc = b * fullDurationSec; // a.durationSec
  4409.  
  4410. // console.log(231, fullDurationSec, b, currentDuationSrc, a.durationSec);
  4411.  
  4412. /*
  4413. if (a.mdsz && typeof a.mdst) return a.mdst;
  4414. a.mdsz = 1;
  4415.  
  4416.  
  4417.  
  4418. let c1 = this.colorFromDecimal(a.startBackgroundColor);
  4419. let c2 = this.colorFromDecimal(a.endBackgroundColor);
  4420.  
  4421. let ratio = currentDuationSrc / fullDurationSec;
  4422.  
  4423. let m = (ratio * 100).toFixed(1);
  4424.  
  4425.  
  4426. let s = `--background:linear-gradient(90deg, ${c1},${c1} ${m}%,${c2} ${m}%,${c2});`
  4427. let ro = {
  4428. "privateDoNotAccessOrElseSafeStyleWrappedValue_": s,
  4429. "implementsGoogStringTypedString": true
  4430. };
  4431.  
  4432. ro.getTypedStringValue = ro.toString = function () { return this.privateDoNotAccessOrElseSafeStyleWrappedValue_ };
  4433.  
  4434. a.mdst = s;
  4435.  
  4436. return ro;
  4437. */
  4438. }
  4439.  
  4440.  
  4441.  
  4442. // return this.computeContainerStyle66.apply(this, arguments);
  4443.  
  4444. if (dummyValueForStyleReturn === null) {
  4445.  
  4446. let s = `--nx:82;`
  4447. let ro = {
  4448. "privateDoNotAccessOrElseSafeStyleWrappedValue_": s,
  4449. "implementsGoogStringTypedString": true
  4450. };
  4451.  
  4452. ro.getTypedStringValue = ro.toString = function () { return this.privateDoNotAccessOrElseSafeStyleWrappedValue_ };
  4453.  
  4454.  
  4455. dummyValueForStyleReturn = ro;
  4456.  
  4457.  
  4458. }
  4459.  
  4460.  
  4461. return dummyValueForStyleReturn;
  4462.  
  4463.  
  4464. }
  4465.  
  4466. }
  4467.  
  4468. if (doTimerFnModification === true) hasTimerModified = true;
  4469.  
  4470. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  4471. console.log('ATTEMPT_ANIMATED_TICKER_BACKGROUND', tag, doAnimator ? 'OK' : 'NG');
  4472. }
  4473.  
  4474. if (!doAnimator && (rafHackState === 2 || rafHackState === 4)) {
  4475. console.log('RAF_HACK_TICKERS', tag, doRAFHack ? "OK" : "NG");
  4476. }
  4477.  
  4478. }
  4479. console.log("[End]");
  4480. console.groupEnd();
  4481.  
  4482.  
  4483. }).catch(console.warn);
  4484.  
  4485. customElements.whenDefined('yt-live-chat-ticker-renderer').then(() => {
  4486.  
  4487. mightFirstCheckOnYtInit();
  4488. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-renderer hacks");
  4489. console.log("[Begin]");
  4490. (() => {
  4491.  
  4492. const tag = "yt-live-chat-ticker-renderer"
  4493. const dummy = document.createElement(tag);
  4494.  
  4495. const cProto = getProto(dummy);
  4496. if (!cProto || !cProto.attached) {
  4497. console.warn(`proto.attached for ${tag} is unavailable.`);
  4498. return;
  4499. }
  4500.  
  4501. if (RAF_FIX_keepScrollClamped) {
  4502.  
  4503. // to be improved
  4504.  
  4505. if (typeof cProto.keepScrollClamped === 'function' && !cProto.keepScrollClamped72 && fnIntegrity(cProto.keepScrollClamped) === '0.17.10') {
  4506.  
  4507. cProto.keepScrollClamped72 = cProto.keepScrollClamped;
  4508. cProto.keepScrollClamped = function () {
  4509. this._bound_keepScrollClamped = this._bound_keepScrollClamped || this.keepScrollClamped.bind(this);
  4510. this.scrollClampRaf = requestAnimationFrame(this._bound_keepScrollClamped);
  4511. this.maybeClampScroll()
  4512. }
  4513.  
  4514. console.log('RAF_FIX: keepScrollClamped', tag, "OK")
  4515. } else {
  4516.  
  4517. assertor(() => fnIntegrity(cProto.keepScrollClamped, '0.17.10'));
  4518. console.log('RAF_FIX: keepScrollClamped', tag, "NG")
  4519. }
  4520.  
  4521. }
  4522.  
  4523.  
  4524. if (RAF_FIX_scrollIncrementally && typeof cProto.startScrolling === 'function' && typeof cProto.scrollIncrementally === 'function' && fnIntegrity(cProto.startScrolling) === '1.44.32' && fnIntegrity(cProto.scrollIncrementally) === '1.82.43') {
  4525. // to be replaced by animator
  4526.  
  4527. cProto.startScrolling = function (a) {
  4528. this.scrollStopHandle && this.cancelAsync(this.scrollStopHandle);
  4529. this.asyncHandle && cancelAnimationFrame(this.asyncHandle);
  4530. this.lastFrameTimestamp = this.scrollStartTime = performance.now();
  4531. this.scrollRatePixelsPerSecond = a;
  4532. this._bound_scrollIncrementally = this._bound_scrollIncrementally || this.scrollIncrementally.bind(this);
  4533. this.asyncHandle = requestAnimationFrame(this._bound_scrollIncrementally)
  4534. };
  4535.  
  4536. cProto.scrollIncrementally = function (a) {
  4537. var b = a - (this.lastFrameTimestamp || 0);
  4538. this.$.items.scrollLeft += b / 1E3 * (this.scrollRatePixelsPerSecond || 0);
  4539. this.maybeClampScroll();
  4540. this.updateArrows();
  4541. this.lastFrameTimestamp = a;
  4542. this._bound_scrollIncrementally = this._bound_scrollIncrementally || this.scrollIncrementally.bind(this);
  4543. 0 < this.$.items.scrollLeft || this.scrollRatePixelsPerSecond && 0 < this.scrollRatePixelsPerSecond ? this.asyncHandle = requestAnimationFrame(this._bound_scrollIncrementally) : this.stopScrolling()
  4544. };
  4545.  
  4546. console.log('RAF_FIX: scrollIncrementally', tag, "OK")
  4547. } else {
  4548. assertor(() => fnIntegrity(cProto.startScrolling, '1.44.32'));
  4549. assertor(() => fnIntegrity(cProto.scrollIncrementally, '1.82.43'));
  4550. console.log('RAF_FIX: scrollIncrementally', tag, "NG")
  4551. }
  4552.  
  4553.  
  4554. })();
  4555.  
  4556. console.log("[End]");
  4557.  
  4558. console.groupEnd();
  4559.  
  4560. }).catch(console.warn);
  4561.  
  4562.  
  4563. if (ENABLE_RAF_HACK_INPUT_RENDERER && rafHub !== null) {
  4564.  
  4565.  
  4566. customElements.whenDefined("yt-live-chat-message-input-renderer").then(() => {
  4567.  
  4568. mightFirstCheckOnYtInit();
  4569. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-message-input-renderer hacks");
  4570. console.log("[Begin]");
  4571. (() => {
  4572.  
  4573. const tag = "yt-live-chat-message-input-renderer"
  4574. const dummy = document.createElement(tag);
  4575.  
  4576. const cProto = getProto(dummy);
  4577. if (!cProto || !cProto.attached) {
  4578. console.warn(`proto.attached for ${tag} is unavailable.`);
  4579. return;
  4580. }
  4581.  
  4582. let doHack = false;
  4583. if (typeof cProto.handleTimeout === 'function' && typeof cProto.updateTimeout === 'function') {
  4584.  
  4585. // not cancellable
  4586.  
  4587.  
  4588. doHack = fnIntegrity(cProto.handleTimeout, '1.27.16') && fnIntegrity(cProto.updateTimeout, '1.50.33');
  4589.  
  4590. }
  4591.  
  4592. if (doHack) {
  4593.  
  4594. cProto.handleTimeout = function (a) {
  4595. console.log('cProto.handleTimeout', tag)
  4596. if (!this.boundUpdateTimeout38_) this.boundUpdateTimeout38_ = this.updateTimeout.bind(this);
  4597. this.timeoutDurationMs = this.timeoutMs = a;
  4598. this.countdownRatio = 1;
  4599. 0 === this.lastTimeoutTimeMs && rafHub.request(this.boundUpdateTimeout38_)
  4600. };
  4601. cProto.updateTimeout = function (a) {
  4602. console.log('cProto.updateTimeout', tag)
  4603. if (!this.boundUpdateTimeout38_) this.boundUpdateTimeout38_ = this.updateTimeout.bind(this);
  4604. this.lastTimeoutTimeMs && (this.timeoutMs = Math.max(0, this.timeoutMs - (a - this.lastTimeoutTimeMs)),
  4605. this.countdownRatio = this.timeoutMs / this.timeoutDurationMs);
  4606. this.isAttached && this.timeoutMs ? (this.lastTimeoutTimeMs = a,
  4607. rafHub.request(this.boundUpdateTimeout38_)) : this.lastTimeoutTimeMs = 0
  4608. };
  4609.  
  4610. console.log('RAF_HACK_INPUT_RENDERER', tag, "OK")
  4611. } else {
  4612.  
  4613. console.log('typeof handleTimeout', typeof cProto.handleTimeout)
  4614. console.log('typeof updateTimeout', typeof cProto.updateTimeout)
  4615.  
  4616. console.log('RAF_HACK_INPUT_RENDERER', tag, "NG")
  4617. }
  4618.  
  4619. })();
  4620.  
  4621. console.log("[End]");
  4622.  
  4623. console.groupEnd();
  4624.  
  4625.  
  4626. })
  4627.  
  4628.  
  4629. }
  4630.  
  4631. if (ENABLE_RAF_HACK_EMOJI_PICKER && rafHub !== null) {
  4632.  
  4633.  
  4634. customElements.whenDefined("yt-emoji-picker-renderer").then(() => {
  4635.  
  4636. mightFirstCheckOnYtInit();
  4637. groupCollapsed("YouTube Super Fast Chat", " | yt-emoji-picker-renderer hacks");
  4638. console.log("[Begin]");
  4639. (() => {
  4640.  
  4641. const tag = "yt-emoji-picker-renderer"
  4642. const dummy = document.createElement(tag);
  4643.  
  4644. const cProto = getProto(dummy);
  4645. if (!cProto || !cProto.attached) {
  4646. console.warn(`proto.attached for ${tag} is unavailable.`);
  4647. return;
  4648. }
  4649.  
  4650. let doHack = false;
  4651. if (typeof cProto.animateScroll_ === 'function') {
  4652.  
  4653. // not cancellable
  4654. console.log('animateScroll_', typeof cProto.animateScroll_)
  4655.  
  4656. doHack = fnIntegrity(cProto.animateScroll_, '1.102.49')
  4657.  
  4658. }
  4659.  
  4660. if (doHack) {
  4661.  
  4662. const querySelector = HTMLElement.prototype.querySelector;
  4663. const U = (element) => ({
  4664. querySelector: (selector) => querySelector.call(element, selector)
  4665. });
  4666.  
  4667. cProto.animateScroll_ = function (a) {
  4668. // console.log('cProto.animateScroll_', tag) // yt-emoji-picker-renderer
  4669. if (!this.boundAnimateScroll39_) this.boundAnimateScroll39_ = this.animateScroll_.bind(this);
  4670. this.lastAnimationTime_ || (this.lastAnimationTime_ = a);
  4671. a -= this.lastAnimationTime_;
  4672. 200 > a ? (U(this.hostElement).querySelector("#categories").scrollTop = this.animationStart_ + (this.animationEnd_ - this.animationStart_) * a / 200,
  4673. rafHub.request(this.boundAnimateScroll39_)) : (null != this.animationEnd_ && (U(this.hostElement).querySelector("#categories").scrollTop = this.animationEnd_),
  4674. this.animationEnd_ = this.animationStart_ = null,
  4675. this.lastAnimationTime_ = 0);
  4676. this.updateButtons_()
  4677. }
  4678.  
  4679. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "OK")
  4680. } else {
  4681.  
  4682. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "NG")
  4683. }
  4684.  
  4685. })();
  4686.  
  4687. console.log("[End]");
  4688.  
  4689. console.groupEnd();
  4690. });
  4691. }
  4692.  
  4693. if (ENABLE_RAF_HACK_DOCKED_MESSAGE && rafHub !== null) {
  4694.  
  4695.  
  4696. customElements.whenDefined("yt-live-chat-docked-message").then(() => {
  4697.  
  4698. mightFirstCheckOnYtInit();
  4699. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-docked-message hacks");
  4700. console.log("[Begin]");
  4701. (() => {
  4702.  
  4703. const tag = "yt-live-chat-docked-message"
  4704. const dummy = document.createElement(tag);
  4705.  
  4706. const cProto = getProto(dummy);
  4707. if (!cProto || !cProto.attached) {
  4708. console.warn(`proto.attached for ${tag} is unavailable.`);
  4709. return;
  4710. }
  4711.  
  4712. let doHack = false;
  4713. if (typeof cProto.detached === 'function' && typeof cProto.checkIntersections === 'function' && typeof cProto.onDockableMessagesChanged === 'function' && typeof cProto.boundCheckIntersections === 'undefined') {
  4714.  
  4715. // cancelable - this.intersectRAF <detached>
  4716. // yt-live-chat-docked-message
  4717. // boundCheckIntersections <-> checkIntersections
  4718. // onDockableMessagesChanged
  4719. // this.intersectRAF = window.requestAnimationFrame(this.boundCheckIntersections);
  4720.  
  4721. console.log('detached', typeof cProto.detached)
  4722. console.log('checkIntersections', typeof cProto.checkIntersections)
  4723. console.log('onDockableMessagesChanged', typeof cProto.onDockableMessagesChanged)
  4724.  
  4725. doHack = fnIntegrity(cProto.detached, '0.32.22') && fnIntegrity(cProto.checkIntersections, '0.128.85') && fnIntegrity(cProto.onDockableMessagesChanged, '0.20.11')
  4726.  
  4727. }
  4728.  
  4729. if (doHack) {
  4730.  
  4731. cProto.checkIntersections = function () {
  4732. // console.log('cProto.checkIntersections', tag)
  4733. if (this.dockableMessages.length) {
  4734. this.intersectRAF = rafHub.request(this.boundCheckIntersections);
  4735. let a = this.dockableMessages[0]
  4736. , b = this.hostElement.getBoundingClientRect();
  4737. a = a.getBoundingClientRect();
  4738. let c = a.top - b.top
  4739. , d = 8 >= c;
  4740. c = 8 >= c - this.hostElement.clientHeight;
  4741. if (d) {
  4742. let e;
  4743. for (; d;) {
  4744. e = this.dockableMessages.shift();
  4745. d = this.dockableMessages[0];
  4746. if (!d)
  4747. break;
  4748. d = d.getBoundingClientRect();
  4749. c = d.top - b.top;
  4750. let f = 8 >= c;
  4751. if (8 >= c - a.height)
  4752. if (f)
  4753. a = d;
  4754. else
  4755. return;
  4756. d = f
  4757. }
  4758. this.dock(e)
  4759. } else
  4760. c && this.dockedItem && this.clear()
  4761. } else
  4762. this.intersectRAF = 0
  4763. }
  4764.  
  4765. cProto.onDockableMessagesChanged = function () {
  4766. // console.log('cProto.onDockableMessagesChanged', tag) // yt-live-chat-docked-message
  4767. this.dockableMessages.length && !this.intersectRAF && (this.intersectRAF = rafHub.request(this.boundCheckIntersections))
  4768. }
  4769.  
  4770. cProto.detached = function () {
  4771. this.intersectRAF && rafHub.cancel(this.intersectRAF)
  4772. }
  4773.  
  4774. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "OK")
  4775. } else {
  4776.  
  4777. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "NG")
  4778. }
  4779.  
  4780. })();
  4781.  
  4782. console.log("[End]");
  4783.  
  4784. console.groupEnd();
  4785.  
  4786. }).catch(console.warn);
  4787.  
  4788. }
  4789.  
  4790. if (FIX_SETSRC_AND_THUMBNAILCHANGE_) {
  4791.  
  4792.  
  4793. customElements.whenDefined("yt-img-shadow").then(() => {
  4794.  
  4795. mightFirstCheckOnYtInit();
  4796. groupCollapsed("YouTube Super Fast Chat", " | yt-img-shadow hacks");
  4797. console.log("[Begin]");
  4798. (() => {
  4799.  
  4800. const tag = "yt-img-shadow"
  4801. const dummy = document.createElement(tag);
  4802.  
  4803. const cProto = getProto(dummy);
  4804. if (!cProto || !cProto.attached) {
  4805. console.warn(`proto.attached for ${tag} is unavailable.`);
  4806. return;
  4807. }
  4808.  
  4809. if (typeof cProto.thumbnailChanged_ === 'function' && !cProto.thumbnailChanged66_) {
  4810.  
  4811. cProto.thumbnailChanged66_ = cProto.thumbnailChanged_;
  4812. cProto.thumbnailChanged_ = function (a) {
  4813.  
  4814. if (this.oldThumbnail_ && this.thumbnail && this.oldThumbnail_.thumbnails === this.thumbnail.thumbnails) return;
  4815. if (!this.oldThumbnail_ && !this.thumbnail) return;
  4816.  
  4817. return this.thumbnailChanged66_.apply(this, arguments)
  4818.  
  4819. }
  4820. console.log("cProto.thumbnailChanged_ - OK");
  4821.  
  4822. } else {
  4823. console.log("cProto.thumbnailChanged_ - NG");
  4824.  
  4825. }
  4826. if (typeof cProto.setSrc_ === 'function' && !cProto.setSrc66_) {
  4827.  
  4828. cProto.setSrc66_ = cProto.setSrc_;
  4829. cProto.setSrc_ = function (a) {
  4830. if ((((this || 0).$ || 0).img || 0).src === a) return;
  4831. return this.setSrc66_.apply(this, arguments)
  4832. }
  4833.  
  4834. console.log("cProto.setSrc_ - OK");
  4835. } else {
  4836.  
  4837. console.log("cProto.setSrc_ - NG");
  4838. }
  4839.  
  4840. })();
  4841.  
  4842. console.log("[End]");
  4843.  
  4844. console.groupEnd();
  4845.  
  4846. }).catch(console.warn);
  4847.  
  4848. }
  4849.  
  4850. if (FIX_THUMBNAIL_DATACHANGED) {
  4851.  
  4852.  
  4853.  
  4854. customElements.whenDefined("yt-live-chat-author-badge-renderer").then(() => {
  4855.  
  4856. mightFirstCheckOnYtInit();
  4857. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-author-badge-renderer hacks");
  4858. console.log("[Begin]");
  4859. (() => {
  4860.  
  4861. const tag = "yt-live-chat-author-badge-renderer"
  4862. const dummy = document.createElement(tag);
  4863.  
  4864. const cProto = getProto(dummy);
  4865. if (!cProto || !cProto.attached) {
  4866. console.warn(`proto.attached for ${tag} is unavailable.`);
  4867. return;
  4868. }
  4869.  
  4870.  
  4871. if (typeof cProto.dataChanged === 'function' && !cProto.dataChanged86 && fnIntegrity(cProto.dataChanged) === '1.159.97') {
  4872.  
  4873.  
  4874.  
  4875. cProto.dataChanged86 = cProto.dataChanged;
  4876. cProto.dataChanged = function (a) {
  4877.  
  4878. /*
  4879.  
  4880. for (var b = xC(Z(this.hostElement).querySelector("#image")); b.firstChild; )
  4881. b.removeChild(b.firstChild);
  4882. if (a)
  4883. if (a.icon) {
  4884. var c = document.createElement("yt-icon");
  4885. "MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge ? (c.icon = "yt-sys-icons:shield-filled",
  4886. c.defaultToFilled = !0) : c.icon = "live-chat-badges:" + a.icon.iconType.toLowerCase();
  4887. b.appendChild(c)
  4888. } else if (a.customThumbnail) {
  4889. c = document.createElement("img");
  4890. var d;
  4891. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  4892. b.appendChild(c),
  4893. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail",a.customThumbnail))
  4894. }
  4895.  
  4896. */
  4897.  
  4898. const image = ((this || 0).$ || 0).image
  4899. if (image && a && image.firstElementChild) {
  4900. let exisiting = image.firstElementChild;
  4901. if (exisiting === image.lastElementChild) {
  4902.  
  4903.  
  4904. if (a.icon && exisiting.nodeName.toUpperCase() === 'YT-ICON') {
  4905.  
  4906. let c = exisiting;
  4907. if ("MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge) {
  4908. if (c.icon !== "yt-sys-icons:shield-filled") c.icon = "yt-sys-icons:shield-filled";
  4909. if (c.defaultToFilled !== true) c.defaultToFilled = true;
  4910. } else {
  4911. let p = "live-chat-badges:" + a.icon.iconType.toLowerCase();;
  4912. if (c.icon !== p) c.icon = p;
  4913. if (c.defaultToFilled !== false) c.defaultToFilled = false;
  4914. }
  4915. return;
  4916.  
  4917.  
  4918. } else if (a.customThumbnail && exisiting.nodeName.toUpperCase() == 'IMG') {
  4919.  
  4920. let c = exisiting;
  4921. if (a.customThumbnail.thumbnails.map(e => e.url).includes(c.src)) {
  4922.  
  4923. c.setAttribute("alt", this.hostElement.ariaLabel || "");
  4924. return;
  4925. }
  4926. /*
  4927.  
  4928. var d;
  4929. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  4930.  
  4931.  
  4932. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail", a.customThumbnail))
  4933. */
  4934. }
  4935.  
  4936.  
  4937. }
  4938. }
  4939. return this.dataChanged86.apply(this, arguments)
  4940.  
  4941. }
  4942. console.log("cProto.dataChanged - OK");
  4943.  
  4944. } else {
  4945. assertor(() => fnIntegrity(cProto.dataChanged, '1.159.97'));
  4946. console.log("cProto.dataChanged - NG");
  4947.  
  4948. }
  4949.  
  4950. })();
  4951.  
  4952. console.log("[End]");
  4953.  
  4954. console.groupEnd();
  4955.  
  4956. }).catch(console.warn);
  4957.  
  4958.  
  4959. }
  4960.  
  4961.  
  4962. if (FIX_TOOLTIP_DISPLAY) {
  4963.  
  4964.  
  4965. customElements.whenDefined("tp-yt-paper-tooltip").then(() => {
  4966.  
  4967. mightFirstCheckOnYtInit();
  4968. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-paper-tooltip hacks");
  4969. console.log("[Begin]");
  4970. (() => {
  4971.  
  4972. const tag = "tp-yt-paper-tooltip"
  4973. const dummy = document.createElement(tag);
  4974.  
  4975. const cProto = getProto(dummy);
  4976. if (!cProto || !cProto.attached) {
  4977. console.warn(`proto.attached for ${tag} is unavailable.`);
  4978. return;
  4979. }
  4980.  
  4981. if (typeof cProto.attached === 'function' && typeof cProto.detached === 'function' && cProto._readyClients && cProto._attachDom && cProto.ready && !cProto._readyClients43) {
  4982.  
  4983. cProto._readyClients43 = cProto._readyClients;
  4984. cProto._readyClients = function () {
  4985. let r = cProto._readyClients43.apply(this, arguments);
  4986. if (this.$ && this.$$ && this.$.tooltip) this.root = null; // fix this.root = null != (b = a.root) ? b : this.host
  4987. return r;
  4988. }
  4989.  
  4990. console.log("_readyClients - OK");
  4991.  
  4992. } else {
  4993. console.log("_readyClients - NG");
  4994.  
  4995. }
  4996.  
  4997.  
  4998. })();
  4999.  
  5000. console.log("[End]");
  5001.  
  5002. console.groupEnd();
  5003.  
  5004. }).catch(console.warn);
  5005.  
  5006.  
  5007.  
  5008. }
  5009.  
  5010.  
  5011.  
  5012. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK) {
  5013.  
  5014.  
  5015. const hookDocumentMouseDownSetupFn = () => {
  5016.  
  5017.  
  5018.  
  5019. let muzTimestamp = 0;
  5020. let nszDropdown = null;
  5021.  
  5022.  
  5023.  
  5024. const handlerObject = {
  5025.  
  5026. // mdHandler282 : function (evt) {
  5027. // // console.log(evt, 1, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  5028. // if (!evt || !evt.isTrusted) return;
  5029. // muzTimestamp = 0;
  5030. // nszDropdown = null;
  5031.  
  5032. // const hostElement = this.hostElement || this;
  5033. // if (!evt || !evt.isTrusted || !hostElement.hasAttribute('menu-visible')) return;
  5034. // if (!hostElement.contains(evt.target)) return;
  5035. // let targetDropDown = null;
  5036. // for(const dropdown of document.querySelectorAll('tp-yt-iron-dropdown.style-scope.yt-live-chat-app')){
  5037. // if(dropdown && dropdown.positionTarget && hostElement.contains( dropdown.positionTarget)){
  5038. // targetDropDown = dropdown;
  5039. // }
  5040. // }
  5041. // if ((nszDropdown = targetDropDown)) {
  5042. // muzTimestamp = Date.now();
  5043. // evt.stopImmediatePropagation();
  5044. // evt.stopPropagation();
  5045. // }
  5046.  
  5047. // },
  5048.  
  5049.  
  5050. muHandler282: function (evt) {
  5051. // console.log(evt, 7, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  5052. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  5053. const dropdown = nszDropdown;
  5054. muzTimestamp = 0;
  5055. nszDropdown = null;
  5056.  
  5057. const kurMPC = kRef(currentMenuPivotWR) || 0;
  5058. const hostElement = kurMPC.hostElement || kurMPC;
  5059. if (!hostElement.hasAttribute('menu-visible')) return;
  5060. if (dropdown && dropdown.positionTarget && hostElement.contains(dropdown.positionTarget)) {
  5061. muzTimestamp = Date.now();
  5062. evt.stopImmediatePropagation();
  5063. evt.stopPropagation();
  5064. Promise.resolve(dropdown).then((dropdown) => {
  5065. dropdown.cancel();
  5066. });
  5067. // document.body.click();
  5068. }
  5069.  
  5070. },
  5071.  
  5072. mlHandler282: function (evt) {
  5073. muzTimestamp = 0;
  5074. nszDropdown = null;
  5075. },
  5076.  
  5077. ckHandler282: function (evt) {
  5078. // console.log(evt, 3, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  5079.  
  5080. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  5081. if (Date.now() - muzTimestamp < 40) {
  5082. muzTimestamp = Date.now();
  5083. evt.stopImmediatePropagation();
  5084. evt.stopPropagation();
  5085. }
  5086.  
  5087. },
  5088.  
  5089. tapHandler282: function (evt) {
  5090. // console.log(evt, 2, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  5091.  
  5092. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  5093. if (Date.now() - muzTimestamp < 40) {
  5094. muzTimestamp = Date.now();
  5095. evt.stopImmediatePropagation();
  5096. evt.stopPropagation();
  5097. }
  5098.  
  5099. },
  5100.  
  5101.  
  5102. handleEvent(evt) {
  5103.  
  5104.  
  5105. if (evt) {
  5106. const kurMPC = kRef(currentMenuPivotWR) || 0;
  5107. const cnt = kurMPC.inst || kurMPC;
  5108. const hostElement = cnt.hostElement || cnt;
  5109. if (!cnt || cnt.isAttached !== true || hostElement.isConnected !== true) return;
  5110. switch (evt.type) {
  5111. // case 'mousedown':
  5112. // return this.mdHandler282.call(kurMPC, evt);
  5113. case 'mouseup':
  5114. return this.muHandler282(evt);
  5115. case 'mouseleave':
  5116. return this.mlHandler282(evt);
  5117. case 'tap':
  5118. return this.tapHandler282(evt);
  5119. case 'click':
  5120. return this.ckHandler282(evt);
  5121. }
  5122. }
  5123.  
  5124. }
  5125.  
  5126.  
  5127.  
  5128. }
  5129.  
  5130. document.addEventListener('mousedown', function (evt) {
  5131.  
  5132. if (!evt || !evt.isTrusted || !evt.target) return;
  5133. muzTimestamp = 0;
  5134. nszDropdown = null;
  5135.  
  5136. /** @type {HTMLElement | null} */
  5137. const kurMP = kRef(currentMenuPivotWR);
  5138. if (!kurMP) return;
  5139. const kurMPC = kurMP.closest('[menu-visible]') || 0;
  5140.  
  5141. if (!kurMPC.isClickableChatRow111 || !kurMPC.isClickableChatRow111() || !kurMPC.contains(evt.target)) return;
  5142.  
  5143. let targetDropDown = null;
  5144. for (const dropdown of document.querySelectorAll('tp-yt-iron-dropdown.style-scope.yt-live-chat-app')) {
  5145. if (dropdown && dropdown.positionTarget === kurMP) {
  5146. targetDropDown = dropdown;
  5147. }
  5148. }
  5149.  
  5150. if ((nszDropdown = targetDropDown)) {
  5151. muzTimestamp = Date.now();
  5152. evt.stopImmediatePropagation();
  5153. evt.stopPropagation();
  5154. currentMenuPivotWR = mWeakRef(kurMPC);
  5155.  
  5156. const listenOpts = { capture: true, passive: false, once: true };
  5157.  
  5158. // remove unexcecuted eventHandler
  5159. document.removeEventListener('mouseup', handlerObject, listenOpts);
  5160. document.removeEventListener('mouseleave', handlerObject, listenOpts);
  5161. document.removeEventListener('tap', handlerObject, listenOpts);
  5162. document.removeEventListener('click', handlerObject, listenOpts);
  5163.  
  5164. // inject one time eventHandler to by pass events
  5165. document.addEventListener('mouseup', handlerObject, listenOpts);
  5166. document.addEventListener('mouseleave', handlerObject, listenOpts);
  5167. document.addEventListener('tap', handlerObject, listenOpts);
  5168. document.addEventListener('click', handlerObject, listenOpts);
  5169.  
  5170. }
  5171.  
  5172. }, true);
  5173.  
  5174. }
  5175.  
  5176.  
  5177.  
  5178. customElements.whenDefined('yt-live-chat-text-message-renderer').then(() => {
  5179.  
  5180.  
  5181. mightFirstCheckOnYtInit();
  5182. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-text-message-renderer hacks");
  5183. console.log("[Begin]");
  5184. (() => {
  5185.  
  5186. const tag = "yt-live-chat-text-message-renderer"
  5187. const dummy = document.createElement(tag);
  5188.  
  5189. const cProto = getProto(dummy);
  5190. if (!cProto || !cProto.attached) {
  5191. console.warn(`proto.attached for ${tag} is unavailable.`);
  5192. return;
  5193. }
  5194.  
  5195.  
  5196. cProto.isClickableChatRow111 = function () {
  5197. return (
  5198. this.data && typeof this.shouldSupportWholeItemClick === 'function' && typeof this.hasModerationOverlayVisible === 'function' &&
  5199. this.data.contextMenuEndpoint && this.wholeMessageClickable && this.shouldSupportWholeItemClick() && !this.hasModerationOverlayVisible()
  5200. ); // follow .onItemTap(a)
  5201. }
  5202.  
  5203.  
  5204.  
  5205. const toHookDocumentMouseDown = typeof cProto.shouldSupportWholeItemClick === 'function' && typeof cProto.hasModerationOverlayVisible === 'function';
  5206.  
  5207. if (toHookDocumentMouseDown) {
  5208.  
  5209. hookDocumentMouseDownSetupFn();
  5210.  
  5211.  
  5212. console.log("FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK - Doc MouseEvent OK");
  5213.  
  5214.  
  5215.  
  5216. } else {
  5217.  
  5218. console.log("FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK - Doc MouseEvent NG");
  5219.  
  5220. }
  5221.  
  5222.  
  5223. if (FIX_MENU_REOPEN_RENDER_PERFORMANCE_2 && typeof cProto.showContextMenu === 'function' && typeof cProto.showContextMenu_ === 'function' && !cProto.showContextMenu37 && !cProto.showContextMenu37_ && cProto.showContextMenu.length === 1 && cProto.showContextMenu_.length === 1) {
  5224.  
  5225. cProto.showContextMenu37_ = cProto.showContextMenu_;
  5226. cProto.showContextMenu37 = cProto.showContextMenu;
  5227.  
  5228.  
  5229. const wm37 = new WeakMap();
  5230. cProto.showContextMenu = function (a) {
  5231. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  5232. if (endpoint) {
  5233. const resolvedEndpoint = wm37.get(endpoint);
  5234. if (resolvedEndpoint) {
  5235. this.showContextMenu37_(a);
  5236. return;
  5237. }
  5238. }
  5239. return this.showContextMenu37(a);
  5240. }
  5241.  
  5242. cProto.showContextMenu_ = function (a) {
  5243. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  5244. if (endpoint) {
  5245. wm37.set(endpoint, a);
  5246. }
  5247. return this.showContextMenu37_(a);
  5248. }
  5249.  
  5250.  
  5251. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANCE_2 - OK");
  5252.  
  5253.  
  5254.  
  5255. } else {
  5256.  
  5257. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANCE_2 - NG");
  5258.  
  5259. }
  5260.  
  5261.  
  5262.  
  5263. })();
  5264.  
  5265. console.log("[End]");
  5266.  
  5267. console.groupEnd();
  5268.  
  5269. }).catch(console.warn);
  5270.  
  5271. }
  5272.  
  5273.  
  5274. customElements.whenDefined('tp-yt-iron-dropdown').then(() => {
  5275.  
  5276. mightFirstCheckOnYtInit();
  5277. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-iron-dropdown hacks");
  5278. console.log("[Begin]");
  5279. (() => {
  5280.  
  5281. const tag = "tp-yt-iron-dropdown";
  5282. const dummy = document.createElement(tag);
  5283.  
  5284. const cProto = getProto(dummy);
  5285. if (!cProto || !cProto.attached) {
  5286. console.warn(`proto.attached for ${tag} is unavailable.`);
  5287. return;
  5288. }
  5289.  
  5290.  
  5291. if (USE_VANILLA_DEREF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf34 && fnIntegrity(cProto.__deraf) === '2.42.24') {
  5292. cProto.__deraf_hn__ = function (sId, fn) {
  5293. const rhKey = `_rafHandler_${sId}`;
  5294. const m = this[rhKey] || (this[rhKey] = new WeakMap());
  5295. if (m.has(fn)) return m.get(fn);
  5296. const resFn = () => {
  5297. this.__rafs[sId] = null;
  5298. fn.call(this)
  5299. };
  5300. m.set(fn, resFn);
  5301. m.set(resFn, resFn);
  5302. return resFn;
  5303. };
  5304. cProto.__deraf34 = cProto.__deraf;
  5305. cProto.__deraf = function (a, b) { // sId, fn
  5306. let c = this.__rafs;
  5307. null !== c[a] && cancelAnimationFrame(c[a]);
  5308. c[a] = requestAnimationFrame(this.__deraf_hn__(a, b));
  5309. };
  5310. console.log("USE_VANILLA_DEREF - OK");
  5311. } else {
  5312. console.log("USE_VANILLA_DEREF - NG");
  5313. }
  5314.  
  5315. if (FIX_DROPDOWN_DERAF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf66) {
  5316. cProto.__deraf66 = cProto.__deraf;
  5317. cProto.__deraf = function (sId, fn) {
  5318. if (this.__byPassRAF__) {
  5319. Promise.resolve().then(() => {
  5320. fn.call(this);
  5321. });
  5322. }
  5323. let r = this.__deraf66.apply(this, arguments);
  5324. return r;
  5325. }
  5326. console.log("FIX_DROPDOWN_DERAF - OK");
  5327. } else {
  5328. console.log("FIX_DROPDOWN_DERAF - NG");
  5329. }
  5330.  
  5331.  
  5332. if (FIX_MENU_REOPEN_RENDER_PERFORMANCE_1 && typeof cProto.__openedChanged === 'function' && !cProto.__mtChanged__ && fnIntegrity(cProto.__openedChanged) === '0.46.20') {
  5333.  
  5334. let lastClose = null;
  5335. let lastOpen = null;
  5336. let cid = 0;
  5337.  
  5338. cProto.__mtChanged__ = function (b) {
  5339.  
  5340. Promise.resolve().then(() => {
  5341. this._applyFocus();
  5342. }).then(() => {
  5343. b ? this._renderOpened() : this._renderClosed();
  5344. }).catch(console.warn);
  5345.  
  5346. };
  5347.  
  5348. const __moChanged__ = () => {
  5349. if (!cid) return;
  5350. // console.log(553, !!lastOpen, !!lastClose);
  5351. cid = 0;
  5352. if (lastOpen && !lastClose && lastOpen.isAttached) {
  5353. lastOpen.__mtChanged__(1)
  5354. } else if (lastClose && !lastOpen && lastClose.isAttached) {
  5355. lastClose.__mtChanged__(0);
  5356. }
  5357. lastOpen = null;
  5358. lastClose = null;
  5359. };
  5360.  
  5361.  
  5362. if (typeof cProto._openedChanged === 'function' && !cProto._openedChanged66) {
  5363. cProto._openedChanged66 = cProto._openedChanged;
  5364. cProto._openedChanged = function () {
  5365. // this.__byPassRAF__ = !lastOpen ? true : false; // or just true?
  5366. this.__byPassRAF__ = true;
  5367. let r = this._openedChanged66.apply(this, arguments);
  5368. this.__byPassRAF__ = false;
  5369. return r;
  5370. }
  5371. }
  5372.  
  5373. const pSetGet = (key, pdThis, pdBase) => {
  5374. // note: this is not really a standard way for the getOwnPropertyDescriptors; but it is sufficient to make the job done
  5375. return {
  5376. get: (pdThis[key] || 0).get || (pdBase[key] || 0).get,
  5377. set: (pdThis[key] || 0).set || (pdBase[key] || 0).set
  5378. };
  5379. };
  5380.  
  5381. cProto.__modifiedMenuPropsFn__ = function () {
  5382. const pdThis = Object.getOwnPropertyDescriptors(this.constructor.prototype)
  5383. const pdBase = Object.getOwnPropertyDescriptors(this)
  5384.  
  5385. const pdAutoFitOnAttach = pSetGet('autoFitOnAttach', pdThis, pdBase);
  5386. const pdExpandSizingTargetForScrollbars = pSetGet('expandSizingTargetForScrollbars', pdThis, pdBase);
  5387. const pdAllowOutsideScroll = pSetGet('allowOutsideScroll', pdThis, pdBase);
  5388.  
  5389. if (pdAutoFitOnAttach.get || pdAutoFitOnAttach.set) {
  5390. console.warn('there is setter/getter for autoFitOnAttach');
  5391. return;
  5392. }
  5393. if (pdExpandSizingTargetForScrollbars.get || pdExpandSizingTargetForScrollbars.set) {
  5394. console.warn('there is setter/getter for expandSizingTargetForScrollbars');
  5395. return;
  5396. }
  5397. if (!pdAllowOutsideScroll.get || !pdAllowOutsideScroll.set) {
  5398. console.warn('there is NO setter-getter for allowOutsideScroll');
  5399. return;
  5400. }
  5401.  
  5402. let { autoFitOnAttach, expandSizingTargetForScrollbars, allowOutsideScroll } = this;
  5403.  
  5404. this.__AllowOutsideScrollPD__ = pdAllowOutsideScroll;
  5405.  
  5406. const fitEnable = CHAT_MENU_REFIT_ALONG_SCROLLING === 2;
  5407.  
  5408. Object.defineProperties(this, {
  5409. autoFitOnAttach: {
  5410. get() {
  5411. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  5412. return autoFitOnAttach;
  5413. },
  5414. set(nv) {
  5415. autoFitOnAttach = nv;
  5416. return true;
  5417. },
  5418. enumerable: true,
  5419. configurable: true
  5420. }, expandSizingTargetForScrollbars: {
  5421. get() {
  5422. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  5423. return expandSizingTargetForScrollbars;
  5424. },
  5425. set(nv) {
  5426. expandSizingTargetForScrollbars = nv;
  5427. return true;
  5428. },
  5429. enumerable: true,
  5430. configurable: true
  5431. }, allowOutsideScroll: {
  5432. get() {
  5433. if (this._modifiedMenuPropOn062__) return true;
  5434. return allowOutsideScroll;
  5435. },
  5436. set(nv) {
  5437. allowOutsideScroll = nv;
  5438. this.__AllowOutsideScrollPD__.set.call(this, nv);
  5439. return true;
  5440. },
  5441. enumerable: true,
  5442. configurable: true
  5443. }
  5444. })
  5445. };
  5446.  
  5447. /*
  5448. // ***** position() to be changed. *****
  5449. tp-yt-iron-dropdown[class], tp-yt-iron-dropdown[class] #contentWrapper, tp-yt-iron-dropdown[class] ytd-menu-popup-renderer[class] {
  5450.  
  5451. overflow: visible !important;
  5452. min-width: max-content !important;
  5453. max-width: max-content !important;
  5454. max-height: max-content !important;
  5455. min-height: max-content !important;
  5456. white-space: nowrap;
  5457. }
  5458.  
  5459. */
  5460. if (FIX_MENU_POSITION_N_SIZING_ON_SHOWN && typeof cProto.position === 'function' && !cProto.position34 && typeof cProto.refit === 'function') {
  5461.  
  5462. let m34 = 0;
  5463. cProto.__refitByPosition__ = function () {
  5464. m34++;
  5465. if (m34 <= 0) m34 = 0;
  5466. if (m34 !== 1) return;
  5467. const hostElement = this.hostElement || this;
  5468. if (document.visibilityState === 'visible') {
  5469. const sizingTarget = this.sizingTarget;
  5470. if (!sizingTarget) {
  5471. m34 = 0;
  5472. return;
  5473. }
  5474.  
  5475. let useVisibilityCollapse = true;
  5476. if (HTMLElement.prototype.querySelector.call(sizingTarget, 'yt-icon:empty')) {
  5477. useVisibilityCollapse = false;
  5478. }
  5479.  
  5480. if (useVisibilityCollapse) {
  5481. hostElement.style.visibility = 'collapse';
  5482. sizingTarget.style.visibility = 'collapse';
  5483. } else {
  5484. hostElement.setAttribute('rNgzQ', '');
  5485. sizingTarget.setAttribute('rNgzQ', '');
  5486. }
  5487.  
  5488. const gn = () => {
  5489.  
  5490. if (useVisibilityCollapse) {
  5491. hostElement.style.visibility = '';
  5492. sizingTarget.style.visibility = '';
  5493. } else {
  5494. hostElement.removeAttribute('rNgzQ');
  5495. sizingTarget.removeAttribute('rNgzQ');
  5496. }
  5497. }
  5498.  
  5499. const an = async () => {
  5500. while (m34 >= 1) {
  5501. await renderReadyPn(sizingTarget);
  5502. if (this.opened && this.isAttached && sizingTarget.isConnected === true && sizingTarget === this.sizingTarget) {
  5503. if (sizingTarget.matches('ytd-menu-popup-renderer[slot="dropdown-content"].yt-live-chat-app')) this.refit();
  5504. }
  5505. m34--;
  5506. }
  5507. m34 = 0;
  5508. Promise.resolve().then(gn);
  5509. }
  5510. an();
  5511.  
  5512.  
  5513. } else {
  5514. m34 = 0;
  5515. }
  5516. }
  5517. cProto.position34 = cProto.position
  5518. cProto.position = function () {
  5519. if (this._positionInitialize_) {
  5520. this._positionInitialize_ = 0;
  5521. this.__refitByPosition__();
  5522. }
  5523. let r = cProto.position34.apply(this, arguments);
  5524. return r;
  5525. }
  5526. console.log("FIX_MENU_POSITION_ON_SHOWN - OK");
  5527.  
  5528. } else {
  5529.  
  5530. console.log("FIX_MENU_POSITION_ON_SHOWN - NG");
  5531.  
  5532. }
  5533.  
  5534.  
  5535.  
  5536. cProto.__openedChanged = function () {
  5537. this._positionInitialize_ = 1;
  5538. // this.removeAttribute('horizontal-align')
  5539. // this.removeAttribute('vertical-align')
  5540. if (typeof this.__menuTypeCheck__ !== 'boolean') {
  5541. this.__menuTypeCheck__ = true;
  5542. if (CHAT_MENU_SCROLL_UNLOCKING) {
  5543. this._modifiedMenuPropOn062__ = false;
  5544. // console.log(513, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  5545. // this.autoFitOnAttach = true;
  5546. // this.expandSizingTargetForScrollbars = true;
  5547. // this.allowOutsideScroll = true;
  5548. // console.log(519,Object.getOwnPropertyDescriptors(this.constructor.prototype))
  5549. this.__modifiedMenuPropsFn__();
  5550. // this.constrain= function(){}
  5551. // this.position= function(){}
  5552.  
  5553. // this.autoFitOnAttach = true;
  5554. // this.expandSizingTargetForScrollbars = true;
  5555. // this.allowOutsideScroll = true;
  5556. }
  5557. }
  5558. if (CHAT_MENU_SCROLL_UNLOCKING && this.opened) {
  5559. let newValue = null;
  5560. const positionTarget = this.positionTarget;
  5561. if (positionTarget && positionTarget.classList.contains('yt-live-chat-text-message-renderer')) {
  5562. if (this._modifiedMenuPropOn062__ === false) {
  5563. newValue = true;
  5564. }
  5565. } else if (this._modifiedMenuPropOn062__ === true) {
  5566. newValue = false;
  5567. }
  5568. if (newValue !== null) {
  5569. const beforeAllowOutsideScroll = this.allowOutsideScroll;
  5570. this._modifiedMenuPropOn062__ = newValue;
  5571. const afterAllowOutsideScroll = this.allowOutsideScroll;
  5572. if (beforeAllowOutsideScroll !== afterAllowOutsideScroll) this.__AllowOutsideScrollPD__.set.call(this, afterAllowOutsideScroll);
  5573. }
  5574. }
  5575.  
  5576. if (this.opened) {
  5577.  
  5578. Promise.resolve().then(() => {
  5579.  
  5580. this._prepareRenderOpened();
  5581. }).then(() => {
  5582. this._manager.addOverlay(this);
  5583. if (this._manager._overlays.length === 1) {
  5584. lastOpen = this;
  5585. lastClose = null;
  5586. } else {
  5587. return 1;
  5588. }
  5589. // if (cid) {
  5590. // clearTimeout(cid);
  5591. // cid = -1;
  5592. // this.__moChanged__();
  5593. // cid = 0;
  5594. // } else {
  5595. // cid = -1;
  5596. // this.__moChanged__();
  5597. // cid = 0;
  5598. // }
  5599. // cid = cid > 0 ? clearTimeout(cid) : 0;
  5600. // console.log(580, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  5601. // cid = cid || setTimeout(__moChanged__, delay1);
  5602. cid = cid || requestAnimationFrame(__moChanged__);
  5603. }).then((r) => {
  5604.  
  5605. if (r) this.__mtChanged__(1);
  5606. }).catch(console.warn);
  5607.  
  5608. } else {
  5609. Promise.resolve().then(() => {
  5610. this._manager.removeOverlay(this);
  5611. if (this._manager._overlays.length === 0) {
  5612. lastClose = this;
  5613. lastOpen = null;
  5614. } else {
  5615. return 1;
  5616. }
  5617. // cid = cid > 0 ? clearTimeout(cid) : 0;
  5618. // console.log(581, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  5619. // cid = cid || setTimeout(__moChanged__, delay1);
  5620. cid = cid || requestAnimationFrame(__moChanged__);
  5621. }).then((r) => {
  5622. if (r) this.__mtChanged__(0);
  5623. }).catch(console.warn);
  5624.  
  5625. }
  5626.  
  5627. }
  5628. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANCE_1 - OK");
  5629.  
  5630. } else {
  5631.  
  5632. assertor(() => fnIntegrity(cProto.__openedChanged, '0.46.20'));
  5633. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANC_1 - NG");
  5634.  
  5635. }
  5636.  
  5637.  
  5638. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK && typeof cProto.__openedChanged === 'function' && !cProto.__openedChanged82) {
  5639.  
  5640. cProto.__openedChanged82 = cProto.__openedChanged;
  5641.  
  5642.  
  5643. cProto.__openedChanged = function () {
  5644.  
  5645. // currentMenuPivotWR = null;
  5646. // console.log(1480, '__openedChanged.A', this.positionTarget)
  5647.  
  5648.  
  5649.  
  5650. // if (this.opened && this.positionTarget) {
  5651.  
  5652. // const positionTarget = this.positionTarget;
  5653. // console.log(1480, '__openedChanged.B', positionTarget)
  5654. // currentMenuPivotWR = mWeakRef(positionTarget);
  5655.  
  5656. // }
  5657.  
  5658. const positionTarget = this.positionTarget;
  5659. currentMenuPivotWR = positionTarget ? mWeakRef(positionTarget) : null;
  5660. return this.__openedChanged82.apply(this, arguments);
  5661. }
  5662. }
  5663.  
  5664.  
  5665. // if(FIX_MENU_CAPTURE_SCROLL && typeof cProto.__onCaptureScroll === 'function' && !cProto.__onCaptureScroll66){
  5666.  
  5667. // cProto.__onCaptureScroll66 = cProto.__onCaptureScroll;
  5668.  
  5669. // cProto.__onCaptureScroll = function(a){
  5670.  
  5671. // const q = true;
  5672. // if(this.scrollAction === 'lock' && q && this.opened){
  5673.  
  5674. // // console.log(9107, this.scrollAction, this.__isAnimating, this.opened, a); // lock; __isAnimating = false
  5675. // async function af() {
  5676. // this.__isAnimating && this._finishRenderOpened();
  5677. // if (!this.opened) return;
  5678. // this.__restoreScrollPosition();
  5679. // await new Promise(r => requestAnimationFrame(r));
  5680. // if (!this.opened) return;
  5681. // this.opened && this.__isAnimating && this._finishRenderOpened();
  5682. // if (!this.opened) return;
  5683. // this.__restoreScrollPosition();
  5684. // await new Promise(r => requestAnimationFrame(r));
  5685. // if (!this.opened) return;
  5686. // this.opened && this.__isAnimating && this._finishRenderOpened();
  5687. // if (!this.opened) return;
  5688. // this.opened && !this.__isAnimating && this.refit();
  5689. // }
  5690. // Promise.resolve().then(af);
  5691.  
  5692. // return cProto.__onCaptureScroll66.apply(this, arguments);
  5693. // }else{
  5694.  
  5695. // // console.log(9102, this.scrollAction, this.__isAnimating, this.opened, a); // lock
  5696.  
  5697. // return cProto.__onCaptureScroll66.apply(this, arguments);
  5698. // }
  5699. // }
  5700. // console.log("FIX_MENU_CAPTURE_SCROLL - OK");
  5701. // }else{
  5702. // console.log("FIX_MENU_CAPTURE_SCROLL - NG");
  5703.  
  5704. // }
  5705.  
  5706.  
  5707. })();
  5708.  
  5709. console.log("[End]");
  5710.  
  5711. console.groupEnd();
  5712.  
  5713. }).catch(console.warn);
  5714.  
  5715.  
  5716.  
  5717.  
  5718. }
  5719.  
  5720. promiseForCustomYtElementsReady.then(onRegistryReadyForDOMOperations);
  5721.  
  5722.  
  5723.  
  5724.  
  5725.  
  5726. });
  5727.  
  5728. })({ IntersectionObserver });