YouTube 超快聊天

YouTube直播聊天的終極性能提升

目前為 2024-12-22 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name YouTube Super Fast Chat
  3. // @version 0.66.5
  4. // @license MIT
  5. // @name:ja YouTube スーパーファーストチャット
  6. // @name:zh-TW YouTube 超快聊天
  7. // @name:zh-CN YouTube 超快聊天
  8. // @icon https://raw.githubusercontent.com/cyfung1031/userscript-supports/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. // @require https://update.greasyfork.org/scripts/475632/1361351/ytConfigHacks.js
  19. //
  20. // @compatible firefox Violentmonkey
  21. // @compatible firefox Tampermonkey
  22. // @compatible firefox FireMonkey
  23. // @compatible chrome Violentmonkey
  24. // @compatible chrome Tampermonkey
  25. // @compatible opera Violentmonkey
  26. // @compatible opera Tampermonkey
  27. // @compatible safari Stay
  28. // @compatible edge Violentmonkey
  29. // @compatible edge Tampermonkey
  30. // @compatible brave Violentmonkey
  31. // @compatible brave Tampermonkey
  32. //
  33. // @description Ultimate Performance Boost for YouTube Live Chats
  34. // @description:ja YouTubeのライブチャットの究極のパフォーマンスブースト
  35. // @description:zh-TW YouTube直播聊天的終極性能提升
  36. // @description:zh-CN YouTube直播聊天的终极性能提升
  37. //
  38. // ==/UserScript==
  39.  
  40. ((__CONTEXT__) => {
  41. 'use strict';
  42.  
  43. /** @type {WeakMapConstructor} */
  44. const WeakMap = window.WeakMapOriginal || window.WeakMap;
  45.  
  46. // *********** DON'T REPORT NOT WORKING DUE TO THE CHANGED SETTINGS ********************
  47. // The settings are FIXED! You might change them to try but if the script does not work due to your change, please, don't report them as issues
  48.  
  49. 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
  50. 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. (not exceeding 900)
  51. 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. (not exceeding 900)
  52.  
  53. const ENABLE_NO_SMOOTH_TRANSFORM = true; // Depends on whether you want the animation effect for new chat messages <<< DON'T CHANGE >>>
  54. const USE_OPTIMIZED_ON_SCROLL_ITEMS = true; // TRUE for the majority
  55. const ENABLE_OVERFLOW_ANCHOR_PREFERRED = true; // Enable `overflow-anchor: auto` to lock the scroll list at the bottom for no smooth transform.
  56.  
  57. const FIX_SHOW_MORE_BUTTON_LOCATION = true; // When there are voting options (bottom panel), move the "show more" button to the top.
  58. const FIX_INPUT_PANEL_OVERFLOW_ISSUE = true; // When the super chat button is flicking with color, the scrollbar might come out.
  59. const FIX_INPUT_PANEL_BORDER_ISSUE = true; // No border should be allowed if there is an empty input panel.
  60. const SET_CONTAIN_FOR_CHATROOM = true; // Rendering hacks (`contain`) for chatroom elements. [ General ]
  61.  
  62. const FORCE_CONTENT_VISIBILITY_UNSET = true; // Content-visibility should be always VISIBLE for high performance and great rendering.
  63. const FORCE_WILL_CHANGE_UNSET = true; // Will-change should be always UNSET (auto) for high performance and low energy impact.
  64.  
  65. // Replace requestAnimationFrame timers with custom implementation
  66. const ENABLE_RAF_HACK_TICKERS = true; // When there is a ticker
  67. const ENABLE_RAF_HACK_DOCKED_MESSAGE = true; // To be confirmed
  68. const ENABLE_RAF_HACK_INPUT_RENDERER = true; // To be confirmed
  69. const ENABLE_RAF_HACK_EMOJI_PICKER = true; // When changing the page of the emoji picker
  70.  
  71. // Force rendering all the character subsets of the designated font(s) before messages come (Pre-Rendering of Text)
  72. const ENABLE_FONT_PRE_RENDERING_PREFERRED = 1 | 2 | 4 | 8 | 16;
  73.  
  74. // Backdrop `filter: blur(4px)` inside the iframe can extend to the whole page, causing a negative visual impact on the video you are watching.
  75. const NO_BACKDROP_FILTER_WHEN_MENU_SHOWN = true;
  76.  
  77. // Data Manipulation for Participants (Participant List)
  78. // << if DO_PARTICIPANT_LIST_HACKS >>
  79. const DO_PARTICIPANT_LIST_HACKS = true; // TRUE for the majority
  80. const SHOW_PARTICIPANT_CHANGES_IN_CONSOLE = false; // Just too annoying to show them all in popular chat
  81. const CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = true; // Only consider changes in renderable content (not concerned with the last chat message of the participants)
  82. const PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED = true;
  83. // << end >>
  84.  
  85. // show more button
  86. const ENABLE_SHOW_MORE_BLINKER = true; // BLINK WHEN NEW MESSAGES COME
  87.  
  88. // faster stampDomArray_ for participants list creation
  89. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL = 1; // 0 - OFF; 1 - ON; 2 - ON(PARTICIPANTS_LIST ONLY)
  90. const USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET = false;
  91.  
  92. // reuse yt components
  93. const ENABLE_FLAGS_REUSE_COMPONENTS = true;
  94.  
  95. // ShadyDom Free is buggy
  96. const DISABLE_FLAGS_SHADYDOM_FREE = true;
  97.  
  98. // images <Group#I01>
  99. const AUTHOR_PHOTO_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  100. const EMOJI_IMAGE_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  101. const LEAST_IMAGE_SIZE = 48; // minium size = 48px
  102.  
  103. const DO_LINK_PREFETCH = true; // DO NOT CHANGE
  104. // << if DO_LINK_PREFETCH >>
  105. const ENABLE_BASE_PREFETCHING = true; // (SUB-)DOMAIN | dns-prefetch & preconnect
  106. const ENABLE_PRELOAD_THUMBNAIL = true; // subresource (prefetch) [LINK for Images]
  107. const SKIP_PRELOAD_EMOJI = true;
  108. const PREFETCH_LIMITED_SIZE_EMOJI = 512; // DO NOT CHANGE THIS
  109. const PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO = 68; // DO NOT CHANGE THIS
  110. // << end >>
  111.  
  112. const FIX_SETSRC_AND_THUMBNAILCHANGE_ = true; // Function Replacement for yt-img-shadow....
  113. const FIX_THUMBNAIL_DATACHANGED = true; // Function Replacement for yt-live-chat-author-badge-renderer..dataChanged
  114. // const REMOVE_PRELOADAVATARFORADDACTION = false; // Function Replacement for yt-live-chat-renderer..preloadAvatarForAddAction
  115.  
  116. const FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION = true; // important [depends on <Group#I01>]
  117. const FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT = true; // [depends on <Group#I01>]
  118.  
  119. const ATTEMPT_ANIMATED_TICKER_BACKGROUND = ''; // false OR '' for disabled, 'linear', 'steps' for easing-function
  120. // <<<< ATTEMPT_ANIMATED_TICKER_BACKGROUND to be reviewed with memory leakage issues >>>>
  121. // << if ATTEMPT_ANIMATED_TICKER_BACKGROUND >>
  122. // BROWSER SUPPORT: Chrome 75+, Edge 79+, Safari 13.1+, Firefox 63+, Opera 62+
  123. const TICKER_MAX_STEPS_LIMIT = 500; // NOT LESS THAN 5 STEPS!!
  124. // [limiting 500 max steps] is recommended for "confortable visual change"
  125. // min. step increment 0.2% => max steps: 500 => 800ms per each update
  126. // min. step increment 0.5% => max steps: 200 => 1000ms per each update
  127. // min. step increment 1.0% => max steps: 100 => 1000ms per each update
  128. // min. step increment 2.5% => max steps: 40 => 1000ms per each update
  129. // min. step increment 5.0% => max steps: 20 => 1250ms per each update
  130. const ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX = true; // for video playback's ticker issue. [ Playback Replay - Pause at Middle - Backwards Seeking ]
  131. const SKIP_VIDEO_PLAYBACK_PROGRESS_STATE_FIX_FOR_NO_TIMEFX = false; // debug use; yt-live-chat-ticker-renderer might not require ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX
  132. // << end >>
  133.  
  134. const FIX_TOOLTIP_DISPLAY = true; // changed in 2024.05.02
  135. const USE_VANILLA_DEREF = true;
  136. const FIX_DROPDOWN_DERAF = true; // DONT CHANGE
  137.  
  138.  
  139. const CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true; // cache the menu data and used for the next reopen
  140. const ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU = false; // pause auto scroll faster when the context menu is about to show
  141. const ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU = true; // avoid multiple requests on the same time
  142.  
  143. const BOOST_MENU_OPENCHANGED_RENDERING = true;
  144. const FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK = true; // click again = close
  145. const NO_ITEM_TAP_FOR_NON_STATIONARY_TAP = true; // dont open the menu (e.g. text message) if cursor is moved or long press
  146. const TAP_ACTION_DURATION = 280; // exceeding 280ms would not consider as a tap action
  147. const PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN = true; // require CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true
  148. // const FIX_MENU_CAPTURE_SCROLL = true;
  149. const CHAT_MENU_REFIT_ALONG_SCROLLING = 0; // 0 for locking / default; 1 for unlocking only; 2 for unlocking and refit
  150.  
  151. const RAF_FIX_keepScrollClamped = true;
  152. const RAF_FIX_scrollIncrementally = 2; // 0: no action; 1: basic fix; 2: also fix scroll position
  153.  
  154. // << if BOOST_MENU_OPENCHANGED_RENDERING >>
  155. const FIX_MENU_POSITION_N_SIZING_ON_SHOWN = 1; // correct size and position when the menu dropdown opens
  156.  
  157. const CHECK_JSONPRUNE = true; // This is a bug in Brave
  158. // << end >>
  159.  
  160. // const LIVE_CHAT_FLUSH_ON_FOREGROUND_ONLY = false;
  161.  
  162. const CHANGE_DATA_FLUSH_ASYNC = false;
  163. // CHANGE_DATA_FLUSH_ASYNC is disabled due to bug report: https://greasyfork.org/scripts/469878/discussions/199479
  164. // to be further investigated
  165.  
  166. const CHANGE_MANAGER_UNSUBSCRIBE = true;
  167.  
  168. const INTERACTIVITY_BACKGROUND_ANIMATION = 1; // mostly for pinned message
  169. // 0 = default Yt animation background [= no fix];
  170. // 1 = disable default animation background [= keep special animation];
  171. // 2 = disable all animation backgrounds [= no animation backbround]
  172.  
  173. const CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED = true;
  174.  
  175. const MAX_TOOLTIP_NO_WRAP_WIDTH = '72vw'; // '' for disable; accept values like '60px', '25vw'
  176.  
  177.  
  178.  
  179. // (Dec 2024: AMEND_TICKER_handleLiveChatAction to be removed)
  180. const AMEND_TICKER_handleLiveChatAction = false; // to fix ticker duplication and unresponsively fast ticker generation
  181. // AMEND_TICKER_handleLiveChatAction to be fixed (2024.05.21)
  182.  
  183. // (Dec 2024: AMEND_TICKER_handleLiveChatAction_v3 to be removed)
  184. const AMEND_TICKER_handleLiveChatAction_v3 = true; // responsiveness fix (Major Feature)
  185.  
  186. const USE_ADVANCED_TICKING = true; // added in Dec 2024 v0.66.0; need to ensure it would not affect the function if ticker design changed. to be reviewed
  187. const END_ANIMATING_TICKERS = true; // added in Dec 2024 v0.66.5; see pressure test like https://www.youtube.com/watch?v=CQaUs-vNgXo
  188.  
  189.  
  190.  
  191. const ATTEMPT_TICKER_ANIMATION_START_TIME_DETECTION = true;
  192. const ADJUST_TICKER_DURATION_ALIGN_RENDER_TIME = true;
  193. const FIX_BATCH_TICKER_ORDER = true;
  194.  
  195. const DISABLE_Translation_By_Google = true;
  196.  
  197. const FASTER_ICON_RENDERING = true;
  198.  
  199. const DELAY_FOCUSEDCHANGED = true;
  200.  
  201. const skipErrorForhandleAddChatItemAction_ = true; // currently depends on ENABLE_NO_SMOOTH_TRANSFORM
  202. const fixChildrenIssue801 = true; // if __children801__ is set [fix polymer controller method extration for `.set()`]
  203.  
  204. const SUPPRESS_refreshOffsetContainerHeight_ = true; // added in FEB 2024; true for default layout options; no effect if ENABLE_NO_SMOOTH_TRANSFORM is false
  205.  
  206. const NO_FILTER_DROPDOWN_BORDER = true; // added in 2024.03.02
  207.  
  208. const FIX_ANIMATION_TICKER_TEXT_POSITION = true; // CSS fix; experimental; added in 2024.04.07
  209. const FIX_AUTHOR_CHIP_BADGE_POSITION = true;
  210.  
  211. const FIX_ToggleRenderPolymerControllerExtractionBug = false; // to be reviewed
  212.  
  213. const REACTION_ANIMATION_PANEL_CSS_FIX = true;
  214.  
  215. // -------------------------------
  216.  
  217.  
  218. const FIX_MEMORY_LEAKAGE_TICKER_ACTIONMAP = true; // To fix Memory Leakage in yt-live-chat-ticker-...-item-renderer
  219. const FIX_MEMORY_LEAKAGE_TICKER_STATSBAR = true; // To fix Memory Leakage in updateStatsBarAndMaybeShowAnimation
  220. const FIX_MEMORY_LEAKAGE_TICKER_TIMER = true; // To fix Memory Leakage in setContainerWidth, slideDown, collapse // Dec 2024 fix in advance tickering
  221. const FIX_MEMORY_LEAKAGE_TICKER_DATACHANGED_setContainerWidth = true; // To fix Memory Leakage due to _.ytLiveChatTickerItemBehavior.setContainerWidth()
  222.  
  223. // leakage in ytd-sponsorships-live-chat-gift-purchase-announcement-renderer - to be confirmed
  224.  
  225. // <<<<< FOR MEMORY LEAKAGE >>>>
  226. const DEBUG_wmList = false;
  227. let DEBUG_wmList_started = false;
  228. // const FLAG_001 = true;
  229. const FLAG_001a = false;
  230. const FLAG_001b = false;
  231. const FLAG_001c = false;
  232. const FLAG_001d = false;
  233. const FLAG_001e = false;
  234. const FLAG_001f = false;
  235. // const FLAG_001g = true;
  236.  
  237.  
  238.  
  239. /**
  240. *
  241. *
  242. *
  243. *
  244. *
  245. rendererStamperObserver_: function(a, b, c) {
  246. if (c.path == a) {
  247. if (c.value === void 0 && !this.hasDataPath_[a])
  248. return;
  249. this.hasDataPath_[a] = c.value !== void 0
  250. }
  251. this.rendererStamperApplyChangeRecord_(a, b, c)
  252. },
  253.  
  254.  
  255. addStampDomObserverFns_: function() {
  256. for (var a in this.stampDom) {
  257. var b = this.stampDom[a];
  258. b.id ? (this[SQa(b.id)] = this.rendererStamperObserver_.bind(this, a, b.id),
  259. this.hasDataPath_[a] = !1) : Er(new Dn("Bad rendererstamper config",this.is + ":" + a))
  260. }
  261. },
  262. *
  263. *
  264. *
  265. *
  266. *
  267. */
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. // <<<<< FOR MEMORY LEAKAGE >>>>
  275.  
  276. // ========= EXPLANTION FOR 0.2% @ step timing [min. 0.2%] ===========
  277. /*
  278.  
  279. ### Time Approach
  280.  
  281. // all below values can make the time interval > 250ms
  282. // 250ms (practical value) refers to the minimum frequency for timeupdate in most browsers (typically, shorter timeupdate interval in modern browsers)
  283. if (totalDuration > 400000) stepInterval = 0.2; // 400000ms with 0.2% increment => 800ms
  284. else if (totalDuration > 200000) stepInterval = 0.5; // 200000ms with 0.5% increment => 1000ms
  285. else if (totalDuration > 100000) stepInterval = 1; // 100000ms with 1% increment => 1000ms
  286. else if (totalDuration > 50000) stepInterval = 2; // 50000ms with 2% increment => 1000ms
  287. else if (totalDuration > 25000) stepInterval = 5; // 25000ms with 5% increment => 1250ms
  288.  
  289. ### Pixel Check
  290. // Target Max Pixel Increment < 5px for Short Period Ticker (Rapid Background Change)
  291. // Assume total width <= 99px for short period ticker, like small donation & member welcome
  292. 99px * 5% = 4.95px < 5px [Condition Fulfilled]
  293.  
  294. ### Example - totalDuration = 280000
  295. totalDuration 280000
  296. stepInterval 0.5
  297. numOfSteps = Math.round(100 / stepInterval) = 200
  298. time interval = 280000 / 200 = 1400ms <acceptable>
  299.  
  300. ### Example - totalDuration = 18000
  301. totalDuration 18000
  302. stepInterval 5
  303. numOfSteps = Math.round(100 / stepInterval) = 20
  304. time interval = 18000 / 20 = 900ms <acceptable>
  305.  
  306. ### Example - totalDuration = 5000
  307. totalDuration 5000
  308. stepInterval 5
  309. numOfSteps = Math.round(100 / stepInterval) = 20
  310. time interval = 5000 / 20 = 250ms <threshold value>
  311.  
  312. ### Example - totalDuration = 3600
  313. totalDuration 3600
  314. stepInterval 5
  315. numOfSteps = Math.round(100 / stepInterval) = 20
  316. time interval = 3600 / 20 = 180ms <reasonable for 3600ms ticker>
  317.  
  318. */
  319.  
  320. // =======================================================================================================
  321.  
  322. // AUTOMAICALLY DETERMINED
  323. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL === 1;
  324. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL >= 1;
  325. const CHAT_MENU_SCROLL_UNLOCKING = CHAT_MENU_REFIT_ALONG_SCROLLING >= 1;
  326. let runTickerClassName = 'run-ticker';
  327.  
  328. const dummyImgURL = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  329. /*
  330. WebP: data:image/webp;base64,UklGRjAB
  331. PNG: data:image/png;base64,iVBORw0KGg==
  332. JPEG: data:image/jpeg;base64,/9j/4AA=
  333. GIF: data:image/gif;base64,R0lGODlhAQABAIA=
  334. BMP: data:image/bmp;base64,Qk1oAAAA
  335. SVG: data:image/svg+xml;base64,PHN2Zy8+Cg==
  336.  
  337. WebP: data:image/webp;base64,AAAAAAA=
  338. PNG: data:image/png;base64,AAAAAAA=
  339. JPEG: data:image/jpeg;base64,AAAAAAA=
  340. GIF: data:image/gif;base64,AAAAAAA=
  341. BMP: data:image/bmp;base64,AAAAAAA=
  342.  
  343. data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  344.  
  345.  
  346. */
  347.  
  348. // image sizing code
  349. // (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null)
  350.  
  351.  
  352. // function KC(a, b, c, d) {
  353. // d = void 0 === d ? "width" : d;
  354. // if (!a || !a.length)
  355. // return null;
  356. // if (z("kevlar_tuner_should_always_use_device_pixel_ratio")) {
  357. // var e = window.devicePixelRatio;
  358. // 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"));
  359. // HC = e
  360. // } else
  361. // HC || (HC = window.devicePixelRatio);
  362. // e = HC;
  363. // z("kevlar_tuner_should_always_use_device_pixel_ratio") ? b *= e : 1 < e && (b *= e);
  364. // if (z("kevlar_tuner_min_thumbnail_quality"))
  365. // return a[0].url || null;
  366. // e = a.length;
  367. // if (z("kevlar_tuner_max_thumbnail_quality"))
  368. // return a[e - 1].url || null;
  369. // if (c)
  370. // for (var h = 0; h < e; h++)
  371. // if (0 <= a[h].url.indexOf(c))
  372. // return a[h].url || null;
  373. // for (c = 0; c < e; c++)
  374. // if (a[c][d] >= b)
  375. // return a[c].url || null;
  376. // for (b = e - 1; 0 < b; b--)
  377. // if (a[b][d])
  378. // return a[b].url || null;
  379. // return a[0].url || null
  380. // }
  381.  
  382. const { IntersectionObserver } = __CONTEXT__;
  383. let _x69;
  384. try {
  385. _x69 = document.createAttributeNS("http://www.w3.org/2000/svg", "nil").addEventListener;
  386. } catch (e) { }
  387. const pureAddEventListener = _x69;
  388. if (!pureAddEventListener) return console.warn("pureAddEventListener cannot be obtained.");
  389.  
  390. /** @type {globalThis.PromiseConstructor} */
  391. const Promise = (async () => { })().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  392.  
  393. // let jsonParseFix = null;
  394.  
  395. if (!IntersectionObserver) return console.warn("Your browser does not support IntersectionObserver.\nPlease upgrade to the latest version.");
  396. if (typeof WebAssembly !== 'object') return console.warn("Your browser is too old.\nPlease upgrade to the latest version."); // for passive and once
  397.  
  398. // necessity of cssText3_smooth_transform_position to be checked.
  399. const cssText3_smooth_transform_position = ENABLE_NO_SMOOTH_TRANSFORM ? `
  400.  
  401. #item-offset.style-scope.yt-live-chat-item-list-renderer > #items.style-scope.yt-live-chat-item-list-renderer {
  402. position: static !important;
  403. }
  404.  
  405. `: '';
  406.  
  407. // fallback if dummy style fn fails
  408. const cssText4_smooth_transform_forced_props = ENABLE_NO_SMOOTH_TRANSFORM ? `
  409.  
  410. /* optional */
  411. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  412. height: auto !important;
  413. min-height: unset !important;
  414. }
  415.  
  416. #items.style-scope.yt-live-chat-item-list-renderer {
  417. transform: translateY(0px) !important;
  418. }
  419.  
  420. /* optional */
  421.  
  422. `: '';
  423.  
  424. const cssText5 = SET_CONTAIN_FOR_CHATROOM ? `
  425.  
  426. /* ------------------------------------------------------------------------------------------------------------- */
  427.  
  428. 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 {
  429. contain: layout style;
  430. }
  431.  
  432. #items.style-scope.yt-live-chat-item-list-renderer {
  433. contain: layout paint style;
  434. }
  435.  
  436. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  437. contain: style;
  438. }
  439.  
  440. #item-scroller.style-scope.yt-live-chat-item-list-renderer {
  441. contain: size style;
  442. }
  443.  
  444. #contents.style-scope.yt-live-chat-item-list-renderer, #chat.style-scope.yt-live-chat-renderer, img.style-scope.yt-img-shadow[width][height] {
  445. contain: size layout paint style;
  446. }
  447.  
  448. .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label], .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label] > #container {
  449. contain: layout paint style;
  450. }
  451.  
  452. 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 {
  453. contain: layout style;
  454. }
  455.  
  456. tp-yt-paper-tooltip[style*="inset"][role="tooltip"] {
  457. contain: layout paint style;
  458. }
  459.  
  460. /* ------------------------------------------------------------------------------------------------------------- */
  461.  
  462. ` : '';
  463.  
  464. const cssText6b_show_more_button = FIX_SHOW_MORE_BUTTON_LOCATION ? `
  465.  
  466. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer{
  467. top: 4px;
  468. transition-property: top;
  469. bottom: unset;
  470. }
  471.  
  472. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer[disabled]{
  473. top: -42px;
  474. }
  475.  
  476. `: '';
  477.  
  478. const cssText6c_input_panel_overflow = FIX_INPUT_PANEL_OVERFLOW_ISSUE ? `
  479.  
  480. #input-panel #picker-buttons yt-live-chat-icon-toggle-button-renderer#product-picker {
  481. contain: layout style;
  482. }
  483.  
  484. #chat.yt-live-chat-renderer ~ #panel-pages.yt-live-chat-renderer {
  485. overflow: visible;
  486. }
  487.  
  488. `: '';
  489.  
  490. const cssText6d_input_panel_border = FIX_INPUT_PANEL_BORDER_ISSUE ? `
  491.  
  492. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer:not(:empty) {
  493. --yt-live-chat-action-panel-top-border: none;
  494. }
  495.  
  496. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer.iron-selected > *:first-child {
  497. border-top: 1px solid var(--yt-live-chat-panel-pages-border-color);
  498. }
  499.  
  500. html #panel-pages.yt-live-chat-renderer {
  501. border-top: 0;
  502. border-bottom: 0;
  503. }
  504.  
  505. `: '';
  506.  
  507. const cssText7b_content_visibility_unset = FORCE_CONTENT_VISIBILITY_UNSET ? `
  508.  
  509. img,
  510. yt-img-shadow[height][width],
  511. yt-img-shadow {
  512. content-visibility: visible !important;
  513. }
  514.  
  515. ` : '';
  516.  
  517. const cssText7c_will_change_unset = FORCE_WILL_CHANGE_UNSET ? `
  518.  
  519. /* remove YouTube constant will-change */
  520. /* constant value will slow down the performance; default auto */
  521.  
  522. /* www-player.css */
  523. html .ytp-contextmenu,
  524. html .ytp-settings-menu {
  525. will-change: unset;
  526. }
  527.  
  528. /* frequently matched elements */
  529. html .fill.yt-interaction,
  530. html .stroke.yt-interaction,
  531. html .yt-spec-touch-feedback-shape__fill,
  532. html .yt-spec-touch-feedback-shape__stroke {
  533. will-change: unset;
  534. }
  535.  
  536. /* live_chat_polymer.js */
  537. /*
  538. html .toggle-button.tp-yt-paper-toggle-button,
  539. html #primaryProgress.tp-yt-paper-progress,
  540. html #secondaryProgress.tp-yt-paper-progress,
  541. html #onRadio.tp-yt-paper-radio-button,
  542. html .fill.yt-interaction,
  543. html .stroke.yt-interaction,
  544. html .yt-spec-touch-feedback-shape__fill,
  545. html .yt-spec-touch-feedback-shape__stroke {
  546. will-change: unset;
  547. }
  548. */
  549.  
  550. /* desktop_polymer_enable_wil_icons.js */
  551. /* html .fill.yt-interaction,
  552. html .stroke.yt-interaction, */
  553. html tp-yt-app-header::before,
  554. html tp-yt-iron-list,
  555. html #items.tp-yt-iron-list > *,
  556. html #onRadio.tp-yt-paper-radio-button,
  557. html .toggle-button.tp-yt-paper-toggle-button,
  558. html ytd-thumbnail-overlay-toggle-button-renderer[use-expandable-tooltip] #label.ytd-thumbnail-overlay-toggle-button-renderer,
  559. html #items.ytd-post-multi-image-renderer,
  560. html #items.ytd-horizontal-card-list-renderer,
  561. html #items.yt-horizontal-list-renderer,
  562. html #left-arrow.yt-horizontal-list-renderer,
  563. html #right-arrow.yt-horizontal-list-renderer,
  564. html #items.ytd-video-description-infocards-section-renderer,
  565. html #items.ytd-video-description-music-section-renderer,
  566. html #chips.ytd-feed-filter-chip-bar-renderer,
  567. html #chips.yt-chip-cloud-renderer,
  568. html #items.ytd-merch-shelf-renderer,
  569. html #items.ytd-product-details-image-carousel-renderer,
  570. html ytd-video-preview,
  571. html #player-container.ytd-video-preview,
  572. html #primaryProgress.tp-yt-paper-progress,
  573. html #secondaryProgress.tp-yt-paper-progress,
  574. html ytd-miniplayer[enabled] /* ,
  575. html .yt-spec-touch-feedback-shape__fill,
  576. html .yt-spec-touch-feedback-shape__stroke */ {
  577. will-change: unset;
  578. }
  579.  
  580. /* other */
  581. .ytp-videowall-still-info-content[class],
  582. .ytp-suggestion-image[class] {
  583. will-change: unset !important;
  584. }
  585.  
  586. ` : '';
  587.  
  588. const ENABLE_FONT_PRE_RENDERING = typeof HTMLElement.prototype.append === 'function' ? (ENABLE_FONT_PRE_RENDERING_PREFERRED || 0) : 0;
  589. const cssText8_fonts_pre_render = ENABLE_FONT_PRE_RENDERING ? `
  590.  
  591. elzm-fonts {
  592. visibility: collapse;
  593. position: fixed;
  594. top: -10px;
  595. left: -10px;
  596. font-size: 10pt;
  597. line-height: 100%;
  598. width: 100px;
  599. height: 100px;
  600. transform: scale(0.1);
  601. transform: scale(0.01);
  602. transform: scale(0.001);
  603. transform-origin: 0 0;
  604. contain: strict;
  605. display: block;
  606.  
  607. pointer-events: none !important;
  608. user-select: none !important;
  609. }
  610.  
  611. elzm-fonts[id]#elzm-fonts-yk75g {
  612. user-select: none !important;
  613. pointer-events: none !important;
  614. }
  615.  
  616. elzm-font {
  617. visibility: collapse;
  618. position: absolute;
  619. line-height: 100%;
  620. width: 100px;
  621. height: 100px;
  622. contain: strict;
  623. display: block;
  624.  
  625. user-select: none !important;
  626. pointer-events: none !important;
  627. }
  628.  
  629. elzm-font::before {
  630. visibility: collapse;
  631. position: absolute;
  632. line-height: 100%;
  633. width: 100px;
  634. height: 100px;
  635. contain: strict;
  636. display: block;
  637.  
  638. 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';
  639.  
  640. user-select: none !important;
  641. pointer-events: none !important;
  642. }
  643.  
  644. `: '';
  645.  
  646. const cssText9_no_backdrop_filter_when_menu_shown = NO_BACKDROP_FILTER_WHEN_MENU_SHOWN ? `
  647. tp-yt-iron-dropdown.yt-live-chat-app ytd-menu-popup-renderer {
  648. -webkit-backdrop-filter: none;
  649. backdrop-filter: none;
  650. }
  651. `: '';
  652.  
  653. const cssText10_show_more_blinker = ENABLE_SHOW_MORE_BLINKER ? `
  654.  
  655. @keyframes blinker-miuzp {
  656. 0%, 60%, 100% {
  657. opacity: 1;
  658. }
  659. 30% {
  660. opacity: 0.6;
  661. }
  662. }
  663.  
  664. yt-icon-button#show-more.has-new-messages-miuzp {
  665. animation: blinker-miuzp 1.74s linear infinite;
  666. }
  667.  
  668. `: '';
  669.  
  670. const cssText11_entire_message_clickable = FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK ? `
  671.  
  672. yt-live-chat-paid-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  673. pointer-events: none !important;
  674. }
  675.  
  676. yt-live-chat-membership-item-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  677. pointer-events: none !important;
  678. }
  679.  
  680. yt-live-chat-paid-sticker-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  681. pointer-events: none !important;
  682. }
  683.  
  684. yt-live-chat-text-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  685. pointer-events: none !important; /* TO_BE_REVIEWED */
  686. }
  687.  
  688. yt-live-chat-auto-mod-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  689. pointer-events: none !important;
  690. }
  691.  
  692. `: '';
  693.  
  694. const cssText12_nowrap_tooltip = MAX_TOOLTIP_NO_WRAP_WIDTH && typeof MAX_TOOLTIP_NO_WRAP_WIDTH === 'string' ? `
  695.  
  696.  
  697. tp-yt-paper-tooltip[role="tooltip"] {
  698. box-sizing: content-box !important;
  699. margin: 0px !important;
  700. padding: 0px !important;
  701. contain: none !important;
  702. }
  703.  
  704. tp-yt-paper-tooltip[role="tooltip"] #tooltip[style-target="tooltip"] {
  705. box-sizing: content-box !important;
  706. display: inline-block;
  707. contain: none !important;
  708. }
  709.  
  710.  
  711. tp-yt-paper-tooltip[role="tooltip"] #tooltip[style-target="tooltip"]{
  712. max-width: ${MAX_TOOLTIP_NO_WRAP_WIDTH};
  713. width: max-content;
  714. text-overflow: ellipsis;
  715. overflow: hidden;
  716. white-space: nowrap;
  717. }
  718.  
  719.  
  720. `: '';
  721.  
  722.  
  723. const cssText13_no_text_select_when_menu_visible = `
  724. [menu-visible] {
  725. --sfc47-text-select: none;
  726. }
  727. [menu-visible] #header[id][class],
  728. [menu-visible] #content[id][class],
  729. [menu-visible] #header[id][class] *,
  730. [menu-visible] #content[id][class] * {
  731. user-select: var(--sfc47-text-select) !important;
  732. }
  733. [menu-visible] #menu {
  734. --sfc47-text-select: inherit;
  735. }
  736. `;
  737.  
  738. const cssText14_NO_FILTER_DROPDOWN_BORDER = NO_FILTER_DROPDOWN_BORDER ? `
  739. yt-live-chat-header-renderer.yt-live-chat-renderer #label.yt-dropdown-menu::before {
  740. border:0;
  741. }
  742. ` : '';
  743.  
  744. const cssText15_FIX_ANIMATION_TICKER_TEXT_POSITION = FIX_ANIMATION_TICKER_TEXT_POSITION ? `
  745. .style-scope.yt-live-chat-ticker-renderer #animation-container[id][class] {
  746. position: relative;
  747. display: grid;
  748. grid-auto-columns: 1fr;
  749. grid-auto-rows: 1fr;
  750. grid-template-columns: repeat(1, 1fr);
  751. gap: 7px;
  752. padding-bottom: 0;
  753. margin-bottom: 0;
  754. padding-top: 0;
  755. align-self: flex-start;
  756. flex-wrap: nowrap;
  757. margin-top: 1px;
  758. }
  759.  
  760. .style-scope.yt-live-chat-ticker-renderer #animation-container > [id][class] {
  761. margin-top: 0px;
  762. margin-bottom: 0px;
  763. flex-direction: row;
  764. flex-wrap: nowrap;
  765. align-items: center;
  766. justify-content: flex-start;
  767. }
  768.  
  769. .style-scope.yt-live-chat-ticker-renderer #animation-container > [id][class]:first-child::after {
  770. content: '補';
  771. visibility: collapse;
  772. display: inline-block;
  773. position: relative;
  774. width: 0;
  775. line-height: 22px;
  776. }
  777.  
  778. ` : '';
  779.  
  780. const cssText16_FIX_AUTHOR_CHIP_BADGE_POSITION = FIX_AUTHOR_CHIP_BADGE_POSITION ? `
  781. #card #author-name-chip > yt-live-chat-author-chip[single-line] {
  782. flex-wrap: nowrap;
  783. white-space: nowrap;
  784. display: inline-flex;
  785. flex-direction: row;
  786. text-wrap: nowrap;
  787. flex-shrink: 0;
  788. align-items: center;
  789. }
  790.  
  791. #card #author-name-chip {
  792. display: inline-flex;
  793. flex-direction: row;
  794. align-items: flex-start;
  795. }
  796. `: '';
  797.  
  798.  
  799. // Example: https://www.youtube.com/watch?v=Xfytz-igsuc
  800. const cssText17_FIX_overwidth_banner_message = `
  801. yt-live-chat-banner-manager#live-chat-banner.style-scope.yt-live-chat-item-list-renderer {
  802. max-width: 100%;
  803. box-sizing: border-box;
  804. }
  805. `;
  806.  
  807.  
  808. const cssText18_REACTION_ANIMATION_PANEL_CSS_FIX = REACTION_ANIMATION_PANEL_CSS_FIX ? `
  809. #reaction-control-panel-overlay[class] {
  810. contain: strict;
  811. margin: 0;
  812. padding: 0;
  813. border: 0;
  814. box-sizing: border-box;
  815. will-change: initial;
  816. }
  817. #reaction-control-panel-overlay[class] *[class] {
  818. will-change: initial;
  819. }
  820. `: '';
  821.  
  822. const cssText19_FOR_ADVANCED_TICKING = `
  823. ticker-bg-overlay {
  824. display: block;
  825. position: absolute;
  826. z-index: -1;
  827. box-sizing: border-box;
  828. border: 0;
  829. padding: 0;
  830. margin: 0;
  831. width: 200%;
  832. top: 0;
  833. bottom: 0;
  834. left: clamp(-100%, calc( -100% * ( var(--ticker-current-time) - var(--ticker-start-time) ) / var(--ticker-duration-time) ), 0%);
  835. contain: strict;
  836. }
  837. ticker-bg-overlay-end {
  838. position: absolute;
  839. right: 0px;
  840. top: 50%;
  841. display: block;
  842. width: 1px;
  843. height: 1px;
  844. opacity: 0;
  845. pointer-events: none;
  846. box-sizing: border-box;
  847. border: 0;
  848. padding: 0;
  849. margin: 0;
  850. contain: strict;
  851. }
  852.  
  853. ticker-bg-overlay-end2 {
  854.  
  855. all:unset;
  856. position: fixed;
  857. display: block;
  858. margin-left: -0.5px;
  859. top: 8px;
  860. left: clamp(-250px, calc( 250px * ( ( var(--ticker-current-time) - var(--ticker-start-time) ) / var(--ticker-duration-time) - 1 ) ), 2px);
  861.  
  862. width: 1px;
  863. height: 1px;
  864. opacity: 0;
  865. pointer-events: none;
  866. box-sizing: border-box;
  867. border: 0;
  868. padding: 0;
  869. margin: 0;
  870. contain: strict;
  871. z-index: -1;
  872. visibility: collapse;
  873.  
  874. }
  875.  
  876. .ticker-no-transition-time, .ticker-no-transition-time [id] {
  877. transition-duration: 0s !important;
  878. }
  879.  
  880. /*
  881.  
  882.  
  883. ey.style.position = 'absolute';
  884. ey.style.right = '0px';
  885. ey.style.top = '50%';
  886. ey.style.display='block';
  887. ey.style.width='1px';
  888. ey.style.height='1px';
  889. ey.style.opacity = '0';
  890.  
  891. em.style.display = 'block';
  892. em.style.position = 'absolute';
  893. em.style.boxSizing = 'border-box';
  894. em.style.width = '200%';
  895. em.style.top = '0';
  896. em.style.bottom = '0';
  897. // em.style.height = '100%';
  898.  
  899.  
  900. // em.style.left = '-50%';
  901. // em.style.left = "clamp(-100%, calc( -100% * ( var(--ticker-current-time) - var(--ticker-start-time) ) / var(--ticker-duration-time) ), 0%)";
  902.  
  903. */
  904.  
  905. `;
  906.  
  907. const addCss = () => `
  908.  
  909. @property --ticker-rtime {
  910. syntax: "<percentage>";
  911. inherits: false;
  912. initial-value: 0%;
  913. }
  914.  
  915. /*
  916. .run-ticker {
  917. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  918. }
  919.  
  920. .run-ticker-test {
  921. background: #00000001;
  922. }
  923.  
  924. .run-ticker-forced,
  925. yt-live-chat-ticker-renderer #items > * > #container.run-ticker-forced,
  926. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker-forced[class]
  927. {
  928. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2)) !important;
  929. }
  930. */
  931.  
  932. .run-ticker {
  933. --ticker-bg:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  934. }
  935.  
  936. .run-ticker,
  937. yt-live-chat-ticker-renderer #items > * > #container.run-ticker,
  938. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker[class]
  939. {
  940. background: var(--ticker-bg) !important;
  941. }
  942.  
  943. yt-live-chat-ticker-dummy777-item-renderer {
  944. background: #00000001;
  945. }
  946.  
  947. yt-live-chat-ticker-dummy777-item-renderer[dummy777] {
  948. position: fixed !important;
  949. top: -1000px !important;
  950. left: -1000px !important;
  951. font-size: 1px !important;
  952. color: transparent !important;
  953. pointer-events: none !important;
  954. z-index: -1 !important;
  955. contain: strict !important;
  956. box-sizing: border-box !important;
  957. pointer-events: none !important;
  958. user-select: none !important;
  959. max-width: 1px !important;
  960. max-height: 1px !important;
  961. overflow: hidden !important;
  962. visibility: collapse !important;
  963. display: none !important;
  964. }
  965.  
  966. yt-live-chat-ticker-dummy777-item-renderer #container {
  967. background: inherit;
  968. }
  969.  
  970.  
  971. ${cssText8_fonts_pre_render}
  972.  
  973. ${cssText9_no_backdrop_filter_when_menu_shown}
  974.  
  975. @supports (contain: layout paint style) {
  976.  
  977. ${cssText5}
  978.  
  979. }
  980.  
  981. @supports (color: var(--general)) {
  982.  
  983. html {
  984. --yt-live-chat-item-list-renderer-padding: 0px 0px;
  985. }
  986.  
  987. ${cssText3_smooth_transform_position}
  988.  
  989. ${cssText7c_will_change_unset}
  990.  
  991. ${cssText7b_content_visibility_unset}
  992.  
  993. yt-live-chat-item-list-renderer:not([allow-scroll]) #item-scroller.yt-live-chat-item-list-renderer {
  994. overflow-y: scroll;
  995. padding-right: 0;
  996. }
  997.  
  998. ${cssText4_smooth_transform_forced_props}
  999.  
  1000. yt-icon[icon="down_arrow"] > *, yt-icon-button#show-more > * {
  1001. pointer-events: none !important;
  1002. }
  1003.  
  1004. #continuations, #continuations * {
  1005. contain: strict;
  1006. position: fixed;
  1007. top: 2px;
  1008. height: 1px;
  1009. width: 2px;
  1010. height: 1px;
  1011. visibility: collapse;
  1012. }
  1013.  
  1014. ${cssText6b_show_more_button}
  1015.  
  1016. ${cssText6d_input_panel_border}
  1017.  
  1018. ${cssText6c_input_panel_overflow}
  1019.  
  1020. }
  1021.  
  1022.  
  1023. @supports (overflow-anchor: auto) {
  1024.  
  1025. .no-anchor * {
  1026. overflow-anchor: none;
  1027. }
  1028. .no-anchor > item-anchor {
  1029. overflow-anchor: auto;
  1030. }
  1031.  
  1032. item-anchor {
  1033.  
  1034. height:1px;
  1035. width: 100%;
  1036. transform: scaleY(0.00001);
  1037. transform-origin:0 0;
  1038. contain: strict;
  1039. opacity:0;
  1040. display:flex;
  1041. position:relative;
  1042. flex-shrink:0;
  1043. flex-grow:0;
  1044. margin-bottom:0;
  1045. overflow:hidden;
  1046. box-sizing:border-box;
  1047. visibility: visible;
  1048. content-visibility: visible;
  1049. contain-intrinsic-size: auto 1px;
  1050. pointer-events:none !important;
  1051.  
  1052. }
  1053.  
  1054. #item-scroller.style-scope.yt-live-chat-item-list-renderer[class] {
  1055. overflow-anchor: initial !important; /* whenever ENABLE_OVERFLOW_ANCHOR or not */
  1056. }
  1057.  
  1058. html item-anchor {
  1059.  
  1060. height: 1px;
  1061. width: 1px;
  1062. top: auto;
  1063. left: auto;
  1064. right: auto;
  1065. bottom: auto;
  1066. transform: translateY(-1px);
  1067. position: absolute;
  1068. z-index: -1;
  1069.  
  1070. }
  1071.  
  1072. }
  1073.  
  1074. @supports (color: var(--pre-rendering)) {
  1075.  
  1076. @keyframes dontRenderAnimation {
  1077. 0% {
  1078. background-position-x: 3px;
  1079. }
  1080. 100% {
  1081. background-position-x: 4px;
  1082. }
  1083. }
  1084.  
  1085. .dont-render[class] {
  1086. /* visibility: collapse !important; */
  1087. /* visibility: collapse will make innerText become "" which conflicts with BetterStreamChat; see https://greasyfork.org/scripts/469878/discussions/197267 */
  1088.  
  1089. transform: scale(0.01) !important;
  1090. transform: scale(0.00001) !important;
  1091. transform: scale(0.0000001) !important;
  1092. transform-origin: 0 0 !important;
  1093. z-index: -1 !important;
  1094. contain: strict !important;
  1095. box-sizing: border-box !important;
  1096.  
  1097. height: 1px !important;
  1098. height: 0.1px !important;
  1099. height: 0.01px !important;
  1100. height: 0.0001px !important;
  1101. height: 0.000001px !important;
  1102.  
  1103. animation: dontRenderAnimation 1ms linear 80ms 1 normal forwards !important;
  1104.  
  1105. pointer-events: none !important;
  1106. user-select: none !important;
  1107.  
  1108. }
  1109.  
  1110. #sk35z {
  1111. display: block !important;
  1112.  
  1113. visibility: collapse !important;
  1114.  
  1115. transform: scale(0.01) !important;
  1116. transform: scale(0.00001) !important;
  1117. transform: scale(0.0000001) !important;
  1118. transform-origin: 0 0 !important;
  1119. z-index: -1 !important;
  1120. contain: strict !important;
  1121. box-sizing: border-box !important;
  1122.  
  1123. height: 1px !important;
  1124. height: 0.1px !important;
  1125. height: 0.01px !important;
  1126. height: 0.0001px !important;
  1127. height: 0.000001px !important;
  1128.  
  1129. position: absolute !important;
  1130. top: -1000px !important;
  1131. left: -1000px !important;
  1132.  
  1133. }
  1134.  
  1135. }
  1136.  
  1137. [rNgzQ] {
  1138. opacity: 0 !important;
  1139. pointer-events: none !important;
  1140. }
  1141.  
  1142.  
  1143. ${cssText10_show_more_blinker}
  1144.  
  1145. ${cssText11_entire_message_clickable}
  1146.  
  1147. ${cssText12_nowrap_tooltip}
  1148.  
  1149. ${cssText13_no_text_select_when_menu_visible}
  1150.  
  1151. ${cssText14_NO_FILTER_DROPDOWN_BORDER}
  1152.  
  1153. ${cssText15_FIX_ANIMATION_TICKER_TEXT_POSITION}
  1154.  
  1155. ${cssText16_FIX_AUTHOR_CHIP_BADGE_POSITION}
  1156.  
  1157. ${cssText17_FIX_overwidth_banner_message}
  1158.  
  1159. ${cssText18_REACTION_ANIMATION_PANEL_CSS_FIX}
  1160.  
  1161. ${cssText19_FOR_ADVANCED_TICKING}
  1162.  
  1163. `;
  1164.  
  1165.  
  1166. const konsole = {
  1167. nil: Symbol(),
  1168. logs: [],
  1169. style: '',
  1170. log(...args) {
  1171. konsole.logs.push({
  1172. type: 'log',
  1173. msg: [konsole.tag || konsole.nil, ...args, konsole.style || konsole.nil].filter(e => e !== konsole.nil)
  1174. });
  1175. },
  1176. setTag(tag) {
  1177. konsole.tag = tag;
  1178. },
  1179. setStyle(style) {
  1180. konsole.style = style;
  1181. },
  1182. groupCollapsed(...args) {
  1183.  
  1184. konsole.logs.push({
  1185. type: 'groupCollapsed',
  1186. msg: [...args].filter(e => e !== konsole.nil)
  1187. });
  1188. },
  1189. groupEnd() {
  1190.  
  1191. konsole.logs.push({
  1192. type: 'groupEnd'
  1193. })
  1194. },
  1195. print() {
  1196. const copy = konsole.logs.slice(0);
  1197. konsole.logs.length = 0;
  1198. for (const { type, msg } of copy) {
  1199. if (type === 'log') {
  1200. console.log(...msg)
  1201. } else if (type === 'groupCollapsed') {
  1202.  
  1203. console.groupCollapsed(...msg)
  1204. } else if (type === 'groupEnd') {
  1205. console.groupEnd();
  1206. }
  1207.  
  1208. }
  1209.  
  1210. }
  1211. };
  1212.  
  1213. /*
  1214. konsole.groupCollapsedX = (text1, text2) => {
  1215.  
  1216. if(!text2){
  1217.  
  1218. konsole.groupCollapsed(`%c${text1}`,
  1219. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;"
  1220. );
  1221. }else{
  1222.  
  1223. konsole.groupCollapsed(`%c${text1}%c${text2}`,
  1224. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;",
  1225. "background-color: #010502; color: #6ad9fe; font-weight: 300; padding: 2px;"
  1226. );
  1227. }
  1228. }
  1229.  
  1230. konsole.groupCollapsedX('YouTube Super Fast Chat');
  1231.  
  1232. setTimeout(()=>{
  1233.  
  1234. konsole.setTag('[[Fonts Pre-Rendering]]');
  1235. konsole.log(123);
  1236. konsole.log('wsd',332, 'ssa');
  1237. konsole.setTag('');
  1238. }, 100);
  1239.  
  1240. setTimeout(()=>{
  1241.  
  1242. konsole.setTag('[[Fonts Pre-Rendering 2]]');
  1243. konsole.log(123);
  1244. konsole.log('wsd',332, 'ssa');
  1245. konsole.setTag('');
  1246. }, 300);
  1247.  
  1248. setTimeout(()=>{
  1249.  
  1250. konsole.groupEnd();
  1251. konsole.print();
  1252. }, 1000);
  1253.  
  1254. */
  1255.  
  1256. const win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : (this instanceof Window ? this : window);
  1257.  
  1258. // Create a unique key for the script and check if it is already running
  1259. const hkey_script = 'mchbwnoasqph';
  1260. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  1261. win[hkey_script] = true;
  1262.  
  1263. let unexpectedErr = "";
  1264.  
  1265. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  1266.  
  1267. let te4 = setTimeout(() => { }); // dummy; skip timerId only;
  1268. if (te4 < 3) {
  1269. setTimeout(() => { });
  1270. setTimeout(() => { });
  1271. }
  1272.  
  1273. }
  1274.  
  1275. const firstKey = (obj) => {
  1276. for (const key in obj) {
  1277. if (obj.hasOwnProperty(key)) return key;
  1278. }
  1279. return null;
  1280. }
  1281.  
  1282. const firstObjectKey = (obj) => {
  1283. for (const key in obj) {
  1284. if (obj.hasOwnProperty(key) && typeof obj[key] === 'object') return key;
  1285. }
  1286. return null;
  1287. }
  1288.  
  1289. /**
  1290. * Takes in a __SORTED__ array and inserts the provided value into
  1291. * the correct, sorted, position.
  1292. * > https://github.com/bhowell2/binary-insert-js/
  1293. * @param array the sorted array where the provided value needs to be inserted (in order)
  1294. * @param insertValue value to be added to the array
  1295. * @param comparator function that helps determine where to insert the value (
  1296. */
  1297. function binaryInsert(array, insertValue, comparator) {
  1298. let left = 0;
  1299. let right = array.length;
  1300.  
  1301. let z;
  1302. // Directly return if array is empty or the insertValue should be at the end
  1303. if (right === 0 || (z = comparator(array[right - 1], insertValue)) <= 0) {
  1304. array.push(insertValue);
  1305. return array;
  1306. }
  1307.  
  1308. // Check if the insertValue should be at the beginning
  1309. if ((right === 1 ? z : comparator(array[0], insertValue)) >= 0) {
  1310. array.unshift(insertValue);
  1311. return array;
  1312. }
  1313. ++left; --right;
  1314.  
  1315. // Main binary search loop to find the insertion position
  1316. while (left < right) {
  1317. const mid = Math.floor((right + left) / 2);
  1318. const compared = comparator(array[mid], insertValue);
  1319. if (compared < 0) {
  1320. left = mid + 1;
  1321. } else if (compared > 0) {
  1322. right = mid;
  1323. } else {
  1324. // If equal, insert at the mid position
  1325. left = right = mid;
  1326. break;
  1327. }
  1328. }
  1329.  
  1330. // Insertion is always at the right position due to the nature of the binary search
  1331. array.splice(right, 0, insertValue);
  1332. return array;
  1333. }
  1334.  
  1335.  
  1336.  
  1337.  
  1338. class LimitedSizeSet extends Set {
  1339. constructor(n) {
  1340. super();
  1341. this.limit = n;
  1342. }
  1343.  
  1344. add(key) {
  1345. if (!super.has(key)) {
  1346. super.add(key);
  1347. let n = super.size - this.limit;
  1348. if (n > 0) {
  1349. const iterator = super.values();
  1350. do {
  1351. const firstKey = iterator.next().value; // Get the first (oldest) key
  1352. super.delete(firstKey); // Delete the oldest key
  1353. } while (--n > 0)
  1354. }
  1355. }
  1356. }
  1357.  
  1358. removeAdd(key) {
  1359. super.delete(key);
  1360. this.add(key);
  1361. }
  1362.  
  1363. }
  1364.  
  1365.  
  1366. class LimitedSizeMap extends Map {
  1367. constructor(n) {
  1368. super();
  1369. this.limit = n;
  1370. }
  1371.  
  1372. set(key, val) {
  1373. if (!super.has(key)) {
  1374. super.set(key, val);
  1375. let n = super.size - this.limit;
  1376. if (n > 0) {
  1377. const iterator = super.keys();
  1378. do {
  1379. const firstKey = iterator.next().value; // Get the first (oldest) key
  1380. super.delete(firstKey); // Delete the oldest key
  1381. } while (--n > 0)
  1382. }
  1383. }
  1384. }
  1385.  
  1386. removeSet(key, val) {
  1387. super.delete(key);
  1388. this.set(key, val);
  1389. }
  1390.  
  1391. }
  1392.  
  1393. // function removeElementFromArray(arr, index) {
  1394. // if (index >= 0 && index < arr.length) {
  1395. // arr.splice(index, 1);
  1396. // }
  1397. // }
  1398.  
  1399. // function getRandomInt(a, b) {
  1400. // // Ensure that 'a' and 'b' are integers
  1401. // a = Math.ceil(a);
  1402. // b = Math.floor(b);
  1403.  
  1404. // // Generate a random integer in the range [a, b]
  1405. // return Math.floor(Math.random() * (b - a + 1)) + a;
  1406. // }
  1407.  
  1408. function deepCopy(obj, skipKeys) {
  1409. skipKeys = skipKeys || [];
  1410. if (!obj || typeof obj !== 'object') return obj;
  1411. if (Array.isArray(obj)) {
  1412. return obj.map(item => deepCopy(item, skipKeys));
  1413. }
  1414. const copy = {};
  1415. for (let key in obj) {
  1416. if (!skipKeys.includes(key)) {
  1417. copy[key] = deepCopy(obj[key], skipKeys);
  1418. }
  1419. }
  1420. return copy;
  1421. }
  1422.  
  1423. class Mutex {
  1424.  
  1425. constructor() {
  1426. this.p = Promise.resolve()
  1427. }
  1428.  
  1429. /**
  1430. * @param {(lockResolve: () => void)} f
  1431. */
  1432. lockWith(f) {
  1433. this.p = this.p.then(() => new Promise(f).catch(console.warn))
  1434. }
  1435.  
  1436. }
  1437.  
  1438. const PromiseExternal = ((resolve_, reject_) => {
  1439. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  1440. return class PromiseExternal extends Promise {
  1441. constructor(cb = h) {
  1442. super(cb);
  1443. if (cb === h) {
  1444. /** @type {(value: any) => void} */
  1445. this.resolve = resolve_;
  1446. /** @type {(reason?: any) => void} */
  1447. this.reject = reject_;
  1448. }
  1449. }
  1450. };
  1451. })();
  1452.  
  1453.  
  1454. const createPipeline = () => {
  1455. let pipelineMutex = Promise.resolve();
  1456. const pipelineExecution = fn => {
  1457. return new Promise((resolve, reject) => {
  1458. pipelineMutex = pipelineMutex.then(async () => {
  1459. let res;
  1460. try {
  1461. res = await fn();
  1462. } catch (e) {
  1463. console.log('error_F1', e);
  1464. reject(e);
  1465. }
  1466. resolve(res);
  1467. }).catch(console.warn);
  1468. });
  1469. };
  1470. return pipelineExecution;
  1471. };
  1472.  
  1473. const tickerPE = createPipeline();
  1474.  
  1475. /** @type {typeof PromiseExternal.prototype | null} */
  1476. let relayPromise = null;
  1477.  
  1478.  
  1479. /** @type {typeof PromiseExternal.prototype | null} */
  1480. let onPlayStateChangePromise = null;
  1481.  
  1482.  
  1483.  
  1484.  
  1485. const valAssign = (elm, attr, val) => {
  1486. if (typeof val === 'number') val = val.toFixed(3);
  1487. if (!(Math.abs(elm.style.getPropertyValue(attr) - val) < 1e-5)) {
  1488. elm.style.setProperty(attr, val);
  1489. return true;
  1490. }
  1491. return false;
  1492. };
  1493.  
  1494. let playEventsStack = Promise.resolve();
  1495.  
  1496.  
  1497. let playerProgressChangedArg1 = null;
  1498. let playerProgressChangedArg2 = null;
  1499. let playerProgressChangedArg3 = null;
  1500.  
  1501. let dntElementWeak = null;
  1502.  
  1503.  
  1504. let timestampUnderLiveMode = false;
  1505.  
  1506. const updateTickerCurrentTime = () => {
  1507.  
  1508. if(resistanceUpdateDebugMode){
  1509. console.log('updateTickerCurrentTime')
  1510.  
  1511. if(!dntElementWeak || !kRef(dntElementWeak)) dntElementWeak = mWeakRef(document.querySelector('yt-live-chat-ticker-renderer'));
  1512. timestampUnderLiveMode = true;
  1513. }
  1514.  
  1515. const dntElement = kRef(dntElementWeak);
  1516. const v = timestampUnderLiveMode ? (Date.now() / 1000 - timeOriginDT / 1000) : playerProgressChangedArg1;
  1517. if (dntElement instanceof HTMLElement && v >= 0) {
  1518. valAssign(dntElement, '--ticker-current-time', v);
  1519. }
  1520. }
  1521.  
  1522. // ================== FOR USE_ADVANCED_TICKING ================
  1523.  
  1524. const timeOriginDT = +new Date(performance.timeOrigin);
  1525. let startResistanceUpdaterStarted = false;
  1526.  
  1527. const RESISTANCE_UPDATE_OPT = 3;
  1528. let resistanceUpdateLast = 0;
  1529. let resistanceUpdateBusy = false;
  1530. let resistanceUpdateRetry = false;
  1531. const resistanceUpdateDebugMode = false;
  1532. const allBackgroundOverLays = document.getElementsByTagName('ticker-bg-overlay');
  1533. const rgFlag = {};
  1534. const resistanceUpdateFn = (b) => {
  1535. if(b !== rgFlag && resistanceUpdateRetry === false) return;
  1536. if (!resistanceUpdateDebugMode && allBackgroundOverLays.length === 0) return;
  1537. resistanceUpdateBusy = false;
  1538. const t = Date.now();
  1539. const d = t - resistanceUpdateLast;
  1540. if (d > 375) {
  1541. resistanceUpdateLast = t;
  1542. resistanceUpdateRetry = false;
  1543. updateTickerCurrentTime();
  1544. } else if (typeof requestIdleCallback === 'function') {
  1545. resistanceUpdateRetry = true;
  1546. requestIdleCallback(resistanceUpdateFn);
  1547. } else {
  1548. resistanceUpdateRetry = true;
  1549. setTimeout(resistanceUpdateFn, d + 17);
  1550. }
  1551. }
  1552. const resistanceUpdateFn_ = ()=>{
  1553. if (!resistanceUpdateBusy) {
  1554. resistanceUpdateBusy = true;
  1555. resistanceUpdateRetry = false;
  1556. Promise.resolve(rgFlag).then(resistanceUpdateFn);
  1557. }
  1558. }
  1559. const startResistanceUpdater = () => {
  1560.  
  1561. if (startResistanceUpdaterStarted) return;
  1562. startResistanceUpdaterStarted = true;
  1563.  
  1564.  
  1565. if (RESISTANCE_UPDATE_OPT & 1)
  1566. document.addEventListener('yt-action', () => {
  1567. resistanceUpdateFn_();
  1568. }, true)
  1569.  
  1570. if (RESISTANCE_UPDATE_OPT & 2)
  1571. new MutationObserver(() => {
  1572. resistanceUpdateFn_();
  1573. }).observe(document, {
  1574. subtree: true, childList: true, attributes: true
  1575. });
  1576. resistanceUpdateFn_();
  1577. }
  1578.  
  1579. if(resistanceUpdateDebugMode) startResistanceUpdater();
  1580.  
  1581.  
  1582. function dr(s) {
  1583. // reserved for future use
  1584. return s;
  1585. // return window.deWeakJS ? window.deWeakJS(s) : s;
  1586. }
  1587.  
  1588. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  1589. const indr = o => insp(o).$ || o.$ || 0;
  1590.  
  1591. const getProto = (element) => {
  1592. if (element) {
  1593. const cnt = insp(element);
  1594. return cnt.constructor.prototype || null;
  1595. }
  1596. return null;
  1597. }
  1598.  
  1599. const assertor = (f) => f() || console.assert(false, f + "");
  1600.  
  1601. const fnIntegrity = (f, d) => {
  1602.  
  1603.  
  1604. if (!f || typeof f !== 'function') {
  1605. console.warn('f is not a function', f);
  1606. return;
  1607. }
  1608. // return; // M44
  1609. let p = `${f}`, s = 0, j = -1, w = 0;
  1610. // return; // M44
  1611. for (let i = 0, l = p.length; i < l; i++) {
  1612. const t = p[i];
  1613. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  1614. if (j < i - 1) w++;
  1615. j = i;
  1616. } else {
  1617. s++;
  1618. }
  1619. }
  1620. // if(p.length > 44 && p.length < 50){
  1621.  
  1622. // (window.skam|| (window.skam=[])).push(p);
  1623. // return false;
  1624. // }
  1625.  
  1626. // if(p.length > 405 && p.length < 415 ){ //350 450
  1627.  
  1628.  
  1629. // //  [353, 411, 411, 411]
  1630.  
  1631. // // if(p.length >= 350 && p.length<=450){
  1632.  
  1633. // // (window.skam|| (window.skam=[])).push(p.length);
  1634. // // }
  1635. // (window.skam|| (window.skam=[])).push(p);
  1636. // return false;
  1637. // }
  1638.  
  1639. // if(p.length < 50) return true; else return false;
  1640. // return; // M44
  1641. let itz = `${f.length}.${s}.${w}`;
  1642. if (!d) {
  1643. return itz;
  1644. } else if (itz !== d) {
  1645. console.warn('fnIntegrity=false', itz);
  1646. return false;
  1647. } else {
  1648. return true;
  1649. }
  1650. }
  1651.  
  1652.  
  1653. const px2cm = (px) => px * window.devicePixelRatio * 0.026458333;
  1654. const px2mm = (px) => px * window.devicePixelRatio * 0.26458333;
  1655.  
  1656.  
  1657. ; (ENABLE_FLAGS_MAINTAIN_STABLE_LIST || ENABLE_FLAGS_REUSE_COMPONENTS || DISABLE_FLAGS_SHADYDOM_FREE) && (() => {
  1658.  
  1659. const _config_ = () => {
  1660. try {
  1661. return ytcfg.data_;
  1662. } catch (e) { }
  1663. return null;
  1664. };
  1665.  
  1666. const flagsFn = (EXPERIMENT_FLAGS) => {
  1667.  
  1668. // console.log(700)
  1669.  
  1670. if (!EXPERIMENT_FLAGS) return;
  1671.  
  1672. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST) {
  1673. if (USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true : true) {
  1674. // EXPERIMENT_FLAGS.kevlar_tuner_should_test_maintain_stable_list = true; // timestamp toggle issue
  1675. EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list = true;
  1676. // console.log(701)
  1677. }
  1678. }
  1679.  
  1680. if (ENABLE_FLAGS_REUSE_COMPONENTS) {
  1681. EXPERIMENT_FLAGS.kevlar_tuner_should_test_reuse_components = true;
  1682. EXPERIMENT_FLAGS.kevlar_tuner_should_reuse_components = true;
  1683. // console.log(702);
  1684. }
  1685.  
  1686. if (DISABLE_FLAGS_SHADYDOM_FREE) {
  1687. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_node_methods = false;
  1688. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_query_methods = false;
  1689. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_readonly_properties_batch_one = false;
  1690. EXPERIMENT_FLAGS.enable_shadydom_free_parent_node = false;
  1691. EXPERIMENT_FLAGS.enable_shadydom_free_children = false;
  1692. EXPERIMENT_FLAGS.enable_shadydom_free_last_child = false;
  1693. }
  1694.  
  1695. // EXPERIMENT_FLAGS.enable_button_behavior_reuse = false;
  1696.  
  1697. };
  1698.  
  1699. const uf = (config_) => {
  1700. config_ = config_ || _config_();
  1701. if (config_) {
  1702. const { EXPERIMENT_FLAGS, EXPERIMENTS_FORCED_FLAGS } = config_;
  1703. if (EXPERIMENT_FLAGS) {
  1704. flagsFn(EXPERIMENT_FLAGS);
  1705. if (EXPERIMENTS_FORCED_FLAGS) flagsFn(EXPERIMENTS_FORCED_FLAGS);
  1706. }
  1707. }
  1708. }
  1709.  
  1710. window._ytConfigHacks.add((config_) => {
  1711. uf(config_);
  1712. });
  1713.  
  1714. uf();
  1715.  
  1716. })();
  1717.  
  1718. if (DISABLE_Translation_By_Google) {
  1719.  
  1720. let mo = new MutationObserver(() => {
  1721.  
  1722. if (!mo) return;
  1723. let h = document.head;
  1724. if (!h) return;
  1725. mo.disconnect();
  1726. mo.takeRecords();
  1727. mo = null;
  1728.  
  1729. let meta = document.createElement('meta');
  1730. meta.setAttribute('name', 'google');
  1731. meta.setAttribute('content', 'notranslate');
  1732. h.appendChild(meta);
  1733.  
  1734.  
  1735. });
  1736. mo.observe(document, { subtree: true, childList: true });
  1737. }
  1738.  
  1739.  
  1740. console.assert(MAX_ITEMS_FOR_TOTAL_DISPLAY > 0 && MAX_ITEMS_FOR_FULL_FLUSH > 0 && MAX_ITEMS_FOR_TOTAL_DISPLAY > MAX_ITEMS_FOR_FULL_FLUSH)
  1741.  
  1742. const isContainSupport = CSS.supports('contain', 'layout paint style');
  1743. if (!isContainSupport) {
  1744. console.warn("Your browser does not support css property 'contain'.\nPlease upgrade to the latest version.".trim());
  1745. }
  1746.  
  1747. const isOverflowAnchorSupport = CSS.supports('overflow-anchor', 'auto');
  1748. if (!isOverflowAnchorSupport) {
  1749. console.warn("Your browser does not support css property 'overflow-anchor'.\nPlease upgrade to the latest version.".trim());
  1750. }
  1751.  
  1752. const ENABLE_OVERFLOW_ANCHOR = ENABLE_OVERFLOW_ANCHOR_PREFERRED && isOverflowAnchorSupport && ENABLE_NO_SMOOTH_TRANSFORM;
  1753.  
  1754. let hasTimerModified = null;
  1755. const DO_CHECK_TICKER_BACKGROUND_OVERRIDED = !!ATTEMPT_ANIMATED_TICKER_BACKGROUND || ENABLE_RAF_HACK_TICKERS;
  1756.  
  1757. const fxOperator = (proto, propertyName) => {
  1758. let propertyDescriptorGetter = null;
  1759. try {
  1760. propertyDescriptorGetter = Object.getOwnPropertyDescriptor(proto, propertyName).get;
  1761. } catch (e) { }
  1762. return typeof propertyDescriptorGetter === 'function' ? (e) => {
  1763. try {
  1764.  
  1765. return propertyDescriptorGetter.call(dr(e));
  1766. } catch (e) { }
  1767. return e[propertyName];
  1768. } : (e) => e[propertyName];
  1769. };
  1770.  
  1771. const nodeParent = fxOperator(Node.prototype, 'parentNode');
  1772. // const nFirstElem = fxOperator(HTMLElement.prototype, 'firstElementChild');
  1773. const nPrevElem = fxOperator(HTMLElement.prototype, 'previousElementSibling');
  1774. const nNextElem = fxOperator(HTMLElement.prototype, 'nextElementSibling');
  1775. const nLastElem = fxOperator(HTMLElement.prototype, 'lastElementChild');
  1776.  
  1777. const groupCollapsed = (text1, text2) => {
  1778.  
  1779. console.groupCollapsed(`%c${text1}%c${text2}`,
  1780. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;",
  1781. "background-color: #010502; color: #6ad9fe; font-weight: 300; padding: 2px;"
  1782. );
  1783. }
  1784.  
  1785. // const microNow = () => performance.now() + (performance.timeOrigin || performance.timing.navigationStart);
  1786.  
  1787.  
  1788. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  1789. const onRegistryReady = (callback) => {
  1790. if (typeof customElements === 'undefined') {
  1791. if (!('__CE_registry' in document)) {
  1792. // https://github.com/webcomponents/polyfills/
  1793. Object.defineProperty(document, '__CE_registry', {
  1794. get() {
  1795. // return undefined
  1796. },
  1797. set(nv) {
  1798. if (typeof nv == 'object') {
  1799. delete this.__CE_registry;
  1800. this.__CE_registry = nv;
  1801. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  1802. }
  1803. return true;
  1804. },
  1805. enumerable: false,
  1806. configurable: true
  1807. })
  1808. }
  1809. let eventHandler = (evt) => {
  1810. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1811. const f = callback;
  1812. callback = null;
  1813. eventHandler = null;
  1814. f();
  1815. };
  1816. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1817. } else {
  1818. callback();
  1819. }
  1820. };
  1821.  
  1822. const promiseForCustomYtElementsReady = new Promise(onRegistryReady);
  1823.  
  1824. const renderReadyPn = typeof ResizeObserver !== 'undefined' ? (sizingTarget) => {
  1825.  
  1826. return new Promise(resolve => {
  1827.  
  1828. let ro = new ResizeObserver(entries => {
  1829. if (entries && entries.length >= 1) {
  1830. resolve();
  1831. ro.disconnect();
  1832. ro = null;
  1833. }
  1834. });
  1835. ro.observe(sizingTarget);
  1836.  
  1837.  
  1838.  
  1839. });
  1840.  
  1841. } : (sizingTarget) => {
  1842.  
  1843.  
  1844. return new Promise(resolve => {
  1845.  
  1846. let io = new IntersectionObserver(entries => {
  1847. if (entries && entries.length >= 1) {
  1848. resolve();
  1849. io.disconnect();
  1850. io = null;
  1851. }
  1852. });
  1853. io.observe(sizingTarget);
  1854.  
  1855.  
  1856.  
  1857. });
  1858.  
  1859. };
  1860.  
  1861. /* globals WeakRef:false */
  1862.  
  1863. /** @type {(o: Object | null) => WeakRef | null} */
  1864. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  1865.  
  1866. /** @type {(wr: Object | null) => Object | null} */
  1867. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  1868.  
  1869. const getLCRDummy = () => {
  1870. // direct createElement or createComponent_ will make the emoji rendering crashed. reason TBC
  1871.  
  1872. return Promise.all([customElements.whenDefined('yt-live-chat-app'), customElements.whenDefined('yt-live-chat-renderer')]).then(async () => {
  1873.  
  1874. const tag = "yt-live-chat-renderer"
  1875. let dummy = document.querySelector(tag);
  1876. if (!dummy) {
  1877.  
  1878. let mo = null;
  1879.  
  1880. const ytLiveChatApp = document.querySelector('yt-live-chat-app') || document.createElement('yt-live-chat-app');
  1881.  
  1882. const lcaProto = getProto(ytLiveChatApp);
  1883.  
  1884. dummy = await new Promise(resolve => {
  1885.  
  1886. if (typeof lcaProto.createComponent_ === 'function' && !lcaProto.createComponent99_) {
  1887.  
  1888. lcaProto.createComponent99_ = lcaProto.createComponent_;
  1889. lcaProto.createComponent98_ = function (a, b, c) {
  1890. // (3) ['yt-live-chat-renderer', {…}, true]
  1891. const r = this.createComponent99_.apply(this, arguments);
  1892. if (a === 'yt-live-chat-renderer') {
  1893. resolve(r);
  1894. }
  1895. return r;
  1896. };
  1897. lcaProto.createComponent_ = lcaProto.createComponent98_;
  1898.  
  1899. } else {
  1900.  
  1901. mo = new MutationObserver(() => {
  1902. const t = document.querySelector(tag);
  1903. if (t) {
  1904. resolve(t);
  1905. }
  1906. });
  1907. mo.observe(document, { subtree: true, childList: true })
  1908. }
  1909.  
  1910. });
  1911.  
  1912. if (mo) {
  1913. mo.disconnect();
  1914. mo.takeRecords();
  1915. mo = null;
  1916. }
  1917.  
  1918. if (lcaProto.createComponent99_ && lcaProto.createComponent_ && lcaProto.createComponent98_ === lcaProto.createComponent_) {
  1919. lcaProto.createComponent_ = lcaProto.createComponent99_;
  1920. lcaProto.createComponent99_ = null;
  1921. lcaProto.createComponent98_ = null;
  1922. }
  1923.  
  1924. }
  1925. return dummy;
  1926.  
  1927. });
  1928. }
  1929.  
  1930. const { addCssManaged } = (() => {
  1931.  
  1932. const addFontPreRendering = () => {
  1933.  
  1934. groupCollapsed("YouTube Super Fast Chat", " | Fonts Pre-Rendering");
  1935.  
  1936. let efsContainer = document.createElement('elzm-fonts');
  1937. efsContainer.id = 'elzm-fonts-yk75g'
  1938.  
  1939. const arr = [];
  1940. let p = document.createElement('elzm-font');
  1941. arr.push(p);
  1942.  
  1943. if (ENABLE_FONT_PRE_RENDERING & 1) {
  1944. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1945.  
  1946. p = document.createElement('elzm-font');
  1947. p.style.fontWeight = size;
  1948. arr.push(p);
  1949. }
  1950. }
  1951.  
  1952. if (ENABLE_FONT_PRE_RENDERING & 2) {
  1953. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1954.  
  1955. p = document.createElement('elzm-font');
  1956. p.style.fontFamily = 'Roboto';
  1957. p.style.fontWeight = size;
  1958. arr.push(p);
  1959. }
  1960. }
  1961.  
  1962. if (ENABLE_FONT_PRE_RENDERING & 4) {
  1963. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1964.  
  1965. p = document.createElement('elzm-font');
  1966. p.style.fontFamily = '"YouTube Noto",Roboto,Arial,Helvetica,sans-serif';
  1967. p.style.fontWeight = size;
  1968. arr.push(p);
  1969. }
  1970. }
  1971.  
  1972.  
  1973. if (ENABLE_FONT_PRE_RENDERING & 8) {
  1974. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1975.  
  1976. p = document.createElement('elzm-font');
  1977. p.style.fontFamily = '"Noto",Roboto,Arial,Helvetica,sans-serif';
  1978. p.style.fontWeight = size;
  1979. arr.push(p);
  1980. }
  1981. }
  1982.  
  1983.  
  1984. if (ENABLE_FONT_PRE_RENDERING & 16) {
  1985. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1986.  
  1987. p = document.createElement('elzm-font');
  1988. p.style.fontFamily = 'sans-serif';
  1989. p.style.fontWeight = size;
  1990. arr.push(p);
  1991. }
  1992. }
  1993.  
  1994. console.log('number of elzm-font elements', arr.length);
  1995.  
  1996. HTMLElement.prototype.append.apply(efsContainer, arr);
  1997.  
  1998. (document.body || document.documentElement).appendChild(efsContainer);
  1999.  
  2000.  
  2001. console.log('elzm-font elements have been added to the page for rendering.');
  2002.  
  2003. console.groupEnd();
  2004.  
  2005. }
  2006.  
  2007. let isCssAdded = false;
  2008.  
  2009. function addCssElement() {
  2010. let s = document.createElement('style');
  2011. s.id = 'ewRvC';
  2012. return s;
  2013. }
  2014.  
  2015. const addCssManaged = () => {
  2016. if (!isCssAdded && document.documentElement && document.head) {
  2017. isCssAdded = true;
  2018. document.head.appendChild(dr(addCssElement())).textContent = addCss();
  2019. if (ENABLE_FONT_PRE_RENDERING) {
  2020. Promise.resolve().then(addFontPreRendering)
  2021. }
  2022. }
  2023. }
  2024.  
  2025. return { addCssManaged };
  2026. })();
  2027.  
  2028.  
  2029. const { setupStyle } = (() => {
  2030.  
  2031. const sp7 = Symbol();
  2032.  
  2033. const proxyHelperFn = (dummy) => ({
  2034.  
  2035. get(target, prop) {
  2036. return (prop in dummy) ? dummy[prop] : prop === sp7 ? target : target[prop];
  2037. },
  2038. set(target, prop, value) {
  2039. if (!(prop in dummy)) {
  2040. target[prop] = value;
  2041. }
  2042. return true;
  2043. },
  2044. has(target, prop) {
  2045. return (prop in target);
  2046. },
  2047. deleteProperty(target, prop) {
  2048. return true;
  2049. },
  2050. ownKeys(target) {
  2051. return Object.keys(target);
  2052. },
  2053. defineProperty(target, key, descriptor) {
  2054. return Object.defineProperty(target, key, descriptor);
  2055. },
  2056. getOwnPropertyDescriptor(target, key) {
  2057. return Object.getOwnPropertyDescriptor(target, key);
  2058. },
  2059.  
  2060. });
  2061.  
  2062. const setupStyle = (m1, m2) => {
  2063. if (!ENABLE_NO_SMOOTH_TRANSFORM) return;
  2064.  
  2065. const dummy1v = {
  2066. transform: '',
  2067. height: '',
  2068. minHeight: '',
  2069. paddingBottom: '',
  2070. paddingTop: ''
  2071. };
  2072.  
  2073. const dummyStyleFn = (k) => (function () { const style = this[sp7]; return style[k](...arguments); });
  2074. for (const k of ['toString', 'getPropertyPriority', 'getPropertyValue', 'item', 'removeProperty', 'setProperty']) {
  2075. dummy1v[k] = dummyStyleFn(k);
  2076. }
  2077.  
  2078. const dummy1p = proxyHelperFn(dummy1v);
  2079. const sp1v = new Proxy(m1.style, dummy1p);
  2080. const sp2v = new Proxy(m2.style, dummy1p);
  2081. Object.defineProperty(m1, 'style', { get() { return sp1v }, set() { }, enumerable: true, configurable: true });
  2082. Object.defineProperty(m2, 'style', { get() { return sp2v }, set() { }, enumerable: true, configurable: true });
  2083. m1.removeAttribute("style");
  2084. m2.removeAttribute("style");
  2085.  
  2086. }
  2087.  
  2088. return { setupStyle };
  2089.  
  2090. })();
  2091.  
  2092.  
  2093.  
  2094. function setThumbnails(config) {
  2095.  
  2096. const { baseObject, thumbnails, flag0, imageLinks } = config;
  2097.  
  2098. if (flag0 || (ENABLE_PRELOAD_THUMBNAIL && imageLinks)) {
  2099.  
  2100.  
  2101. if (thumbnails && thumbnails.length > 0) {
  2102. if (flag0 > 0 && thumbnails.length > 1) {
  2103. let pSize = 0;
  2104. let newThumbnails = [];
  2105. for (const thumbnail of thumbnails) {
  2106. if (!thumbnail || !thumbnail.url) continue;
  2107. const squarePhoto = thumbnail.width === thumbnail.height && typeof thumbnail.width === 'number';
  2108. const condSize = pSize <= 0 || (flag0 === 1 ? pSize > thumbnail.width : pSize < thumbnail.width);
  2109. const leastSizeFulfilled = squarePhoto ? thumbnail.width >= LEAST_IMAGE_SIZE : true;
  2110. if ((!squarePhoto || condSize) && leastSizeFulfilled) {
  2111. newThumbnails.push(thumbnail);
  2112. if (imageLinks) imageLinks.add(thumbnail.url);
  2113. }
  2114. if (squarePhoto && condSize && leastSizeFulfilled) {
  2115. pSize = thumbnail.width;
  2116. }
  2117. }
  2118. if (thumbnails.length !== newThumbnails.length && thumbnails === baseObject.thumbnails && newThumbnails.length > 0) {
  2119. baseObject.thumbnails = newThumbnails;
  2120. } else {
  2121. newThumbnails.length = 0;
  2122. }
  2123. newThumbnails = null;
  2124. } else {
  2125. for (const thumbnail of thumbnails) {
  2126. if (thumbnail && thumbnail.url) {
  2127. if (imageLinks) imageLinks.add(thumbnail.url);
  2128. }
  2129. }
  2130. }
  2131. }
  2132.  
  2133. }
  2134. }
  2135.  
  2136. function fixLiveChatItem(item, imageLinks) {
  2137. const liveChatTextMessageRenderer = (item || 0).liveChatTextMessageRenderer || 0;
  2138. if (liveChatTextMessageRenderer) {
  2139. const messageRuns = (liveChatTextMessageRenderer.message || 0).runs || 0;
  2140. if (messageRuns && messageRuns.length > 0) {
  2141. for (const run of messageRuns) {
  2142. const emojiImage = (((run || 0).emoji || 0).image || 0);
  2143. setThumbnails({
  2144. baseObject: emojiImage,
  2145. thumbnails: emojiImage.thumbnails,
  2146. flag0: EMOJI_IMAGE_SINGLE_THUMBNAIL,
  2147. imageLinks
  2148. });
  2149. }
  2150. }
  2151. const authorPhoto = liveChatTextMessageRenderer.authorPhoto || 0;
  2152. setThumbnails({
  2153. baseObject: authorPhoto,
  2154. thumbnails: authorPhoto.thumbnails,
  2155. flag0: AUTHOR_PHOTO_SINGLE_THUMBNAIL,
  2156. imageLinks
  2157. });
  2158. }
  2159. }
  2160.  
  2161.  
  2162.  
  2163. let kptPF = null;
  2164. const emojiPrefetched = new LimitedSizeSet(PREFETCH_LIMITED_SIZE_EMOJI);
  2165. const authorPhotoPrefetched = new LimitedSizeSet(PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO);
  2166.  
  2167. function linker(link, rel, href, _as) {
  2168. return new Promise(resolve => {
  2169. if (!link) link = document.createElement('link');
  2170. link.rel = rel;
  2171. if (_as) link.setAttribute('as', _as);
  2172. link.onload = function () {
  2173. resolve({
  2174. link: this,
  2175. success: true
  2176. })
  2177. this.remove();
  2178. };
  2179. link.onerror = function () {
  2180. resolve({
  2181. link: this,
  2182. success: false
  2183. });
  2184. this.remove();
  2185. };
  2186. link.href = href;
  2187. document.head.appendChild(link);
  2188. link = null;
  2189. });
  2190. }
  2191.  
  2192.  
  2193.  
  2194. const cleanContext = async (win) => {
  2195. const waitFn = requestAnimationFrame; // shall have been binded to window
  2196. try {
  2197. let mx = 16; // MAX TRIAL
  2198. const frameId = 'vanillajs-iframe-v1';
  2199. /** @type {HTMLIFrameElement | null} */
  2200. let frame = document.getElementById(frameId);
  2201. let removeIframeFn = null;
  2202. if (!frame) {
  2203. frame = document.createElement('iframe');
  2204. frame.id = frameId;
  2205. const blobURL = typeof webkitCancelAnimationFrame === 'function' && typeof kagi === 'undefined' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  2206. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  2207. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  2208. n.appendChild(frame);
  2209. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  2210. const root = document.documentElement;
  2211. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  2212. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  2213.  
  2214. removeIframeFn = (setTimeout) => {
  2215. const removeIframeOnDocumentReady = (e) => {
  2216. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2217. e = n;
  2218. n = win = removeIframeFn = 0;
  2219. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  2220. }
  2221. if (!setTimeout || document.readyState !== 'loading') {
  2222. removeIframeOnDocumentReady();
  2223. } else {
  2224. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2225. }
  2226. }
  2227. }
  2228. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  2229. const fc = frame.contentWindow;
  2230. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  2231. try {
  2232. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, getComputedStyle } = fc;
  2233. const res = { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, getComputedStyle };
  2234. for (let k in res) res[k] = res[k].bind(win); // necessary
  2235. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  2236.  
  2237. /** @type {HTMLElement} */
  2238. const HTMLElementProto = fc.HTMLElement.prototype;
  2239. /** @type {EventTarget} */
  2240. const EventTargetProto = fc.EventTarget.prototype;
  2241. // jsonParseFix = {
  2242. // _JSON: fc.JSON, _parse: fc.JSON.parse
  2243. // }
  2244. return {
  2245. ...res,
  2246. animate: HTMLElementProto.animate,
  2247. addEventListener: EventTargetProto.addEventListener,
  2248. removeEventListener: EventTargetProto.removeEventListener
  2249. };
  2250. } catch (e) {
  2251. if (removeIframeFn) removeIframeFn();
  2252. return null;
  2253. }
  2254. } catch (e) {
  2255. console.warn(e);
  2256. return null;
  2257. }
  2258. };
  2259.  
  2260.  
  2261. let xoIcjPr = null;
  2262. window.addEventListener('message', (evt) => {
  2263. if ((evt || 0).data === 'xoIcj' && xoIcjPr !== null) xoIcjPr.resolve();
  2264. });
  2265. const timelineResolve = async () => {
  2266. if (xoIcjPr !== null) {
  2267. await xoIcjPr.then();
  2268. return;
  2269. }
  2270. xoIcjPr = new PromiseExternal();
  2271. window.postMessage('xoIcj');
  2272. await xoIcjPr.then();
  2273. xoIcjPr = null;
  2274. }
  2275.  
  2276. cleanContext(win).then(__CONTEXT__ => {
  2277. if (!__CONTEXT__) return null;
  2278.  
  2279. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, getComputedStyle, addEventListener, removeEventListener } = __CONTEXT__;
  2280.  
  2281. const wmComputedStyle = new WeakMap();
  2282. const getComputedStyleCached = (elem) => {
  2283. let cs = wmComputedStyle.get(elem);
  2284. if (!cs) {
  2285. cs = getComputedStyle(elem);
  2286. wmComputedStyle.set(elem, cs);
  2287. }
  2288. return cs;
  2289. }
  2290.  
  2291.  
  2292. const isGPUAccelerationAvailable = (() => {
  2293. // https://gist.github.com/cvan/042b2448fcecefafbb6a91469484cdf8
  2294. try {
  2295. const canvas = document.createElement('canvas');
  2296. return !!(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
  2297. } catch (e) {
  2298. return false;
  2299. }
  2300. })();
  2301.  
  2302. const foregroundPromiseFn_noGPU = (() => {
  2303.  
  2304. if (isGPUAccelerationAvailable) return null;
  2305.  
  2306. const pd = Object.getOwnPropertyDescriptor(Document.prototype, 'visibilityState');
  2307. if (!pd || typeof pd.get !== 'function') return null;
  2308. const pdGet = pd.get;
  2309.  
  2310. let pr = null;
  2311.  
  2312. let hState = pdGet.call(document) === 'hidden';
  2313. // let cid = 0;
  2314. pureAddEventListener.call(document, 'visibilitychange', (evt) => {
  2315. const newHState = pdGet.call(document) === 'hidden';
  2316. if (hState !== newHState) {
  2317. // if (cid > 0) cid = clearInterval(cid);
  2318. hState = newHState;
  2319. if (!hState && pr) pr = pr.resolve();
  2320. }
  2321. });
  2322.  
  2323. // cid = setInterval(() => {
  2324. // const newHState = document.visibilityState === 'hidden';
  2325. // if (hState !== newHState) {
  2326. // hState = newHState;
  2327. // if (!hState && pr) pr = pr.resolve();
  2328. // }
  2329. // }, 100);
  2330.  
  2331.  
  2332. return (() => {
  2333. if (pr) return pr;
  2334. const w = ((!hState && setTimeout(() => {
  2335. if (!hState && pr === w) pr = pr.resolve();
  2336. })), (pr = new PromiseExternal()));
  2337. return w;
  2338. });
  2339.  
  2340. })();
  2341.  
  2342. // window.foregroundPromiseFn_noGPU = foregroundPromiseFn_noGPU;
  2343.  
  2344. let rafPromise = null;
  2345. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  2346. requestAnimationFrame(hRes => {
  2347. rafPromise = null;
  2348. resolve(hRes);
  2349. });
  2350. }));
  2351. const foregroundPromiseFn = foregroundPromiseFn_noGPU || getRafPromise;
  2352.  
  2353. const iAFP = foregroundPromiseFn_noGPU ? foregroundPromiseFn_noGPU : typeof IntersectionObserver === 'undefined' ? getRafPromise : (() => {
  2354.  
  2355. const ioWM = new WeakMap();
  2356. const ek = Symbol();
  2357. /** @type {IntersectionObserverCallback} */
  2358. const ioCb = (entries, observer) => {
  2359. /** @type {PromiseExternal} */
  2360. const pr = observer[ek];
  2361. const resolve = pr.resolve;
  2362. let target;
  2363. if (resolve && (target = ((entries ? entries[0] : 0) || 0).target) instanceof Element) {
  2364. pr.resolve = null;
  2365. observer.unobserve(target);
  2366. resolve();
  2367. }
  2368. };
  2369. /**
  2370. *
  2371. * @param {Element} elm
  2372. * @returns {Promise<void>}
  2373. */
  2374. const iAFP = (elm) => {
  2375. let io = ioWM.get(elm);
  2376. if (!io) {
  2377. io = new IntersectionObserver(ioCb);
  2378. ioWM.set(elm, io); // strong reference
  2379. }
  2380. let pr = io[ek];
  2381. if (!pr) {
  2382. pr = io[ek] = new PromiseExternal();
  2383. io.observe(elm);
  2384. }
  2385. return pr;
  2386. }
  2387.  
  2388. return iAFP;
  2389.  
  2390. })();
  2391.  
  2392. let playerState = null;
  2393. let _playerState = null;
  2394. let lastPlayerProgress = null;
  2395. let relayCount = 0;
  2396. let playerEventsByIframeRelay = false;
  2397. let isPlayProgressTriggered = false;
  2398. let waitForInitialDataCompletion = 0;
  2399.  
  2400.  
  2401.  
  2402. let aeConstructor = null;
  2403.  
  2404. // << __openedChanged82 >>
  2405. let currentMenuPivotWR = null;
  2406.  
  2407. // << if DO_PARTICIPANT_LIST_HACKS >>
  2408. const beforeParticipantsMap = new WeakMap();
  2409. // << end >>
  2410.  
  2411.  
  2412.  
  2413. // << if onRegistryReadyForDOMOperations >>
  2414.  
  2415. let dt0 = Date.now() - 2000;
  2416. const dateNow = () => Date.now() - dt0;
  2417. // let lastScroll = 0;
  2418. // let lastLShow = 0;
  2419. let lastWheel = 0;
  2420. let lastMouseDown = 0;
  2421. let lastMouseUp = 0;
  2422. let currentMouseDown = false;
  2423. let lastTouchDown = 0;
  2424. let lastTouchUp = 0;
  2425. let currentTouchDown = false;
  2426. let lastUserInteraction = 0;
  2427.  
  2428. let scrollChatFn = null;
  2429.  
  2430. let skipDontRender = true; // true first; false by flushActiveItems_
  2431. let allowDontRender = null;
  2432.  
  2433. // ---- #items mutation ----
  2434. let sk35zResolveFn = null;
  2435. let firstList = true;
  2436.  
  2437. // << end >>
  2438.  
  2439. class RAFHub {
  2440. constructor() {
  2441. /** @type {number} */
  2442. this.startAt = 8170;
  2443. /** @type {number} */
  2444. this.counter = 0;
  2445. /** @type {number} */
  2446. this.rid = 0;
  2447. /** @type {Map<number, FrameRequestCallback>} */
  2448. this.funcs = new Map();
  2449. const funcs = this.funcs;
  2450. /** @type {FrameRequestCallback} */
  2451. this.bCallback = this.mCallback.bind(this);
  2452. this.pClear = () => funcs.clear();
  2453. this.keepRAF = false;
  2454. }
  2455. /** @param {DOMHighResTimeStamp} highResTime */
  2456. mCallback(highResTime) {
  2457. this.rid = 0;
  2458. Promise.resolve().then(this.pClear);
  2459. this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  2460. }
  2461. /** @param {FrameRequestCallback} f */
  2462. request(f) {
  2463. if (this.counter > 1e9) this.counter = 9;
  2464. let cid = this.startAt + (++this.counter);
  2465. this.funcs.set(cid, f);
  2466. if (this.rid === 0) this.rid = requestAnimationFrame(this.bCallback);
  2467. return cid;
  2468. }
  2469. /** @param {number} cid */
  2470. cancel(cid) {
  2471. cid = +cid;
  2472. if (cid > 0) {
  2473. if (cid <= this.startAt) {
  2474. return cancelAnimationFrame(cid);
  2475. }
  2476. if (this.rid > 0) {
  2477. this.funcs.delete(cid);
  2478. if (this.funcs.size === 0 && !this.keepRAF) {
  2479. cancelAnimationFrame(this.rid);
  2480. this.rid = 0;
  2481. }
  2482. }
  2483. }
  2484. }
  2485. }
  2486.  
  2487. function basePrefetching() {
  2488.  
  2489. new Promise(resolve => {
  2490.  
  2491. if (document.readyState !== 'loading') {
  2492. resolve();
  2493. } else {
  2494. win.addEventListener("DOMContentLoaded", resolve, false);
  2495. }
  2496.  
  2497. }).then(() => {
  2498. const hostL1 = [
  2499. 'https://www.youtube.com', 'https://googlevideo.com',
  2500. 'https://googleapis.com', 'https://accounts.youtube.com',
  2501. 'https://www.gstatic.com', 'https://ggpht.com',
  2502. 'https://yt3.ggpht.com', 'https://yt4.ggpht.com'
  2503. ];
  2504.  
  2505. const hostL2 = [
  2506. 'https://youtube.com',
  2507. 'https://fonts.googleapis.com', 'https://fonts.gstatic.com'
  2508. ];
  2509.  
  2510. let link = null;
  2511.  
  2512. function kn() {
  2513.  
  2514. link = document.createElement('link');
  2515. if (link.relList && link.relList.supports) {
  2516. 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)
  2517. } else {
  2518. kptPF = 0;
  2519. }
  2520.  
  2521. groupCollapsed("YouTube Super Fast Chat", " | PREFETCH SUPPORTS");
  2522. if (ENABLE_BASE_PREFETCHING) console.log('dns-prefetch', (kptPF & 1) ? 'OK' : 'NG');
  2523. if (ENABLE_BASE_PREFETCHING) console.log('preconnect', (kptPF & 2) ? 'OK' : 'NG');
  2524. if (ENABLE_PRELOAD_THUMBNAIL) console.log('prefetch', (kptPF & 4) ? 'OK' : 'NG');
  2525. // console.log('subresource', (kptPF & 8) ? 'OK' : 'NG');
  2526. if (ENABLE_PRELOAD_THUMBNAIL) console.log('preload', (kptPF & 16) ? 'OK' : 'NG');
  2527. console.groupEnd();
  2528.  
  2529. }
  2530.  
  2531. for (const h of hostL1) {
  2532.  
  2533. if (kptPF === null) kn();
  2534. if (ENABLE_BASE_PREFETCHING) {
  2535. // if (kptPF & 1) {
  2536. // linker(link, 'dns-prefetch', h);
  2537. // link = null;
  2538. // }
  2539. if (kptPF & 2) {
  2540. linker(link, 'preconnect', h);
  2541. link = null;
  2542. }
  2543. }
  2544. }
  2545.  
  2546. for (const h of hostL2) {
  2547. if (kptPF === null) kn();
  2548. if (ENABLE_BASE_PREFETCHING) {
  2549. if (kptPF & 1) {
  2550. linker(link, 'dns-prefetch', h);
  2551. link = null;
  2552. }
  2553. }
  2554. }
  2555.  
  2556. })
  2557.  
  2558.  
  2559. }
  2560.  
  2561. if (DO_LINK_PREFETCH) basePrefetching();
  2562.  
  2563. const { notifyPath7081 } = (() => {
  2564. // DO_PARTICIPANT_LIST_HACKS
  2565.  
  2566. const mutexParticipants = new Mutex();
  2567.  
  2568. let uvid = 0;
  2569. let r95dm = 0;
  2570. let c95dm = -1;
  2571.  
  2572. const foundMap = (base, content) => {
  2573. /*
  2574. let lastSearch = 0;
  2575. let founds = base.map(baseEntry => {
  2576. let search = content.indexOf(baseEntry, lastSearch);
  2577. if (search < 0) return false;
  2578. lastSearch = search + 1;
  2579. return true;
  2580. });
  2581. return founds;
  2582. */
  2583. const contentSet = new Set(content);
  2584. return base.map(baseEntry => contentSet.has(baseEntry));
  2585.  
  2586. }
  2587.  
  2588.  
  2589.  
  2590. let participantsForSpliceWR = null;
  2591.  
  2592. class IndexSpliceEntry {
  2593. /**
  2594. *
  2595. * @param {number} _index
  2596. * @param {number} _addedCount
  2597. * @param {any[]} _removed
  2598. */
  2599. constructor(_index, _addedCount, _removed) {
  2600. this.index = _index;
  2601. this.addedCount = _addedCount;
  2602. this.removed = _removed;
  2603. }
  2604. get __proxy312__() {
  2605. return 1
  2606. }
  2607. get type() {
  2608. return 'splice'
  2609. }
  2610. get object() {
  2611. return kRef(participantsForSpliceWR); // avoid memory leakage
  2612. }
  2613. }
  2614.  
  2615. const spliceIndicesFunc = (beforeParticipants, participants, idsBefore, idsAfter) => {
  2616.  
  2617. let foundsForAfter = foundMap(idsAfter, idsBefore);
  2618. let foundsForBefore = foundMap(idsBefore, idsAfter);
  2619.  
  2620. const nAfter = foundsForAfter.length;
  2621. const nBefore = foundsForBefore.length;
  2622.  
  2623. const indexSplices = [];
  2624. const contentUpdates = [];
  2625. participantsForSpliceWR = null;
  2626. for (let i = 0, j = 0; i < nBefore || j < nAfter;) {
  2627. if (beforeParticipants[i] === participants[j]) {
  2628. i++; j++;
  2629. } else if (idsBefore[i] === idsAfter[j]) {
  2630. // content changed
  2631. contentUpdates.push({ indexI: i, indexJ: j })
  2632. i++; j++;
  2633. } else {
  2634. let addedCount = 0;
  2635. for (let q = j; q < nAfter; q++) {
  2636. if (foundsForAfter[q] === false) addedCount++;
  2637. else break;
  2638. }
  2639. let removedCount = 0;
  2640. for (let q = i; q < nBefore; q++) {
  2641. if (foundsForBefore[q] === false) removedCount++;
  2642. else break;
  2643. }
  2644. if (!addedCount && !removedCount) {
  2645. throw 'ERROR(0xFF32): spliceIndicesFunc';
  2646. }
  2647. const entry = new IndexSpliceEntry(
  2648. j,
  2649. addedCount,
  2650. removedCount >= 1 ? beforeParticipants.slice(i, i + removedCount) : []
  2651. );
  2652. indexSplices.push(entry);
  2653. i += removedCount;
  2654. j += addedCount;
  2655. }
  2656. }
  2657. foundsForBefore = null;
  2658. foundsForAfter = null;
  2659. idsBefore = null;
  2660. idsAfter = null;
  2661. beforeParticipants = null;
  2662. participantsForSpliceWR = indexSplices.length > 0 ? mWeakRef(participants) : null;
  2663. participants = null;
  2664. return { indexSplices, contentUpdates };
  2665.  
  2666. }
  2667.  
  2668. /*
  2669.  
  2670. customElements.get("yt-live-chat-participant-renderer").prototype.notifyPath=function(){ console.log(123); console.log(new Error().stack)}
  2671.  
  2672. VM63631:1 Error
  2673. at customElements.get.notifyPath (<anonymous>:1:122)
  2674. at e.forwardRendererStamperChanges_ (live_chat_polymer.js:4453:35)
  2675. at e.rendererStamperApplyChangeRecord_ (live_chat_polymer.js:4451:12)
  2676. at e.rendererStamperObserver_ (live_chat_polymer.js:4448:149)
  2677. at Object.pu [as fn] (live_chat_polymer.js:1692:118)
  2678. at ju (live_chat_polymer.js:1674:217)
  2679. at a._propertiesChanged (live_chat_polymer.js:1726:122)
  2680. at b._flushProperties (live_chat_polymer.js:1597:200)
  2681. at a._invalidateProperties (live_chat_polymer.js:1718:69)
  2682. at a.notifyPath (live_chat_polymer.js:1741:182)
  2683.  
  2684. */
  2685.  
  2686. function convertToIds(participants) {
  2687. return participants.map(participant => {
  2688. if (!participant || typeof participant !== 'object') {
  2689. console.warn('Error(0xFA41): convertToIds', participant);
  2690. return participant; // just in case
  2691. }
  2692. let keys = Object.keys(participant);
  2693. // liveChatTextMessageRenderer
  2694. // liveChatParticipantRenderer - livestream channel owner [no authorExternalChannelId]
  2695. // liveChatPaidMessageRenderer
  2696. /*
  2697.  
  2698. 'yt-live-chat-participant-renderer' utilizes the following:
  2699. authorName.simpleText: string
  2700. authorPhoto.thumbnails: Object{url:string, width:int, height:int} []
  2701. authorBadges[].liveChatAuthorBadgeRenderer.icon.iconType: string
  2702. authorBadges[].liveChatAuthorBadgeRenderer.tooltip: string
  2703. authorBadges[].liveChatAuthorBadgeRenderer.accessibility.accessibilityData: Object{label:string}
  2704.  
  2705. */
  2706. if (keys.length !== 1) {
  2707. console.warn('Error(0xFA42): convertToIds', participant);
  2708. return participant; // just in case
  2709. }
  2710. let key = keys[0];
  2711. let renderer = (participant[key] || 0);
  2712. let authorName = (renderer.authorName || 0);
  2713. let text = `${authorName.simpleText || authorName.text}`
  2714. let res = participant; // fallback if it is not a vaild entry
  2715. if (typeof text !== 'string') {
  2716. console.warn('Error(0xFA53): convertToIds', participant);
  2717. } else {
  2718. text = `${renderer.authorExternalChannelId || 'null'}|${text || ''}`;
  2719. if (text.length > 1) res = text;
  2720. }
  2721. return res;
  2722. // return renderer?`${renderer.id}|${renderer.authorExternalChannelId}`: '';
  2723. // note: renderer.id will be changed if the user typed something to trigger the update of the participants' record.
  2724. });
  2725. }
  2726.  
  2727. const checkChangeToParticipantRendererContent = CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT ? (p1, p2) => {
  2728. // just update when content is changed.
  2729. if (p1.authorName !== p2.authorName) return true;
  2730. if (p1.authorPhoto !== p2.authorPhoto) return true;
  2731. if (p1.authorBadges !== p2.authorBadges) return true;
  2732. return false;
  2733. } : (p1, p2) => {
  2734. // keep integrity all the time.
  2735. return p1 !== p2; // always true
  2736. }
  2737.  
  2738. function notifyPath7081(path) { // cnt "yt-live-chat-participant-list-renderer"
  2739.  
  2740. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  2741. if (path !== "participantsManager.participants") {
  2742. return this.__notifyPath5036__.apply(this, arguments);
  2743. }
  2744. if (c95dm === r95dm) return;
  2745. } else {
  2746. const stack = new Error().stack;
  2747. if (path !== "participantsManager.participants" || stack.indexOf('.onParticipantsChanged') < 0) {
  2748. return this.__notifyPath5036__.apply(this, arguments);
  2749. }
  2750. }
  2751.  
  2752. if (uvid > 1e8) uvid = uvid % 100;
  2753. let tid = ++uvid;
  2754.  
  2755.  
  2756. // const cnt = this; // "yt-live-chat-participant-list-renderer"
  2757.  
  2758. const wNode = mWeakRef(this);
  2759.  
  2760. mutexParticipants.lockWith(lockResolve => {
  2761.  
  2762. const cnt = kRef(wNode);
  2763.  
  2764. const participants00 = (((cnt || 0).participantsManager || 0).participants || 0);
  2765.  
  2766. if (tid !== uvid || !cnt || typeof (participants00 || 0).splice !== 'function') {
  2767. lockResolve();
  2768. return;
  2769. }
  2770.  
  2771. let doUpdate = false;
  2772.  
  2773. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  2774.  
  2775. if (!participants00.r94dm) {
  2776. participants00.r94dm = 1;
  2777. if (++r95dm > 1e9) r95dm = 9;
  2778. participants00.push = function () {
  2779. if (++r95dm > 1e9) r95dm = 9;
  2780. return Array.prototype.push.apply(this, arguments);
  2781. }
  2782. participants00.pop = function () {
  2783. if (++r95dm > 1e9) r95dm = 9;
  2784. return Array.prototype.pop.apply(this, arguments);
  2785. }
  2786. participants00.shift = function () {
  2787. if (++r95dm > 1e9) r95dm = 9;
  2788. return Array.prototype.shift.apply(this, arguments);
  2789. }
  2790. participants00.unshift = function () {
  2791. if (++r95dm > 1e9) r95dm = 9;
  2792. return Array.prototype.unshift.apply(this, arguments);
  2793. }
  2794. participants00.splice = function () {
  2795. if (++r95dm > 1e9) r95dm = 9;
  2796. return Array.prototype.splice.apply(this, arguments);
  2797. }
  2798. participants00.sort = function () {
  2799. if (++r95dm > 1e9) r95dm = 9;
  2800. return Array.prototype.sort.apply(this, arguments);
  2801. }
  2802. participants00.reverse = function () {
  2803. if (++r95dm > 1e9) r95dm = 9;
  2804. return Array.prototype.reverse.apply(this, arguments);
  2805. }
  2806. }
  2807.  
  2808. if (c95dm !== r95dm) {
  2809. c95dm = r95dm;
  2810. doUpdate = true;
  2811. }
  2812.  
  2813. } else {
  2814. doUpdate = true;
  2815. }
  2816.  
  2817. if (!doUpdate) {
  2818. lockResolve();
  2819. return;
  2820. }
  2821.  
  2822. const participants = participants00.slice(0);
  2823. const beforeParticipants = beforeParticipantsMap.get(cnt) || [];
  2824. beforeParticipantsMap.set(cnt, participants);
  2825.  
  2826. const resPromise = (async () => {
  2827.  
  2828. if (beforeParticipants.length === 0) {
  2829. // not error
  2830. return 0;
  2831. }
  2832.  
  2833. let countOfElements = cnt.__getAllParticipantsDOMRenderedLength__()
  2834.  
  2835. // console.log(participants.length, doms.length) // different if no requestAnimationFrame
  2836. if (beforeParticipants.length !== countOfElements) {
  2837. // there is somewrong for the cache. - sometimes happen
  2838. return 0;
  2839. }
  2840.  
  2841. const idsBefore = convertToIds(beforeParticipants);
  2842. const idsAfter = convertToIds(participants);
  2843.  
  2844. let { indexSplices, contentUpdates } = spliceIndicesFunc(beforeParticipants, participants, idsBefore, idsAfter);
  2845.  
  2846. let res = 1; // default 1 for no update
  2847.  
  2848. if (indexSplices.length >= 1) {
  2849.  
  2850.  
  2851. // let p2 = participants.slice(indexSplices[0].index, indexSplices[0].index+indexSplices[0].addedCount);
  2852. // let p1 = indexSplices[0].removed;
  2853. // console.log(indexSplices.length, indexSplices ,p1,p2, convertToIds(p1),convertToIds(p2))
  2854.  
  2855. /* folllow
  2856. a.notifyPath(c + ".splices", d);
  2857. a.notifyPath(c + ".length", b.length);
  2858. */
  2859. // stampDomArraySplices_
  2860.  
  2861.  
  2862. await new Promise(resolve => {
  2863. cnt.resolveForDOMRendering781 = resolve;
  2864.  
  2865. cnt.__notifyPath5036__("participantsManager.participants.splices", {
  2866. indexSplices
  2867. });
  2868. indexSplices = null;
  2869. participantsForSpliceWR = null;
  2870. cnt.__notifyPath5036__("participantsManager.participants.length",
  2871. participants.length
  2872. );
  2873.  
  2874. });
  2875.  
  2876. // play safe for the change of 'length'
  2877. if (typeof nextBrowserTick !== 'function') {
  2878. await Promise.resolve(0);
  2879. } else {
  2880. await new Promise(resolve => nextBrowserTick(resolve)).then();
  2881. }
  2882.  
  2883. countOfElements = cnt.__getAllParticipantsDOMRenderedLength__();
  2884.  
  2885. const wrongSize = participants.length !== countOfElements
  2886. if (wrongSize) {
  2887. console.warn("ERROR(0xE2C3): notifyPath7081", beforeParticipants.length, participants.length, doms.length)
  2888. return 0;
  2889. }
  2890.  
  2891. res = 2 | 4;
  2892.  
  2893. } else {
  2894.  
  2895. indexSplices = null;
  2896. participantsForSpliceWR = null;
  2897.  
  2898. if (participants.length !== countOfElements) {
  2899. // other unhandled cases
  2900. return 0;
  2901. }
  2902.  
  2903. }
  2904.  
  2905. // participants.length === countOfElements before contentUpdates
  2906. if (contentUpdates.length >= 1) {
  2907. for (const contentUpdate of contentUpdates) {
  2908. let isChanged = checkChangeToParticipantRendererContent(beforeParticipants[contentUpdate.indexI], participants[contentUpdate.indexJ]);
  2909. if (isChanged) {
  2910. cnt.__notifyPath5036__(`participantsManager.participants[${contentUpdate.indexJ}]`);
  2911. res |= 4 | 8;
  2912. }
  2913. }
  2914. }
  2915. contentUpdates = null;
  2916.  
  2917. return res;
  2918.  
  2919.  
  2920. })();
  2921.  
  2922.  
  2923. resPromise.then(resValue => {
  2924.  
  2925. const isLogRequired = SHOW_PARTICIPANT_CHANGES_IN_CONSOLE && ((resValue === 0) || ((resValue & 4) === 4));
  2926. isLogRequired && groupCollapsed("Participant List Change", `tid = ${tid}; res = ${resValue}`);
  2927. if (resValue === 0) {
  2928. new Promise(resolve => {
  2929. cnt.resolveForDOMRendering781 = resolve;
  2930. isLogRequired && console.log("Full Refresh begins");
  2931. cnt.__notifyPath5036__("participantsManager.participants"); // full refresh
  2932. }).then(() => {
  2933. isLogRequired && console.log("Full Refresh ends");
  2934. console.groupEnd();
  2935. }).then(lockResolve);
  2936. return;
  2937. }
  2938.  
  2939. const delayLockResolve = (resValue & 4) === 4;
  2940.  
  2941. if (delayLockResolve) {
  2942. isLogRequired && console.log(`Number of participants (before): ${beforeParticipants.length}`);
  2943. isLogRequired && console.log(`Number of participants (after): ${participants.length}`);
  2944. isLogRequired && console.log(`Total number of rendered participants: ${cnt.__getAllParticipantsDOMRenderedLength__()}`);
  2945. isLogRequired && console.log(`Participant Renderer Content Updated: ${(resValue & 8) === 8}`);
  2946. isLogRequired && console.groupEnd();
  2947. // requestAnimationFrame is required to avoid particiant update during DOM changing (stampDomArraySplices_)
  2948. // mutex lock with requestAnimationFrame can also disable participants update in background
  2949. requestAnimationFrame(lockResolve);
  2950. } else {
  2951. lockResolve();
  2952. }
  2953.  
  2954. });
  2955.  
  2956. });
  2957.  
  2958. }
  2959.  
  2960. return { notifyPath7081 };
  2961.  
  2962. })();
  2963.  
  2964. const whenDefinedMultiple = async (tags) => {
  2965.  
  2966. const sTags = [...new Set(tags)];
  2967. const len = sTags.length;
  2968.  
  2969. const pTags = new Array(len);
  2970. for (let i = 0; i < len; i++) {
  2971. pTags[i] = customElements.whenDefined(sTags[i]);
  2972. }
  2973.  
  2974. await Promise.all(pTags);
  2975. pTags.length = 0;
  2976.  
  2977. return sTags;
  2978.  
  2979. }
  2980.  
  2981. const onRegistryReadyForDataManipulation = () => {
  2982.  
  2983. function dummy5035(a, b, c) { }
  2984. function dummy411(a, b, c) { }
  2985.  
  2986.  
  2987.  
  2988. customElements.whenDefined("yt-live-chat-participant-list-renderer").then(() => {
  2989.  
  2990. if (!DO_PARTICIPANT_LIST_HACKS) return;
  2991.  
  2992. const tag = "yt-live-chat-participant-list-renderer";
  2993. const cProto = getProto(document.createElement(tag));
  2994. if (!cProto || typeof cProto.attached !== 'function') {
  2995. // for _registered, proto.attached shall exist when the element is defined.
  2996. // for controller extraction, attached shall exist when instance creates.
  2997. console.warn(`proto.attached for ${tag} is unavailable.`);
  2998. return;
  2999. }
  3000.  
  3001.  
  3002. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-participant-list-renderer hacks");
  3003.  
  3004. 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'];
  3005. const fgs = {};
  3006. for (const key of fgsArr) fgs[key] = undefined;
  3007.  
  3008. try {
  3009. const EXPERIMENT_FLAGS = ytcfg.data_.EXPERIMENT_FLAGS;
  3010. for (const key of fgsArr) fgs[key] = EXPERIMENT_FLAGS[key];
  3011. } catch (e) { }
  3012. console.log(`EXPERIMENT_FLAGS: ${JSON.stringify(fgs, null, 2)}`);
  3013.  
  3014. const canDoReplacement = (() => {
  3015. if (typeof cProto.__notifyPath5035__ === 'function' && cProto.__notifyPath5035__.name !== 'dummy5035') {
  3016. console.warn('YouTube Live Chat Tamer is running.');
  3017. return;
  3018. }
  3019.  
  3020. if (typeof cProto.__attached411__ === 'function' && cProto.__attached411__.name !== 'dummy411') {
  3021. console.warn('YouTube Live Chat Tamer is running.');
  3022. return;
  3023. }
  3024.  
  3025. cProto.__notifyPath5035__ = dummy5035 // just to against Live Chat Tamer
  3026. cProto.__attached411__ = dummy411 // just to against Live Chat Tamer
  3027.  
  3028. if (typeof cProto.flushRenderStamperComponentBindings_ !== 'function' || cProto.flushRenderStamperComponentBindings_.length !== 0) {
  3029. console.warn("ERROR(0xE355): cProto.flushRenderStamperComponentBindings_ not found");
  3030. return;
  3031. }
  3032.  
  3033. if (typeof cProto.flushRenderStamperComponentBindings66_ === 'function') {
  3034. console.warn("ERROR(0xE356): cProto.flushRenderStamperComponentBindings66_");
  3035. return;
  3036. }
  3037.  
  3038. if (typeof cProto.__getAllParticipantsDOMRenderedLength__ === 'function') {
  3039. console.warn("ERROR(0xE357): cProto.__getAllParticipantsDOMRenderedLength__");
  3040. return;
  3041. }
  3042. return true;
  3043. })();
  3044.  
  3045. console.log(`Data Manipulation Boost = ${canDoReplacement}`);
  3046.  
  3047. assertor(() => fnIntegrity(cProto.attached, '0.32.22')) // just warning
  3048. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  3049. const fiRSCB = fnIntegrity(cProto.flushRenderStamperComponentBindings_);
  3050. // const s = fiRSCB.split('.');
  3051. // Feb 2024: 0.403.247 => NG
  3052. // if (s[0] === '0' && +s[1] > 381 && +s[1] < 391 && +s[2] > 228 && +s[2] < 238) {
  3053. // console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - OK`);
  3054. // } else {
  3055. // console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - NG`);
  3056. // }
  3057. console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ###`);
  3058. } else {
  3059. console.log("flushRenderStamperComponentBindings_ - not found");
  3060. }
  3061. // assertor(() => fnIntegrity(cProto.flushRenderStamperComponentBindings_, '0.386.233')) // just warning
  3062.  
  3063. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  3064. cProto.flushRenderStamperComponentBindings66_ = cProto.flushRenderStamperComponentBindings_;
  3065. cProto.flushRenderStamperComponentBindings_ = function () {
  3066. // console.log('flushRenderStamperComponentBindings_')
  3067. this.flushRenderStamperComponentBindings66_();
  3068. if (this.resolveForDOMRendering781) {
  3069. this.resolveForDOMRendering781();
  3070. this.resolveForDOMRendering781 = null;
  3071. }
  3072. };
  3073. }
  3074.  
  3075. cProto.__getAllParticipantsDOMRenderedLength__ = function () {
  3076. const container = ((this || 0).$ || 0).participants;
  3077. if (!container) return 0;
  3078. return HTMLElement.prototype.querySelectorAll.call(container, 'yt-live-chat-participant-renderer').length;
  3079. }
  3080.  
  3081. const onPageElements = [...document.querySelectorAll('yt-live-chat-participant-list-renderer:not(.n9fJ3)')];
  3082.  
  3083. cProto.__attached412__ = cProto.attached;
  3084. const fpPList = function (hostElement) {
  3085. const cnt = insp(hostElement);
  3086. if (beforeParticipantsMap.has(cnt)) return;
  3087. hostElement.classList.add('n9fJ3');
  3088.  
  3089. assertor(() => (cnt.__dataEnabled === true && cnt.__dataReady === true));
  3090. if (typeof cnt.notifyPath !== 'function' || typeof cnt.__notifyPath5036__ !== 'undefined') {
  3091. console.warn("ERROR(0xE318): yt-live-chat-participant-list-renderer")
  3092. return;
  3093. }
  3094.  
  3095. groupCollapsed("Participant List attached", "");
  3096. // cnt.$.participants.appendChild = cnt.$.participants.__shady_native_appendChild = function(){
  3097. // console.log(123, 'appendChild');
  3098. // return HTMLElement.prototype.appendChild.apply(this, arguments)
  3099. // }
  3100.  
  3101. // cnt.$.participants.insertBefore =cnt.$.participants.__shady_native_insertBefore = function(){
  3102. // console.log(123, 'insertBefore');
  3103. // return HTMLElement.prototype.insertBefore.apply(this, arguments)
  3104. // }
  3105.  
  3106. cnt.__notifyPath5036__ = cnt.notifyPath
  3107. const participants = ((cnt.participantsManager || 0).participants || 0);
  3108. assertor(() => (participants.length > -1 && typeof participants.slice === 'function'));
  3109. console.log(`initial number of participants: ${participants.length}`);
  3110. const newParticipants = (participants.length >= 1 && typeof participants.slice === 'function') ? participants.slice(0) : [];
  3111. beforeParticipantsMap.set(cnt, newParticipants);
  3112. cnt.notifyPath = notifyPath7081;
  3113. console.log(`CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = ${CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT}`);
  3114. console.groupEnd();
  3115. }
  3116. cProto.attached = function () {
  3117. fpPList(this.hostElement || this);
  3118. this.__attached412__.apply(this, arguments);
  3119. };
  3120.  
  3121.  
  3122. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST) {
  3123.  
  3124. /** @type {boolean | (()=>boolean)} */
  3125. let toUseMaintainStableList = USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? (() => ytcfg.data_.EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true) : true;
  3126. if (typeof cProto.stampDomArray_ === 'function' && cProto.stampDomArray_.length === 6 && !cProto.stampDomArray_.nIegT && !cProto.stampDomArray66_) {
  3127.  
  3128. let lastMessageDate = 0;
  3129. cProto.stampDomArray66_ = cProto.stampDomArray_;
  3130.  
  3131. cProto.stampDomArray_ = function (...args) {
  3132. if (args[0] && args[0].length > 0 && args[1] === "participants" && args[2] && args[3] === true && !args[5]) {
  3133. if (typeof toUseMaintainStableList === 'function') {
  3134. toUseMaintainStableList = toUseMaintainStableList();
  3135. }
  3136. args[5] = toUseMaintainStableList;
  3137. let currentDate = Date.now();
  3138. if (currentDate - lastMessageDate > 440) {
  3139. lastMessageDate = currentDate;
  3140. console.log('maintain_stable_list for participants list', toUseMaintainStableList);
  3141. }
  3142. }
  3143. return this.stampDomArray66_.apply(this, args);
  3144. }
  3145.  
  3146. cProto.stampDomArray_.nIegT = 1;
  3147.  
  3148. }
  3149. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - YES`);
  3150. } else {
  3151. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - NO`);
  3152. }
  3153.  
  3154. console.groupEnd();
  3155.  
  3156. if (onPageElements.length >= 1) {
  3157. for (const s of onPageElements) {
  3158. if (insp(s).isAttached === true) {
  3159. fpPList(s);
  3160. }
  3161. }
  3162. }
  3163.  
  3164. }).catch(console.warn);
  3165.  
  3166. };
  3167.  
  3168. if (DO_PARTICIPANT_LIST_HACKS) {
  3169. promiseForCustomYtElementsReady.then(onRegistryReadyForDataManipulation);
  3170. }
  3171.  
  3172.  
  3173.  
  3174. const rafHub = (ENABLE_RAF_HACK_TICKERS || ENABLE_RAF_HACK_DOCKED_MESSAGE || ENABLE_RAF_HACK_INPUT_RENDERER || ENABLE_RAF_HACK_EMOJI_PICKER) ? new RAFHub() : null;
  3175.  
  3176. const transitionEndAfterFnSimple = new WeakMap();
  3177. let prevTransitionClosing = null;
  3178.  
  3179. const fixChildrenIssue = !!fixChildrenIssue801;
  3180. if (fixChildrenIssue && typeof Object.getOwnPropertyDescriptor === 'function' && typeof Proxy !== 'undefined') {
  3181. const divProto = HTMLDivElement.prototype;
  3182. const polymerControllerSetData3 = function (c, d, e) {
  3183. return insp(this).set(c, d, e);
  3184. }
  3185. const polymerControllerSetData2 = function (c, d) {
  3186. return insp(this).set(c, d);
  3187. }
  3188. const dummyFn = function () {
  3189. console.log('dummyFn', ...arguments);
  3190. };
  3191.  
  3192. const wm44 = new Map();
  3193. function unPolymerSet(elem) {
  3194. const is = elem.is;
  3195. if (is && !elem.set) {
  3196. let rt = wm44.get(is);
  3197. if (!rt) {
  3198. rt = 1;
  3199. const cnt = insp(elem);
  3200. if (cnt !== elem && cnt && typeof cnt.set === 'function') {
  3201. const pcSet = cnt.constructor.prototype.set;
  3202. if (pcSet && typeof pcSet === 'function' && pcSet.length === 3) {
  3203. rt = polymerControllerSetData3;
  3204. } else if (pcSet && typeof pcSet === 'function' && pcSet.length === 2) {
  3205. rt = polymerControllerSetData2;
  3206. }
  3207. }
  3208. wm44.set(is, rt);
  3209. }
  3210. if (typeof rt === 'function') {
  3211. elem.set = rt;
  3212. } else {
  3213. elem.set = dummyFn;
  3214. }
  3215. }
  3216. }
  3217. if (!divProto.__children577__ && !divProto.__children578__) {
  3218.  
  3219. const dp = Object.getOwnPropertyDescriptor(Element.prototype, 'children');
  3220. const dp2 = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'children');
  3221. const dp3 = Object.getOwnPropertyDescriptor(divProto, 'children');
  3222.  
  3223. if (dp && dp.configurable === true && dp.enumerable === true && typeof dp.get === 'function' && !dp2 && !dp3) {
  3224.  
  3225. if (divProto instanceof HTMLElement && divProto instanceof Element) {
  3226.  
  3227. let m = Object.assign({}, dp);
  3228. divProto.__children577__ = dp.get;
  3229. divProto.__children578__ = function () {
  3230. if (this.__children803__) return this.__children803__;
  3231. if (this.__children801__) {
  3232. let arr = [];
  3233. for (let elem = this.firstElementChild; elem !== null; elem = elem.nextElementSibling) {
  3234. if (elem.is) {
  3235. unPolymerSet(elem);
  3236. arr.push(elem);
  3237. }
  3238. }
  3239. if (this.__children801__ === 2) this.__children803__ = arr;
  3240. return arr;
  3241. }
  3242. return 577;
  3243. };
  3244. m.get = function () {
  3245. const r = this.__children578__();
  3246. if (r !== 577) return r;
  3247. return this.__children577__();
  3248. };
  3249. Object.defineProperty(divProto, 'children', m);
  3250.  
  3251. console.log('fixChildrenIssue - set OK')
  3252.  
  3253. }
  3254. }
  3255.  
  3256. }
  3257.  
  3258.  
  3259. }
  3260.  
  3261.  
  3262. // const bnForDelayChatOccurrence = () => {
  3263.  
  3264. // document.addEventListener('animationstart', (evt) => {
  3265.  
  3266. // if (evt.animationName === 'dontRenderAnimation') {
  3267. // evt.target.classList.remove('dont-render');
  3268. // if (scrollChatFn) scrollChatFn();
  3269. // }
  3270.  
  3271. // }, true);
  3272.  
  3273. // const f = (elm) => {
  3274. // if (elm && elm.nodeType === 1) {
  3275. // if (!skipDontRender && allowDontRender === true) {
  3276. // // innerTextFixFn();
  3277. // elm.classList.add('dont-render');
  3278. // }
  3279. // }
  3280. // }
  3281.  
  3282. // Node.prototype.__appendChild931__ = function (a) {
  3283. // a = dr(a);
  3284. // if (this.id === 'items' && this.classList.contains('yt-live-chat-item-list-renderer')) {
  3285. // if (a && a.nodeType === 1) f(a);
  3286. // else if (a instanceof DocumentFragment) {
  3287. // for (let n = a.firstChild; n; n = n.nextSibling) {
  3288. // f(n);
  3289. // }
  3290. // }
  3291. // }
  3292. // }
  3293.  
  3294. // Node.prototype.__appendChild932__ = function () {
  3295. // this.__appendChild931__.apply(this, arguments);
  3296. // return Node.prototype.appendChild.apply(this, arguments);
  3297. // }
  3298.  
  3299.  
  3300. // };
  3301.  
  3302. const watchUserCSS = () => {
  3303.  
  3304. // if (!CSS.supports('contain-intrinsic-size', 'auto var(--wsr94)')) return;
  3305.  
  3306. const getElemFromWR = (nr) => {
  3307. const n = kRef(nr);
  3308. if (n && n.isConnected) return n;
  3309. return null;
  3310. }
  3311.  
  3312. const clearContentVisibilitySizing = () => {
  3313. Promise.resolve().then(() => {
  3314.  
  3315. const e = document.querySelector('#show-more[disabled]');
  3316. let btnShowMoreWR = e ? mWeakRef(e) : null;
  3317.  
  3318. let lastVisibleItemWR = null;
  3319. for (const elm of document.querySelectorAll('[wSr93]')) {
  3320. if (elm.getAttribute('wSr93') === 'visible') lastVisibleItemWR = mWeakRef(elm);
  3321. elm.setAttribute('wSr93', '');
  3322. // custom CSS property --wsr94 not working when attribute wSr93 removed
  3323. }
  3324. foregroundPromiseFn().then(() => {
  3325. const btnShowMore = getElemFromWR(btnShowMoreWR); btnShowMoreWR = null;
  3326. if (btnShowMore) btnShowMore.click();
  3327. else {
  3328. // would not work if switch it frequently
  3329. const lastVisibleItem = getElemFromWR(lastVisibleItemWR); lastVisibleItemWR = null;
  3330. if (lastVisibleItem) {
  3331.  
  3332. Promise.resolve()
  3333. .then(() => lastVisibleItem.scrollIntoView())
  3334. .then(() => lastVisibleItem.scrollIntoView(false))
  3335. .then(() => lastVisibleItem.scrollIntoView({ behavior: "instant", block: "end", inline: "nearest" }))
  3336. .catch(e => { }) // break the chain when method not callable
  3337.  
  3338. }
  3339. }
  3340. });
  3341.  
  3342. });
  3343.  
  3344. }
  3345.  
  3346. const mutObserver = new MutationObserver((mutations) => {
  3347. for (const mutation of mutations) {
  3348. if ((mutation.addedNodes || 0).length >= 1) {
  3349. for (const addedNode of mutation.addedNodes) {
  3350. if (addedNode.nodeName === 'STYLE') {
  3351. clearContentVisibilitySizing();
  3352. return;
  3353. }
  3354. }
  3355. }
  3356. if ((mutation.removedNodes || 0).length >= 1) {
  3357. for (const removedNode of mutation.removedNodes) {
  3358. if (removedNode.nodeName === 'STYLE') {
  3359. clearContentVisibilitySizing();
  3360. return;
  3361. }
  3362. }
  3363. }
  3364. }
  3365. });
  3366.  
  3367. mutObserver.observe(document.documentElement, {
  3368. childList: true,
  3369. subtree: false
  3370. });
  3371. mutObserver.observe(document.head, {
  3372. childList: true,
  3373. subtree: false
  3374. });
  3375. mutObserver.observe(document.body, {
  3376. childList: true,
  3377. subtree: false
  3378. });
  3379.  
  3380. }
  3381.  
  3382.  
  3383. class WillChangeController {
  3384. constructor(itemScroller, willChangeValue) {
  3385. this.element = itemScroller;
  3386. this.counter = 0;
  3387. this.active = false;
  3388. this.willChangeValue = willChangeValue;
  3389. }
  3390.  
  3391. beforeOper() {
  3392. if (!this.active) {
  3393. this.active = true;
  3394. this.element.style.willChange = this.willChangeValue;
  3395. }
  3396. this.counter++;
  3397. }
  3398.  
  3399. afterOper() {
  3400. const c = this.counter;
  3401. foregroundPromiseFn().then(() => {
  3402. if (c === this.counter) {
  3403. this.active = false;
  3404. this.element.style.willChange = '';
  3405. }
  3406. });
  3407. }
  3408.  
  3409. release() {
  3410. const element = this.element;
  3411. this.element = null;
  3412. this.counter = 1e16;
  3413. this.active = false;
  3414. try {
  3415. element.style.willChange = '';
  3416. } catch (e) { }
  3417. }
  3418.  
  3419. }
  3420.  
  3421.  
  3422. const skzData = (skz) => skz.data = {
  3423. "message": {
  3424. "runs": [
  3425. {
  3426. "text": "em2o"
  3427. },
  3428. {
  3429. "emoji": {
  3430. "emojiId": "cm35z",
  3431. "shortcuts": [
  3432. ":_s:",
  3433. ":s:"
  3434. ],
  3435. "searchTerms": [
  3436. "_s",
  3437. "s"
  3438. ],
  3439. "image": {
  3440. "thumbnails": [
  3441. {
  3442. "url": dummyImgURL,
  3443. "width": 48,
  3444. "height": 48
  3445. }
  3446. ],
  3447. "accessibility": {
  3448. "accessibilityData": {
  3449. "label": "s"
  3450. }
  3451. }
  3452. },
  3453. "isCustomEmoji": true
  3454. }
  3455. },
  3456. {
  3457. "text": "ji"
  3458. }
  3459. ]
  3460. },
  3461. "authorName": {
  3462. "simpleText": "N"
  3463. },
  3464. "authorPhoto": {
  3465. "thumbnails": [
  3466. {
  3467. "url": dummyImgURL,
  3468. "width": 64,
  3469. "height": 64
  3470. }
  3471. ]
  3472. },
  3473. "contextMenuEndpoint": {
  3474. "commandMetadata": {
  3475. "webCommandMetadata": {
  3476. "ignoreNavigation": true
  3477. }
  3478. },
  3479. "liveChatItemContextMenuEndpoint": {
  3480. "params": "123=="
  3481. }
  3482. },
  3483. "id": "sk35z",
  3484. "timestampUsec": "1232302352350000",
  3485. "authorBadges": [
  3486. {
  3487. "liveChatAuthorBadgeRenderer": {
  3488. "customThumbnail": {
  3489. "thumbnails": [
  3490. {
  3491. "url": dummyImgURL,
  3492. "width": 16,
  3493. "height": 16
  3494. },
  3495. {
  3496. "url": dummyImgURL,
  3497. "width": 32,
  3498. "height": 32
  3499. }
  3500. ]
  3501. },
  3502. "tooltip": "T",
  3503. "accessibility": {
  3504. "accessibilityData": {
  3505. "label": "E"
  3506. }
  3507. }
  3508. }
  3509. }
  3510. ],
  3511. "authorExternalChannelId": "A",
  3512. "contextMenuAccessibility": {
  3513. "accessibilityData": {
  3514. "label": "E"
  3515. }
  3516. },
  3517. "timestampText": {
  3518. "simpleText": "0:43"
  3519. }
  3520. };
  3521.  
  3522.  
  3523.  
  3524. const { lcRendererElm, visObserver } = (() => {
  3525.  
  3526.  
  3527.  
  3528. let lcRendererWR = null;
  3529.  
  3530. const lcRendererElm = () => {
  3531. let lcRenderer = kRef(lcRendererWR);
  3532. if (!lcRenderer || !lcRenderer.isConnected) {
  3533. lcRenderer = document.querySelector('yt-live-chat-item-list-renderer.yt-live-chat-renderer');
  3534. lcRendererWR = lcRenderer ? mWeakRef(lcRenderer) : null;
  3535. }
  3536. return lcRenderer;
  3537. };
  3538.  
  3539.  
  3540. let hasFirstShowMore = false;
  3541.  
  3542. const visObserverFn = (entry) => {
  3543.  
  3544. const target = entry.target;
  3545. if (!target) return;
  3546. // if(target.classList.contains('dont-render')) return;
  3547. let isVisible = entry.isIntersecting === true && entry.intersectionRatio > 0.5;
  3548. // const h = entry.boundingClientRect.height;
  3549. /*
  3550. if (h < 16) { // wrong: 8 (padding/margin); standard: 32; test: 16 or 20
  3551. // e.g. under fullscreen. the element created but not rendered.
  3552. target.setAttribute('wSr93', '');
  3553. return;
  3554. }
  3555. */
  3556. if (isVisible) {
  3557. // target.style.setProperty('--wsr94', h + 'px');
  3558. target.setAttribute('wSr93', 'visible');
  3559. if (nNextElem(target) === null) {
  3560.  
  3561. // firstVisibleItemDetected = true;
  3562. /*
  3563. if (dateNow() - lastScroll < 80) {
  3564. lastLShow = 0;
  3565. lastScroll = 0;
  3566. Promise.resolve().then(clickShowMore);
  3567. } else {
  3568. lastLShow = dateNow();
  3569. }
  3570. */
  3571. // lastLShow = dateNow();
  3572. } else if (!hasFirstShowMore) { // should more than one item being visible
  3573. // implement inside visObserver to ensure there is sufficient delay
  3574. hasFirstShowMore = true;
  3575. foregroundPromiseFn().then(() => {
  3576. // foreground page
  3577. // page visibly ready -> load the latest comments at initial loading
  3578. const lcRenderer = lcRendererElm();
  3579. if (lcRenderer) {
  3580. if (typeof nextBrowserTick !== 'function') {
  3581. insp(lcRenderer).scrollToBottom_();
  3582. } else {
  3583. nextBrowserTick(() => {
  3584. const cnt = insp(lcRenderer);
  3585. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3586. cnt.scrollToBottom_();
  3587. });
  3588. }
  3589. }
  3590. });
  3591. }
  3592. }
  3593. else if (target.getAttribute('wSr93') === 'visible') { // ignore target.getAttribute('wSr93') === '' to avoid wrong sizing
  3594.  
  3595. // target.style.setProperty('--wsr94', h + 'px');
  3596. target.setAttribute('wSr93', 'hidden');
  3597. } // note: might consider 0 < entry.intersectionRatio < 0.5 and target.getAttribute('wSr93') === '' <new last item>
  3598.  
  3599. }
  3600.  
  3601.  
  3602.  
  3603. const visObserver = new IntersectionObserver((entries) => {
  3604.  
  3605. for (const entry of entries) {
  3606.  
  3607. Promise.resolve(entry).then(visObserverFn);
  3608.  
  3609. }
  3610.  
  3611. }, {
  3612. // root: HTMLElement.prototype.closest.call(m2, '#item-scroller.yt-live-chat-item-list-renderer'), // nullable
  3613. rootMargin: "0px",
  3614. threshold: [0.05, 0.95],
  3615. });
  3616.  
  3617.  
  3618. return { lcRendererElm, visObserver }
  3619.  
  3620.  
  3621. })();
  3622.  
  3623. const { setupMutObserver } = (() => {
  3624.  
  3625. async function asyncTickerBackgroundOverridedChecker() {
  3626.  
  3627. try {
  3628. await promiseForCustomYtElementsReady.then();
  3629. await customElements.whenDefined('yt-live-chat-text-message-renderer');
  3630. await new Promise(r => setTimeout(r, 800));
  3631.  
  3632. if (!hasTimerModified) return;
  3633. const tickerRenderer = document.querySelector('#ticker yt-live-chat-ticker-renderer.style-scope.yt-live-chat-renderer');
  3634. if (!tickerRenderer) return;
  3635.  
  3636. const tickerRendererDollar = indr(tickerRenderer);
  3637. const items = (tickerRendererDollar || 0).items || 0;
  3638. if (!items) return;
  3639. const template = document.createElement('template');
  3640. template.innerHTML = `<yt-live-chat-ticker-dummy777-item-renderer class="style-scope yt-live-chat-ticker-renderer" whole-message-clickable=""
  3641. modern="" aria-label="¥1,000" role="button" tabindex="0" id="Chw777" style="width: 94px; overflow: hidden;"
  3642. dimmed="" [dummy777]>
  3643. <div id="container" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"
  3644. 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));">
  3645. <div id="content" class="style-scope yt-live-chat-ticker-dummy777-item-renderer" style="color: rgb(255, 255, 255);">
  3646. <yt-img-shadow777 id="author-photo" height="24" width="24"
  3647. class="style-scope yt-live-chat-ticker-dummy777-item-renderer no-transition"
  3648. style="background-color: transparent;" loaded=""><img id="img"
  3649. draggable="false" class="style-scope yt-img-shadow" alt="I" height="24" width="24"
  3650. src="${dummyImgURL}"></yt-img-shadow777>
  3651.  
  3652. <span id="text" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"1,000</span>
  3653. </div>
  3654. </div>
  3655. </yt-live-chat-ticker-dummy777-item-renderer>`;
  3656. const dummy777 = template.content.firstElementChild;
  3657. await Promise.resolve().then();
  3658. let res = 0;
  3659. if (items instanceof HTMLElement && items.isConnected === true) {
  3660. try {
  3661. items.appendChild(dummy777);
  3662. let container = HTMLElement.prototype.querySelector.call(dummy777, '#container') || 0;
  3663. if (container.isConnected === true) {
  3664. const evaluated = `${getComputedStyleCached(container).background}`;
  3665. container = null;
  3666. res = evaluated.indexOf('0.') < 4 ? 1 : 2;
  3667. }
  3668. } catch (e) { console.warn(e) }
  3669. HTMLElement.prototype.remove.call(dummy777);
  3670. }
  3671. await Promise.resolve().then();
  3672. dummy777.textContent = '';
  3673. if (res === 1) {
  3674. // not fulfilling
  3675. // rgba(0, 0, 0, 0.004) none repeat scroll 0% 0% / auto padding-box border-box
  3676. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  3677. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  3678. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  3679. );
  3680. 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');
  3681. console.groupEnd();
  3682. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND (Overriding other scripting)', 'background-color: #7eb32b; color: #102624; padding: 2px 4px');
  3683. } else if (res === 2) {
  3684. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  3685. }
  3686. } catch (e) {
  3687. console.warn(e);
  3688. }
  3689. }
  3690.  
  3691. // async function asyncDelayChatOccurrence(m2) {
  3692. // try {
  3693. // await promiseForCustomYtElementsReady.then();
  3694. // await customElements.whenDefined('yt-live-chat-text-message-renderer');
  3695. // await new Promise(r => setTimeout(r, 1));
  3696. // const dummy888 = document.createElement('yt-live-chat-text-message-renderer');
  3697. // // const template = document.createElement('template');
  3698. // // template.innerHTML = "<yt-live-chat-text-message-renderer></yt-live-chat-text-message-renderer>"
  3699. // // const dummy888 = template.content.firstElementChild;
  3700. // const skzCnt = insp(dummy888);
  3701. // if (!(skzCnt && 'data' in skzCnt && 'attached' in skzCnt)) {
  3702. // return;
  3703. // }
  3704. // if (!skzCnt.hostElement) skzCnt.hostElement = dummy888;
  3705. // /** @type {HTMLTemplateElement} */
  3706. // const skzElem = dummy888;
  3707. // let cz1 = null;
  3708. // const deferredZy1 = new Promise(resolve => {
  3709. // skzCnt.attached = function () {
  3710. // cz1 = HTMLElement.prototype.querySelector.call(skzElem, '#message img') !== null;
  3711. // resolve(skzElem.textContent);
  3712. // }
  3713. // skzCnt.detached = function () {
  3714. // }
  3715. // });
  3716. // skzElem.id = 'sk35z';
  3717. // skzData(skzCnt);
  3718. // sk35zResolveFn = null;
  3719. // const deferredMutation = new Promise(resolve => {
  3720. // sk35zResolveFn = resolve;
  3721. // HTMLElement.prototype.appendChild.call(m2, skzElem);
  3722. // });
  3723. // const [zy1, _] = await Promise.all([deferredZy1, deferredMutation]);
  3724. // skzCnt.attached = function () { };
  3725. // function fn() {
  3726. // const zy2 = skzElem.textContent;
  3727. // const cz2 = HTMLElement.prototype.querySelector.call(skzElem, '#message img') !== null;
  3728. // if (typeof zy1 === 'string' && typeof zy2 === 'string') {
  3729. // allowDontRender = zy1 === zy2 && cz1 === cz2; // '0:43N​em2oji'
  3730. // }
  3731. // if (allowDontRender === true) return true;
  3732. // if (allowDontRender === false) {
  3733. // console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  3734. // "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  3735. // "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  3736. // );
  3737. // 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');
  3738. // console.groupEnd();
  3739. // }
  3740. // }
  3741. // await new Promise(r => setTimeout(r, 1));
  3742. // if (!fn()) return;
  3743. // await foregroundPromiseFn().then();
  3744. // if (!fn()) return;
  3745. // skzElem.remove();
  3746. // await Promise.resolve().then();
  3747. // skzElem.textContent = '';
  3748. // console.log('%cALLOW_DELAYED_CHAT_OCCURRENCE', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  3749. // } catch (e) {
  3750. // console.warn(e);
  3751. // }
  3752. // }
  3753.  
  3754. const mutFn = (items) => {
  3755. let seqIndex = -1;
  3756. const elementSet = new Set();
  3757. for (let node = nLastElem(items); node !== null; node = nPrevElem(node)) {
  3758. if (node.hasAttribute('wSr93')) {
  3759. seqIndex = parseInt(node.getAttribute('yt-chat-item-seq'), 10);
  3760. break;
  3761. }
  3762. node.setAttribute('wSr93', '');
  3763. visObserver.observe(node);
  3764. elementSet.add(node);
  3765. }
  3766. let iter = elementSet.values();
  3767. let i = seqIndex + elementSet.size;
  3768. for (let curr; curr = iter.next().value;) {
  3769. curr.setAttribute('yt-chat-item-seq', i % 60);
  3770. curr.classList.add('yt-chat-item-' + ((i % 2) ? 'odd' : 'even'));
  3771. i--;
  3772. }
  3773. iter = null;
  3774. elementSet.clear();
  3775. }
  3776.  
  3777. const mutObserver = new MutationObserver((mutations) => {
  3778. const items = (mutations[0] || 0).target;
  3779. if (!items) return;
  3780. if (sk35zResolveFn) {
  3781. sk35zResolveFn();
  3782. sk35zResolveFn = null;
  3783. }
  3784. mutFn(items);
  3785. });
  3786.  
  3787. const setupMutObserver = (m2) => {
  3788. scrollChatFn = null;
  3789. mutObserver.disconnect();
  3790. mutObserver.takeRecords();
  3791. if (m2) {
  3792. if (typeof m2.__appendChild932__ === 'function') {
  3793. if (typeof m2.appendChild === 'function') m2.appendChild = m2.__appendChild932__;
  3794. if (typeof m2.__shady_native_appendChild === 'function') m2.__shady_native_appendChild = m2.__appendChild932__;
  3795. }
  3796. mutObserver.observe(m2, {
  3797. childList: true,
  3798. subtree: false
  3799. });
  3800. mutFn(m2);
  3801.  
  3802. const isFirstList = firstList;
  3803. firstList = false;
  3804.  
  3805. if (ENABLE_OVERFLOW_ANCHOR) {
  3806.  
  3807. let items = m2;
  3808. let addedAnchor = false;
  3809. if (items) {
  3810. if (items.nextElementSibling === null) {
  3811. items.classList.add('no-anchor');
  3812. addedAnchor = true;
  3813. items.parentNode.appendChild(dr(document.createElement('item-anchor')));
  3814. }
  3815. }
  3816.  
  3817.  
  3818.  
  3819. if (addedAnchor) {
  3820. nodeParent(m2).classList.add('no-anchor'); // required
  3821. }
  3822.  
  3823. }
  3824.  
  3825.  
  3826.  
  3827. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  3828.  
  3829. (() => {
  3830.  
  3831. const tag = 'yt-iframed-player-events-relay'
  3832. const dummy = document.createElement(tag);
  3833.  
  3834. const cProto = getProto(dummy);
  3835. if (!cProto || !cProto.handlePostMessage_) {
  3836. console.warn(`proto.handlePostMessage_ for ${tag} is unavailable.`);
  3837. return;
  3838. }
  3839.  
  3840. if (typeof cProto.handlePostMessage_ === 'function' && !cProto.handlePostMessage66_ && !cProto.handlePostMessage67_ ) {
  3841.  
  3842. cProto.handlePostMessage66_ = cProto.handlePostMessage_;
  3843.  
  3844. const handlePostMessageAfterPromiseA = (da) => {
  3845.  
  3846. if (!da || typeof da !== 'object') return;
  3847.  
  3848. if ('yt-player-state-change' in da) {
  3849.  
  3850. const qc = da['yt-player-state-change'];
  3851.  
  3852.  
  3853. let isQcChanged = false;
  3854.  
  3855. if (qc === 2) { isQcChanged = qc !== _playerState; _playerState = 2; relayCount = 0; } // paused
  3856. else if (qc === 3) { isQcChanged = qc !== _playerState; _playerState = 3; } // playing
  3857. else if (qc === 1) { isQcChanged = qc !== _playerState; _playerState = 1; } // playing
  3858.  
  3859.  
  3860. if ((isQcChanged) && playerState !== _playerState) {
  3861. playerEventsByIframeRelay = true;
  3862. onPlayStateChangePromise = new Promise((resolve) => {
  3863. const k = _playerState;
  3864. foregroundPromiseFn().then(() => {
  3865. if (k === _playerState && playerState !== _playerState) playerState = _playerState;
  3866. onPlayStateChangePromise = null;
  3867. resolve();
  3868. })
  3869. }).catch(console.warn);
  3870.  
  3871. }
  3872.  
  3873. } else if ('yt-player-video-progress' in da) {
  3874. const vp = da['yt-player-video-progress'];
  3875.  
  3876.  
  3877. relayCount++;
  3878. lastPlayerProgress = vp > 0 ? vp : 0;
  3879.  
  3880.  
  3881. if (relayPromise && vp > 0 && relayCount >= 2) {
  3882. if (onPlayStateChangePromise) {
  3883. onPlayStateChangePromise.then(() => {
  3884. relayPromise && relayPromise.resolve();
  3885. relayPromise = null;
  3886. })
  3887. } else {
  3888. relayPromise.resolve();
  3889. relayPromise = null;
  3890. }
  3891. }
  3892.  
  3893. }
  3894.  
  3895. };
  3896.  
  3897. cProto.handlePostMessage67_ = function (a) {
  3898.  
  3899. let da = a.data;
  3900. const wNode = mWeakRef(this);
  3901. // const wData = mWeakRef(da);
  3902.  
  3903. playEventsStack = playEventsStack.then(() => {
  3904.  
  3905. const cnt = kRef(wNode);
  3906. // const da = kRef(wData);
  3907.  
  3908. if (!cnt || !a || !da) return;
  3909. handlePostMessageAfterPromiseA(da);
  3910. da = null;
  3911.  
  3912. const r = cnt.handlePostMessage66_(a);
  3913. a = null;
  3914.  
  3915. }).catch(console.warn);
  3916.  
  3917. }
  3918.  
  3919. const handlePostMessageAfterPromiseB = (da) => {
  3920.  
  3921. const lcr = document.querySelector('yt-live-chat-renderer');
  3922. const psc = document.querySelector("yt-player-seek-continuation");
  3923. if (lcr && psc && lcr.replayBuffer_) {
  3924.  
  3925. const rbProgress = lcr.replayBuffer_.lastVideoOffsetTimeMsec;
  3926. const daProgress = da['yt-player-video-progress'] * 1000
  3927. // document.querySelector('yt-live-chat-renderer').playerProgressChanged_(1e-5);
  3928.  
  3929. const front_ = (lcr.replayBuffer_.replayQueue || 0).front_;
  3930. const back_ = (lcr.replayBuffer_.replayQueue || 0).back_;
  3931.  
  3932. // console.log(deepCopy( front_))
  3933. // console.log(deepCopy( back_))
  3934. // console.log(rbProgress, daProgress, )
  3935. if (front_ && back_ && rbProgress > daProgress && back_.length > 2 && back_.some(e => e && +e.videoOffsetTimeMsec > daProgress) && back_.some(e => e && +e.videoOffsetTimeMsec < daProgress)) {
  3936. // no action
  3937. // console.log('ss1')
  3938. } else if (rbProgress < daProgress + 3400 && rbProgress > daProgress - 1200) {
  3939. // daProgress - 1200 < rbProgress < daProgress + 3400
  3940. // console.log('ss2')
  3941. } else {
  3942.  
  3943. lcr.previousProgressSec = 1E-5;
  3944. // lcr._setIsSeeking(!0),
  3945. lcr.replayBuffer_.clear()
  3946. psc.fireSeekContinuation_(da['yt-player-video-progress']);
  3947. }
  3948.  
  3949. }
  3950.  
  3951.  
  3952. };
  3953.  
  3954. cProto.handlePostMessage_ = function (a) {
  3955.  
  3956. let da = (a || 0).data || 0;
  3957. const wNode = mWeakRef(this);
  3958.  
  3959. if (typeof da !== 'object') return;
  3960.  
  3961. if (waitForInitialDataCompletion === 1) return;
  3962.  
  3963. if (!isPlayProgressTriggered) {
  3964. isPlayProgressTriggered = true; // set once
  3965.  
  3966. if ('yt-player-video-progress' in da) {
  3967. waitForInitialDataCompletion = 1;
  3968.  
  3969. const wrapWith = (data) => {
  3970. const { origin } = a;
  3971. return {
  3972. origin,
  3973. data
  3974. };
  3975. }
  3976.  
  3977. this.handlePostMessage67_(wrapWith({
  3978. "yt-iframed-parent-ready": true
  3979. }));
  3980.  
  3981.  
  3982. playEventsStack = playEventsStack.then(() => {
  3983.  
  3984. const cnt = kRef(wNode);
  3985.  
  3986. if (!cnt || !a || !da) return;
  3987.  
  3988. handlePostMessageAfterPromiseB(da);
  3989. da = null;
  3990.  
  3991. waitForInitialDataCompletion = 2;
  3992.  
  3993. const r = cnt.handlePostMessage_(a); // isPlayProgressTriggered is set
  3994. a = null;
  3995.  
  3996. }).catch(console.warn);
  3997.  
  3998. return;
  3999.  
  4000. }
  4001.  
  4002. }
  4003.  
  4004. this.handlePostMessage67_(a);
  4005.  
  4006. }
  4007.  
  4008. }
  4009.  
  4010.  
  4011. })();
  4012.  
  4013. }
  4014.  
  4015. if (isFirstList && DO_CHECK_TICKER_BACKGROUND_OVERRIDED) {
  4016. asyncTickerBackgroundOverridedChecker();
  4017. }
  4018.  
  4019. }
  4020. }
  4021.  
  4022. return { setupMutObserver };
  4023.  
  4024.  
  4025.  
  4026. })();
  4027.  
  4028. const setupEvents = () => {
  4029.  
  4030.  
  4031. let scrollCount = 0;
  4032.  
  4033. const passiveCapture = typeof IntersectionObserver === 'function' ? { capture: true, passive: true } : true;
  4034.  
  4035.  
  4036. const delayFlushActiveItemsAfterUserActionK_ = () => {
  4037.  
  4038. const lcRenderer = lcRendererElm();
  4039. if (lcRenderer) {
  4040. const cnt = insp(lcRenderer);
  4041. if (!cnt.hasUserJustInteracted11_) return;
  4042. if (cnt.atBottom && cnt.allowScroll && cnt.activeItems_.length >= 1 && cnt.hasUserJustInteracted11_()) {
  4043. cnt.delayFlushActiveItemsAfterUserAction11_ && cnt.delayFlushActiveItemsAfterUserAction11_();
  4044. }
  4045. }
  4046.  
  4047. }
  4048.  
  4049. document.addEventListener('scroll', (evt) => {
  4050. if (!evt || !evt.isTrusted) return;
  4051. // lastScroll = dateNow();
  4052. if (++scrollCount > 1e9) scrollCount = 9;
  4053. }, passiveCapture); // support contain => support passive
  4054.  
  4055. let lastScrollCount = -1;
  4056. document.addEventListener('wheel', (evt) => {
  4057. if (!evt || !evt.isTrusted) return;
  4058. if (lastScrollCount === scrollCount) return;
  4059. lastScrollCount = scrollCount;
  4060. lastWheel = dateNow();
  4061. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4062. }, passiveCapture); // support contain => support passive
  4063.  
  4064. document.addEventListener('mousedown', (evt) => {
  4065. if (!evt || !evt.isTrusted) return;
  4066. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  4067. lastMouseDown = dateNow();
  4068. currentMouseDown = true;
  4069. lastUserInteraction = lastMouseDown;
  4070. }, passiveCapture);
  4071.  
  4072. document.addEventListener('pointerdown', (evt) => {
  4073. if (!evt || !evt.isTrusted) return;
  4074. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  4075. lastMouseDown = dateNow();
  4076. currentMouseDown = true;
  4077. lastUserInteraction = lastMouseDown;
  4078. }, passiveCapture);
  4079.  
  4080. document.addEventListener('click', (evt) => {
  4081. if (!evt || !evt.isTrusted) return;
  4082. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  4083. lastMouseDown = lastMouseUp = dateNow();
  4084. currentMouseDown = false;
  4085. lastUserInteraction = lastMouseDown;
  4086. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4087. }, passiveCapture);
  4088.  
  4089. document.addEventListener('tap', (evt) => {
  4090. if (!evt || !evt.isTrusted) return;
  4091. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  4092. lastMouseDown = lastMouseUp = dateNow();
  4093. currentMouseDown = false;
  4094. lastUserInteraction = lastMouseDown;
  4095. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4096. }, passiveCapture);
  4097.  
  4098.  
  4099. document.addEventListener('mouseup', (evt) => {
  4100. if (!evt || !evt.isTrusted) return;
  4101. if (currentMouseDown) {
  4102. lastMouseUp = dateNow();
  4103. currentMouseDown = false;
  4104. lastUserInteraction = lastMouseUp;
  4105. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4106. }
  4107. }, passiveCapture);
  4108.  
  4109.  
  4110. document.addEventListener('pointerup', (evt) => {
  4111. if (!evt || !evt.isTrusted) return;
  4112. if (currentMouseDown) {
  4113. lastMouseUp = dateNow();
  4114. currentMouseDown = false;
  4115. lastUserInteraction = lastMouseUp;
  4116. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4117. }
  4118. }, passiveCapture);
  4119.  
  4120. document.addEventListener('touchstart', (evt) => {
  4121. if (!evt || !evt.isTrusted) return;
  4122. lastTouchDown = dateNow();
  4123. currentTouchDown = true;
  4124. lastUserInteraction = lastTouchDown;
  4125. }, passiveCapture);
  4126.  
  4127. document.addEventListener('touchmove', (evt) => {
  4128. if (!evt || !evt.isTrusted) return;
  4129. lastTouchDown = dateNow();
  4130. currentTouchDown = true;
  4131. lastUserInteraction = lastTouchDown;
  4132. }, passiveCapture);
  4133.  
  4134. document.addEventListener('touchend', (evt) => {
  4135. if (!evt || !evt.isTrusted) return;
  4136. if (currentTouchDown) {
  4137. lastTouchUp = dateNow();
  4138. currentTouchDown = false;
  4139. lastUserInteraction = lastTouchUp;
  4140. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4141. }
  4142. }, passiveCapture);
  4143.  
  4144. document.addEventListener('touchcancel', (evt) => {
  4145. if (!evt || !evt.isTrusted) return;
  4146. if (currentTouchDown) {
  4147. lastTouchUp = dateNow();
  4148. currentTouchDown = false;
  4149. lastUserInteraction = lastTouchUp;
  4150. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  4151. }
  4152. }, passiveCapture);
  4153.  
  4154.  
  4155. }
  4156.  
  4157. const getTimestampUsec = (itemRenderer) => {
  4158. if (itemRenderer && 'timestampUsec' in itemRenderer) {
  4159. return itemRenderer.timestampUsec
  4160. } else if (itemRenderer && itemRenderer.showItemEndpoint) {
  4161. const messageRenderer = ((itemRenderer.showItemEndpoint.showLiveChatItemEndpoint || 0).renderer || 0);
  4162. if (messageRenderer) {
  4163.  
  4164. const messageRendererKey = firstObjectKey(messageRenderer);
  4165. if (messageRendererKey && messageRenderer[messageRendererKey]) {
  4166. const messageRendererData = messageRenderer[messageRendererKey];
  4167. if (messageRendererData && 'timestampUsec' in messageRendererData) {
  4168. return messageRendererData.timestampUsec
  4169. }
  4170. }
  4171. }
  4172. }
  4173. return null;
  4174. }
  4175.  
  4176. const onRegistryReadyForDOMOperations = () => {
  4177.  
  4178. let firstCheckedOnYtInit = false;
  4179.  
  4180. const assertorURL = () => assertor(() => location.pathname.startsWith('/live_chat') && (location.search.indexOf('continuation=') > 0 || location.search.indexOf('v=') > 0));
  4181.  
  4182. const mightFirstCheckOnYtInit = () => {
  4183. if (firstCheckedOnYtInit) return;
  4184. firstCheckedOnYtInit = true;
  4185.  
  4186. if (!document.body || !document.head) return;
  4187. if (!assertorURL()) return;
  4188.  
  4189. addCssManaged();
  4190.  
  4191. let efsContainer = document.getElementById('elzm-fonts-yk75g');
  4192. if (efsContainer && efsContainer.parentNode !== document.body) {
  4193. document.body.appendChild(efsContainer);
  4194. }
  4195.  
  4196. };
  4197.  
  4198. if (!assertorURL()) return;
  4199. // if (!assertor(() => document.getElementById('yt-masthead') === null)) return;
  4200.  
  4201.  
  4202. const { weakWrap } = (() => {
  4203.  
  4204.  
  4205. // const tickerFuncProps = new Set([
  4206. // 'animateShowStats', 'animateHideStats', // updateStatsBarAndMaybeShowAnimationRevised
  4207. // 'collapse', // slideDownNoSelfLeakage
  4208. // 'requestRemoval', // collapseNoSelfLeakage
  4209. // 'setContainerWidth', 'get', 'set', // deletedChangedNoSelfLeakage
  4210. // 'computeAriaLabel', //dataChanged
  4211. // 'startCountdown', // dataChanged [in case]
  4212. // ]);
  4213.  
  4214. // const tickerTags = new Set([
  4215. // "yt-live-chat-ticker-renderer",
  4216. // "yt-live-chat-ticker-paid-message-item-renderer",
  4217. // "yt-live-chat-ticker-paid-sticker-item-renderer",
  4218. // "yt-live-chat-ticker-sponsor-item-renderer"
  4219. // ]);
  4220.  
  4221. // const emptySet = new Set();
  4222.  
  4223.  
  4224.  
  4225. // const tickerFuncPropsFn = (cnt) => {
  4226.  
  4227. // const is = `${cnt.is}`;
  4228.  
  4229. // if (tickerTags.has(is)) {
  4230. // let flg = 0;
  4231. // if (cnt.get && cnt.set) flg |= 1;
  4232. // if (cnt.setContainerWidth && cnt.collapse && cnt.requestRemoval) flg |= 2;
  4233. // if (cnt.animateShowStats && cnt.animateHideStats) flg |= 4;
  4234. // if (cnt.startCountdown) flg |= 8;
  4235. // console.log(`DEBUG flag_6877 = ${flg}`, is);
  4236. // // DEBUG flag_6877 = 15 yt-live-chat-ticker-paid-message-item-renderer
  4237. // // DEBUG flag_6877 = 11 yt-live-chat-ticker-sponsor-item-renderer
  4238. // return tickerFuncProps;
  4239. // }
  4240.  
  4241. // return emptySet;
  4242.  
  4243.  
  4244. // }
  4245.  
  4246.  
  4247. // const smb = Symbol();
  4248. const vmb = 'dtz02' // Symbol(); // return kThis for thisArg
  4249. const vmc = 'dtz04' // Symbol(); // whether it is proxied fn
  4250. const vmd = 'dtz08' // Symbol(); // self fn proxy (fn--fn)
  4251.  
  4252.  
  4253.  
  4254.  
  4255. const thisConversionFn = (thisArg) => {
  4256. if (!thisArg) return null;
  4257. const kThis = thisArg[vmb];
  4258. if (kThis) {
  4259. const ref = kThis.ref;
  4260. return (ref ? kRef(ref) : null) || null;
  4261. }
  4262. return thisArg;
  4263. }
  4264. const pFnHandler2 = {
  4265. get(target, prop) {
  4266. if (prop === vmc) return target;
  4267. return Reflect.get(target, prop);
  4268. },
  4269. apply(target, thisArg, argumentsList) {
  4270. thisArg = thisConversionFn(thisArg);
  4271. if (thisArg) return Reflect.apply(target, thisArg, argumentsList);
  4272. }
  4273. }
  4274. const proxySelfHandler = {
  4275. get(target, prop) {
  4276. if(prop === vmb) return target;
  4277. const ref = target.ref;
  4278. const cnt = kRef(ref);
  4279. if (!cnt) return;
  4280. if (typeof cnt[prop] === 'function' && !cnt[prop][vmc] && !cnt[prop][vmb]) {
  4281. if (!cnt[prop][vmd]) cnt[prop][vmd] = new Proxy(cnt[prop], pFnHandler2);
  4282. return cnt[prop][vmd];
  4283. }
  4284. return cnt[prop];
  4285. },
  4286. set(target, prop, value) {
  4287. const cnt = kRef(target.ref);
  4288. if (!cnt) return true;
  4289. if(value && (value[vmc] || value[vmb])){
  4290. cnt[prop] = value[vmc] || thisConversionFn(value);
  4291. return true;
  4292. }
  4293. cnt[prop] = value;
  4294. return true;
  4295. }
  4296. };
  4297. const weakWrap = (thisArg) => {
  4298. thisArg = thisConversionFn(thisArg);
  4299. if (!thisArg) {
  4300. console.error('thisArg is not found');
  4301. return null;
  4302. }
  4303. return new Proxy({ ref: mWeakRef(thisArg) }, proxySelfHandler);
  4304. }
  4305.  
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311. if (!window.getComputedStyle533 && typeof window.getComputedStyle === 'function') {
  4312. window.getComputedStyle533 = window.getComputedStyle;
  4313. window.getComputedStyle = function (a, ...args) {
  4314. a = thisConversionFn(a);
  4315. if (a) {
  4316. return getComputedStyle533(a, ...args);
  4317. }
  4318. return null;
  4319. }
  4320. }
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328. // const fnProxySelf = function (...args) {
  4329. // const cnt = kRef(this.ref);
  4330. // if (cnt) {
  4331. // return cnt[this.prop](...args); // might throw error
  4332. // }
  4333. // }
  4334. // const proxySelfHandler = {
  4335. // get(target, prop) {
  4336. // const ref = target.ref;
  4337. // const cnt = kRef(ref);
  4338. // if (!cnt) return;
  4339. // if (prop === 'dtz06') return 1;
  4340. // if (typeof cnt[prop] === 'function') {
  4341. // if (!target.funcs.has(prop)) {
  4342. // console.warn(`proxy get to function | prop: ${prop} | is: ${cnt.is}`);
  4343. // }
  4344. // if (!target[`$$${prop}$$`]) target[`$$${prop}$$`] = fnProxySelf.bind({ prop, ref });
  4345. // return target[`$$${prop}$$`];
  4346. // }
  4347. // return cnt[prop];
  4348. // },
  4349. // set(target, prop, value) {
  4350. // const cnt = kRef(target.ref);
  4351. // if (!cnt) return true;
  4352. // if (typeof value === 'function') {
  4353. // console.warn(`proxy set to function | prop: ${prop} | is: ${cnt.is}`);
  4354. // cnt[prop] = value;
  4355. // return true;
  4356. // }
  4357. // cnt[prop] = value;
  4358. // return true;
  4359. // }
  4360. // };
  4361.  
  4362. // return { tickerFuncPropsFn, proxySelfHandler }
  4363.  
  4364. return {weakWrap}
  4365. })();
  4366.  
  4367.  
  4368.  
  4369. if (document.documentElement && document.head) {
  4370. addCssManaged();
  4371. }
  4372. // console.log(document.body===null)
  4373.  
  4374. const preprocessChatLiveActionsMap = new WeakSet();
  4375.  
  4376. const toLAObj=(aItem)=>{
  4377.  
  4378. if (!aItem || typeof aItem !== 'object') return false;
  4379. const key = firstObjectKey(aItem); // addLiveChatTickerItemAction
  4380. if (!key) return false;
  4381. let obj = aItem[key];
  4382. if (!obj || typeof obj !== 'object') return false;
  4383.  
  4384. if (typeof (obj.item || 0) == 'object' && firstObjectKey(obj) === 'item') {
  4385. obj = obj.item;
  4386. const key = firstObjectKey(obj);
  4387. if (key) {
  4388. obj = obj[key];
  4389. }
  4390. }
  4391.  
  4392. return obj;
  4393.  
  4394. };
  4395.  
  4396. const preprocessChatLiveActions = (arr) =>{
  4397.  
  4398. if(!arr || !arr.length) return arr;
  4399.  
  4400. if(preprocessChatLiveActionsMap.has(arr)) return arr;
  4401. preprocessChatLiveActionsMap.add(arr);
  4402.  
  4403. const ct = Date.now();
  4404.  
  4405. // console.log('preprocessChatLiveActions', arr)
  4406.  
  4407.  
  4408. const mapper = new Map();
  4409.  
  4410. // without delaying. get the time of request
  4411. // (both streaming and replay, but replay relys on progress update so background operation is suppressed)
  4412. for (let j = 0, l = arr.length; j < l; j++) {
  4413. const aItem = arr[j];
  4414.  
  4415. const obj = toLAObj(aItem);
  4416. if(obj === false) continue;
  4417. if (obj.id && !obj.__timestampActionRequest__) {
  4418. // for all item entries
  4419. obj.__timestampActionRequest__ = ct;
  4420. }
  4421.  
  4422. if (obj.id && obj.__timestampActionRequest__ > 0 && obj.durationSec > 0 && obj.fullDurationSec) {
  4423.  
  4424. // console.log(948700, obj , obj.id, (obj.fullDurationSec - obj.durationSec) * 1000)
  4425. const m = obj.__timestampActionRequest__ - (obj.fullDurationSec - obj.durationSec) * 1000;
  4426. // obj.__orderTime__ = m;
  4427. mapper.set(aItem, m);
  4428.  
  4429.  
  4430. }
  4431.  
  4432. }
  4433.  
  4434. if (mapper.size > 1) {
  4435.  
  4436. const idxices = [];
  4437.  
  4438. // sort ticker
  4439. let mArr1 = arr.filter((aItem,idx) => {
  4440.  
  4441. if (mapper.has(aItem)) {
  4442. idxices.push(idx);
  4443. return true;
  4444. }
  4445. return false;
  4446.  
  4447. });
  4448.  
  4449.  
  4450. let mArr2 = mArr1/*.slice(0)*/.sort((a, b) => {
  4451. return mapper.get(a) - mapper.get(b);
  4452. // low index = oldest = smallest timestamp
  4453. });
  4454.  
  4455.  
  4456.  
  4457. // console.log(948701, arr.slice(0));
  4458. for(let j = 0, l=mArr1.length;j <l;j++){
  4459.  
  4460. const idx = idxices[j];
  4461. // arr[idx] = mArr1[j]
  4462. arr[idx] = mArr2[j];
  4463.  
  4464. // const obj1 = toObj(mArr1[j]);
  4465. // const obj2 = toObj(mArr2[j]);
  4466.  
  4467. // console.log(948705, idx, obj1 , obj1.id, (obj1.fullDurationSec - obj1.durationSec) * 1000, obj1.__orderTime__)
  4468.  
  4469. // console.log(948706, idx, obj2 , obj2.id, (obj2.fullDurationSec - obj2.durationSec) * 1000, obj2.__orderTime__)
  4470.  
  4471. }
  4472.  
  4473. // console.log(948702, arr.slice(0));
  4474. // console.log(948701, arr);
  4475. // arr = arr.map(aItem => {
  4476. // const idx = mArr1.indexOf(aItem);
  4477. // if (idx < 0) return aItem;
  4478. // return mArr2[idx];
  4479. // });
  4480. // console.log(948702, arr);
  4481.  
  4482. // mostly in order, but some not in order
  4483.  
  4484.  
  4485. // eg
  4486.  
  4487. /*
  4488.  
  4489.  
  4490. 948711 68 '1734488590715474'
  4491. 948711 69 '1734488590909853'
  4492. 948711 70 '1734488594763719'
  4493. 948711 71 '1734488602334615' <
  4494. 948711 72 '1734488602267214' <
  4495. 948711 73 '1734488602751771'
  4496. */
  4497.  
  4498. // arr.filter(aItem=>{
  4499.  
  4500. // const p = toObj(aItem);
  4501. // if(p.timestampUsec) return true;
  4502.  
  4503. // }).forEach((aItem,idx)=>{
  4504.  
  4505. // const p = toObj(aItem);
  4506. // console.log(948711, idx, p.timestampUsec);
  4507. // })
  4508.  
  4509. // return arr;
  4510.  
  4511. }
  4512.  
  4513.  
  4514. {
  4515.  
  4516.  
  4517. const mapper = new Map();
  4518.  
  4519.  
  4520. const idxices = [];
  4521.  
  4522. let mArr1 = arr.filter((aItem,idx) => {
  4523.  
  4524. const timestampUsec = +toLAObj(aItem).timestampUsec; // +false.x = NaN
  4525. if(timestampUsec > 0){
  4526. idxices.push(idx);
  4527. mapper.set(aItem, timestampUsec)
  4528. return true;
  4529. }
  4530. return false;
  4531. });
  4532.  
  4533. if(mapper.size > 1){
  4534.  
  4535.  
  4536. let mArr2 = mArr1/*.slice(0)*/.sort((a, b) => {
  4537. return mapper.get(a) - mapper.get(b);
  4538. // low index = oldest = smallest timestamp
  4539. });
  4540. // console.log(948701, arr.slice(0));
  4541. for(let j = 0, l=mArr1.length;j <l;j++){
  4542. const idx = idxices[j];
  4543. arr[idx] = mArr2[j];
  4544. // const obj1 = toObj(mArr1[j]);
  4545. // const obj2 = toObj(mArr2[j]);
  4546. // console.log(948711, idx, obj1 === obj2, obj1, obj1.timestampUsec);
  4547. // console.log(948712, idx, obj1 === obj2, obj2, obj2.timestampUsec);
  4548. }
  4549.  
  4550. }
  4551.  
  4552. }
  4553.  
  4554.  
  4555. return arr;
  4556.  
  4557.  
  4558. }
  4559.  
  4560. if (ATTEMPT_TICKER_ANIMATION_START_TIME_DETECTION) {
  4561. getLCRDummy().then(async (lcrDummy) => {
  4562.  
  4563. const tag = "yt-live-chat-renderer"
  4564. const dummy = lcrDummy;
  4565.  
  4566. const cProto = getProto(dummy);
  4567. if (!cProto || !cProto.attached) {
  4568. console.warn(`proto.attached for ${tag} is unavailable.`);
  4569. return;
  4570. }
  4571.  
  4572. mightFirstCheckOnYtInit();
  4573. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-renderer hacks");
  4574. console.log("[Begin]");
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581. if (typeof cProto.playerProgressChanged_ === 'function' && !cProto.playerProgressChanged32_) {
  4582.  
  4583. cProto.playerProgressChanged32_ = cProto.playerProgressChanged_;
  4584.  
  4585. const pop078 = function () {
  4586. const r = this.pop78();
  4587.  
  4588. if (r && (r.actions || 0).length >= 1 && r.videoOffsetTimeMsec) {
  4589. for (const action of r.actions) {
  4590.  
  4591. const itemActionKey = !action ? null : 'addChatItemAction' in action ? 'addChatItemAction' : 'addLiveChatTickerItemAction' in action ? 'addLiveChatTickerItemAction' : null;
  4592. if (itemActionKey) {
  4593.  
  4594. const itemAction = action[itemActionKey];
  4595. const item = (itemAction || 0).item;
  4596. if (typeof item === 'object') {
  4597.  
  4598. const rendererKey = firstObjectKey(item);
  4599. if (rendererKey) {
  4600. const renderer = item[rendererKey];
  4601. if (renderer && typeof renderer === 'object') {
  4602. renderer.__videoOffsetTimeMsec__ = r.videoOffsetTimeMsec;
  4603. renderer.__progressAt__ = playerProgressChangedArg1;
  4604.  
  4605. // console.log(48117006)
  4606. }
  4607.  
  4608. }
  4609.  
  4610. }
  4611. }
  4612. }
  4613. }
  4614. return r;
  4615. }
  4616.  
  4617. const replayQueueProxyHandler = {
  4618. get(target, prop, receiver) {
  4619. if (prop === 'qe3') return 1;
  4620. const v = target[prop];
  4621. if (prop === 'front_') {
  4622. if (v && typeof v.length === 'number') {
  4623. if (!v.pop78) {
  4624. v.pop78 = v.pop;
  4625. v.pop = pop078;
  4626. }
  4627. }
  4628. }
  4629. return v;
  4630. }
  4631. };
  4632.  
  4633. cProto.playerProgressChanged_ = function (a, b, c) {
  4634. // console.log(48117005)
  4635. playerProgressChangedArg1 = a;
  4636. playerProgressChangedArg2 = b;
  4637. playerProgressChangedArg3 = c;
  4638. const replayBuffer_ = this.replayBuffer_;
  4639. if (replayBuffer_) {
  4640. const replayQueue = replayBuffer_.replayQueue
  4641. if (replayQueue && typeof replayQueue === 'object' && !replayQueue.qe3) {
  4642. replayBuffer_.replayQueue = new Proxy(replayBuffer_.replayQueue, replayQueueProxyHandler);
  4643. }
  4644. }
  4645. Promise.resolve().then(updateTickerCurrentTime);
  4646. return this.playerProgressChanged32_.apply(this, arguments);
  4647. };
  4648.  
  4649. }
  4650.  
  4651. console.log("[End]");
  4652. console.groupEnd();
  4653.  
  4654.  
  4655. });
  4656.  
  4657. }
  4658.  
  4659.  
  4660.  
  4661. customElements.whenDefined('yt-live-chat-item-list-renderer').then(() => {
  4662.  
  4663.  
  4664. const tag = "yt-live-chat-item-list-renderer"
  4665. const dummy = document.createElement(tag);
  4666.  
  4667. const cProto = getProto(dummy);
  4668. if (!cProto || !cProto.attached) {
  4669. console.warn(`proto.attached for ${tag} is unavailable.`);
  4670. return;
  4671. }
  4672.  
  4673. mightFirstCheckOnYtInit();
  4674. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-item-list-renderer hacks");
  4675. console.log("[Begin]");
  4676.  
  4677. const mclp = cProto;
  4678. const _flag0281_ = window._flag0281_ || mclp._flag0281_;
  4679.  
  4680. try {
  4681. assertor(() => typeof mclp.scrollToBottom_ === 'function');
  4682. assertor(() => typeof mclp.flushActiveItems_ === 'function');
  4683. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  4684. assertor(() => typeof mclp.setAtBottom === 'function');
  4685. assertor(() => typeof mclp.scrollToBottom66_ === 'undefined');
  4686. assertor(() => typeof mclp.flushActiveItems66_ === 'undefined');
  4687. } catch (e) { }
  4688.  
  4689.  
  4690. try {
  4691. assertor(() => typeof mclp.attached === 'function');
  4692. assertor(() => typeof mclp.detached === 'function');
  4693. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  4694. assertor(() => typeof mclp.isSmoothScrollEnabled_ === 'function');
  4695. assertor(() => typeof mclp.maybeResizeScrollContainer_ === 'function');
  4696. assertor(() => typeof mclp.refreshOffsetContainerHeight_ === 'function');
  4697. assertor(() => typeof mclp.smoothScroll_ === 'function');
  4698. assertor(() => typeof mclp.resetSmoothScroll_ === 'function');
  4699. } catch (e) { }
  4700.  
  4701. mclp.__intermediate_delay__ = null;
  4702.  
  4703. let myk = 0;
  4704. let mlf = 0;
  4705. let myw = 0;
  4706. let mzt = 0;
  4707. let zarr = null;
  4708. let mlg = 0;
  4709.  
  4710. if ((_flag0281_ & 0x2000) == 0) {
  4711.  
  4712. if ((mclp.clearList || 0).length === 0) {
  4713. (_flag0281_ & 0x2) == 0 && assertor(() => fnIntegrity(mclp.clearList, '0.106.50'));
  4714. mclp.clearList66 = mclp.clearList;
  4715. mclp.clearList = function () {
  4716. myk++;
  4717. mlf++;
  4718. myw++;
  4719. mzt++;
  4720. mlg++;
  4721. zarr = null;
  4722. this.__intermediate_delay__ = null;
  4723. this.clearList66();
  4724. };
  4725. console.log("clearList", "OK");
  4726. } else {
  4727. console.log("clearList", "NG");
  4728. }
  4729.  
  4730. }
  4731.  
  4732.  
  4733.  
  4734. let onListRendererAttachedDone = false;
  4735.  
  4736. function setList(itemOffset, items) {
  4737.  
  4738. const isFirstTime = onListRendererAttachedDone === false;
  4739.  
  4740. if (isFirstTime) {
  4741. onListRendererAttachedDone = true;
  4742. Promise.resolve().then(watchUserCSS);
  4743. addCssManaged();
  4744. setupEvents();
  4745. }
  4746.  
  4747. setupStyle(itemOffset, items);
  4748.  
  4749. setupMutObserver(items);
  4750. }
  4751.  
  4752. mclp.attached419 = async function () {
  4753.  
  4754. if (!this.isAttached) return;
  4755.  
  4756. let maxTrial = 16;
  4757. while (!this.$ || !this.$['item-scroller'] || !this.$['item-offset'] || !this.$['items']) {
  4758. if (--maxTrial < 0 || !this.isAttached) return;
  4759. await iAFP(this.hostElement).then();
  4760. // await new Promise(requestAnimationFrame);
  4761. }
  4762.  
  4763. if (this.isAttached !== true) return;
  4764.  
  4765. if (!this.$) {
  4766. console.warn("!this.$");
  4767. return;
  4768. }
  4769. if (!this.$) return;
  4770. /** @type {HTMLElement | null} */
  4771. const itemScroller = this.$['item-scroller'];
  4772. /** @type {HTMLElement | null} */
  4773. const itemOffset = this.$['item-offset'];
  4774. /** @type {HTMLElement | null} */
  4775. const items = this.$['items'];
  4776.  
  4777. if (!itemScroller || !itemOffset || !items) {
  4778. console.warn("items.parentNode !== itemOffset");
  4779. return;
  4780. }
  4781.  
  4782. if (nodeParent(items) !== itemOffset) {
  4783.  
  4784. console.warn("items.parentNode !== itemOffset");
  4785. return;
  4786. }
  4787.  
  4788.  
  4789. if (items.id !== 'items' || itemOffset.id !== "item-offset") {
  4790.  
  4791. console.warn("id incorrect");
  4792. return;
  4793. }
  4794.  
  4795. 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')
  4796.  
  4797. if (!isTargetItems) {
  4798. console.warn("!isTargetItems");
  4799. return;
  4800. }
  4801.  
  4802. setList(itemOffset, items);
  4803.  
  4804. }
  4805.  
  4806. mclp.attached331 = mclp.attached;
  4807. mclp.attached = function () {
  4808. this.attached419 && this.attached419();
  4809. return this.attached331();
  4810. }
  4811.  
  4812. mclp.detached331 = mclp.detached;
  4813.  
  4814. mclp.detached = function () {
  4815. setupMutObserver();
  4816. return this.detached331();
  4817. }
  4818.  
  4819. const t29s = document.querySelectorAll("yt-live-chat-item-list-renderer");
  4820. for (const t29 of t29s) {
  4821. if (insp(t29).isAttached === true) {
  4822. t29.attached419();
  4823. }
  4824. }
  4825.  
  4826. if ((mclp.async || 0).length === 2 && (mclp.cancelAsync || 0).length === 1) {
  4827.  
  4828. assertor(() => fnIntegrity(mclp.async, '2.24.15'));
  4829. assertor(() => fnIntegrity(mclp.cancelAsync, '1.15.8'));
  4830.  
  4831. /** @type {Map<number, any>} */
  4832. const aMap = new Map();
  4833. let count = 6150;
  4834. mclp.async66 = mclp.async;
  4835. mclp.async = function (e, f) {
  4836. // ensure the previous operation is done
  4837. // .async is usually after the time consuming functions like flushActiveItems_ and scrollToBottom_
  4838. const hasF = arguments.length === 2;
  4839. const stack = new Error().stack;
  4840. const isFlushAsync = stack.indexOf('flushActiveItems_') >= 0;
  4841. if (count > 1e9) count = 6159;
  4842. const resId = ++count;
  4843. aMap.set(resId, e);
  4844. (this.__intermediate_delay__ || Promise.resolve()).then(rk => {
  4845. const rp = aMap.get(resId);
  4846. if (typeof rp !== 'function') {
  4847. return;
  4848. }
  4849. let cancelCall = false;
  4850. if (isFlushAsync) {
  4851. if (rk < 0) {
  4852. cancelCall = true;
  4853. } else if (rk === 2 && arguments[0] === this.maybeScrollToBottom_) {
  4854. cancelCall = true;
  4855. }
  4856. }
  4857. if (cancelCall) {
  4858. aMap.delete(resId);
  4859. } else {
  4860. const asyncEn = function () {
  4861. aMap.delete(resId);
  4862. return rp.apply(this, arguments);
  4863. };
  4864. aMap.set(resId, hasF ? this.async66(asyncEn, f) : this.async66(asyncEn));
  4865. }
  4866. });
  4867.  
  4868. return resId;
  4869. }
  4870.  
  4871. mclp.cancelAsync66 = mclp.cancelAsync;
  4872. mclp.cancelAsync = function (resId) {
  4873. if (resId <= 6150) {
  4874. this.cancelAsync66(resId);
  4875. } else if (aMap.has(resId)) {
  4876. const rp = aMap.get(resId);
  4877. aMap.delete(resId);
  4878. if (typeof rp !== 'function') {
  4879. this.cancelAsync66(rp);
  4880. }
  4881. }
  4882. }
  4883.  
  4884. console.log("async", "OK");
  4885. } else {
  4886. console.log("async", "NG");
  4887. }
  4888.  
  4889.  
  4890. if ((_flag0281_ & 0x2) == 0) {
  4891. if ((mclp.showNewItems_ || 0).length === 0 && ENABLE_NO_SMOOTH_TRANSFORM) {
  4892.  
  4893. assertor(() => fnIntegrity(mclp.showNewItems_, '0.170.79'));
  4894. mclp.showNewItems66_ = mclp.showNewItems_;
  4895.  
  4896. mclp.showNewItems77_ = async function () {
  4897. if (myk > 1e9) myk = 9;
  4898. let tid = ++myk;
  4899.  
  4900. await iAFP(this.hostElement).then();
  4901. // await new Promise(requestAnimationFrame);
  4902.  
  4903. if (tid !== myk) {
  4904. return;
  4905. }
  4906.  
  4907. const cnt = this;
  4908.  
  4909. await Promise.resolve();
  4910. cnt.showNewItems66_();
  4911.  
  4912. await Promise.resolve();
  4913.  
  4914. }
  4915.  
  4916. mclp.showNewItems_ = function () {
  4917.  
  4918. const cnt = this;
  4919. cnt.__intermediate_delay__ = new Promise(resolve => {
  4920. cnt.showNewItems77_().then(() => {
  4921. resolve();
  4922. });
  4923. });
  4924. }
  4925.  
  4926. console.log("showNewItems_", "OK");
  4927. } else {
  4928. console.log("showNewItems_", "NG");
  4929. }
  4930.  
  4931. }
  4932.  
  4933. if ((_flag0281_ & 0x2000) == 0) {
  4934. if ((mclp.flushActiveItems_ || 0).length === 0) {
  4935.  
  4936. if ((_flag0281_ & 0x2) == 0) {
  4937.  
  4938. const sfi = fnIntegrity(mclp.flushActiveItems_);
  4939. if (sfi === '0.156.86') {
  4940. // https://www.youtube.com/s/desktop/f61c8d85/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4941.  
  4942. // added "refreshOffsetContainerHeight_"
  4943.  
  4944. // f.flushActiveItems_ = function() {
  4945. // var a = this;
  4946. // if (0 < this.activeItems_.length)
  4947. // if (this.canScrollToBottom_()) {
  4948. // var b = Math.max(this.visibleItems.length + this.activeItems_.length - this.data.maxItemsToDisplay, 0);
  4949. // b && this.splice("visibleItems", 0, b);
  4950. // if (this.isSmoothScrollEnabled_() || this.dockableMessages.length)
  4951. // this.preinsertHeight_ = this.items.clientHeight;
  4952. // this.activeItems_.unshift("visibleItems");
  4953. // try {
  4954. // this.push.apply(this, this.activeItems_)
  4955. // } catch (c) {
  4956. // fm(c)
  4957. // }
  4958. // this.activeItems_ = [];
  4959. // this.isSmoothScrollEnabled_() ? this.canScrollToBottom_() && Mw(function() {
  4960. // a.showNewItems_()
  4961. // }) : Mw(function() {
  4962. // a.refreshOffsetContainerHeight_();
  4963. // a.maybeScrollToBottom_()
  4964. // })
  4965. // } else
  4966. // this.activeItems_.length > this.data.maxItemsToDisplay && this.activeItems_.splice(0, this.activeItems_.length - this.data.maxItemsToDisplay)
  4967. // }
  4968. // ;
  4969.  
  4970. } else if (sfi === '0.150.84') {
  4971. // https://www.youtube.com/s/desktop/e4d15d2c/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4972. // var b = Math.max(this.visibleItems.length + this.activeItems_.length - this.data.maxItemsToDisplay, 0);
  4973. // b && this.splice("visibleItems", 0, b);
  4974. // if (this.isSmoothScrollEnabled_() || this.dockableMessages.length)
  4975. // this.preinsertHeight_ = this.items.clientHeight;
  4976. // this.activeItems_.unshift("visibleItems");
  4977. // try {
  4978. // this.push.apply(this, this.activeItems_)
  4979. // } catch (c) {
  4980. // nm(c)
  4981. // }
  4982. // this.activeItems_ = [];
  4983. // this.isSmoothScrollEnabled_() ? this.canScrollToBottom_() && zQ(function() {
  4984. // a.showNewItems_()
  4985. // }) : zQ(function() {
  4986. // a.maybeScrollToBottom_()
  4987. // })
  4988. } else if (sfi === '0.137.81' || sfi === '0.138.81') {
  4989. // e.g. https://www.youtube.com/yts/jsbin/live_chat_polymer-vflCyWEBP/live_chat_polymer.js
  4990. } else {
  4991. assertor(() => fnIntegrity(mclp.flushActiveItems_, '0.150.84'));
  4992. }
  4993. }
  4994.  
  4995. let hasMoreMessageState = !ENABLE_SHOW_MORE_BLINKER ? -1 : 0;
  4996.  
  4997. mclp.flushActiveItems66_ = mclp.flushActiveItems_;
  4998.  
  4999.  
  5000. const preloadFn = (acItems) => {
  5001. let waitFor = [];
  5002. /** @type {Set<string>} */
  5003. const imageLinks = new Set();
  5004.  
  5005. if (ENABLE_PRELOAD_THUMBNAIL || EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL) {
  5006. for (const item of acItems) {
  5007. fixLiveChatItem(item, imageLinks);
  5008. }
  5009. }
  5010. if (ENABLE_PRELOAD_THUMBNAIL && kptPF !== null && (kptPF & (8 | 4)) && imageLinks.size > 0) {
  5011.  
  5012. // reference: https://github.com/Yuanfang-fe/Blog-X/issues/34
  5013. const rel = kptPF & 8 ? 'subresource' : kptPF & 16 ? 'preload' : kptPF & 4 ? 'prefetch' : '';
  5014. // preload performs the high priority fetching.
  5015. // prefetch delays the chat display if the video resoruce is demanding.
  5016.  
  5017. if (rel) {
  5018.  
  5019. imageLinks.forEach(imageLink => {
  5020. let d = false;
  5021. if (SKIP_PRELOAD_EMOJI && imageLink.includes('.ggpht.com/')) return;
  5022. const isEmoji = imageLink.includes('/emoji/');
  5023. const pretechedSet = isEmoji ? emojiPrefetched : authorPhotoPrefetched;
  5024. if (!pretechedSet.has(imageLink)) {
  5025. pretechedSet.add(imageLink);
  5026. d = true;
  5027. }
  5028. if (d) {
  5029. waitFor.push(linker(null, rel, imageLink, 'image'));
  5030.  
  5031. }
  5032. })
  5033.  
  5034. }
  5035.  
  5036. }
  5037.  
  5038. return async () => {
  5039. if (waitFor.length > 0) {
  5040. await Promise.race([new Promise(r => setTimeout(r, 250)), Promise.all(waitFor)]);
  5041. }
  5042. waitFor.length = 0;
  5043. waitFor = null;
  5044. };
  5045.  
  5046. };
  5047.  
  5048. mclp.flushActiveItems78_ = async function (tid) {
  5049. try {
  5050.  
  5051. if (tid !== mlf) return;
  5052. if ((this._flag0281_ & 0x4) == 0x4) {
  5053. const cnt = this;
  5054.  
  5055. if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5056. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return;
  5057.  
  5058. mlf++;
  5059. if (mlg > 1e9) mlg = 9;
  5060. ++mlg;
  5061. const acItems = cnt.activeItems_;
  5062. if (acItems.length < MAX_ITEMS_FOR_FULL_FLUSH) {
  5063. const pn = preloadFn(acItems);
  5064. await pn();
  5065. }
  5066. cnt.flushActiveItems66_();
  5067.  
  5068. return 1;
  5069.  
  5070. }
  5071. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  5072. let logger = false;
  5073. const cnt = this;
  5074. let immd = cnt.__intermediate_delay__;
  5075. await iAFP(this.hostElement).then();
  5076. // await new Promise(requestAnimationFrame);
  5077.  
  5078. if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5079. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return;
  5080.  
  5081. mlf++;
  5082. if (mlg > 1e9) mlg = 9;
  5083. ++mlg;
  5084.  
  5085. const tmpMaxItemsCount = this.data.maxItemsToDisplay;
  5086. const reducedMaxItemsToDisplay = MAX_ITEMS_FOR_FULL_FLUSH;
  5087. let changeMaxItemsToDisplay = false;
  5088. const activeItemsLen = this.activeItems_.length;
  5089. if (activeItemsLen > tmpMaxItemsCount && tmpMaxItemsCount > 0) {
  5090. logger = true;
  5091.  
  5092. groupCollapsed("YouTube Super Fast Chat", " | flushActiveItems78_");
  5093.  
  5094. logger && console.log('[Begin]')
  5095.  
  5096. console.log('this.activeItems_.length > N', activeItemsLen, tmpMaxItemsCount);
  5097. if (ENABLE_REDUCED_MAXITEMS_FOR_FLUSH && lockedMaxItemsToDisplay === tmpMaxItemsCount && lockedMaxItemsToDisplay !== reducedMaxItemsToDisplay) {
  5098. console.log('reduce maxitems');
  5099. if (tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  5100. // as all the rendered chats are already "outdated"
  5101. // all old chats shall remove and reduced number of few chats will be rendered
  5102. // then restore to the original number
  5103. changeMaxItemsToDisplay = true;
  5104. this.data.maxItemsToDisplay = reducedMaxItemsToDisplay;
  5105. console.log(`'maxItemsToDisplay' is reduced from ${tmpMaxItemsCount} to ${reducedMaxItemsToDisplay}.`)
  5106. }
  5107. this.activeItems_.splice(0, activeItemsLen - this.data.maxItemsToDisplay);
  5108. // console.log('changeMaxItemsToDisplay 01', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  5109.  
  5110. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  5111. } else {
  5112. this.activeItems_.splice(0, activeItemsLen - (tmpMaxItemsCount < 900 ? tmpMaxItemsCount : 900));
  5113.  
  5114. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  5115. }
  5116. }
  5117. // it is found that it will render all stacked chats after switching back from background
  5118. // to avoid lagging in popular livestream with massive chats, trim first before rendering.
  5119. // this.activeItems_.length > this.data.maxItemsToDisplay && this.activeItems_.splice(0, this.activeItems_.length - this.data.maxItemsToDisplay);
  5120.  
  5121. cnt.__intermediate_delay__ = Promise.all([cnt.__intermediate_delay__ || null, immd || null]);
  5122. await Promise.resolve();
  5123. const acItems = cnt.activeItems_;
  5124. const len1 = acItems.length;
  5125. if (!len1) console.warn('cnt.activeItems_.length = 0');
  5126.  
  5127. const pn = preloadFn(acItems);
  5128. const noVisibleItem1 = ((cnt.visibleItems || 0).length || 0) === 0;
  5129. skipDontRender = noVisibleItem1;
  5130. await pn();
  5131. // console.log('ss2', Date.now())
  5132. cnt.flushActiveItems66_();
  5133. const noVisibleItem2 = ((cnt.visibleItems || 0).length || 0) === 0;
  5134. skipDontRender = noVisibleItem2;
  5135. await Promise.resolve();
  5136. if (changeMaxItemsToDisplay && this.data.maxItemsToDisplay === reducedMaxItemsToDisplay && tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  5137. this.data.maxItemsToDisplay = tmpMaxItemsCount;
  5138.  
  5139. logger && console.log(`'maxItemsToDisplay' is restored from ${reducedMaxItemsToDisplay} to ${tmpMaxItemsCount}.`);
  5140. // console.log('changeMaxItemsToDisplay 02', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  5141. } else if (changeMaxItemsToDisplay) {
  5142.  
  5143. logger && console.log(`'maxItemsToDisplay' cannot be restored`, {
  5144. maxItemsToDisplay: this.data.maxItemsToDisplay,
  5145. reducedMaxItemsToDisplay,
  5146. originalMaxItemsToDisplay: tmpMaxItemsCount
  5147. });
  5148. }
  5149. logger && console.log('[End]');
  5150.  
  5151. logger && console.groupEnd();
  5152.  
  5153. if (noVisibleItem1 && !noVisibleItem2) {
  5154. // fix possible no auto scroll issue.
  5155. !((cnt.__notRequired__ || 0) & 256) && setTimeout(() => cnt.setAtBottom(), 1);
  5156. }
  5157.  
  5158. if (!ENABLE_NO_SMOOTH_TRANSFORM) {
  5159.  
  5160.  
  5161. const ff = () => {
  5162.  
  5163. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5164. // if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5165. if (!cnt.atBottom && cnt.allowScroll && cnt.hasUserJustInteracted11_ && !cnt.hasUserJustInteracted11_()) {
  5166.  
  5167. if (typeof nextBrowserTick !== 'function') {
  5168. cnt.scrollToBottom_();
  5169. Promise.resolve().then(() => {
  5170. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5171. if (!cnt.canScrollToBottom_()) cnt.scrollToBottom_();
  5172. });
  5173. } else {
  5174. nextBrowserTick(() => {
  5175. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  5176. cnt.scrollToBottom_();
  5177. });
  5178. }
  5179.  
  5180. }
  5181. }
  5182.  
  5183. ff();
  5184.  
  5185.  
  5186. Promise.resolve().then(ff);
  5187.  
  5188. // requestAnimationFrame(ff);
  5189. } else if (true) { // it might not be sticky to bottom when there is a full refresh.
  5190.  
  5191. const knt = cnt;
  5192. if (!scrollChatFn) {
  5193. const cnt = knt;
  5194. const f = () => {
  5195. const itemScroller = cnt.itemScroller;
  5196. if (!itemScroller || itemScroller.isConnected === false || cnt.isAttached === false) return;
  5197. if (!cnt.atBottom) {
  5198. cnt.scrollToBottom_();
  5199. } else if (itemScroller.scrollTop === 0) { // not yet interacted by user; cannot stick to bottom
  5200. itemScroller.scrollTop = itemScroller.scrollHeight;
  5201. }
  5202. };
  5203. if (typeof nextBrowserTick !== 'function') {
  5204. scrollChatFn = () => Promise.resolve().then(f).then(f);
  5205. } else {
  5206. scrollChatFn = () => nextBrowserTick(f);
  5207. }
  5208. }
  5209.  
  5210. scrollChatFn();
  5211. }
  5212.  
  5213. return 1;
  5214.  
  5215.  
  5216. } catch (e) {
  5217. console.warn(e);
  5218. }
  5219. }
  5220.  
  5221. mclp.flushActiveItems77_ = function () {
  5222.  
  5223. return new Promise(resResolve => {
  5224. try {
  5225. const cnt = this;
  5226. if (mlf > 1e9) mlf = 9;
  5227. let tid = ++mlf;
  5228. const hostElement = cnt.hostElement || cnt;
  5229. if (tid !== mlf || cnt.isAttached === false || hostElement.isConnected === false) return resResolve();
  5230. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return resResolve();
  5231.  
  5232. // 4 times to maxItems to avoid frequent trimming.
  5233. // 1 ... 10 ... 20 ... 30 ... 40 ... 50 ... 60 => 16 ... 20 ... 30 ..... 60 ... => 16
  5234.  
  5235. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  5236. this.activeItems_.length > lockedMaxItemsToDisplay * 4 && lockedMaxItemsToDisplay > 4 && this.activeItems_.splice(0, this.activeItems_.length - lockedMaxItemsToDisplay - 1);
  5237. if (cnt.canScrollToBottom_()) {
  5238. cnt.mutexPromiseFA78 = (cnt.mutexPromiseFA78 || Promise.resolve())
  5239. .then(() => cnt.flushActiveItems78_(tid)) // async function
  5240. .then((asyncResult) => {
  5241. resResolve(asyncResult); // either undefined or 1
  5242. resResolve = null;
  5243. }).catch((e) => {
  5244. console.warn(e);
  5245. if (resResolve) resResolve();
  5246. });
  5247. } else {
  5248. resResolve(2);
  5249. resResolve = null;
  5250. }
  5251. } catch (e) {
  5252. console.warn(e);
  5253. if (resResolve) resResolve();
  5254. }
  5255.  
  5256.  
  5257. });
  5258.  
  5259. }
  5260.  
  5261. mclp.flushActiveItems_ = function () {
  5262. const cnt = this;
  5263.  
  5264. if (arguments.length !== 0 || !cnt.activeItems_ || !cnt.canScrollToBottom_) return cnt.flushActiveItems66_.apply(this, arguments);
  5265.  
  5266. if (cnt.activeItems_.length === 0) {
  5267. cnt.__intermediate_delay__ = null;
  5268. return;
  5269. }
  5270.  
  5271. const cntData = ((cnt || 0).data || 0);
  5272. if (cntData.maxItemsToDisplay944 === undefined) {
  5273. cntData.maxItemsToDisplay944 = null;
  5274. if (cntData.maxItemsToDisplay > MAX_ITEMS_FOR_TOTAL_DISPLAY) cntData.maxItemsToDisplay = MAX_ITEMS_FOR_TOTAL_DISPLAY;
  5275. cntData.maxItemsToDisplay944 = cntData.maxItemsToDisplay || null;
  5276. }
  5277.  
  5278. // ignore previous __intermediate_delay__ and create a new one
  5279. cnt.__intermediate_delay__ = new Promise(resolve => {
  5280. cnt.flushActiveItems77_().then(rt => { // either undefined or 1 or 2
  5281. if (rt === 1) {
  5282. resolve(1); // success, scroll to bottom
  5283. if (hasMoreMessageState === 1) {
  5284. hasMoreMessageState = 0;
  5285. const showMore = (cnt.$ || 0)['show-more'];
  5286. if (showMore) {
  5287. showMore.classList.remove('has-new-messages-miuzp');
  5288. }
  5289. }
  5290. }
  5291. else if (rt === 2) {
  5292. resolve(2); // success, trim
  5293. if (hasMoreMessageState === 0) {
  5294. hasMoreMessageState = 1;
  5295. const showMore = cnt.$['show-more'];
  5296. if (showMore) {
  5297. showMore.classList.add('has-new-messages-miuzp');
  5298. }
  5299. }
  5300. }
  5301. else resolve(-1); // skip
  5302. }).catch(e => {
  5303. console.warn(e);
  5304. });
  5305. });
  5306.  
  5307. }
  5308. console.log("flushActiveItems_", "OK");
  5309. } else {
  5310. console.log("flushActiveItems_", "NG");
  5311. }
  5312. }
  5313.  
  5314. if ((_flag0281_ & 0x40) == 0) {
  5315.  
  5316. if (ENABLE_NO_SMOOTH_TRANSFORM && SUPPRESS_refreshOffsetContainerHeight_ && typeof mclp.refreshOffsetContainerHeight_ === 'function' && !mclp.refreshOffsetContainerHeight26_ && mclp.refreshOffsetContainerHeight_.length === 0) {
  5317. assertor(() => fnIntegrity(mclp.refreshOffsetContainerHeight_, '0.31.21'));
  5318. mclp.refreshOffsetContainerHeight26_ = mclp.refreshOffsetContainerHeight_;
  5319. mclp.refreshOffsetContainerHeight_ = function () {
  5320. // var a = this.itemScroller.clientHeight;
  5321. // this.itemOffset.style.height = this.items.clientHeight + "px";
  5322. // this.bottomAlignMessages && (this.itemOffset.style.minHeight = a + "px")
  5323. }
  5324. console.log("refreshOffsetContainerHeight_", "OK");
  5325. } else {
  5326. console.log("refreshOffsetContainerHeight_", "NG");
  5327. }
  5328.  
  5329. }
  5330.  
  5331. if ((_flag0281_ & 0x80) == 0) {
  5332. mclp.delayFlushActiveItemsAfterUserAction11_ = async function () {
  5333. try {
  5334. if (mlg > 1e9) mlg = 9;
  5335. const tid = ++mlg;
  5336. const keepTrialCond = () => this.atBottom && this.allowScroll && (tid === mlg) && this.isAttached === true && this.activeItems_.length >= 1 && (this.hostElement || 0).isConnected === true;
  5337. const runCond = () => this.canScrollToBottom_();
  5338. if (!keepTrialCond()) return;
  5339. if (runCond()) return this.flushActiveItems_() | 1; // avoid return promise
  5340. await new Promise(r => setTimeout(r, 80));
  5341. if (!keepTrialCond()) return;
  5342. if (runCond()) return this.flushActiveItems_() | 1;
  5343. await iAFP(this.hostElement).then();
  5344. // await new Promise(requestAnimationFrame);
  5345. if (runCond()) return this.flushActiveItems_() | 1;
  5346. } catch (e) {
  5347. console.warn(e);
  5348. }
  5349. }
  5350. }
  5351.  
  5352. if ((_flag0281_ & 0x40) == 0 ) {
  5353.  
  5354. if( (mclp.atBottomChanged_ || 0).length === 0) {
  5355. // note: if the scrolling is too frequent, the show more visibility might get wrong.
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361. const sfi = fnIntegrity(mclp.atBottomChanged_);
  5362.  
  5363. if(sfi === '0.75.37'){
  5364. // https://www.youtube.com/s/desktop/f7495da0/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  5365.  
  5366.  
  5367. // Dec 2024.
  5368.  
  5369. /**
  5370. *
  5371. *
  5372. f.atBottomChanged_ = function() {
  5373. var a = this;
  5374. this.atBottom ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = Zu(function() {
  5375. R(a.hostElement).querySelector("#show-more").style.visibility = "hidden"
  5376. }, 200)) : (this.hideShowMoreAsync_ && $u(this.hideShowMoreAsync_),
  5377. this.hideShowMoreAsync_ = null,
  5378. R(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  5379. }
  5380. *
  5381. */
  5382.  
  5383. } else {
  5384. assertor(() => fnIntegrity(mclp.atBottomChanged_, '0.75.37'));
  5385. }
  5386.  
  5387.  
  5388. const querySelector = HTMLElement.prototype.querySelector;
  5389. const U = (element) => ({
  5390. querySelector: (selector) => querySelector.call(element, selector)
  5391. });
  5392.  
  5393. let qid = 0;
  5394. mclp.__updateButtonVisibility371__ = function (button) {
  5395. Promise.resolve(this).then((cnt) => {
  5396. button.style.visibility = cnt.__buttonVisibility371__;
  5397. });
  5398. }
  5399. const fixButtonOnClick = function (cnt, button) {
  5400. button.addEventListener('click', (evt) => {
  5401. evt.stopImmediatePropagation();
  5402. evt.stopPropagation();
  5403. evt.preventDefault();
  5404. Promise.resolve(cnt).then((cnt) => {
  5405. cnt.scrollToBottom_();
  5406. });
  5407. }, true);
  5408. // button.addEventListener('pointerup', (evt)=>{
  5409. // evt.stopImmediatePropagation();
  5410. // evt.stopPropagation();
  5411. // }, true);
  5412. // button.addEventListener('mouseup', (evt)=>{
  5413. // evt.stopImmediatePropagation();
  5414. // evt.stopPropagation();
  5415. // }, true);
  5416. }
  5417. mclp.atBottomChanged_ = function () {
  5418. let a = this.atBottom;
  5419. const button = (this.$ || 0)['show-more'];
  5420. if (button) {
  5421. // primary execution
  5422. if (a) {
  5423. if (this.__buttonVisibility371__ !== "hidden") {
  5424. this.__buttonVisibility371__ = "hidden";
  5425. if (!this.hideShowMoreAsync_) {
  5426. const tid = ++qid;
  5427. this.hideShowMoreAsync_ = foregroundPromiseFn().then(() => {
  5428. if (tid !== qid) {
  5429. return;
  5430. }
  5431. this.__updateButtonVisibility371__(button);
  5432. });
  5433. }
  5434. }
  5435. } else {
  5436. if (this.__buttonVisibility371__ !== "visible") {
  5437. this.__buttonVisibility371__ = "visible";
  5438. if (this.hideShowMoreAsync_) {
  5439. qid++;
  5440. }
  5441. this.hideShowMoreAsync_ = null;
  5442. if (!button.__fix_onclick__) {
  5443. button.__fix_onclick__ = true;
  5444. fixButtonOnClick(this, button);
  5445. }
  5446. this.__updateButtonVisibility371__(button);
  5447. }
  5448. }
  5449. } else {
  5450. // fallback
  5451. let tid = ++qid;
  5452. let b = this;
  5453. a ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = this.async(function () {
  5454. if (tid !== qid) return;
  5455. U(b.hostElement).querySelector("#show-more").style.visibility = "hidden"
  5456. }, 200)) : (this.hideShowMoreAsync_ && this.cancelAsync(this.hideShowMoreAsync_),
  5457. this.hideShowMoreAsync_ = null,
  5458. U(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  5459. }
  5460. }
  5461.  
  5462. console.log("atBottomChanged_", "OK");
  5463.  
  5464. } else if ((mclp.atBottomChanged_ || 0).length === 1) {
  5465. // note: if the scrolling is too frequent, the show more visibility might get wrong.
  5466.  
  5467. const sfi = fnIntegrity(mclp.atBottomChanged_);
  5468. if (sfi === '1.73.37') {
  5469. // https://www.youtube.com/s/desktop/e4d15d2c/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  5470.  
  5471. /**
  5472. *
  5473. *
  5474. *
  5475. f.atBottomChanged_ = function(a) {
  5476. var b = this;
  5477. a ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = zQ(function() {
  5478. T(b.hostElement).querySelector("#show-more").style.visibility = "hidden"
  5479. }, 200)) : (this.hideShowMoreAsync_ && AQ(this.hideShowMoreAsync_),
  5480. this.hideShowMoreAsync_ = null,
  5481. T(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  5482. };
  5483.  
  5484. *
  5485. *
  5486. */
  5487.  
  5488.  
  5489. } else if (sfi === '1.75.39') {
  5490. // e.g. https://www.youtube.com/yts/jsbin/live_chat_polymer-vflCyWEBP/live_chat_polymer.js
  5491. } else {
  5492. assertor(() => fnIntegrity(mclp.atBottomChanged_, '1.73.37'));
  5493. }
  5494.  
  5495. const querySelector = HTMLElement.prototype.querySelector;
  5496. const U = (element) => ({
  5497. querySelector: (selector) => querySelector.call(element, selector)
  5498. });
  5499.  
  5500. let qid = 0;
  5501. mclp.__updateButtonVisibility371__ = function (button) {
  5502. Promise.resolve(this).then((cnt) => {
  5503. button.style.visibility = cnt.__buttonVisibility371__;
  5504. });
  5505. }
  5506. const fixButtonOnClick = function (cnt, button) {
  5507. button.addEventListener('click', (evt) => {
  5508. evt.stopImmediatePropagation();
  5509. evt.stopPropagation();
  5510. evt.preventDefault();
  5511. Promise.resolve(cnt).then((cnt) => {
  5512. cnt.scrollToBottom_();
  5513. });
  5514. }, true);
  5515. // button.addEventListener('pointerup', (evt)=>{
  5516. // evt.stopImmediatePropagation();
  5517. // evt.stopPropagation();
  5518. // }, true);
  5519. // button.addEventListener('mouseup', (evt)=>{
  5520. // evt.stopImmediatePropagation();
  5521. // evt.stopPropagation();
  5522. // }, true);
  5523. }
  5524. mclp.atBottomChanged_ = function (a) {
  5525. const button = (this.$ || 0)['show-more'];
  5526. if (button) {
  5527. // primary execution
  5528. if (a) {
  5529. if (this.__buttonVisibility371__ !== "hidden") {
  5530. this.__buttonVisibility371__ = "hidden";
  5531. if (!this.hideShowMoreAsync_) {
  5532. const tid = ++qid;
  5533. this.hideShowMoreAsync_ = foregroundPromiseFn().then(() => {
  5534. if (tid !== qid) {
  5535. return;
  5536. }
  5537. this.__updateButtonVisibility371__(button);
  5538. });
  5539. }
  5540. }
  5541. } else {
  5542. if (this.__buttonVisibility371__ !== "visible") {
  5543. this.__buttonVisibility371__ = "visible";
  5544. if (this.hideShowMoreAsync_) {
  5545. qid++;
  5546. }
  5547. this.hideShowMoreAsync_ = null;
  5548. if (!button.__fix_onclick__) {
  5549. button.__fix_onclick__ = true;
  5550. fixButtonOnClick(this, button);
  5551. }
  5552. this.__updateButtonVisibility371__(button);
  5553. }
  5554. }
  5555. } else {
  5556. // fallback
  5557. let tid = ++qid;
  5558. let b = this;
  5559. a ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = this.async(function () {
  5560. if (tid !== qid) return;
  5561. U(b.hostElement).querySelector("#show-more").style.visibility = "hidden"
  5562. }, 200)) : (this.hideShowMoreAsync_ && this.cancelAsync(this.hideShowMoreAsync_),
  5563. this.hideShowMoreAsync_ = null,
  5564. U(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  5565. }
  5566. }
  5567.  
  5568. console.log("atBottomChanged_", "OK");
  5569. } else {
  5570. console.log("atBottomChanged_", "NG");
  5571. }
  5572. }
  5573.  
  5574.  
  5575. if ((_flag0281_ & 0x2) == 0) {
  5576. if ((mclp.onScrollItems_ || 0).length === 1) {
  5577.  
  5578. assertor(() => fnIntegrity(mclp.onScrollItems_, '1.17.9'));
  5579. mclp.onScrollItems66_ = mclp.onScrollItems_;
  5580. mclp.onScrollItems77_ = async function (evt) {
  5581. if (myw > 1e9) myw = 9;
  5582. let tid = ++myw;
  5583.  
  5584. await iAFP(this.hostElement).then();
  5585. // await new Promise(requestAnimationFrame);
  5586.  
  5587. if (tid !== myw) {
  5588. return;
  5589. }
  5590.  
  5591. const cnt = this;
  5592.  
  5593. await Promise.resolve();
  5594. if (USE_OPTIMIZED_ON_SCROLL_ITEMS) {
  5595. const onScrollItemsBasicOnly_ = !!((cnt.__notRequired__ || 0) & 512);
  5596. await Promise.resolve().then(() => {
  5597. this.ytRendererBehavior.onScroll(evt);
  5598. }).then(() => {
  5599. if (onScrollItemsBasicOnly_) return;
  5600. if (this.canScrollToBottom_()) {
  5601. const hasUserJustInteracted = this.hasUserJustInteracted11_ ? this.hasUserJustInteracted11_() : true;
  5602. if (hasUserJustInteracted) {
  5603. // only when there is an user action
  5604. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  5605. return 1;
  5606. }
  5607. } else {
  5608. // no message inserting
  5609. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  5610. return 1;
  5611. }
  5612. }).then((r) => {
  5613.  
  5614. if (onScrollItemsBasicOnly_) return;
  5615. if (this.activeItems_.length) {
  5616.  
  5617. if (this.canScrollToBottom_()) {
  5618. this.flushActiveItems_();
  5619. return 1 && r;
  5620. } else if (this.atBottom && this.allowScroll && (this.hasUserJustInteracted11_ && this.hasUserJustInteracted11_())) {
  5621. // delayed due to user action
  5622. this.delayFlushActiveItemsAfterUserAction11_ && this.delayFlushActiveItemsAfterUserAction11_();
  5623. return 0;
  5624. }
  5625. }
  5626. }).then((r) => {
  5627. if (onScrollItemsBasicOnly_) return;
  5628. if (r) {
  5629. // ensure setAtBottom is correctly set
  5630. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  5631. }
  5632. });
  5633. } else {
  5634. cnt.onScrollItems66_(evt);
  5635. }
  5636.  
  5637. await Promise.resolve();
  5638.  
  5639. }
  5640.  
  5641. mclp.onScrollItems_ = function (evt) {
  5642.  
  5643. const cnt = this;
  5644. cnt.__intermediate_delay__ = new Promise(resolve => {
  5645. cnt.onScrollItems77_(evt).then(() => {
  5646. resolve();
  5647. });
  5648. });
  5649. }
  5650. console.log("onScrollItems_", "OK");
  5651. } else {
  5652. console.log("onScrollItems_", "NG");
  5653. }
  5654. }
  5655.  
  5656. if ((_flag0281_ & 0x2) == 0) {
  5657. if ((mclp.handleLiveChatActions_ || 0).length === 1) {
  5658.  
  5659. const sfi = fnIntegrity(mclp.handleLiveChatActions_);
  5660. if (sfi === '1.39.20') {
  5661. // TBC
  5662. } else if (sfi === '1.31.17') {
  5663. // original
  5664. } else {
  5665. assertor(() => fnIntegrity(mclp.handleLiveChatActions_, '1.31.17'));
  5666. }
  5667.  
  5668. mclp.handleLiveChatActions66_ = mclp.handleLiveChatActions_;
  5669.  
  5670. mclp.handleLiveChatActions77_ = async function (arr) {
  5671. if (typeof (arr || 0).length !== 'number') {
  5672. this.handleLiveChatActions66_(arr);
  5673. return;
  5674. }
  5675. if (mzt > 1e9) mzt = 9;
  5676. let tid = ++mzt;
  5677.  
  5678. if (zarr === null) zarr = arr;
  5679. else Array.prototype.push.apply(zarr, arr);
  5680. arr = null;
  5681.  
  5682. await iAFP(this.hostElement).then();
  5683. // await new Promise(requestAnimationFrame);
  5684.  
  5685. if (tid !== mzt || zarr === null) {
  5686. return;
  5687. }
  5688.  
  5689. const carr = zarr;
  5690. zarr = null;
  5691.  
  5692. await Promise.resolve();
  5693. this.handleLiveChatActions66_(carr);
  5694. await Promise.resolve();
  5695.  
  5696. }
  5697.  
  5698. mclp.handleLiveChatActions_ = function (arr) {
  5699.  
  5700.  
  5701. preprocessChatLiveActions(arr);
  5702.  
  5703.  
  5704.  
  5705. // console.log(1929, cnt.activeItems_)
  5706. // console.log(9487, arr);
  5707.  
  5708. const cnt = this;
  5709. cnt.__intermediate_delay__ = new Promise(resolve => {
  5710. cnt.handleLiveChatActions77_(arr).then(() => {
  5711. resolve();
  5712. });
  5713. });
  5714.  
  5715. resistanceUpdateFn_();
  5716. }
  5717. console.log("handleLiveChatActions_", "OK");
  5718. } else {
  5719. console.log("handleLiveChatActions_", "NG");
  5720. }
  5721. }
  5722.  
  5723. mclp.hasUserJustInteracted11_ = () => {
  5724. const t = dateNow();
  5725. return (t - lastWheel < 80) || currentMouseDown || currentTouchDown || (t - lastUserInteraction < 80);
  5726. }
  5727.  
  5728. if ((mclp.canScrollToBottom_ || 0).length === 0) {
  5729.  
  5730. assertor(() => fnIntegrity(mclp.canScrollToBottom_, '0.9.5'));
  5731.  
  5732. mclp.canScrollToBottom_ = function () {
  5733. return this.atBottom && this.allowScroll && !this.hasUserJustInteracted11_();
  5734. }
  5735.  
  5736. console.log("canScrollToBottom_", "OK");
  5737. } else {
  5738. console.log("canScrollToBottom_", "NG");
  5739. }
  5740.  
  5741. if (ENABLE_NO_SMOOTH_TRANSFORM) {
  5742.  
  5743. mclp.isSmoothScrollEnabled_ = function () {
  5744. return false;
  5745. }
  5746.  
  5747. mclp.maybeResizeScrollContainer_ = function () {
  5748. //
  5749. }
  5750.  
  5751. mclp.refreshOffsetContainerHeight_ = function () {
  5752. //
  5753. }
  5754.  
  5755. mclp.smoothScroll_ = function () {
  5756. //
  5757. }
  5758.  
  5759. mclp.resetSmoothScroll_ = function () {
  5760. //
  5761. }
  5762. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "OK");
  5763. } else {
  5764. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "NG");
  5765. }
  5766.  
  5767. if ((_flag0281_ & 0x8) == 0) {
  5768.  
  5769.  
  5770. if (typeof mclp.forEachItem_ === 'function' && !mclp.forEachItem66_ && skipErrorForhandleAddChatItemAction_ && mclp.forEachItem_.length === 1) {
  5771.  
  5772. mclp.forEachItem66_ = mclp.forEachItem_;
  5773. mclp.forEachItem_ = function (a) {
  5774.  
  5775. if ((this._flag0281_ & 0x8) == 0x8) return this.forEachItem66_(a);
  5776.  
  5777. // ƒ (a){this.visibleItems.forEach(a.bind(this,"visibleItems"));this.activeItems_.forEach(a.bind(this,"activeItems_"))}
  5778.  
  5779. try {
  5780.  
  5781. let items801 = false;
  5782. if (typeof a === 'function') {
  5783. const items = this.items;
  5784. if (items instanceof HTMLDivElement) {
  5785. const ev = this.visibleItems;
  5786. const ea = this.activeItems_;
  5787. if (ev && ea && ev.length >= 0 && ea.length >= 0) {
  5788. items801 = items;
  5789. }
  5790. }
  5791. }
  5792.  
  5793. if (items801) {
  5794. items801.__children801__ = 1;
  5795. const res = this.forEachItem66_(a);
  5796. items801.__children801__ = 0;
  5797. return res;
  5798. }
  5799.  
  5800. } catch (e) { }
  5801. return this.forEachItem66_(a);
  5802.  
  5803.  
  5804. // this.visibleItems.forEach((val, idx, arr)=>{
  5805. // a.call(this, 'visibleItems', val, idx, arr);
  5806. // });
  5807.  
  5808. // this.activeItems_.forEach((val, idx, arr)=>{
  5809. // a.call(this, 'activeItems_', val, idx, arr);
  5810. // });
  5811.  
  5812.  
  5813.  
  5814. }
  5815.  
  5816.  
  5817. }
  5818.  
  5819. }
  5820.  
  5821. if (typeof mclp.handleAddChatItemAction_ === 'function' && !mclp.handleAddChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  5822.  
  5823. mclp.handleAddChatItemAction66_ = mclp.handleAddChatItemAction_;
  5824. mclp.handleAddChatItemAction_ = function (a) {
  5825. try {
  5826. if (a && typeof a === 'object' && !('length' in a)) {
  5827. fixLiveChatItem(a.item, null);
  5828. console.assert(arguments[0] === a);
  5829. }
  5830. } catch (e) { console.warn(e) }
  5831. let res;
  5832. if (skipErrorForhandleAddChatItemAction_) { // YouTube Native Engine Issue
  5833. try {
  5834. res = this.handleAddChatItemAction66_.apply(this, arguments);
  5835. } catch (e) {
  5836. if (e && (e.message || '').includes('.querySelector(')) {
  5837. console.log("skipErrorForhandleAddChatItemAction_", e.message);
  5838. } else {
  5839. throw e;
  5840. }
  5841. }
  5842. } else {
  5843. res = this.handleAddChatItemAction66_.apply(this, arguments);
  5844. }
  5845. return res;
  5846. }
  5847.  
  5848. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  5849. } else {
  5850.  
  5851. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  5852. }
  5853.  
  5854.  
  5855. if (typeof mclp.handleReplaceChatItemAction_ === 'function' && !mclp.handleReplaceChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  5856.  
  5857. mclp.handleReplaceChatItemAction66_ = mclp.handleReplaceChatItemAction_;
  5858. mclp.handleReplaceChatItemAction_ = function (a) {
  5859. try {
  5860. if (a && typeof a === 'object' && !('length' in a)) {
  5861. fixLiveChatItem(a.replacementItem, null);
  5862. console.assert(arguments[0] === a);
  5863. }
  5864. } catch (e) { console.warn(e) }
  5865. return this.handleReplaceChatItemAction66_.apply(this, arguments);
  5866. }
  5867.  
  5868. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  5869. } else {
  5870.  
  5871. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  5872. }
  5873.  
  5874. console.log("[End]");
  5875. console.groupEnd();
  5876.  
  5877. }).catch(console.warn);
  5878.  
  5879.  
  5880. const tickerContainerSetAttribute = function (attrName, attrValue) { // ensure '14.30000001%'.toFixed(1)
  5881.  
  5882. let yd = (this.__dataHost || insp(this).__dataHost || 0).__data;
  5883.  
  5884. if (arguments.length === 2 && attrName === 'style' && yd && attrValue) {
  5885.  
  5886. // let v = yd.containerStyle.privateDoNotAccessOrElseSafeStyleWrappedValue_;
  5887. let v = `${attrValue}`;
  5888. // conside a ticker is 101px width
  5889. // 1% = 1.01px
  5890. // 0.2% = 0.202px
  5891.  
  5892.  
  5893. const ratio1 = (yd.ratio * 100);
  5894. if (ratio1 > -1) { // avoid NaN
  5895.  
  5896. // countdownDurationMs
  5897. // 600000 - 0.2% <1% = 6s> <0.2% = 1.2s>
  5898. // 300000 - 0.5% <1% = 3s> <0.5% = 1.5s>
  5899. // 150000 - 1% <1% = 1.5s>
  5900. // 75000 - 2% <1% =0.75s > <2% = 1.5s>
  5901. // 30000 - 5% <1% =0.3s > <5% = 1.5s>
  5902.  
  5903. // 99px * 5% = 4.95px
  5904.  
  5905. // 15000 - 10% <1% =0.15s > <10% = 1.5s>
  5906.  
  5907.  
  5908. // 1% Duration
  5909.  
  5910. let ratio2 = ratio1;
  5911.  
  5912. const ydd = yd.data;
  5913. if (ydd) {
  5914.  
  5915. const d1 = ydd.durationSec;
  5916. const d2 = ydd.fullDurationSec;
  5917.  
  5918. // @ step timing [min. 0.2%]
  5919. let numOfSteps = 500;
  5920. if ((d1 === d2 || (d1 + 1 === d2)) && d1 > 1) {
  5921. if (d2 > 400) numOfSteps = 500; // 0.2%
  5922. else if (d2 > 200) numOfSteps = 200; // 0.5%
  5923. else if (d2 > 100) numOfSteps = 100; // 1%
  5924. else if (d2 > 50) numOfSteps = 50; // 2%
  5925. else if (d2 > 25) numOfSteps = 20; // 5% (max => 99px * 5% = 4.95px)
  5926. else numOfSteps = 20;
  5927. }
  5928. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  5929. if (numOfSteps < 5) numOfSteps = 5;
  5930.  
  5931. const rd = numOfSteps / 100.0;
  5932.  
  5933. ratio2 = Math.round(ratio2 * rd) / rd;
  5934.  
  5935. // ratio2 = Math.round(ratio2 * 5) / 5;
  5936. ratio2 = ratio2.toFixed(1);
  5937. v = v.replace(`${ratio1}%`, `${ratio2}%`).replace(`${ratio1}%`, `${ratio2}%`);
  5938.  
  5939. if (yd.__style_last__ === v) return;
  5940. yd.__style_last__ = v;
  5941. // do not consider any delay here.
  5942. // it shall be inside the looping for all properties changes. all the css background ops are in the same microtask.
  5943.  
  5944. }
  5945. }
  5946.  
  5947. HTMLElement.prototype.setAttribute.call(dr(this), attrName, v);
  5948.  
  5949.  
  5950. } else {
  5951. HTMLElement.prototype.setAttribute.apply(dr(this), arguments);
  5952. }
  5953.  
  5954. };
  5955.  
  5956.  
  5957. const fpTicker = (renderer) => {
  5958. if (FLAG_001a) return;
  5959. const cnt = insp(renderer);
  5960. assertor(() => typeof (cnt || 0).is === 'string');
  5961. assertor(() => ((cnt || 0).hostElement || 0).nodeType === 1);
  5962. const container = (cnt.$ || 0).container;
  5963. if (container) {
  5964. assertor(() => (container || 0).nodeType === 1);
  5965. assertor(() => typeof container.setAttribute === 'function');
  5966. container.setAttribute = tickerContainerSetAttribute;
  5967. } else {
  5968. console.warn(`"container" does not exist in ${cnt.is}`);
  5969. }
  5970. };
  5971.  
  5972.  
  5973. const tags = [
  5974. "yt-live-chat-ticker-renderer",
  5975. "yt-live-chat-ticker-paid-message-item-renderer",
  5976. "yt-live-chat-ticker-paid-sticker-item-renderer",
  5977. "yt-live-chat-ticker-sponsor-item-renderer"
  5978. ];
  5979.  
  5980. const tagsItemRenderer = [
  5981. "yt-live-chat-ticker-renderer",
  5982. "yt-live-chat-ticker-paid-message-item-renderer",
  5983. "yt-live-chat-ticker-paid-sticker-item-renderer",
  5984. "yt-live-chat-ticker-sponsor-item-renderer"
  5985. ];
  5986.  
  5987. const wmList = new Set;
  5988. if (DEBUG_wmList) {
  5989.  
  5990. setInterval(() => {
  5991. let q = document.querySelector('#label-text');
  5992. if(!q) return;
  5993. const size = new Set([...wmList].filter(e => e?.deref()?.isConnected === false).map(e => e?.deref())).size;
  5994. q.textContent = `${48833}, ${DEBUG_wmList_started}, ${size}`;
  5995.  
  5996. // console.log(48833, )
  5997. }, 100);
  5998. }
  5999.  
  6000.  
  6001. /*
  6002. Promise.all(tags.map(tag => customElements.whenDefined(tag))).then(() => {
  6003. const dProto = {
  6004. detachedForTickerInit: function () {
  6005. try {
  6006. this.actionHandlerBehavior.unregisterActionMap(this.behaviorActionMap)
  6007. // this.behaviorActionMap = 0;
  6008. // this.isVisibilityRoot = 0;
  6009. } catch (e) { }
  6010. return this.detached582MemoryLeak();
  6011. },
  6012. attachedForTickerInit: function () {
  6013. wmList.add(new WeakRef(this))
  6014. // fpTicker(this.hostElement || this);
  6015. return this.attached77();
  6016. },
  6017. }
  6018. for (const tag of tagsItemRenderer) { // ##tag##
  6019. const dummy = document.createElement(tag);
  6020. const cProto = getProto(dummy);
  6021. if (!cProto || !cProto.attached) {
  6022. console.warn(`proto.attached for ${tag} is unavailable.`);
  6023. continue;
  6024. }
  6025. if (FIX_MEMORY_LEAKAGE_TICKER_ACTIONMAP && typeof cProto.detached582MemoryLeak !== 'function' && typeof cProto.detached === 'function') {
  6026. cProto.detached582MemoryLeak = cProto.detached;
  6027. cProto.detached = cProto.detachedForTickerInit;
  6028. }
  6029. cProto.attached77 = cProto.attached;
  6030. cProto.attached = dProto.attachedForTickerInit;
  6031. }
  6032. });
  6033. */
  6034.  
  6035.  
  6036. Promise.all(tags.map(tag => customElements.whenDefined(tag))).then(() => {
  6037.  
  6038. if (FLAG_001b) return;
  6039. mightFirstCheckOnYtInit();
  6040. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-... hacks");
  6041. console.log("[Begin]");
  6042.  
  6043. let dummyValueForStyleReturn = null;
  6044.  
  6045. const genDummyValueForStyleReturn = () => {
  6046. let s = `--nx:82;`
  6047. let ro = {
  6048. "privateDoNotAccessOrElseSafeStyleWrappedValue_": s,
  6049. "implementsGoogStringTypedString": true
  6050. };
  6051. ro.getTypedStringValue = ro.toString = function () { return this.privateDoNotAccessOrElseSafeStyleWrappedValue_ };
  6052. return ro;
  6053. }
  6054.  
  6055. let isCSSPropertySupported_ = null;
  6056. const isCSSPropertySupported = () => {
  6057.  
  6058. // @property --ticker-rtime
  6059.  
  6060. if (typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_;
  6061. isCSSPropertySupported_ = false;
  6062.  
  6063. if (typeof CSS !== 'object' || typeof (CSS || 0).registerProperty !== 'function') return false;
  6064. const documentElement = document.documentElement;
  6065. if (!documentElement) {
  6066. console.warn('document.documentElement is not found');
  6067. return false;
  6068. }
  6069. if (`${getComputedStyleCached(documentElement).getPropertyValue('--ticker-rtime')}`.length === 0) {
  6070. return false;
  6071. }
  6072.  
  6073. const ae = animate.call(documentElement,
  6074. [
  6075. { '--ticker-rtime': '70%' },
  6076. { '--ticker-rtime': '30%' }
  6077. ],
  6078. {
  6079. fill: "forwards",
  6080. duration: 1000 * 40,
  6081. easing: 'linear'
  6082. }
  6083. );
  6084.  
  6085. let animatedValue = getComputedStyleCached(document.documentElement).getPropertyValue('--ticker-rtime');
  6086. ae.finish();
  6087. if (`${animatedValue}`.length !== 3) return false;
  6088.  
  6089. isCSSPropertySupported_ = true;
  6090. return true;
  6091.  
  6092. };
  6093.  
  6094. let tickerAttachmentId = 0;
  6095.  
  6096. let windowShownAt = -1;
  6097. const setupEventForWindowShownAt = () => {
  6098. window.addEventListener('visibilitychange', () => {
  6099. if (document.visibilityState === 'visible') windowShownAt = Date.now();
  6100. else windowShownAt = 0;
  6101. }, false);
  6102. }
  6103.  
  6104. const __requestRemoval__ = function (cnt) {
  6105. if (cnt.hostElement && typeof cnt.requestRemoval === 'function') {
  6106. try {
  6107. const id = (cnt.data || 0).id;
  6108. if (!id) cnt.data = { id: 1 };
  6109. } catch (e) { }
  6110. try {
  6111. cnt.requestRemoval();
  6112. return true;
  6113. } catch (e) { }
  6114. }
  6115. return false;
  6116. }
  6117.  
  6118. const widthIORes = new WeakMap();
  6119. const widthIO = new IntersectionObserver((mutations) => {
  6120. for (const mutation of mutations) {
  6121. const elm = mutation.target;
  6122. widthIO.unobserve(elm);
  6123. const {promise, values} =widthIORes.get(elm) || {};
  6124. if(promise && values){
  6125.  
  6126.  
  6127. widthIORes.delete(elm);
  6128. values.width= mutation.boundingClientRect.width;
  6129. promise.resolve(values);
  6130. }
  6131. }
  6132. });
  6133. const widthReq = (elm)=>{
  6134.  
  6135. {
  6136.  
  6137. const {promise, values} =widthIORes.get(elm) || {};
  6138. if(promise) return promise;
  6139. }
  6140. const promise = new PromiseExternal();
  6141. widthIORes.set(elm, {promise, values: {}});
  6142. widthIO.unobserve(elm);
  6143. widthIO.observe(elm);
  6144.  
  6145. return promise;
  6146.  
  6147. }
  6148.  
  6149.  
  6150.  
  6151. const dProto = {
  6152.  
  6153.  
  6154. /**
  6155. *
  6156.  
  6157. f.updateStatsBarAndMaybeShowAnimation = function(a, b, c) {
  6158. var d = this;
  6159. a || c();
  6160. a && this.statsBar && this.username && this.textContent && (this.isMouseOver ? (b(),
  6161. c()) : (a = this.animateShowStats(),
  6162. this.data.animationOrigin && this.data.trackingParams && aB().stateChanged(this.data.trackingParams, {
  6163. animationEventData: {
  6164. origin: this.data.animationOrigin
  6165. }
  6166. }),
  6167. a.finished.then(function() {
  6168. var e;
  6169. setTimeout(function() {
  6170. b();
  6171. c();
  6172. if (!d.isMouseOver) {
  6173. var g, k;
  6174. d.animateHideStats(((g = d.data) == null ? void 0 : g.dynamicStateData.stateSlideDurationMs) || 0, ((k = d.data) == null ? void 0 : k.dynamicStateData.stateUpdateDelayAfterMs) || 0)
  6175. }
  6176. }, ((e = d.data) == null ? void 0 : e.dynamicStateData.stateUpdateDelayBeforeMs) || 0)
  6177. })))
  6178. }
  6179.  
  6180. *
  6181. */
  6182.  
  6183.  
  6184.  
  6185. /**
  6186. *
  6187. *
  6188.  
  6189. f.animateShowStats = function() {
  6190. var a = this.textContent.animate({
  6191. transform: "translateY(-30px)"
  6192. }, {
  6193. duration: this.data.dynamicStateData.stateSlideDurationMs,
  6194. fill: "forwards"
  6195. });
  6196. this.username.animate({
  6197. opacity: 0
  6198. }, {
  6199. duration: 500,
  6200. fill: "forwards"
  6201. });
  6202. this.statsBar.animate({
  6203. opacity: 1
  6204. }, {
  6205. duration: 500,
  6206. fill: "forwards"
  6207. });
  6208. return a
  6209. }
  6210. ;
  6211. f.animateHideStats = function(a, b) {
  6212. this.textContent.animate({
  6213. transform: "translateY(0)"
  6214. }, {
  6215. duration: a,
  6216. fill: "forwards",
  6217. delay: b
  6218. });
  6219. this.username.animate({
  6220. opacity: 1
  6221. }, {
  6222. duration: 300,
  6223. fill: "forwards",
  6224. delay: b
  6225. });
  6226. this.statsBar.animate({
  6227. opacity: 0
  6228. }, {
  6229. duration: 300,
  6230. fill: "forwards",
  6231. delay: b
  6232. })
  6233. }
  6234. *
  6235. */
  6236. updateStatsBarAndMaybeShowAnimationRevised: function (a, b, c) {
  6237. // prevent memory leakage due to d.data was asked in a.finished.then
  6238. try{
  6239. // console.log('updateStatsBarAndMaybeShowAnimation called', this.is)
  6240. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  6241. return this.updateStatsBarAndMaybeShowAnimation38.call(this.__proxySelf0__, a, b, c);
  6242. }catch(e){
  6243. console.log('updateStatsBarAndMaybeShowAnimationRevised ERROR');
  6244. console.error(e);
  6245. }
  6246. },
  6247.  
  6248. detachedForMemoryLeakage: function () {
  6249.  
  6250. try{
  6251. this.actionHandlerBehavior.unregisterActionMap(this.behaviorActionMap)
  6252. // this.behaviorActionMap = 0;
  6253. // this.isVisibilityRoot = 0;
  6254. }catch(e){}
  6255. return this.detached582MemoryLeak();
  6256. },
  6257.  
  6258. detachedForTickerInit: function () {
  6259.  
  6260. Promise.resolve(this).then((cnt) => {
  6261. if (cnt.isAttached) return;
  6262. cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false && __requestRemoval__(cnt);
  6263. cnt.rafId > 1 && rafHub.cancel(cnt.rafId);
  6264. }).catch(console.warn);
  6265.  
  6266. let r;
  6267. try {
  6268. r = this.detached77();
  6269. } catch (e) {
  6270. console.warn(e);
  6271. }
  6272. this.__ticker_attachmentId__ = 0;
  6273. return r;
  6274. },
  6275.  
  6276. attachedForTickerInit: function () {
  6277. if (tickerAttachmentId > 1e9) tickerAttachmentId = 9;
  6278. this.__ticker_attachmentId__ = ++tickerAttachmentId;
  6279.  
  6280. DEBUG_wmList && wmList.add(new WeakRef(this))
  6281. if (DEBUG_wmList && !DEBUG_wmList_started) {
  6282. console.log('!!!!!!!!!!!!! DEBUG_wmList_started !!!!!!!!!')
  6283. DEBUG_wmList_started = 1;
  6284. }
  6285.  
  6286. fpTicker(this.hostElement || this);
  6287. return this.attached77();
  6288.  
  6289. },
  6290.  
  6291.  
  6292. // doAnimator
  6293.  
  6294. _makeAnimator: function () {
  6295. if (this._r782) return;
  6296. // if (!this.isAttached) return;
  6297. if (!this._runnerAE) {
  6298. /** @type {HTMLElement | null} */
  6299. const aElement = (this.$ || 0).container;
  6300. if (!aElement) return console.warn("this.$.container is undefined");
  6301. const da = this.data;
  6302. if (!da || !da.startBackgroundColor || !da.endBackgroundColor) return console.warn("this.data is undefined or incorrect");
  6303. const c1 = this.colorFromDecimal(da.startBackgroundColor);
  6304. const c2 = this.colorFromDecimal(da.endBackgroundColor);
  6305. if (typeof c1 !== 'string' || typeof c2 !== 'string') return console.warn('c1, c2 is not a string');
  6306.  
  6307. // if (!this.__tickerBackgroundInitialChecked__) {
  6308. // this.constructor.prototype.__tickerBackgroundInitialChecked__ = true;
  6309. // console.log('__tickerBackgroundInitialChecked__')
  6310. // this._checkTickerBackgroundChanged();
  6311. // }
  6312.  
  6313. aElement.style.setProperty('--ticker-c1', c1);
  6314. aElement.style.setProperty('--ticker-c2', c2);
  6315. aElement.classList.add(runTickerClassName);
  6316. const p = (this.countdownMs / this.countdownDurationMs) * 100;
  6317. // this._aeStartV = this.countdownMs;
  6318. // this._aeStartT = this.countdownDurationMs;
  6319. if (!(p >= 0 && p <= 100)) {
  6320. console.warn('incorrect time ratio', p);
  6321. } else {
  6322. /*
  6323. const u0 = p.toFixed(4) + '%';
  6324. this._runnerAE = animate.call(aElement,
  6325. [
  6326. { '--ticker-rtime': u0 },
  6327. { '--ticker-rtime': '0%' }
  6328. ]
  6329. ,
  6330. {
  6331. fill: "forwards",
  6332. duration: this.countdownMs,
  6333. easing: "linear"
  6334. }
  6335. );
  6336. */
  6337.  
  6338. let timingFn = 'linear';
  6339.  
  6340. const totalDuration = this.countdownDurationMs;
  6341.  
  6342. if (ATTEMPT_ANIMATED_TICKER_BACKGROUND === 'steps') {
  6343.  
  6344. // @ step timing [min. 0.2%]
  6345. let stepInterval = 0.2; // unit: %
  6346. if (totalDuration > 400000) stepInterval = 0.2;
  6347. else if (totalDuration > 200000) stepInterval = 0.5;
  6348. else if (totalDuration > 100000) stepInterval = 1;
  6349. else if (totalDuration > 50000) stepInterval = 2;
  6350. else if (totalDuration > 25000) stepInterval = 5;
  6351. else stepInterval = 5;
  6352.  
  6353. let numOfSteps = Math.round(100 / stepInterval);
  6354.  
  6355. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  6356. if (numOfSteps < 5) numOfSteps = 5;
  6357.  
  6358. timingFn = `steps(${numOfSteps}, end)`;
  6359.  
  6360. }
  6361.  
  6362.  
  6363. /** @type {Animation} */
  6364. const ae = animate.call(aElement,
  6365. [
  6366. { '--ticker-rtime': '100%' },
  6367. { '--ticker-rtime': '0%' }
  6368. ]
  6369. ,
  6370. {
  6371. fill: "forwards",
  6372. duration: totalDuration,
  6373. easing: timingFn
  6374. }
  6375. );
  6376.  
  6377. this._runnerAE = ae;
  6378.  
  6379. ae.onfinish = (event) => {
  6380. this.onfinish = null;
  6381. if (this._runnerAE !== ae) return;
  6382. if (this.isAttached === true && !this._r782 && ((this.$ || 0).container || 0).isConnected === true) {
  6383. this._aeFinished(event);
  6384. }
  6385. }
  6386.  
  6387. let bq = (1.0 - (this.countdownMs / totalDuration)) * totalDuration;
  6388.  
  6389. if (bq >= 0 && bq <= totalDuration) {
  6390.  
  6391. if (bq > totalDuration - 1) {
  6392. ae.currentTime = bq;
  6393. // setTimeout(() => {
  6394. // if (this._runnerAE === ae && ae.onfinish) ae.onfinish();
  6395. // }, 1);
  6396. } else {
  6397. ae.currentTime = bq;
  6398. }
  6399. } else {
  6400. console.warn('Error on setting _runnerAE.currentTime!');
  6401. }
  6402.  
  6403.  
  6404. aeConstructor = ae.constructor; // constructor is from iframe
  6405. return ae;
  6406. }
  6407. } else {
  6408. if (!aeConstructor) return console.warn('aeConstructor is undefined');
  6409. // assume just time update
  6410. const ae = this._runnerAE;
  6411. if (!(ae instanceof aeConstructor)) return console.warn('this._runnerAE is not Animation');
  6412. if (ae.playState !== 'paused') console.warn('ae.playState !== paused');
  6413. let p = (this.countdownMs / this.countdownDurationMs) * 100;
  6414. if (!(p >= 0 && p <= 100)) {
  6415. console.warn('incorrect time ratio', p);
  6416. } else {
  6417. // let u0 = p.toFixed(4) + '%'
  6418. /*
  6419. ae.effect.setKeyframes([
  6420. { '--ticker-rtime': u0 },
  6421. { '--ticker-rtime': '0%' }
  6422. ]);
  6423. ae.effect.updateTiming({ duration: this.countdownMs });
  6424. */
  6425. // ae.currentTime = 0;
  6426.  
  6427.  
  6428.  
  6429. let bq = (1.0 - (this.countdownMs / this.countdownDurationMs)) * this.countdownDurationMs;
  6430. if (bq >= 0 && bq <= this.countdownDurationMs) {
  6431.  
  6432. this._runnerAE.currentTime = bq
  6433. } else {
  6434. console.warn('Error on setting _runnerAE.currentTime!');
  6435. }
  6436.  
  6437.  
  6438. ae.play();
  6439. return ae;
  6440. }
  6441. }
  6442. },
  6443.  
  6444. _aeFinished: function (event) {
  6445.  
  6446. if (this._r782) return;
  6447.  
  6448. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  6449. this._throwOut();
  6450. return;
  6451. }
  6452.  
  6453. if (!this._runnerAE) console.warn('Error in .updateTimeout; this._runnerAE is undefined');
  6454.  
  6455. let lc = window.performance.now();
  6456. this.countdownMs = Math.max(0, this.countdownMs - (lc - this.lastCountdownTimeMs));
  6457. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  6458. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = lc;
  6459. if (this.countdownMs > 76) console.warn('Warning: this.countdownMs is not zero when finished!', this.countdownMs, this, event); // just warning.
  6460.  
  6461. this.countdownMs = 0;
  6462. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = null;
  6463.  
  6464. if (this.isAttached) {
  6465. let fastRemoved = false;
  6466. if (Date.now() - windowShownAt < 80 && typeof this.requestRemoval === 'function') {
  6467. // no animation if the video page is switched from background to foreground
  6468. // this.hostElement.style.display = 'none';
  6469.  
  6470. fastRemoved = __requestRemoval__(this);
  6471. }
  6472.  
  6473. if (!fastRemoved) {
  6474. "auto" === this.hostElement.style.width && this.setContainerWidth();
  6475. this.slideDown();
  6476. }
  6477. }
  6478.  
  6479.  
  6480.  
  6481. },
  6482.  
  6483.  
  6484. /** @type {()} */
  6485. _throwOut: function () {
  6486. this._r782 = 1;
  6487. Promise.resolve(this).then((cnt) => {
  6488. __requestRemoval__(cnt);
  6489. cnt.detached();
  6490. if (cnt.__dataClientsReady === true) cnt.__dataClientsReady = false;
  6491. if (cnt.__dataEnabled === true) cnt.__dataEnabled = false;
  6492. if (cnt.__dataReady === true) cnt.__dataReady = false;
  6493. cnt.data = null;
  6494. cnt.countdownMs = 0;
  6495. cnt.lastCountdownTimeMs = null;
  6496. const hm = cnt.hostElement || cnt;
  6497. if (hm.parentNode) hm.remove();
  6498. for (let t; t = hm.firstChild;) t.remove();
  6499. }).catch(e => {
  6500. console.warn(e);
  6501. });
  6502. },
  6503.  
  6504.  
  6505. // doTimerFnModification
  6506.  
  6507.  
  6508. /** @type {(a, b)} */
  6509. startCountdownForTimerFnModA: function (a, b) { // .startCountdown(a.durationSec, a.fullDurationSec)
  6510. try {
  6511.  
  6512. const cnt = kRef(this);
  6513. if (!cnt) return;
  6514. if (!cnt.hostElement) return;
  6515.  
  6516. const attachementId = cnt.__ticker_attachmentId__;
  6517. if(!attachementId) return;
  6518.  
  6519. // a.durationSec [s] => countdownMs [ms]
  6520. // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  6521. // lastCountdownTimeMs => raf ongoing
  6522. // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  6523.  
  6524. if (cnt._r782) return;
  6525.  
  6526. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6527. cnt._throwOut();
  6528. return;
  6529. }
  6530.  
  6531. // TimerFnModA
  6532.  
  6533. b = void 0 === b ? 0 : b;
  6534. if (void 0 !== a) {
  6535.  
  6536. cnt.countdownMs = 1E3 * a; // decreasing from durationSec[s] to zero
  6537. cnt.countdownDurationMs = b ? 1E3 * b : cnt.countdownMs; // constant throughout the animation
  6538. if (!(cnt.lastCountdownTimeMs || cnt.isAnimationPaused)) {
  6539. cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = performance.now()
  6540. cnt.rafId = 1
  6541. if (cnt._runnerAE) console.warn('Error in .startCountdown; cnt._runnerAE already created.')
  6542. cnt.detlaSincePausedSecs = 0;
  6543. const ae = cnt._makeAnimator();
  6544. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  6545.  
  6546. // if (playerProgressChangedArg1 === null) {
  6547. // console.log('startCountdownForTimerFnModA', cnt.data)
  6548. // }
  6549.  
  6550. if (isPlayProgressTriggered && cnt.isAnimationPaused !== true && cnt.__ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED__) {
  6551.  
  6552.  
  6553.  
  6554.  
  6555. cnt.playerProgressSec = lastPlayerProgress > 0 ? lastPlayerProgress : 0; // save the progress first
  6556. cnt.isAnimationPaused = true; // trigger isAnimationPausedChanged
  6557. cnt.detlaSincePausedSecs = 0;
  6558. cnt._forceNoDetlaSincePausedSecs783 = 1; // reset cnt.detlaSincePausedSecs = 0 when resumed
  6559.  
  6560. relayPromise = relayPromise || new PromiseExternal();
  6561.  
  6562. relayPromise.then(() => {
  6563.  
  6564. const cnt = kRef(this);
  6565. if (!cnt) return;
  6566. if (!cnt.hostElement) return;
  6567.  
  6568. if (cnt && attachementId !== cnt.__ticker_attachmentId__) return;
  6569. if (cnt.isAttached === true && cnt.countdownDurationMs > 0 && cnt.isAnimationPaused === true && cnt.isReplayPaused !== true) {
  6570. cnt.isAnimationPaused = false;
  6571. }
  6572. });
  6573.  
  6574.  
  6575. }
  6576.  
  6577.  
  6578.  
  6579. }
  6580. }
  6581.  
  6582. } catch (e) {
  6583. console.warn(e);
  6584. }
  6585.  
  6586. },
  6587.  
  6588.  
  6589.  
  6590. /** @type {(a, b)} */
  6591. startCountdownForTimerFnModT: function (a, b) { // .startCountdown(a.durationSec, a.fullDurationSec)
  6592.  
  6593. try {
  6594. const cnt = kRef(this);
  6595. if (!cnt) return;
  6596. if (!cnt.hostElement) return;
  6597.  
  6598. const attachementId = cnt.__ticker_attachmentId__;
  6599. if(!attachementId) return;
  6600.  
  6601. // a.durationSec [s] => countdownMs [ms]
  6602. // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  6603. // lastCountdownTimeMs => raf ongoing
  6604. // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  6605.  
  6606. if (cnt._r782) return;
  6607.  
  6608. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6609. cnt._throwOut();
  6610. return;
  6611. }
  6612.  
  6613. // TimerFnModT
  6614.  
  6615. // console.log('cProto.startCountdown', tag) // yt-live-chat-ticker-sponsor-item-renderer
  6616. if (!cnt.boundUpdateTimeout37_) cnt.boundUpdateTimeout37_ = cnt.updateTimeout.bind(mWeakRef(cnt));
  6617. b = void 0 === b ? 0 : b;
  6618. void 0 !== a && (cnt.countdownMs = 1E3 * a,
  6619. cnt.countdownDurationMs = b ? 1E3 * b : cnt.countdownMs,
  6620. cnt.ratio = 1,
  6621. cnt.lastCountdownTimeMs || cnt.isAnimationPaused || (cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = performance.now(),
  6622. cnt.rafId = rafHub.request(cnt.boundUpdateTimeout37_)))
  6623.  
  6624. } catch (e) {
  6625. console.warn(e);
  6626. }
  6627.  
  6628. },
  6629.  
  6630.  
  6631. /** @type {(a,)} */
  6632. updateTimeoutForTimerFnModA: function (a) {
  6633.  
  6634. try {
  6635. const cnt = kRef(this);
  6636. if (!cnt) return;
  6637. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  6638.  
  6639. const attachementId = cnt.__ticker_attachmentId__;
  6640. if(!attachementId) return;
  6641.  
  6642. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  6643.  
  6644. if (cnt._r782) return;
  6645.  
  6646. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6647. cnt._throwOut();
  6648. return;
  6649. }
  6650.  
  6651. // TimerFnModA
  6652.  
  6653. if (!cnt._runnerAE) console.warn('Error in .updateTimeout; cnt._runnerAE is undefined');
  6654. if (cnt.lastCountdownTimeMs !== cnt._lastCountdownTimeMsX0) {
  6655. cnt.countdownMs = Math.max(0, cnt.countdownMs - (a - (cnt.lastCountdownTimeMs || 0)));
  6656. }
  6657. if (cnt.countdownMs > cnt.countdownDurationMs) cnt.countdownMs = cnt.countdownDurationMs;
  6658. if (cnt.isAttached && cnt.countdownMs) {
  6659. cnt.lastCountdownTimeMs = a
  6660. const ae = cnt._makeAnimator(); // request raf
  6661. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  6662. } else {
  6663. (cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = null,
  6664. cnt.isAttached && ("auto" === cnt.hostElement.style.width && cnt.setContainerWidth(),
  6665. cnt.slideDown()));
  6666. }
  6667.  
  6668. } catch (e) {
  6669. console.warn(e);
  6670. }
  6671.  
  6672.  
  6673. },
  6674.  
  6675. /** @type {(a,)} */
  6676. updateTimeoutForTimerFnModT: function (a) {
  6677.  
  6678. try {
  6679. const cnt = kRef(this);
  6680. if (!cnt) return;
  6681. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  6682.  
  6683. const attachementId = cnt.__ticker_attachmentId__;
  6684. if(!attachementId) return;
  6685.  
  6686. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  6687.  
  6688. if (cnt._r782) return;
  6689.  
  6690. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6691. cnt._throwOut();
  6692. return;
  6693. }
  6694.  
  6695. // TimerFnModT
  6696.  
  6697. // console.log('cProto.updateTimeout', tag) // yt-live-chat-ticker-sponsor-item-renderer
  6698. if (!cnt.boundUpdateTimeout37_) cnt.boundUpdateTimeout37_ = cnt.updateTimeout.bind(mWeakRef(cnt));
  6699. if (cnt.lastCountdownTimeMs !== cnt._lastCountdownTimeMsX0) {
  6700. cnt.countdownMs = Math.max(0, cnt.countdownMs - (a - (cnt.lastCountdownTimeMs || 0)));
  6701. }
  6702. // console.log(703, cnt.countdownMs)
  6703. cnt.ratio = cnt.countdownMs / cnt.countdownDurationMs;
  6704. cnt.isAttached && cnt.countdownMs ? (cnt.lastCountdownTimeMs = a,
  6705. cnt.rafId = rafHub.request(cnt.boundUpdateTimeout37_)) : (cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = null,
  6706. cnt.isAttached && ("auto" === cnt.hostElement.style.width && cnt.setContainerWidth(),
  6707. cnt.slideDown()))
  6708.  
  6709.  
  6710. } catch (e) {
  6711. console.warn(e);
  6712. }
  6713. },
  6714.  
  6715. /** @type {(a,b)} */
  6716. isAnimationPausedChangedForTimerFnModA: function (a, b) {
  6717.  
  6718. const cnt = kRef(this);
  6719. if (!cnt) return;
  6720. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  6721.  
  6722. const attachementId = cnt.__ticker_attachmentId__;
  6723. if(!attachementId) return;
  6724.  
  6725. if (cnt._r782) return;
  6726.  
  6727. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6728. cnt._throwOut();
  6729. return;
  6730. }
  6731. let forceNoDetlaSincePausedSecs783 = cnt._forceNoDetlaSincePausedSecs783;
  6732. cnt._forceNoDetlaSincePausedSecs783 = 0;
  6733.  
  6734. Promise.resolve(cnt).then((cnt) => {
  6735.  
  6736. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6737.  
  6738. if (a) {
  6739.  
  6740. if (cnt._runnerAE && cnt._runnerAE.playState === 'running') {
  6741.  
  6742. cnt._runnerAE.pause()
  6743. let lc = window.performance.now();
  6744. cnt.countdownMs = Math.max(0, cnt.countdownMs - (lc - cnt.lastCountdownTimeMs));
  6745. if (cnt.countdownMs > cnt.countdownDurationMs) cnt.countdownMs = cnt.countdownDurationMs;
  6746. cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = lc;
  6747. }
  6748.  
  6749. } else if (!a && b) {
  6750.  
  6751.  
  6752. if (forceNoDetlaSincePausedSecs783) cnt.detlaSincePausedSecs = 0;
  6753. a = cnt.detlaSincePausedSecs ? (cnt.lastCountdownTimeMs || 0) + 1000 * cnt.detlaSincePausedSecs : (cnt.lastCountdownTimeMs || 0);
  6754. cnt.detlaSincePausedSecs = 0;
  6755. cnt.updateTimeout(a);
  6756. cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = window.performance.now();
  6757.  
  6758. }
  6759.  
  6760. cnt = null;
  6761.  
  6762.  
  6763. }).catch(e => {
  6764. console.log(e);
  6765. });
  6766.  
  6767.  
  6768.  
  6769. },
  6770.  
  6771.  
  6772. /** @type {(a,b)} */
  6773. isAnimationPausedChangedForTimerFnModT: function (a, b) {
  6774.  
  6775. const cnt = kRef(this);
  6776. if (!cnt) return;
  6777. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  6778.  
  6779. const attachementId = cnt.__ticker_attachmentId__;
  6780. if(!attachementId) return;
  6781.  
  6782. if (cnt._r782) return;
  6783.  
  6784. if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  6785. cnt._throwOut();
  6786. return;
  6787. }
  6788. // let forceNoDetlaSincePausedSecs783 = cnt._forceNoDetlaSincePausedSecs783;
  6789. // cnt._forceNoDetlaSincePausedSecs783 = 0;
  6790.  
  6791. Promise.resolve(cnt).then((cnt) => {
  6792.  
  6793. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6794.  
  6795. // TimerFnModT
  6796.  
  6797. // ez++;
  6798. // if(ez> 1e9) ez=9;
  6799. if (!cnt.boundUpdateTimeout37_) cnt.boundUpdateTimeout37_ = cnt.updateTimeout.bind(mWeakRef(cnt));
  6800. a ? rafHub.cancel(cnt.rafId) : !a && b && (a = cnt.lastCountdownTimeMs || 0,
  6801. cnt.detlaSincePausedSecs && (a = (cnt.lastCountdownTimeMs || 0) + 1E3 * cnt.detlaSincePausedSecs,
  6802. cnt.detlaSincePausedSecs = 0),
  6803. cnt.boundUpdateTimeout37_(a),
  6804. cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = window.performance.now())
  6805.  
  6806. cnt = null;
  6807.  
  6808. }).catch(e => {
  6809. console.log(e);
  6810. });
  6811.  
  6812.  
  6813.  
  6814. },
  6815.  
  6816. setContainerWidthNoSelfLeakage: function(){
  6817. // prevent memory leakage due ot delay function
  6818. try{
  6819. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  6820. return this.setContainerWidth55.call(this.__proxySelf0__);
  6821. }catch(e){
  6822. console.log('setContainerWidthNoSelfLeakage ERROR');
  6823. console.error(e);
  6824. }
  6825.  
  6826. },
  6827.  
  6828. slideDownNoSelfLeakage: function(){
  6829. // prevent memory leakage due ot delay function
  6830. try{
  6831. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  6832. return this.slideDown55.call(this.__proxySelf0__);
  6833. }catch(e){
  6834. console.log('slideDownNoSelfLeakage ERROR');
  6835. console.error(e);
  6836. }
  6837. },
  6838.  
  6839. collapseNoSelfLeakage: function(){
  6840. // prevent memory leakage due ot delay function
  6841. try{
  6842. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  6843. return this.collapse55.call(this.__proxySelf0__);
  6844. }catch(e){
  6845. console.log('collapseNoSelfLeakage ERROR');
  6846. console.error(e);
  6847. }
  6848. },
  6849.  
  6850. deletedChangedNoSelfLeakage: function(){
  6851. // prevent memory leakage due ot delay function
  6852. try{
  6853. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  6854. return this.deletedChanged55.call(this.__proxySelf0__);
  6855. }catch(e){
  6856. console.log('deletedChangedNoSelfLeakage ERROR');
  6857. console.error(e);
  6858. }
  6859.  
  6860. },
  6861.  
  6862.  
  6863. /** @type {(a,b)} */
  6864. computeContainerStyleForAnimatorEnabled: function (a, b) {
  6865.  
  6866. if (this._r782) return;
  6867. const attachementId = this.__ticker_attachmentId__;
  6868. if(!attachementId) return;
  6869.  
  6870. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  6871. this._throwOut();
  6872. return;
  6873. }
  6874.  
  6875. return (dummyValueForStyleReturn || (dummyValueForStyleReturn = genDummyValueForStyleReturn()));
  6876.  
  6877. },
  6878.  
  6879.  
  6880.  
  6881. /** @type {()} */
  6882. handlePauseReplayForPlaybackProgressState: function () {
  6883. if (!playerEventsByIframeRelay) return this.handlePauseReplay66.apply(this, arguments);
  6884.  
  6885. const attachementId = this.__ticker_attachmentId__;
  6886. if(!attachementId) return;
  6887.  
  6888. const jr = mWeakRef(this);
  6889.  
  6890. if (onPlayStateChangePromise) {
  6891.  
  6892. if (this.rtu > 1e9) this.rtu = this.rtu % 1e4;
  6893. const tid = ++this.rtu;
  6894.  
  6895. onPlayStateChangePromise.then(() => {
  6896. const cnt = kRef(jr);
  6897. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6898. if (cnt.isAttached) {
  6899. if (tid === cnt.rtu && !onPlayStateChangePromise && typeof cnt.handlePauseReplay === 'function' && cnt.hostElement) cnt.handlePauseReplay.apply(cnt, arguments);
  6900. // this.handlePauseReplay can be undefined if it is memory cleaned
  6901. }
  6902. });
  6903.  
  6904. return;
  6905. }
  6906.  
  6907. if (playerState !== 2) return;
  6908. if (this.isAttached) {
  6909. if (this.rtk > 1e9) this.rtk = this.rtk % 1e4;
  6910. const tid = ++this.rtk;
  6911. const tc = relayCount;
  6912. foregroundPromiseFn().then(() => {
  6913. const cnt = kRef(jr);
  6914. if (attachementId !== cnt.__ticker_attachmentId__) return;
  6915. if (cnt.isAttached) {
  6916. if (tid === cnt.rtk && tc === relayCount && playerState === 2 && _playerState === playerState && cnt.hostElement) {
  6917. cnt.handlePauseReplay66();
  6918. }
  6919. }
  6920.  
  6921. })
  6922. }
  6923. },
  6924.  
  6925. /** @type {()} */
  6926. handleResumeReplayForPlaybackProgressState: function () {
  6927. if (!playerEventsByIframeRelay) return this.handleResumeReplay66.apply(this, arguments);
  6928.  
  6929. const attachementId = this.__ticker_attachmentId__;
  6930. if(!attachementId) return;
  6931.  
  6932. const jr = mWeakRef(this);
  6933. if (onPlayStateChangePromise) {
  6934.  
  6935. if (this.rtv > 1e9) this.rtv = this.rtv % 1e4;
  6936. const tid = ++this.rtv;
  6937.  
  6938. onPlayStateChangePromise.then(() => {
  6939. const cnt = kRef(jr);
  6940. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6941. if (tid === cnt.rtv && !onPlayStateChangePromise && typeof cnt.handleResumeReplay === 'function' && cnt.hostElement) cnt.handleResumeReplay.apply(cnt, arguments);
  6942. // this.handleResumeReplay can be undefined if it is memory cleaned
  6943. });
  6944.  
  6945. return;
  6946. }
  6947.  
  6948.  
  6949. if (playerState !== 1) return;
  6950. if (this.isAttached) {
  6951. const tc = relayCount;
  6952.  
  6953. relayPromise = relayPromise || new PromiseExternal();
  6954. relayPromise.then(() => {
  6955. const cnt = kRef(jr);
  6956. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6957. if (relayCount > tc && playerState === 1 && _playerState === playerState && cnt.hostElement) {
  6958. cnt.handleResumeReplay66();
  6959. }
  6960. });
  6961. }
  6962. },
  6963.  
  6964. /** @type {(a,)} */
  6965. handleReplayProgressForPlaybackProgressState: function (a) {
  6966. if (this.isAttached) {
  6967. const attachementId = this.__ticker_attachmentId__;
  6968. if(!attachementId) return;
  6969. const tid = ++this.rtk;
  6970. const jr = mWeakRef(kRef(this));
  6971. foregroundPromiseFn().then(() => {
  6972. const cnt = kRef(jr);
  6973. if(attachementId !== cnt.__ticker_attachmentId__) return;
  6974. if (cnt.isAttached) {
  6975. if (tid === cnt.rtk && cnt.hostElement) {
  6976. cnt.handleReplayProgress66(a);
  6977. }
  6978. }
  6979. })
  6980. }
  6981. }
  6982.  
  6983.  
  6984. }
  6985.  
  6986.  
  6987. for (const tag of tagsItemRenderer) { // ##tag##
  6988.  
  6989.  
  6990. const dummy = document.createElement(tag);
  6991.  
  6992. const cProto = getProto(dummy);
  6993. if (!cProto || !cProto.attached) {
  6994. console.warn(`proto.attached for ${tag} is unavailable.`);
  6995. continue;
  6996. }
  6997.  
  6998. if (FIX_MEMORY_LEAKAGE_TICKER_ACTIONMAP && typeof cProto.detached582MemoryLeak !== 'function' && typeof cProto.detached === 'function') {
  6999. cProto.detached582MemoryLeak = cProto.detached;
  7000. cProto.detached = dProto.detachedForMemoryLeakage;
  7001. }
  7002.  
  7003. cProto.detached77 = cProto.detached;
  7004. cProto.detached = dProto.detachedForTickerInit;
  7005.  
  7006. cProto.attached77 = cProto.attached;
  7007.  
  7008. cProto.attached = dProto.attachedForTickerInit;
  7009.  
  7010. if (FLAG_001c) continue;
  7011.  
  7012. let flgLeakageFixApplied = 0;
  7013.  
  7014. if (FIX_MEMORY_LEAKAGE_TICKER_STATSBAR && typeof cProto.updateStatsBarAndMaybeShowAnimation === 'function' && !cProto.updateStatsBarAndMaybeShowAnimation38 && cProto.updateStatsBarAndMaybeShowAnimation.length === 3) {
  7015.  
  7016. cProto.updateStatsBarAndMaybeShowAnimation38 = cProto.updateStatsBarAndMaybeShowAnimation;
  7017. cProto.updateStatsBarAndMaybeShowAnimation = dProto.updateStatsBarAndMaybeShowAnimationRevised;
  7018.  
  7019. flgLeakageFixApplied |= 2;
  7020. } else {
  7021. // the function is only in yt-live-chat-ticker-paid-message-item-renderer
  7022. }
  7023.  
  7024.  
  7025. // ------------- withTimerFn_ -------------
  7026.  
  7027. let withTimerFn_ = 0;
  7028. if (typeof cProto.startCountdown === 'function' && typeof cProto.updateTimeout === 'function' && typeof cProto.isAnimationPausedChanged === 'function') {
  7029.  
  7030. // console.log('startCountdown', typeof cProto.startCountdown)
  7031. // console.log('updateTimeout', typeof cProto.updateTimeout)
  7032. // console.log('isAnimationPausedChanged', typeof cProto.isAnimationPausedChanged)
  7033.  
  7034. // <<< to be reviewed cProto.updateTimeout --- isTimingFunctionHackable -- doHack >>>
  7035. const isTimingFunctionHackable = fnIntegrity(cProto.startCountdown, '2.66.37') && fnIntegrity(cProto.updateTimeout, '1.76.45') && fnIntegrity(cProto.isAnimationPausedChanged, '2.56.30')
  7036. if (!isTimingFunctionHackable) console.log('isTimingFunctionHackable = false');
  7037. withTimerFn_ = isTimingFunctionHackable ? 2 : 1;
  7038. } else {
  7039. let flag = 0;
  7040. if (typeof cProto.startCountdown === 'function') flag |= 1;
  7041. if (typeof cProto.updateTimeout === 'function') flag |= 2;
  7042. if (typeof cProto.isAnimationPausedChanged === 'function') flag |= 4;
  7043.  
  7044. console.log(`Skip Timing Function Modification: ${flag} / ${1 + 2 + 4}`, ` ${tag}`);
  7045. // console.log(Object.getOwnPropertyNames(cProto))
  7046. // continue;
  7047. }
  7048. // ------------- withTimerFn_ -------------
  7049.  
  7050. // ------------- ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX -------------
  7051.  
  7052. let urt = 0;
  7053.  
  7054. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  7055.  
  7056.  
  7057. /**
  7058. *
  7059. f.handlePauseReplay = function() {
  7060. this.isAnimationPaused = !0;
  7061. this.detlaSincePausedSecs = 0
  7062. }
  7063. */
  7064.  
  7065. /**
  7066. *
  7067. f.handlePauseReplay = function() {
  7068. this.isReplayPaused = !0
  7069. }
  7070. *
  7071. */
  7072.  
  7073. if (typeof cProto.handlePauseReplay === 'function' && !cProto.handlePauseReplay66 && cProto.handlePauseReplay.length === 0) {
  7074. const fi = fnIntegrity(cProto.handlePauseReplay);
  7075. urt++;
  7076. if (fi === '0.8.2' || fi === '0.12.4') {
  7077. } else {
  7078. assertor(() => fnIntegrity(cProto.handlePauseReplay, '0.12.4'));
  7079. }
  7080. } else {
  7081. if (withTimerFn_ > 0) console.log('Error for setting cProto.handlePauseReplay', tag)
  7082. }
  7083.  
  7084. if (typeof cProto.handleResumeReplay === 'function' && !cProto.handleResumeReplay66 && cProto.handleResumeReplay.length === 0) {
  7085. urt++;
  7086. assertor(() => fnIntegrity(cProto.handleResumeReplay, '0.8.2'));
  7087. } else {
  7088. if (withTimerFn_ > 0) console.log('Error for setting cProto.handleResumeReplay', tag)
  7089. }
  7090.  
  7091. if (typeof cProto.handleReplayProgress === 'function' && !cProto.handleReplayProgress66 && cProto.handleReplayProgress.length === 1) {
  7092. urt++;
  7093. assertor(() => fnIntegrity(cProto.handleReplayProgress, '1.16.13'));
  7094. } else {
  7095. if (withTimerFn_ > 0) console.log('Error for setting cProto.handleReplayProgress', tag)
  7096. }
  7097.  
  7098.  
  7099.  
  7100. }
  7101.  
  7102. const ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED = ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX && urt === 3 && (SKIP_VIDEO_PLAYBACK_PROGRESS_STATE_FIX_FOR_NO_TIMEFX ? (withTimerFn_ > 0) : true);
  7103. cProto.__ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED__ = ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED;
  7104.  
  7105. if (ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED) {
  7106.  
  7107. cProto.rtk = 0;
  7108. cProto.rtu = 0;
  7109. cProto.rtv = 0;
  7110.  
  7111. cProto.handlePauseReplay66 = cProto.handlePauseReplay;
  7112. cProto.handlePauseReplay = dProto.handlePauseReplayForPlaybackProgressState;
  7113.  
  7114. cProto.handleResumeReplay66 = cProto.handleResumeReplay;
  7115. cProto.handleResumeReplay = dProto.handleResumeReplayForPlaybackProgressState;
  7116.  
  7117. cProto.handleReplayProgress66 = cProto.handleReplayProgress;
  7118. cProto.handleReplayProgress = dProto.handleReplayProgressForPlaybackProgressState;
  7119.  
  7120. }
  7121.  
  7122. // ------------- ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX -------------
  7123.  
  7124. // ------------- FIX_MEMORY_LEAKAGE_TICKER_TIMER -------------
  7125.  
  7126. if (FIX_MEMORY_LEAKAGE_TICKER_TIMER) {
  7127. if (!USE_ADVANCED_TICKING && typeof cProto.setContainerWidth === 'function' && !cProto.setContainerWidth55 && cProto.setContainerWidth.length === 0) {
  7128. cProto.setContainerWidth55 = cProto.setContainerWidth;
  7129. cProto.setContainerWidth = dProto.setContainerWidthNoSelfLeakage;
  7130. flgLeakageFixApplied |= 4;
  7131. }
  7132. if (!USE_ADVANCED_TICKING && typeof cProto.slideDown === 'function' && !cProto.slideDown55 && cProto.slideDown.length === 0) {
  7133. cProto.slideDown55 = cProto.slideDown;
  7134. cProto.slideDown = dProto.slideDownNoSelfLeakage;
  7135. flgLeakageFixApplied |= 8;
  7136. }
  7137. if (!USE_ADVANCED_TICKING && typeof cProto.collapse === 'function' && !cProto.collapse55 && cProto.collapse.length === 0) {
  7138. cProto.collapse55 = cProto.collapse;
  7139. cProto.collapse = dProto.collapseNoSelfLeakage;
  7140. flgLeakageFixApplied |= 16;
  7141. }
  7142. if (typeof cProto.deletedChanged === 'function' && !cProto.deletedChanged55 && cProto.deletedChanged.length === 0) {
  7143.  
  7144. cProto.deletedChanged55 = cProto.deletedChanged;
  7145. cProto.deletedChanged = dProto.deletedChangedNoSelfLeakage;
  7146. flgLeakageFixApplied |= 32;
  7147. }
  7148.  
  7149. }
  7150.  
  7151. console.log(`FIX_MEMORY_LEAKAGE_TICKER_: ${flgLeakageFixApplied} / ${1 + 2 + 4 + 8 + 16 + 32}`, cProto.is);
  7152.  
  7153. // ------------- FIX_MEMORY_LEAKAGE_TICKER_TIMER -------------
  7154.  
  7155.  
  7156.  
  7157.  
  7158. if (withTimerFn_ > 0) {
  7159.  
  7160. const isTimingFunctionHackable = withTimerFn_ & 2;
  7161.  
  7162. let doAnimator_ = false;
  7163.  
  7164. let rafHackState = 0;
  7165. // continue;
  7166. if (ENABLE_RAF_HACK_TICKERS && rafHub !== null) {
  7167.  
  7168. // cancelable - this.rafId < isAnimationPausedChanged >
  7169. rafHackState = 1;
  7170.  
  7171. if (isTimingFunctionHackable) {
  7172. rafHackState = 2;
  7173.  
  7174. } else {
  7175. rafHackState = 4;
  7176. }
  7177.  
  7178. }
  7179. // continue;
  7180.  
  7181. doAnimator_ = !USE_ADVANCED_TICKING && !!ATTEMPT_ANIMATED_TICKER_BACKGROUND && isTimingFunctionHackable && typeof KeyframeEffect === 'function' && typeof animate === 'function' && typeof cProto.computeContainerStyle === 'function' && typeof cProto.colorFromDecimal === 'function' && isCSSPropertySupported();
  7182.  
  7183.  
  7184. const doAnimator = doAnimator_;
  7185.  
  7186. cProto._throwOut = dProto._throwOut;
  7187.  
  7188. cProto._makeAnimator = doAnimator ? dProto._makeAnimator : null;
  7189.  
  7190. cProto._aeFinished = doAnimator ? dProto._aeFinished : null;
  7191.  
  7192.  
  7193. const doRAFHack = rafHackState === 2;
  7194.  
  7195.  
  7196. const doTimerFnModification = !USE_ADVANCED_TICKING && (doRAFHack || doAnimator);
  7197. // doTimerFnModification = false; // M55
  7198.  
  7199. if (doTimerFnModification) { // including memory fix leakage
  7200.  
  7201. if (doAnimator && windowShownAt < 0) {
  7202. windowShownAt = 0;
  7203. setupEventForWindowShownAt();
  7204. }
  7205.  
  7206. cProto.startCountdown = (
  7207. doAnimator ? dProto.startCountdownForTimerFnModA : dProto.startCountdownForTimerFnModT
  7208. );
  7209.  
  7210. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  7211. cProto.updateTimeout = (
  7212. doAnimator ? dProto.updateTimeoutForTimerFnModA : dProto.updateTimeoutForTimerFnModT
  7213. );
  7214.  
  7215.  
  7216. // let ez = 0;
  7217. cProto.isAnimationPausedChanged = (
  7218. doAnimator ? dProto.isAnimationPausedChangedForTimerFnModA : dProto.isAnimationPausedChangedForTimerFnModT
  7219. );
  7220.  
  7221. flgLeakageFixApplied |= 1;
  7222. }
  7223.  
  7224.  
  7225. if (doAnimator) {
  7226.  
  7227.  
  7228. const s = fnIntegrity(cProto.computeContainerStyle);
  7229.  
  7230. if (s === '2.46.29') {
  7231. // f.computeContainerStyle = function(a, b) {
  7232. // if (!a)
  7233. // return $h(kmb);
  7234. // var c = this.colorFromDecimal(a.startBackgroundColor);
  7235. // a = this.colorFromDecimal(a.endBackgroundColor);
  7236. // b = 100 * b + "%";
  7237. // return $h(lmb, c, c, b, a, b, a)
  7238. // }
  7239. } else if (s === '2.44.29' || s === '2.81.31') {
  7240.  
  7241. // var ofb = da([""])
  7242. // pfb = da("background:linear-gradient(90deg, {,{ {,{ {,{);".split("{"))
  7243.  
  7244. // f.computeContainerStyle = function(a, b) {
  7245. // if (!a)
  7246. // return pi(ofb);
  7247. // var c = this.colorFromDecimal(a.startBackgroundColor);
  7248. // a = this.colorFromDecimal(a.endBackgroundColor);
  7249. // b = 100 * b + "%";
  7250. // return pi(pfb, c, c, b, a, b, a)
  7251. // }
  7252.  
  7253. } else {
  7254. assertor(() => fnIntegrity(cProto.computeContainerStyle, '2.46.29'));
  7255. }
  7256.  
  7257. cProto.computeContainerStyle66 = cProto.computeContainerStyle;
  7258.  
  7259. cProto.computeContainerStyle = dProto.computeContainerStyleForAnimatorEnabled;
  7260.  
  7261. }
  7262.  
  7263. if (doTimerFnModification === true) hasTimerModified = true;
  7264.  
  7265.  
  7266. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  7267. console.log('ATTEMPT_ANIMATED_TICKER_BACKGROUND', tag, doAnimator ? 'OK' : 'NG');
  7268. }
  7269.  
  7270.  
  7271. if (!doAnimator && (rafHackState === 2 || rafHackState === 4)) {
  7272. console.log('RAF_HACK_TICKERS', tag, doRAFHack ? "OK" : "NG");
  7273. }
  7274. }
  7275.  
  7276. const canDoAdvancedTicking = 1 &&
  7277. typeof cProto.startCountdown === 'function' && !cProto.startCountdown49 && cProto.startCountdown.length === 2 &&
  7278. typeof cProto.updateTimeout === 'function' && !cProto.updateTimeout49 && cProto.updateTimeout.length === 1 &&
  7279. typeof cProto.isAnimationPausedChanged === 'function' && !cProto.isAnimationPausedChanged49 && cProto.isAnimationPausedChanged.length === 2 &&
  7280. typeof cProto.setContainerWidth === 'function' && cProto.setContainerWidth.length === 0 &&
  7281. typeof cProto.slideDown === 'function' && cProto.slideDown.length === 0 &&
  7282. CSS.supports("left","clamp(-100%, calc( -100% * ( var(--ticker-current-time) - var(--ticker-start-time) ) / var(--ticker-duration-time) ), 0%)");
  7283.  
  7284.  
  7285. if (USE_ADVANCED_TICKING && canDoAdvancedTicking) {
  7286. // startResistanceUpdater();
  7287. // live replay video -> 48117005 -> 48117006 keep fire. ->48117007 0 -> 48117007 {...}
  7288. // live stream video -> 48117007 0 -> 48117007 YES
  7289.  
  7290. console.log('USE_ADVANCED_TICKING')
  7291.  
  7292. const wio2 = dProto.wio2 || (dProto.wio2 = new IntersectionObserver((mutations) => {
  7293.  
  7294. for (const mutation of mutations) {
  7295. if (mutation.isIntersecting) {
  7296.  
  7297. const marker = mutation.target;
  7298. let endId = marker.id
  7299. if(!endId) continue;
  7300. let tid = endId.substring(0, endId.length -2 );
  7301. if(!tid) continue;
  7302. // let bId = `${tid}-b`;
  7303. const bgElm = document.querySelector(`#${tid}-b`);
  7304. if(!bgElm) continue;
  7305. const overlay = bgElm;
  7306.  
  7307. wio2.unobserve(marker);
  7308. marker.remove();
  7309. let p = overlay || 0;
  7310. let cn = 4;
  7311. while ((p = p.parentElement) instanceof HTMLElement) {
  7312. if (p instanceof HTMLElement) {
  7313. const cnt = insp(p);
  7314. if (cnt && typeof cnt.slideDown === 'function' && typeof cnt.setContainerWidth === 'function' && cnt.__advancedTicking038__ === 1 ) {
  7315.  
  7316. cnt.__advancedTicking038__ = 2;
  7317.  
  7318. let deletionMode = false;
  7319. const cntData = ((cnt || 0).__data || 0).data || (cnt || 0).data || 0;
  7320. if (timestampUnderLiveMode && cntData && cntData.durationSec > 0 && cntData.__timestampActionRequest__ > 0) {
  7321.  
  7322. // time choose - 0.2s for transition (slideDown sliding-down)
  7323. // 60hz = 17ms
  7324. // choose 0.28s
  7325. const targetFutureTime = cntData.__timestampActionRequest__ + cntData.durationSec * 1000;
  7326. // check whether the targetFutureTime is already the past
  7327. if (targetFutureTime + 280 < Date.now()) {
  7328. // just dispose
  7329. deletionMode = true;
  7330. }
  7331. } else if (!timestampUnderLiveMode && cntData && cntData.durationSec > 0 && cntData.__progressAt__ > 0) {
  7332.  
  7333. const targetFutureTime = (cntData.__progressAt__ + cntData.durationSec) ;
  7334. // check whether the targetFutureTime is already the past
  7335. if (targetFutureTime + 0.28 < playerProgressChangedArg1) {
  7336. // just dispose
  7337. deletionMode = true;
  7338. }
  7339.  
  7340.  
  7341. }
  7342.  
  7343.  
  7344. if (deletionMode) {
  7345. __requestRemoval__(cnt);
  7346. } else {
  7347.  
  7348. const w = cnt.hostElement.style.width;
  7349. if (w === "auto" || w === "") cnt.setContainerWidth();
  7350. cnt.slideDown();
  7351. }
  7352.  
  7353. break;
  7354. }
  7355. }
  7356. cn--;
  7357. if (!cn) {
  7358. console.log('cnt not found for ticker-bg-overlay');
  7359. break;
  7360. }
  7361. }
  7362.  
  7363.  
  7364. }
  7365. }
  7366.  
  7367. // console.log(mutations);
  7368. },{
  7369.  
  7370. rootMargin: '0px',
  7371. threshold: [1]
  7372.  
  7373. }));
  7374.  
  7375. // const wio = dProto.wio || (dProto.wio = new IntersectionObserver((mutations) => {
  7376.  
  7377. // // for (const mutation of mutations) {
  7378. // // if (mutation.isIntersecting) {
  7379. // // const marker = mutation.target;
  7380. // // const overlay = marker instanceof HTMLElement ? marker.closest('ticker-bg-overlay') : 0;
  7381. // // wio.unobserve(marker);
  7382. // // marker.remove();
  7383. // // let p = overlay || 0;
  7384. // // let cn = 4;
  7385. // // while ((p = p.parentElement) instanceof HTMLElement) {
  7386. // // if (p instanceof HTMLElement) {
  7387. // // const cnt = insp(p);
  7388. // // if (cnt && typeof cnt.slideDown === 'function' && typeof cnt.setContainerWidth === 'function' && cnt.__advancedTicking038__ === 1 ) {
  7389.  
  7390. // // cnt.__advancedTicking038__ = 2;
  7391.  
  7392. // // let deletionMode = false;
  7393. // // const cntData = ((cnt || 0).__data || 0).data || (cnt || 0).data || 0;
  7394. // // if (timestampUnderLiveMode && cntData && cntData.duration > 0 && cntData.__timestampActionRequest__ > 0) {
  7395.  
  7396. // // const targetFutureTime = cntData.__timestampActionRequest__ + cntData.durationSec * 1000;
  7397. // // // check whether the targetFutureTime is already the past
  7398. // // if (targetFutureTime + 800 < Date.now()) {
  7399. // // // just dispose
  7400. // // deletionMode = true;
  7401. // // }
  7402. // // }
  7403.  
  7404. // // if (deletionMode) {
  7405. // // __requestRemoval__(cnt);
  7406. // // } else {
  7407.  
  7408. // // ("auto" === cnt.hostElement.style.width && cnt.setContainerWidth(),
  7409. // // cnt.slideDown());
  7410. // // }
  7411.  
  7412. // // break;
  7413. // // }
  7414. // // }
  7415. // // cn--;
  7416. // // if (!cn) {
  7417. // // console.log('cnt not found for ticker-bg-overlay');
  7418. // // break;
  7419. // // }
  7420. // // }
  7421. // // }
  7422. // // }
  7423. // }, {
  7424. // rootMargin: '1px',
  7425. // threshold: [0]
  7426. // }));
  7427.  
  7428. // cProto._throwOut = dProto._throwOut;
  7429.  
  7430.  
  7431. const u37fn = dProto.u37fn || (dProto.u37fn = function (cnt) {
  7432.  
  7433. const cntData = ((cnt || 0).__data || 0).data || (cnt || 0).data || 0;
  7434. if(!cntData) return;
  7435. const cntElement = cnt.hostElement;
  7436. if(!(cntElement instanceof HTMLElement)) return;
  7437.  
  7438. const duration = (cntData.fullDurationSec || cntData.durationSec || 0);
  7439.  
  7440. let ct;
  7441.  
  7442. if (cntData && duration > 0 && !('__progressAt__' in cntData)) {
  7443. ct = Date.now();
  7444. cntData.__liveTimestamp__ = (cntData.__timestampActionRequest__ || ct) / 1000 - timeOriginDT / 1000;
  7445. timestampUnderLiveMode = true;
  7446. } else if (cntData && duration > 0 && cntData.__progressAt__ > 0) {
  7447. timestampUnderLiveMode = false;
  7448. }
  7449. // console.log(48117007, cntData)
  7450.  
  7451. let tk = cntData.__progressAt__ || cntData.__liveTimestamp__;
  7452.  
  7453. if (!tk) {
  7454. console.log('time property is not found');
  7455. return;
  7456. }
  7457.  
  7458.  
  7459.  
  7460. const liveOffsetMs = ct > 0 && cntData.__timestampActionRequest__ > 0 ? ct - cntData.__timestampActionRequest__ : 0;
  7461.  
  7462. // console.log(1237, liveOffsetMs, cntData.durationSec)
  7463.  
  7464. if (liveOffsetMs > 0) {
  7465. cntData.durationSec -= Math.floor(liveOffsetMs / 1000);
  7466. if (cntData.durationSec < 0) cntData.durationSec = 0;
  7467. // console.log(1238, liveOffsetMs, cntData.durationSec)
  7468. if (!cntData.durationSec) {
  7469. try {
  7470. cnt.requestRemoval();
  7471. } catch (e) { }
  7472. return;
  7473. }
  7474. }
  7475.  
  7476.  
  7477. let offset = cntData.fullDurationSec - cntData.durationSec; // consider this is live replay video, offset can be > 0
  7478. if (offset > 0) tk -= offset;
  7479. // in livestreaming. tk can be negative as we use performance.timeOrigin for t=0s time frame
  7480.  
  7481.  
  7482.  
  7483. const existingOverlaySelector = `ticker-bg-overlay[ticker-id="${cnt.__ticker_attachmentId__}"]`;
  7484.  
  7485. if (valAssign(cntElement, '--ticker-start-time', tk) && duration > 0) {
  7486.  
  7487. // t0 ...... 1 ... fullDurationSec
  7488. // tk ...... k ... fullDurationSec-durationSec
  7489. // t0-fullDurationSec ...... 0 ... 0
  7490.  
  7491. // now - (fullDurationSec-durationSec)
  7492.  
  7493.  
  7494. // update dntElementWeak
  7495. const dnt = cnt.parentComponent;
  7496. const dntElement = dnt ? dnt.hostElement || dnt : 0;
  7497. if (dntElement) {
  7498. dntElementWeak = mWeakRef(dntElement);
  7499. resistanceUpdateBusy = false;
  7500. if (!startResistanceUpdaterStarted) startResistanceUpdater();
  7501. else updateTickerCurrentTime();
  7502. }
  7503.  
  7504. // create overlay if needed
  7505. if (!cntElement.querySelector(existingOverlaySelector)) {
  7506.  
  7507. // remove if any
  7508. const oldElement = cntElement.querySelector('ticker-bg-overlay');
  7509. if (oldElement) oldElement.remove();
  7510. // use advancedTicking, ticker enabled
  7511. cnt.__advancedTicking038__ = 1;
  7512.  
  7513. const em = document.createElement('ticker-bg-overlay');
  7514. // const ey = document.createElement('ticker-bg-overlay-end');
  7515. const wy = document.createElement('ticker-bg-overlay-end2');
  7516.  
  7517. const cr1 = cnt.colorFromDecimal(cntData.startBackgroundColor);
  7518. const cr2 = cnt.colorFromDecimal(cntData.endBackgroundColor);
  7519.  
  7520. const container = cnt.$.container;
  7521. em.setAttribute('ticker-id', `${cnt.__ticker_attachmentId__}`);
  7522.  
  7523. const tid = `ticker-${cnt.__ticker_attachmentId__}-${ Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  7524.  
  7525. em.id = `${tid}-b`;
  7526. em.style.background = `linear-gradient(90deg, ${cr1},${cr1} 50%,${cr2} 50%,${cr2})`;
  7527.  
  7528. if (!(container instanceof HTMLElement)) {
  7529. // em.insertBefore(ey, em.firstChild);
  7530. cntElement.insertBefore(em, cntElement.firstChild);
  7531. cntElement.style.borderRadius = '16px';
  7532. container.style.borderRadius = 'initial';
  7533. } else {
  7534. // em.insertBefore(ey, em.firstChild);
  7535. container.insertBefore(em, container.firstChild);
  7536. }
  7537.  
  7538. // em.style.left = '-50%';
  7539. // em.style.left = "clamp(-100%, calc( -100% * ( var(--ticker-current-time) - var(--ticker-start-time) ) / var(--ticker-duration-time) ), 0%)";
  7540.  
  7541. if (container instanceof HTMLElement) {
  7542.  
  7543. container.style.background = 'transparent';
  7544. container.style.backgroundColor = 'transparent';
  7545. // container.style.zIndex = '1';
  7546. }
  7547. // em.style.zIndex = '-1';
  7548. valAssign(cntElement, '--ticker-duration-time', duration)
  7549.  
  7550. valAssign(wy, '--ticker-start-time', tk);
  7551. valAssign(wy, '--ticker-duration-time', duration);
  7552. wy.id = `${tid}-e`;
  7553.  
  7554. dntElement.appendChild(wy);
  7555.  
  7556. // if (wio instanceof IntersectionObserver) {
  7557. // wio.observe(ey);
  7558. // }
  7559.  
  7560. if (wio2 instanceof IntersectionObserver) {
  7561. wio2.observe(wy);
  7562. }
  7563.  
  7564. }
  7565. }
  7566. });
  7567.  
  7568. const timeFn = (cnt)=>{
  7569.  
  7570. if (!cnt) return;
  7571. if (!cnt.hostElement) return;
  7572.  
  7573. const attachementId = cnt.__ticker_attachmentId__;
  7574. if (!attachementId) return;
  7575.  
  7576. Promise.resolve(cnt).then(u37fn);
  7577.  
  7578. }
  7579.  
  7580. cProto.startCountdown = dProto.startCountdownAdv || (dProto.startCountdownAdv = function (a, b) {
  7581.  
  7582. timeFn(kRef(this));
  7583.  
  7584. // try {
  7585. // const cnt = kRef(this);
  7586. // if (!cnt) return;
  7587. // if (!cnt.hostElement) return;
  7588.  
  7589. // const attachementId = cnt.__ticker_attachmentId__;
  7590. // if (!attachementId) return;
  7591.  
  7592. // // a.durationSec [s] => countdownMs [ms]
  7593. // // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  7594. // // lastCountdownTimeMs => raf ongoing
  7595. // // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  7596.  
  7597. // // if (cnt._r782) return;
  7598.  
  7599. // // if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  7600. // // cnt._throwOut();
  7601. // // return;
  7602. // // }
  7603.  
  7604. // // TimerFnModT
  7605.  
  7606. // // b = void 0 === b ? 0 : b;
  7607. // // void 0 !== a && (cnt.countdownMs = 1E3 * a,
  7608. // // cnt.countdownDurationMs = b ? 1E3 * b : cnt.countdownMs,
  7609. // // // cnt.ratio = 1,
  7610. // // cnt.lastCountdownTimeMs || cnt.isAnimationPaused || (cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = performance.now(),
  7611. // // cnt.rafId = -1))
  7612.  
  7613. // Promise.resolve(cnt).then((cnt) => {
  7614. // u37fn(cnt);
  7615. // })
  7616.  
  7617. // } catch (e) {
  7618. // console.warn(e);
  7619. // }
  7620.  
  7621.  
  7622. });
  7623.  
  7624. cProto.updateTimeout = dProto.updateTimeoutAdv || (dProto.updateTimeoutAdv = function (a) {
  7625.  
  7626.  
  7627. // timeFn(kRef(this));
  7628.  
  7629. // try {
  7630. // const cnt = kRef(this);
  7631. // if (!cnt) return;
  7632. // if (!cnt.hostElement) return; // memory leakage. to be reviewed
  7633.  
  7634. // const attachementId = cnt.__ticker_attachmentId__;
  7635. // if (!attachementId) return;
  7636.  
  7637. // // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  7638.  
  7639. // // if (cnt._r782) return;
  7640.  
  7641. // // if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  7642. // // cnt._throwOut();
  7643. // // return;
  7644. // // }
  7645.  
  7646. // // if (cnt.lastCountdownTimeMs !== cnt._lastCountdownTimeMsX0) {
  7647. // // cnt.countdownMs = Math.max(0, cnt.countdownMs - (a - (cnt.lastCountdownTimeMs || 0)));
  7648. // // }
  7649. // // console.log(703, cnt.countdownMs)
  7650. // // cnt.ratio = cnt.countdownMs / cnt.countdownDurationMs;
  7651.  
  7652. // // u37fn(cnt);
  7653. // // cnt.isAttached && cnt.countdownMs ? (cnt.lastCountdownTimeMs = a,
  7654. // // cnt.rafId = -1) : (cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = null,
  7655. // // cnt.isAttached && ("auto" === cnt.hostElement.style.width && cnt.setContainerWidth(),
  7656. // // cnt.slideDown()))
  7657.  
  7658.  
  7659. // } catch (e) {
  7660. // console.warn(e);
  7661. // }
  7662.  
  7663. });
  7664.  
  7665. cProto.isAnimationPausedChanged = dProto.isAnimationPausedChangedAdv || (dProto.isAnimationPausedChangedAdv = function (a, b) {
  7666.  
  7667.  
  7668. // timeFn(kRef(this));
  7669.  
  7670. // const cnt = kRef(this);
  7671. // if (!cnt) return;
  7672. // if (!cnt.hostElement) return; // memory leakage. to be reviewed
  7673.  
  7674. // const attachementId = cnt.__ticker_attachmentId__;
  7675. // if (!attachementId) return;
  7676.  
  7677. // if (cnt._r782) return;
  7678.  
  7679. // if (cnt.isAttached === false && ((cnt.$ || 0).container || 0).isConnected === false) {
  7680. // cnt._throwOut();
  7681. // return;
  7682. // }
  7683. // let forceNoDetlaSincePausedSecs783 = cnt._forceNoDetlaSincePausedSecs783;
  7684. // cnt._forceNoDetlaSincePausedSecs783 = 0;
  7685.  
  7686. // u37fn(cnt);
  7687. // Promise.resolve(cnt).then((cnt) => {
  7688.  
  7689. // if (attachementId !== cnt.__ticker_attachmentId__) return;
  7690.  
  7691. // // a ? 0 : !a && b && (a = cnt.lastCountdownTimeMs || 0,
  7692. // // cnt.detlaSincePausedSecs && (a = (cnt.lastCountdownTimeMs || 0) + 1E3 * cnt.detlaSincePausedSecs,
  7693. // // cnt.detlaSincePausedSecs = 0),
  7694. // // cnt.lastCountdownTimeMs = cnt._lastCountdownTimeMsX0 = window.performance.now())
  7695.  
  7696. // cnt = null;
  7697.  
  7698. // }).catch(e => {
  7699. // console.log(e);
  7700. // });
  7701.  
  7702.  
  7703. });
  7704.  
  7705. if (typeof cProto.slideDown === 'function' && !cProto.slideDown43 && cProto.slideDown.length === 0) {
  7706.  
  7707. cProto.slideDown43 = cProto.slideDown;
  7708. cProto.slideDown = dProto.slideDownAdv || (dProto.slideDownAdv = async function () {
  7709.  
  7710. // console.log('calling slideDown', Date.now())
  7711. if(this.__advancedTicking038__){
  7712.  
  7713. if (this.__advancedTicking038__ === 1) this.__advancedTicking038__ = 2; // ignore intersectionobserver detection
  7714.  
  7715.  
  7716. const hostElement = this.hostElement;
  7717. const container = this.$.container;
  7718. if (hostElement instanceof HTMLElement && container instanceof HTMLElement) {
  7719. const prevTransitionClosingElm = kRef(prevTransitionClosing);
  7720. if (prevTransitionClosingElm !== hostElement) {
  7721. prevTransitionClosingElm && prevTransitionClosingElm.classList.add('ticker-no-transition-time');
  7722. prevTransitionClosing = mWeakRef(hostElement);
  7723. }
  7724. if (hostElement.classList.contains('ticker-no-transition-time')) hostElement.classList.remove('ticker-no-transition-time');
  7725. const pr = new PromiseExternal();
  7726. transitionEndAfterFnSimple.set(hostElement, pr);
  7727. transitionEndAfterFnSimple.set(container, pr);
  7728. hostElement.classList.add("sliding-down");
  7729. await pr.then();
  7730. transitionEndAfterFnSimple.delete(hostElement);
  7731. transitionEndAfterFnSimple.delete(container);
  7732. if(this && this.hostElement instanceof HTMLElement){
  7733. this.collapse();
  7734. }
  7735. return;
  7736. }
  7737. }
  7738. this.slideDown43();
  7739. });
  7740. }
  7741.  
  7742.  
  7743. if (typeof cProto.collapse === 'function' && !cProto.collapse43 && cProto.collapse.length === 0) {
  7744. cProto.collapse43 = cProto.collapse;
  7745. cProto.collapse = dProto.collapseAdv || (dProto.collapseAdv = async function () {
  7746.  
  7747.  
  7748. if (this.__advancedTicking038__) {
  7749.  
  7750. if (this.__advancedTicking038__ === 1) this.__advancedTicking038__ = 2; // ignore intersectionobserver detection
  7751.  
  7752.  
  7753. const hostElement = this.hostElement;
  7754. const container = this.$.container;
  7755. if (hostElement instanceof HTMLElement && container instanceof HTMLElement) {
  7756. const prevTransitionClosingElm = kRef(prevTransitionClosing);
  7757. if (prevTransitionClosingElm !== hostElement) {
  7758. prevTransitionClosingElm && prevTransitionClosingElm.classList.add('ticker-no-transition-time');
  7759. prevTransitionClosing = mWeakRef(hostElement);
  7760. }
  7761. if (hostElement.classList.contains('ticker-no-transition-time')) hostElement.classList.remove('ticker-no-transition-time');
  7762.  
  7763. const pr = new PromiseExternal();
  7764. transitionEndAfterFnSimple.set(hostElement, pr);
  7765. transitionEndAfterFnSimple.set(container, pr);
  7766. hostElement.classList.add("collapsing");
  7767. hostElement.style.width = "0";
  7768. await pr.then();
  7769. transitionEndAfterFnSimple.delete(hostElement);
  7770. transitionEndAfterFnSimple.delete(container);
  7771. if (this && this.hostElement instanceof HTMLElement) {
  7772.  
  7773. this.requestRemoval();
  7774. }
  7775.  
  7776. return;
  7777. }
  7778.  
  7779.  
  7780. }
  7781. this.collapse43();
  7782.  
  7783.  
  7784. });
  7785. }
  7786.  
  7787. if (typeof cProto.requestRemoval === 'function' && !cProto.requestRemoval49 && cProto.requestRemoval.length === 0) {
  7788. cProto.requestRemoval49 = cProto.requestRemoval;
  7789. cProto.requestRemoval = dProto.requestRemovalAdv || (dProto.requestRemovalAdv = function () {
  7790. if (this.__advancedTicking038__) {
  7791. try {
  7792. const overlayBg = this.hostElement.querySelector('ticker-bg-overlay[id]');
  7793. if (overlayBg) {
  7794. const overlayBgId = overlayBg.id;
  7795. const tid = overlayBgId ? overlayBgId.substring(0, overlayBgId.length - 2) : '';
  7796. const endElm = tid ? document.querySelector(`#${tid}-e`) : null;
  7797. if (endElm) {
  7798. wio2.unobserve(endElm);
  7799. endElm.remove();
  7800. }
  7801. }
  7802. } catch (e) { }
  7803. this.__advancedTicking038__ = 2;
  7804. }
  7805. const hostElement = this.hostElement;
  7806. if (hostElement instanceof HTMLElement) {
  7807. try {
  7808. // hostElement.remove();
  7809. if (!hostElement.classList.contains('ticker-no-transition-time')) hostElement.classList.add('ticker-no-transition-time');
  7810. } catch (e) { }
  7811. return this.requestRemoval49();
  7812. }
  7813. });
  7814. }
  7815.  
  7816. if (typeof cProto.computeContainerStyle === 'function' && !cProto.computeContainerStyle49 && cProto.computeContainerStyle.length === 2) {
  7817. cProto.computeContainerStyle49 = cProto.computeContainerStyle;
  7818. cProto.computeContainerStyle = dProto.computeContainerStyleAdv || (dProto.computeContainerStyleAdv = function (a, b) {
  7819. if (this.__advancedTicking038__) {
  7820. return "";
  7821. }
  7822. return this.computeContainerStyle49(a, b);
  7823. });
  7824. }
  7825.  
  7826.  
  7827.  
  7828. if (typeof cProto.setRevampContainerWidth === 'function' && !cProto.setRevampContainerWidth41 && cProto.setRevampContainerWidth.length === 0) {
  7829. cProto.setRevampContainerWidth41 = cProto.setRevampContainerWidth;
  7830. cProto.setRevampContainerWidth = dProto.setRevampContainerWidthAdv || (dProto.setRevampContainerWidthAdv = async function () {
  7831.  
  7832. // not sure the reason for auto instead of pixel.
  7833. // this is a new function in Dec 2024, but not mainly adopted in the coding yet
  7834.  
  7835. /*
  7836. var a = this;
  7837. (R(this.hostElement).querySelector("#container").clientWidth || 0) === 0 ? (this.hostElement.style.overflow = "visible",
  7838. this.hostElement.style.width = "auto") : (this.hostElement.style.overflow = "hidden",
  7839. this.ytLiveChatTickerItemBehavior.shouldAnimateIn ? (this.hostElement.style.width = "0",
  7840. Zu(function() {
  7841. a.hostElement.style.width = "auto"
  7842. }, 1)) : this.hostElement.style.width = "auto")
  7843. */
  7844.  
  7845.  
  7846.  
  7847.  
  7848. const hostElement = (this || 0).hostElement;
  7849. const container = this.$.container;
  7850.  
  7851.  
  7852. let qw = null;
  7853.  
  7854. {
  7855.  
  7856.  
  7857. let maxC = 4;
  7858.  
  7859. for (let p = hostElement.getAttribute('r6-ticker-width') || ''; maxC--;) {
  7860.  
  7861. const ed = `${hostElement.id}`
  7862. if (!p || !p.startsWith(`${ed}::`)) {
  7863.  
  7864. const w = hostElement.style.width;
  7865. if (w !== '' && w !== 'auto') hostElement.style.width = 'auto';
  7866.  
  7867. const res = await widthReq(container);
  7868.  
  7869. hostElement.setAttribute('r6-ticker-width', p = `${ed}::${(res.width).toFixed(2)}`);
  7870.  
  7871. } else {
  7872. qw = p.split('::');
  7873. break;
  7874. }
  7875.  
  7876. }
  7877.  
  7878. }
  7879.  
  7880. if (!qw) {
  7881.  
  7882. console.log('container width failure');
  7883. this.setRevampContainerWidth41();
  7884. return; // failure
  7885. }
  7886.  
  7887.  
  7888. const shouldAnimateIn = ((this || 0).ytLiveChatTickerItemBehavior || 0).shouldAnimateIn || (this || 0).shouldAnimateIn || false;
  7889. if (shouldAnimateIn) {
  7890.  
  7891.  
  7892.  
  7893. const w = hostElement.style.width;
  7894. if (w !== '0px' && w !== '0') hostElement.style.width = '0';
  7895. hostElement.classList.remove('ticker-no-transition-time');
  7896. await widthReq(container);
  7897.  
  7898. hostElement.style.width = `${qw[1]}px`;
  7899. return;
  7900.  
  7901.  
  7902. } else {
  7903. hostElement.style.width = `${qw[1]}px`;
  7904. }
  7905.  
  7906.  
  7907. // const container = this.$.container;
  7908. // if(hostElement instanceof HTMLElement && hostElement.style.width) hostElement.style.width = '';
  7909. });
  7910. }
  7911.  
  7912.  
  7913. if (typeof cProto.setContainerWidth === 'function' && !cProto.setContainerWidth41 && cProto.setContainerWidth.length === 0) {
  7914. cProto.setContainerWidth41 = cProto.setContainerWidth;
  7915. cProto.setContainerWidth = dProto.setContainerWidthAdv || (dProto.setContainerWidthAdv = async function () {
  7916.  
  7917.  
  7918.  
  7919. /*
  7920.  
  7921.  
  7922. var a = this
  7923. , b = R(this.hostElement).querySelector("#container").clientWidth || 0;
  7924. b === 0 ? (this.hostElement.style.overflow = "visible",
  7925. this.hostElement.style.width = "auto") : (this.hostElement.style.overflow = "hidden",
  7926. this.shouldAnimateIn ? (this.hostElement.style.width = "0",
  7927. Zu(function() {
  7928. a.hostElement.style.width = b + "px"
  7929. }, 1)) : this.hostElement.style.width = b + "px")
  7930.  
  7931. */
  7932.  
  7933. const hostElement = (this || 0).hostElement;
  7934. const container = this.$.container;
  7935.  
  7936. let qw = null;
  7937. {
  7938.  
  7939.  
  7940. let maxC = 4;
  7941.  
  7942. for (let p = hostElement.getAttribute('r6-ticker-width') || ''; maxC--;) {
  7943. const ed = `${hostElement.id}`
  7944. if (!p || !p.startsWith(`${ed}::`)) {
  7945. const w = hostElement.style.width;
  7946. if (w !== '' && w !== 'auto') hostElement.style.width = 'auto';
  7947. const res = await widthReq(container);
  7948. hostElement.setAttribute('r6-ticker-width', p = `${ed}::${(res.width).toFixed(2)}`);
  7949. } else {
  7950. qw = p.split('::');
  7951. break;
  7952. }
  7953. }
  7954.  
  7955. }
  7956.  
  7957. if(!qw){
  7958.  
  7959. console.log('container width failure');
  7960. this.setContainerWidth41();
  7961. return; // failure
  7962. }
  7963.  
  7964.  
  7965. const shouldAnimateIn = ((this || 0).ytLiveChatTickerItemBehavior || 0).shouldAnimateIn || (this || 0).shouldAnimateIn || false;
  7966. if (shouldAnimateIn) {
  7967.  
  7968.  
  7969.  
  7970. const w = hostElement.style.width;
  7971. if (w !== '0px' && w !== '0') hostElement.style.width = '0';
  7972. hostElement.classList.remove('ticker-no-transition-time');
  7973. await widthReq(container);
  7974.  
  7975. hostElement.style.width = `${qw[1]}px`;
  7976. return;
  7977.  
  7978.  
  7979. } else {
  7980. hostElement.style.width = `${qw[1]}px`;
  7981. }
  7982.  
  7983. });
  7984. }
  7985.  
  7986.  
  7987.  
  7988.  
  7989. }
  7990.  
  7991.  
  7992.  
  7993. }
  7994.  
  7995. const selector = tags.join(', ');
  7996. const elements = document.querySelectorAll(selector);
  7997. if (elements.length >= 1) {
  7998. for (const elm of elements) {
  7999. if (insp(elm).isAttached === true) {
  8000. fpTicker(elm);
  8001. }
  8002. }
  8003. }
  8004.  
  8005. console.log("[End]");
  8006. console.groupEnd();
  8007.  
  8008.  
  8009. }).catch(console.warn);
  8010.  
  8011. if(FIX_MEMORY_LEAKAGE_TICKER_DATACHANGED_setContainerWidth){
  8012.  
  8013. /**
  8014. *
  8015. *
  8016. *
  8017. *
  8018. cT.prototype.dataChanged = function() {
  8019. var a = this;
  8020. this.data && (Q(this.hostElement).querySelector("#content").style.color = this.ytLiveChatTickerItemBehavior.colorFromDecimal(this.data.detailTextColor),
  8021. this.hostElement.ariaLabel = this.computeAriaLabel(this.data),
  8022. this.ytLiveChatTickerItemBehavior.startCountdown(this.data.durationSec, this.data.fullDurationSec),
  8023. qw(function() {
  8024. a.ytLiveChatTickerItemBehavior.setContainerWidth()
  8025. }))
  8026. }
  8027.  
  8028.  
  8029. znb.prototype.dataChanged = function(a) {
  8030. var b = this;
  8031. a && (a.tickerThumbnails.length > 1 && Q(this.hostElement).querySelector("#content").classList.add("multiple-thumbnails"),
  8032. this.ytLiveChatTickerItemBehavior.startCountdown(a.durationSec, a.fullDurationSec),
  8033. qw(function() {
  8034. b.ytLiveChatTickerItemBehavior.setContainerWidth()
  8035. }))
  8036. }
  8037.  
  8038. *
  8039. */
  8040.  
  8041. const dProto = {
  8042. dataChanged54500: function () {
  8043. // prevent memory leakage due to _.ytLiveChatTickerItemBehavior.setContainerWidth() in _.dataChanged
  8044. if (typeof (this.ytLiveChatTickerItemBehavior || 0).setContainerWidth === 'function') {
  8045. try {
  8046. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  8047. return this.dataChanged544.call(this.__proxySelf0__);
  8048. } catch (e) {
  8049. console.log('dataChanged54500 ERROR');
  8050. console.error(e);
  8051. }
  8052. } else {
  8053. return this.dataChanged544();
  8054. }
  8055. },
  8056. dataChanged54501: function (a) {
  8057. // prevent memory leakage due to _.ytLiveChatTickerItemBehavior.setContainerWidth() in _.dataChanged
  8058. if (typeof (this.ytLiveChatTickerItemBehavior || 0).setContainerWidth === 'function') {
  8059. try {
  8060. if (!this.__proxySelf0__) this.__proxySelf0__ = weakWrap(this);
  8061. return this.dataChanged544.call(this.__proxySelf0__, a);
  8062. } catch (e) {
  8063. console.log('dataChanged54501 ERROR');
  8064. console.error(e);
  8065. }
  8066. } else {
  8067. return this.dataChanged544(a);
  8068. }
  8069. },
  8070. }
  8071.  
  8072. for (const sto of [
  8073. 'yt-live-chat-ticker-sponsor-item-renderer',
  8074. 'yt-live-chat-ticker-paid-sticker-item-renderer'
  8075. ].map(tag => [tag, customElements.whenDefined(tag)])) {
  8076. const [tag, promise] = sto;
  8077. promise.then(()=>{
  8078. const dummy = document.createElement(tag);
  8079. const cProto = getProto(dummy);
  8080. if (!cProto || !cProto.attached) {
  8081. console.warn(`proto.attached for ${tag} is unavailable.`);
  8082. return;
  8083. }
  8084. if (!cProto.dataChanged || cProto.dataChanged544 || typeof cProto.dataChanged !== 'function' || !(cProto.dataChanged.length >= 0 && cProto.dataChanged.length <= 1)) return;
  8085.  
  8086. cProto.dataChanged544 = cProto.dataChanged;
  8087.  
  8088. if (cProto.dataChanged.length === 0) cProto.dataChanged = dProto.dataChanged54500;
  8089. else if (cProto.dataChanged.length === 1) cProto.dataChanged = dProto.dataChanged54501;
  8090. })
  8091. }
  8092.  
  8093. }
  8094.  
  8095. customElements.whenDefined('yt-live-chat-ticker-renderer').then(() => {
  8096.  
  8097. if (FLAG_001d) return;
  8098.  
  8099. mightFirstCheckOnYtInit();
  8100. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-renderer hacks");
  8101. console.log("[Begin]");
  8102. (() => {
  8103.  
  8104. /* pending!!
  8105.  
  8106. handleLiveChatAction
  8107.  
  8108. removeTickerItemById
  8109.  
  8110. _itemsChanged
  8111. itemsChanged
  8112.  
  8113. handleMarkChatItemAsDeletedAction
  8114. handleMarkChatItemsByAuthorAsDeletedAction
  8115. handleRemoveChatItemByAuthorAction
  8116.  
  8117.  
  8118. */
  8119.  
  8120. const tag = "yt-live-chat-ticker-renderer"
  8121. const dummy = document.createElement(tag);
  8122.  
  8123. const cProto = getProto(dummy);
  8124. if (!cProto || !cProto.attached) {
  8125. console.warn(`proto.attached for ${tag} is unavailable.`);
  8126. return;
  8127. }
  8128.  
  8129. const do_amend_ticker_handleLiveChatAction = AMEND_TICKER_handleLiveChatAction && !AMEND_TICKER_handleLiveChatAction_v3
  8130. && typeof cProto.handleLiveChatAction === 'function' && !cProto.handleLiveChatAction45 && cProto.handleLiveChatAction.length === 1
  8131. && typeof cProto.handleLiveChatActions === 'function' && !cProto.handleLiveChatActions45 && cProto.handleLiveChatActions.length === 1
  8132. && typeof cProto.unshift === 'function' && cProto.unshift.length === 1
  8133. && typeof cProto.handleMarkChatItemAsDeletedAction === 'function' && cProto.handleMarkChatItemAsDeletedAction.length === 1
  8134. && typeof cProto.removeTickerItemById === 'function' && cProto.removeTickerItemById.length === 1
  8135. && typeof cProto.handleMarkChatItemsByAuthorAsDeletedAction === 'function' && cProto.handleMarkChatItemsByAuthorAsDeletedAction.length === 1
  8136. && typeof cProto.handleRemoveChatItemByAuthorAction === 'function' && cProto.handleRemoveChatItemByAuthorAction.length === 1
  8137. ;
  8138.  
  8139. console.log('do_amend_ticker_handleLiveChatAction', fnIntegrity(cProto.handleLiveChatAction), fnIntegrity(cProto.handleLiveChatActions))
  8140.  
  8141.  
  8142. if (do_amend_ticker_handleLiveChatAction) {
  8143.  
  8144.  
  8145. if (fnIntegrity(cProto.handleLiveChatActions) === '1.23.12') {
  8146.  
  8147. console.log(`handleLiveChatActions`, 'modified');
  8148.  
  8149. cProto.handleLiveChatActions45 = cProto.handleLiveChatActions;
  8150.  
  8151. cProto.handleLiveChatActions = function (a) {
  8152. /**
  8153. *
  8154. f.handleLiveChatActions = function(a) {
  8155. a.length && (a.forEach(this.handleLiveChatAction, this),
  8156. this.updateHighlightedItem(),
  8157. this.shouldAnimateIn = !0)
  8158. }
  8159. *
  8160. */
  8161. const len = a.length;
  8162. if (len) {
  8163. const batchToken = String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 19861 + 19861).toString(36);
  8164.  
  8165. if (FIX_BATCH_TICKER_ORDER && len >= 2) {
  8166.  
  8167. // Primarily for the initial batch, this is due to replayBuffer._back.
  8168. const entries = [];
  8169. const entriesI = [];
  8170. for (let i = 0; i < len; i++) {
  8171. const item = ((a[i] || 0).addLiveChatTickerItemAction || 0).item || 0;
  8172. const timestampUsec = item ? parseInt(getTimestampUsec(item[firstObjectKey(item)]), 10) : 0;
  8173. if (timestampUsec > 0) {
  8174. entriesI.push(i);
  8175. binaryInsert(entries, { e: a[i], timestampUsec }, (a, b) => {
  8176. const diff = a.timestampUsec - b.timestampUsec;
  8177. return diff > 0.1 ? 1 : diff < -0.1 ? -1 : 0;
  8178. });
  8179. }
  8180. }
  8181. const mLen = entries.length;
  8182. if (mLen >= 2) {
  8183. for (let j = 0; j < mLen; j++) {
  8184. a[entriesI[j]] = entries[j].e;
  8185. }
  8186. }
  8187. entries.length = 0;
  8188. entriesI.length = 0;
  8189. }
  8190. for (const action of a) {
  8191. action.__batchId45__ = batchToken;
  8192. this.handleLiveChatAction(action);
  8193. }
  8194. }
  8195. }
  8196.  
  8197.  
  8198. }
  8199.  
  8200.  
  8201. console.log(`handleLiveChatAction`, 'modified');
  8202.  
  8203. const cacheChatActions = new LimitedSizeSet(16);
  8204.  
  8205. cProto.handleLiveChatAction45 = cProto.handleLiveChatAction;
  8206.  
  8207. cProto.handleLiveChatAction = function (a) {
  8208.  
  8209. const key = firstObjectKey(a);
  8210. if (!key) return;
  8211.  
  8212. const val = a[key];
  8213. let itemKey = '';
  8214. let itemId = '';
  8215. const valItem = val ? val.item : null;
  8216. if (valItem) {
  8217. itemKey = firstObjectKey(valItem);
  8218. if (itemKey) {
  8219. const itemVal = valItem[itemKey];
  8220. itemId = itemVal ? itemVal.id : '';
  8221. if (itemId) {
  8222. const cacheKey = `${key}.${itemKey}::${itemId}`;
  8223. if (key === 'addChatItemAction' && itemId) return; // no need
  8224. if (cacheChatActions.has(cacheKey)) {
  8225. console.log('handleLiveChatAction Repeated Item', cacheKey);
  8226. return;
  8227. } else {
  8228. cacheChatActions.add(cacheKey);
  8229. }
  8230. }
  8231. }
  8232. }
  8233. return this.handleLiveChatAction45(a);
  8234. };
  8235.  
  8236. console.log("AMEND_TICKER_handleLiveChatAction - OK (v2)");
  8237.  
  8238. } else if (0 && do_amend_ticker_handleLiveChatAction
  8239. && '|1.63.48|1.64.48|'.includes(`|${fnIntegrity(cProto.handleLiveChatAction)}|`)
  8240. && fnIntegrity(cProto.handleLiveChatActions) === '1.23.12'
  8241. ) {
  8242.  
  8243. cProto.handleLiveChatActions45 = cProto.handleLiveChatActions;
  8244.  
  8245. cProto.handleLiveChatActions = function (a) {
  8246. /**
  8247. *
  8248. f.handleLiveChatActions = function(a) {
  8249. a.length && (a.forEach(this.handleLiveChatAction, this),
  8250. this.updateHighlightedItem(),
  8251. this.shouldAnimateIn = !0)
  8252. }
  8253. *
  8254. */
  8255.  
  8256. if (a.length) {
  8257. const batchToken = String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 19861 + 19861).toString(36);
  8258. const len = a.length;
  8259. if (FIX_BATCH_TICKER_ORDER && len >= 2) {
  8260. // Primarily for the initial batch, this is due to replayBuffer._back.
  8261. const entries = [];
  8262. const entriesI = [];
  8263. for (let i = 0; i < len; i++) {
  8264. const item = ((a[i] || 0).addLiveChatTickerItemAction || 0).item || 0;
  8265. if (item) {
  8266. const itemRendererKey = firstObjectKey(item);
  8267. const itemRenderer = item[itemRendererKey];
  8268. if (itemRenderer) {
  8269. let timestampUsec = getTimestampUsec(itemRenderer);
  8270. if (timestampUsec !== null) {
  8271. timestampUsec = parseInt(timestampUsec, 10);
  8272. if (timestampUsec > 0) {
  8273. entriesI.push(i);
  8274. entries.push({ e: a[i], timestampUsec })
  8275. }
  8276. }
  8277. }
  8278. }
  8279. }
  8280. const mLen = entries.length;
  8281. if (mLen >= 2) {
  8282. entries.sort((a, b) => {
  8283. const diff = a.timestampUsec - b.timestampUsec;
  8284. return diff > 0.1 ? 1 : diff < -0.1 ? -1 : 0;
  8285. });
  8286. for (let j = 0; j < mLen; j++) {
  8287. const i = entriesI[j];
  8288. a[i] = entries[j].e;
  8289. }
  8290. }
  8291. entries.length = 0;
  8292. entriesI.length = 0;
  8293. }
  8294. for (const action of a) {
  8295. action.__batchId45__ = batchToken;
  8296. this.handleLiveChatAction(action);
  8297. }
  8298. }
  8299. }
  8300.  
  8301. cProto.handleLiveChatAction45 = cProto.handleLiveChatAction;
  8302.  
  8303. cProto._nszlv_ = 0;
  8304. cProto._stackedLCAs_ = null;
  8305. cProto._lastAddItem_ = null;
  8306. cProto._lastAddItemInStack_ = false;
  8307. cProto.handleLiveChatAction = function (a) {
  8308.  
  8309. /**
  8310. *
  8311. *
  8312. f.handleLiveChatAction = function(a) {
  8313. var b = C(a, xO)
  8314. , c = C(a, yO)
  8315. , d = C(a, o1a)
  8316. , e = C(a, p1a);
  8317. a = C(a, A1a);
  8318. b ? this.unshift("items", b.item) : c ? this.handleMarkChatItemAsDeletedAction(c) : d ? this.removeTickerItemById(d.targetItemId) : e ? this.handleMarkChatItemsByAuthorAsDeletedAction(e) : a && this.handleRemoveChatItemByAuthorAction(a)
  8319. }
  8320. *
  8321. */
  8322.  
  8323. // return this.handleLiveChatAction45(a)
  8324. const { addChatItemAction, addLiveChatTickerItemAction, markChatItemAsDeletedAction,
  8325. removeChatItemAction, markChatItemsByAuthorAsDeletedAction, removeChatItemByAuthorAction, __batchId45__ } = a
  8326.  
  8327. if (addChatItemAction) return;
  8328. const d = Date.now();
  8329.  
  8330. if (this._stackedLCAs_ === null) this._stackedLCAs_ = [];
  8331. const stackArr = this._stackedLCAs_;
  8332. let newStackEntry = null;
  8333. if (addLiveChatTickerItemAction) {
  8334. let isDuplicated = false;
  8335.  
  8336. const newItem = addLiveChatTickerItemAction.item;
  8337. const tickerType = firstObjectKey(newItem);
  8338. if (!tickerType) return;
  8339. const tickerItem = newItem[tickerType];
  8340. const tickerId = tickerItem.id;
  8341. if (!tickerId) return;
  8342.  
  8343. if (this._lastAddItem_ && this._lastAddItem_.id === tickerId) {
  8344. let prevTickerItem = null;
  8345. if (this._lastAddItemInStack_) {
  8346. const entry = stackArr[stackArr.length - 1]; // only consider the last entry
  8347. if (entry && entry.action === 'addItem') {
  8348. prevTickerItem = entry.data; // only consider the first item;
  8349. }
  8350. } else {
  8351. prevTickerItem = this.items[0]; // only consider the first item;
  8352. }
  8353. if (prevTickerItem && prevTickerItem[tickerType]) {
  8354. if (prevTickerItem[tickerType].id === tickerId) {
  8355. isDuplicated = true;
  8356. }
  8357. }
  8358. }
  8359. if (!isDuplicated) {
  8360. this._lastAddItem_ = tickerItem;
  8361. this._lastAddItemInStack_ = true;
  8362. // console.log('newItem', newItem)
  8363.  
  8364. const item = newItem;
  8365. const key = firstObjectKey(item);
  8366. if (key) {
  8367. const itemRenderer = item[key] || 0;
  8368. if (itemRenderer.fullDurationSec > 0) {
  8369. itemRenderer.__actionAt__ = d;
  8370. }
  8371. }
  8372.  
  8373. newStackEntry = { action: 'addItem', data: newItem };
  8374.  
  8375. } else {
  8376. console.log('handleLiveChatAction Repeated Item', tickerItem.id, tickerItem); // happen in both live and playback. Reason Unknown.
  8377. return;
  8378. }
  8379.  
  8380. } else {
  8381. markChatItemAsDeletedAction && (newStackEntry = { action: 'mcItemD', data: markChatItemAsDeletedAction });
  8382. removeChatItemAction && (newStackEntry = { action: 'removeItemById', data: removeChatItemAction.targetId });
  8383. markChatItemsByAuthorAsDeletedAction && (newStackEntry = { action: 'mcItemAD', data: markChatItemsByAuthorAsDeletedAction });
  8384. removeChatItemByAuthorAction && (newStackEntry = { action: 'removeItemA', data: removeChatItemByAuthorAction })
  8385. }
  8386.  
  8387.  
  8388. if (!newStackEntry) return;
  8389. stackArr.push(newStackEntry);
  8390.  
  8391.  
  8392. this._nszlv_++;
  8393. if (this._nszlv_ > 1e9) this._nszlv_ = 9;
  8394. const tid = this._nszlv_;
  8395.  
  8396. newStackEntry.__batchId45__ = __batchId45__ || '';
  8397. newStackEntry.dateTime = Date.now();
  8398.  
  8399.  
  8400. foregroundPromiseFn().then(() => {
  8401.  
  8402. if (tid !== this._nszlv_) return;
  8403. const dateNow = Date.now(); // time difference to shift animation start time shall be considered. (pending)
  8404. const stackArr = this._stackedLCAs_.slice(0);
  8405. this._stackedLCAs_.length = 0;
  8406. this._lastAddItemInStack_ = false;
  8407. let lastDateTime = 0;
  8408. let prevBatchId = '';
  8409. const addItems = [];
  8410. // const previousShouldAnimateIn = this.shouldAnimateIn;
  8411.  
  8412. const addItemsFx = () => {
  8413.  
  8414. if (addItems.length >= 1) {
  8415. const eArr = addItems.slice(0);
  8416. addItems.length = 0;
  8417. if (ADJUST_TICKER_DURATION_ALIGN_RENDER_TIME) {
  8418.  
  8419. const arr = []; // size of arr <= size of eArr
  8420. const d = Date.now();
  8421. for (const item of eArr) {
  8422. const key = firstObjectKey(item);
  8423. if (key) {
  8424.  
  8425.  
  8426. const itemRenderer = item[key] || 0;
  8427. const { durationSec, fullDurationSec, __actionAt__ } = itemRenderer;
  8428. if (__actionAt__ > 0 && durationSec > 0 && fullDurationSec > 0) {
  8429.  
  8430.  
  8431. const offset = d - __actionAt__;
  8432. if (offset > 0 && typeof durationSec === 'number' && typeof fullDurationSec === 'number' && fullDurationSec >= durationSec) {
  8433. const adjustedDurationSec = durationSec - Math.floor(offset / 1000);
  8434. if (adjustedDurationSec < durationSec) { // prevent NaN
  8435. // console.log('adjustedDurationSec', adjustedDurationSec);
  8436. if (adjustedDurationSec > 0) {
  8437. // console.log('offset Sec', Math.floor(offset / 1000));
  8438. itemRenderer.durationSec = adjustedDurationSec;
  8439. } else {
  8440. // if adjustedDurationSec equal 0 or invalid
  8441. continue; // skip adding
  8442. }
  8443. }
  8444.  
  8445. }
  8446.  
  8447. }
  8448.  
  8449. if (fullDurationSec > 0 && durationSec < 1) continue; // fallback check
  8450.  
  8451.  
  8452.  
  8453. }
  8454. arr.push(item)
  8455. // arr.unshift(item);
  8456. }
  8457.  
  8458.  
  8459. // console.log(arr.slice(0))
  8460. this.unshift("items", ...arr);
  8461. } else {
  8462. this.unshift("items", ...eArr);
  8463. }
  8464. }
  8465. }
  8466.  
  8467. for (const entry of stackArr) {
  8468.  
  8469. const { action, data, dateTime, __batchId45__ } = entry;
  8470.  
  8471. const finishLastAction = (
  8472. (prevBatchId !== __batchId45__ && prevBatchId)
  8473. || (dateNow - lastDateTime >= 1000 && dateNow - dateTime < 1000)
  8474. );
  8475.  
  8476. const addPrevItems = addItems.length >= 1 && (finishLastAction || action !== 'addItem');
  8477. lastDateTime = dateTime;
  8478. prevBatchId = __batchId45__;
  8479.  
  8480. if (addPrevItems) {
  8481. addItemsFx();
  8482. }
  8483.  
  8484. if (action === 'addItem') addItems.unshift(data);
  8485. else if (action === 'mcItemD') this.handleMarkChatItemAsDeletedAction(data);
  8486. else if (action === 'removeItemById') this.removeTickerItemById(data);
  8487. else if (action === 'mcItemAD') this.handleMarkChatItemsByAuthorAsDeletedAction(data);
  8488. else if (action === 'removeItemA') this.handleRemoveChatItemByAuthorAction(data);
  8489.  
  8490. }
  8491.  
  8492. addItemsFx();
  8493. })
  8494.  
  8495. }
  8496.  
  8497. console.log("AMEND_TICKER_handleLiveChatAction - OK (v1)");
  8498. } else {
  8499. console.log("AMEND_TICKER_handleLiveChatAction - NG");
  8500. }
  8501.  
  8502.  
  8503.  
  8504. const do_amend_ticker_handleLiveChatAction_v3 = AMEND_TICKER_handleLiveChatAction_v3 && !AMEND_TICKER_handleLiveChatAction
  8505. && typeof cProto.handleLiveChatAction === 'function' && !cProto.handleLiveChatAction45 && cProto.handleLiveChatAction.length === 1
  8506. && typeof cProto.handleLiveChatActions === 'function' && !cProto.handleLiveChatActions45 && cProto.handleLiveChatActions.length === 1
  8507. && typeof cProto.unshift === 'function' && cProto.unshift.length === 1
  8508. && typeof cProto.handleMarkChatItemAsDeletedAction === 'function' && cProto.handleMarkChatItemAsDeletedAction.length === 1
  8509. && typeof cProto.removeTickerItemById === 'function' && cProto.removeTickerItemById.length === 1
  8510. && typeof cProto.handleMarkChatItemsByAuthorAsDeletedAction === 'function' && cProto.handleMarkChatItemsByAuthorAsDeletedAction.length === 1
  8511. && typeof cProto.handleRemoveChatItemByAuthorAction === 'function' && cProto.handleRemoveChatItemByAuthorAction.length === 1
  8512. ;
  8513.  
  8514. if (do_amend_ticker_handleLiveChatAction_v3) {
  8515.  
  8516. /*
  8517. f.handleLiveChatActions = function(a) {
  8518. a.length && (a.forEach(this.handleLiveChatAction, this),
  8519. this.updateHighlightedItem(),
  8520. this.shouldAnimateIn = !0)
  8521. }
  8522. */
  8523.  
  8524. /*
  8525.  
  8526. f.handleLiveChatAction = function(a) {
  8527. var b = y(a, PM)
  8528. , c = y(a, QM)
  8529. , d = y(a, OM)
  8530. , e = y(a, Yab);
  8531. a = y(a, ibb);
  8532. b && this.enableCreatorGoalRevamp ? this.unshift("tickerItems", b.item) : b ? this.unshift("items", b.item) : c ? this.handleMarkChatItemAsDeletedAction(c) : d ? this.removeTickerItemById(d.targetItemId) : e ? this.handleMarkChatItemsByAuthorAsDeletedAction(e) : a && this.handleRemoveChatItemByAuthorAction(a)
  8533. }
  8534. */
  8535.  
  8536. const arr00 = new Array(1);
  8537. arr00.forEach = () => { };
  8538. arr00.push = (...args) => { return 1 + args.length };
  8539. arr00.pop = () => { };
  8540. arr00.shift = () => { };
  8541. arr00.unshift = () => { };
  8542. arr00.splice = () => [];
  8543. cProto.handleLiveChatActionsArr0 = arr00;
  8544.  
  8545. cProto.handleLiveChatActions58 = cProto.handleLiveChatActions;
  8546. cProto.xGqq4mo = null;
  8547. cProto.xGqq4Flg = 0;
  8548. cProto.xGqq4moPreparePromise = null;
  8549. cProto.xGqq4f = function () {
  8550. if (this.xGqq4Flg === 2) {
  8551. this.xGqq4Flg = 0;
  8552. tickerPE(async () => { // avoid confliction with ticker generation
  8553. await this.xGqq4moPreparePromise; // just in case
  8554. const s = this.handleLiveChatActionsArr0;
  8555. try {
  8556. this.handleLiveChatActions58(s);
  8557. } catch (e) {
  8558. console.warn(e);
  8559. }
  8560. // console.log('xGqq4f done')
  8561. });
  8562.  
  8563. }
  8564. }
  8565. const liveActionQM = new WeakSet();
  8566. let liveActionsLastTickerAction = null;
  8567. const lastTickerActionM = new WeakSet();
  8568. cProto.handleLiveChatActions = function (a) {
  8569. // let promise = null;
  8570. if (a && a.length) {
  8571. /** @type {MutationObserver | null} */
  8572. let mo = this.xGqq4mo;
  8573. // console.log('xGqq4f aaaa')
  8574. const hostElement = this.hostElement;
  8575. if (hostElement instanceof HTMLElement) {
  8576. if (mo === null || (mo instanceof MutationObserver && this.xGqq4p !== hostElement.xGqq4q)) {
  8577. if (mo instanceof MutationObserver) {
  8578. mo.disconnect();
  8579. mo.takeRecords();
  8580. }
  8581. this.xGqq4mo = mo = new MutationObserver(() => {
  8582. this.xGqq4f();
  8583. })
  8584. const moid = `dm-${Date.now()}-${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;;
  8585. this.xGqq4p = moid;
  8586. hostElement.xGqq4q = moid;
  8587. mo.observe(hostElement, { subtree: true, childList: true });
  8588. }
  8589. }
  8590. for (const u of a) {
  8591. u && liveActionQM.add(u)
  8592. }
  8593.  
  8594. /** @type {Promise} */
  8595. const pastPromise = this.xGqq4moPreparePromise || null;
  8596. this.xGqq4moPreparePromise = (async () => {
  8597. try {
  8598. await pastPromise; // just in case
  8599. liveActionsLastTickerAction = null;
  8600. a.forEach(this.handleLiveChatAction, this);
  8601. if (liveActionsLastTickerAction) lastTickerActionM.add(liveActionsLastTickerAction)
  8602. } catch (e) { console.warn(e); } // Promise catch can make the promise always resolved
  8603. // now tickerPE can execute
  8604. })();
  8605.  
  8606.  
  8607. // console.log('xGqq4f bbbb')
  8608. // promise = this.handleLiveChatAction_LastPromise;
  8609. // const f = () => {
  8610. // const s = this.handleLiveChatActionsArr0;
  8611. // try {
  8612. // return this.handleLiveChatActions58(s);
  8613. // } catch (e) {
  8614. // console.warn(e);
  8615. // }
  8616. // }
  8617. // if (!promise) {
  8618. // f();
  8619. // } else {
  8620. // promise.then(f);
  8621. // }
  8622. } else {
  8623. return this.handleLiveChatActions58(a);
  8624. }
  8625. }
  8626.  
  8627. // 12:17:05.748 PM
  8628. // 12:17:05.785 v {name: 'addLiveChatTickerItemAction'}
  8629. // 12:17:08.059 QM
  8630. // 12:17:08.068 v {name: 'markChatItemAsDeletedAction'}
  8631. // 12:17:09.123 OM
  8632. // 12:17:09.133 v {name: 'removeChatItemAction'}
  8633. // 12:17:11.566 Yab
  8634. // 12:17:11.574 v {name: 'markChatItemsByAuthorAsDeletedAction'}
  8635. // 12:17:14.272 ibb
  8636. // 12:17:14.282 v {name: 'removeChatItemByAuthorAction'}
  8637.  
  8638. const keyFilter = (a, keySet) => {
  8639. if (typeof (a || 0) === 'object') {
  8640. for (const k of Object.keys(a)) {
  8641. if (keySet.has(k)) {
  8642. return k;
  8643. }
  8644. }
  8645. }
  8646. return null;
  8647. }
  8648.  
  8649. cProto.lcuJB = function () {
  8650. this.ddnB8 = 1;
  8651. let res = new Set();
  8652. const pxy = new Proxy({}, {
  8653. get(target, prop) {
  8654. res.add(prop);
  8655. },
  8656. set(target, prop, value) {
  8657. return true;
  8658. }
  8659. });
  8660. this.handleLiveChatAction(pxy);
  8661. this.ddnB8 = 0;
  8662. return res.size > 0 ? res : null;
  8663. }
  8664.  
  8665. cProto.ddnB8 = 0;
  8666. cProto.handleLiveChatAction58 = cProto.handleLiveChatAction;
  8667. cProto.liveChatActionFilterKeys = null;
  8668. cProto.handleLiveChatActionTM = new LimitedSizeMap(24);
  8669. const tt0 = Date.now() - 100000;
  8670. cProto.handleLiveChatAction = function (a) {
  8671. if (this.ddnB8) return this.handleLiveChatAction58(a);
  8672. const inQM = a && liveActionQM.delete(a); // true if added from handleLiveChatActions
  8673. let keySet = this.liveChatActionFilterKeys;
  8674. if (keySet === null) {
  8675. const keys = this.lcuJB();
  8676. this.liveChatActionFilterKeys = keySet = (keys || false);
  8677. }
  8678. if (!keySet) {
  8679. if (!unexpectedErr) {
  8680. console.error(unexpectedErr = "************************ [YouTube Super Fast Chat] TickerRenderer:handleLiveChatAction keySet not found; ERR 0xF3D0 ************************");
  8681. }
  8682. return this.handleLiveChatAction58(a);
  8683. }
  8684. const key = keyFilter(a, keySet);
  8685. if (!key) {
  8686. return this.handleLiveChatAction58(a); // just by default
  8687. }
  8688.  
  8689. // ------ avoid duplicate items -------
  8690. const item = ((a[key] || 0).item || 0);
  8691. const ifk = item ? firstObjectKey(item) : null;
  8692. const rendererItem = ifk ? item[ifk] : null;
  8693. if (rendererItem && rendererItem.id) {
  8694. const id = rendererItem.id || 0;
  8695. if (typeof id === 'string') {
  8696. const map = this.handleLiveChatActionTM;
  8697. if (map) {
  8698. const mid = `${rendererItem.authorExternalChannelId}::${rendererItem.id}`;
  8699. const prevTime = map.get(mid);
  8700. const now = Date.now() - tt0;
  8701. map.removeSet(mid, now);
  8702. if (prevTime > 0 && now - prevTime < 2400) {
  8703. console.log('handleLiveChatAction Repeated Item OK', rendererItem.id, rendererItem);
  8704. return; // skip
  8705. } else if (prevTime) {
  8706. console.log('handleLiveChatAction Repeated Item NG', mid, now, prevTime, rendererItem.id, rendererItem);
  8707. }
  8708. // map.removeSet(mid, now);
  8709. }
  8710. }
  8711. }
  8712. // ------ avoid duplicate items -------
  8713.  
  8714. if (inQM) {
  8715. liveActionsLastTickerAction = a;
  8716. }
  8717. this.handleLiveChatAction_LastPromise = tickerPE(async () => {
  8718. await this.xGqq4moPreparePromise; // avoid tickerPE is called before actions under looping in handleLiveChatActions
  8719. const inLQM = lastTickerActionM.delete(a); // multiple candidates
  8720. if (inLQM) this.xGqq4Flg = 2; // 2 to 2 in case two batches are added "in the same time"
  8721. this.handleLiveChatAction58(a);
  8722. // if (inLQM) await timelineResolve(); // timing split by marco event to make tickers generation in different 16ms frame
  8723. // else await Promise.resolve();
  8724. // await Promise.resolve();
  8725. await timelineResolve(); // timing split by marco event to make tickers generation in different 16ms frame
  8726. });
  8727. }
  8728.  
  8729. }
  8730.  
  8731. if (RAF_FIX_keepScrollClamped) {
  8732.  
  8733. // to be improved
  8734.  
  8735. if (typeof cProto.keepScrollClamped === 'function' && !cProto.keepScrollClamped72 && fnIntegrity(cProto.keepScrollClamped) === '0.17.10') {
  8736.  
  8737. cProto.keepScrollClamped72 = cProto.keepScrollClamped;
  8738. cProto.keepScrollClamped = function () {
  8739.  
  8740. const cnt = kRef(this);
  8741. if (!cnt) return;
  8742. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  8743.  
  8744. cnt._bound_keepScrollClamped = cnt._bound_keepScrollClamped || cnt.keepScrollClamped.bind(mWeakRef(cnt));
  8745. cnt.scrollClampRaf = requestAnimationFrame(cnt._bound_keepScrollClamped);
  8746. cnt.maybeClampScroll()
  8747. }
  8748.  
  8749. console.log('RAF_FIX: keepScrollClamped', tag, "OK")
  8750. } else {
  8751.  
  8752. assertor(() => fnIntegrity(cProto.keepScrollClamped, '0.17.10'));
  8753. console.log('RAF_FIX: keepScrollClamped', tag, "NG")
  8754. }
  8755.  
  8756. }
  8757.  
  8758.  
  8759. if (RAF_FIX_scrollIncrementally && typeof cProto.startScrolling === 'function' && typeof cProto.scrollIncrementally === 'function' && fnIntegrity(cProto.startScrolling) === '1.44.31' && '|1.78.45|1.82.43|1.43.31'.indexOf('|' + fnIntegrity(cProto.scrollIncrementally) + '|') >= 0) {
  8760. // to be replaced by animator
  8761.  
  8762. cProto.startScrolling = function (a) {
  8763.  
  8764. const cnt = kRef(this);
  8765. if (!cnt) return;
  8766. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  8767.  
  8768. cnt.scrollStopHandle && cnt.cancelAsync(cnt.scrollStopHandle);
  8769. cnt.asyncHandle && cancelAnimationFrame(cnt.asyncHandle);
  8770. cnt.lastFrameTimestamp = cnt.scrollStartTime = performance.now();
  8771. cnt.scrollRatePixelsPerSecond = a;
  8772. cnt._bound_scrollIncrementally = cnt._bound_scrollIncrementally || cnt.scrollIncrementally.bind(mWeakRef(cnt));
  8773. cnt.asyncHandle = requestAnimationFrame(cnt._bound_scrollIncrementally)
  8774. };
  8775.  
  8776. // related functions: startScrollBack, startScrollingLeft, startScrollingRight, etc.
  8777.  
  8778. /**
  8779. *
  8780. * // 2024.12.17
  8781. * // https://www.youtube.com/s/desktop/f7495da0/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  8782.  
  8783. f.startScrolling = function(a) {
  8784. this.scrollStopHandle && $u(this.scrollStopHandle);
  8785. this.asyncHandle && window.cancelAnimationFrame(this.asyncHandle);
  8786. this.scrollStartTime = performance.now();
  8787. this.lastFrameTimestamp = performance.now();
  8788. this.scrollRatePixelsPerSecond = a;
  8789. this.asyncHandle = window.requestAnimationFrame(this.scrollIncrementally.bind(this))
  8790. }
  8791. ;
  8792. f.scrollIncrementally = function(a) {
  8793. var b = a - (this.lastFrameTimestamp || 0);
  8794. R(this.hostElement).querySelector(this.tickerBarQuery).scrollLeft += b / 1E3 * (this.scrollRatePixelsPerSecond || 0);
  8795. this.maybeClampScroll();
  8796. this.updateArrows();
  8797. this.lastFrameTimestamp = a;
  8798. R(this.hostElement).querySelector(this.tickerBarQuery).scrollLeft > 0 || this.scrollRatePixelsPerSecond && this.scrollRatePixelsPerSecond > 0 ? this.asyncHandle = window.requestAnimationFrame(this.scrollIncrementally.bind(this)) : this.stopScrolling()
  8799. }
  8800. ;
  8801. *
  8802. */
  8803.  
  8804. cProto.__getTickerBarQuery__ = function () {
  8805. const tickerBarQuery = this.tickerBarQuery === '#items' ? this.$.items : this.hostElement.querySelector(this.tickerBarQuery);
  8806. return tickerBarQuery;
  8807. }
  8808.  
  8809. cProto.scrollIncrementally = (RAF_FIX_scrollIncrementally === 2) ? function (a) {
  8810.  
  8811. const cnt = kRef(this);
  8812. if (!cnt) return;
  8813. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  8814.  
  8815. const b = a - (cnt.lastFrameTimestamp || 0);
  8816. const rate = cnt.scrollRatePixelsPerSecond
  8817. const q = b / 1E3 * (rate || 0);
  8818.  
  8819. const tickerBarQuery = cnt.__getTickerBarQuery__();
  8820. const sl = tickerBarQuery.scrollLeft;
  8821. // console.log(rate, sl, q)
  8822. if (cnt.lastFrameTimestamp == cnt.scrollStartTime) {
  8823.  
  8824. } else if (q > -1e-5 && q < 1e-5) {
  8825.  
  8826. } else {
  8827. let cond1 = sl > 0 && rate > 0 && q > 0;
  8828. let cond2 = sl > 0 && rate < 0 && q < 0;
  8829. let cond3 = sl < 1e-5 && sl > -1e-5 && rate > 0 && q > 0;
  8830. if (cond1 || cond2 || cond3) {
  8831. tickerBarQuery.scrollLeft += q;
  8832. cnt.maybeClampScroll();
  8833. cnt.updateArrows();
  8834. }
  8835. }
  8836.  
  8837. cnt.lastFrameTimestamp = a;
  8838. cnt._bound_scrollIncrementally = cnt._bound_scrollIncrementally || cnt.scrollIncrementally.bind(mWeakRef(cnt));
  8839. 0 < tickerBarQuery.scrollLeft || rate && 0 < rate ? cnt.asyncHandle = requestAnimationFrame(cnt._bound_scrollIncrementally) : cnt.stopScrolling()
  8840. } : function (a) {
  8841.  
  8842. const cnt = kRef(this);
  8843. if (!cnt) return;
  8844. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  8845.  
  8846. const b = a - (cnt.lastFrameTimestamp || 0);
  8847. const tickerBarQuery = cnt.__getTickerBarQuery__();
  8848. tickerBarQuery.scrollLeft += b / 1E3 * (cnt.scrollRatePixelsPerSecond || 0);
  8849. cnt.maybeClampScroll();
  8850. cnt.updateArrows();
  8851. cnt.lastFrameTimestamp = a;
  8852. cnt._bound_scrollIncrementally = cnt._bound_scrollIncrementally || cnt.scrollIncrementally.bind(mWeakRef(cnt));
  8853. 0 < tickerBarQuery.scrollLeft || cnt.scrollRatePixelsPerSecond && 0 < cnt.scrollRatePixelsPerSecond ? cnt.asyncHandle = requestAnimationFrame(cnt._bound_scrollIncrementally) : cnt.stopScrolling()
  8854. };
  8855.  
  8856. console.log(`RAF_FIX: scrollIncrementally${RAF_FIX_scrollIncrementally}`, tag, "OK")
  8857. } else {
  8858. assertor(() => fnIntegrity(cProto.startScrolling, '1.44.31'));
  8859. assertor(() => fnIntegrity(cProto.scrollIncrementally, '1.78.45'));
  8860. console.log('cProto.startScrolling', cProto.startScrolling);
  8861. console.log('cProto.scrollIncrementally', cProto.scrollIncrementally);
  8862. console.log('RAF_FIX: scrollIncrementally', tag, "NG")
  8863. }
  8864.  
  8865.  
  8866. if (CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED && typeof cProto.attached === 'function' && !cProto.attached37 && typeof cProto.detached === 'function' && !cProto.detached37) {
  8867.  
  8868. cProto.attached37 = cProto.attached;
  8869. cProto.detached37 = cProto.detached;
  8870.  
  8871. let naohzId = 0;
  8872. cProto.__naohzId__ = 0;
  8873. cProto.attached = function () {
  8874. Promise.resolve(this).then((cnt) => {
  8875.  
  8876. const hostElement = cnt.hostElement || cnt;
  8877. if (!(hostElement instanceof HTMLElement)) return;
  8878. if (!HTMLElement.prototype.matches.call(hostElement, '.yt-live-chat-renderer')) return;
  8879. const ironPage = HTMLElement.prototype.closest.call(hostElement, 'iron-pages.yt-live-chat-renderer');
  8880. // or #chat-messages
  8881. if (!ironPage) return;
  8882.  
  8883. if (cnt.__naohzId__) removeEventListener.call(ironPage, 'click', cnt.messageBoxClickHandlerForFade, { capture: false, passive: true });
  8884. if (naohzId > 1e9) naohzId = naohzId % 1e4;
  8885. cnt.__naohzId__ = ++naohzId;
  8886. ironPage.setAttribute('naohz', `${+cnt.__naohzId__}`);
  8887.  
  8888. addEventListener.call(ironPage, 'click', cnt.messageBoxClickHandlerForFade, { capture: false, passive: true });
  8889. cnt = null;
  8890.  
  8891. });
  8892. return this.attached37.apply(this, arguments);
  8893. };
  8894. cProto.detached = function () {
  8895. Promise.resolve(this).then((cnt) => {
  8896.  
  8897. const ironPage = document.querySelector(`iron-pages[naohz="${+cnt.__naohzId__}"]`);
  8898. if (!ironPage) return;
  8899.  
  8900. removeEventListener.call(ironPage, 'click', cnt.messageBoxClickHandlerForFade, { capture: false, passive: true });
  8901.  
  8902. cnt = null;
  8903.  
  8904. });
  8905. return this.detached37.apply(this, arguments);
  8906. };
  8907.  
  8908. const clickFade = (u) => {
  8909. u.click();
  8910. };
  8911. cProto.messageBoxClickHandlerForFade = async (evt) => {
  8912.  
  8913. const target = (evt || 0).target || 0;
  8914. if (!target) return;
  8915.  
  8916. for (let p = target; p instanceof HTMLElement; p = nodeParent(p)) {
  8917. const is = p.is;
  8918. if (typeof is === 'string' && is) {
  8919.  
  8920. if (is === 'yt-live-chat-pinned-message-renderer') {
  8921. return;
  8922. }
  8923. if (is === 'iron-pages' || is === 'yt-live-chat-renderer' || is === 'yt-live-chat-app') {
  8924. const fade = HTMLElement.prototype.querySelector.call(p, 'yt-live-chat-pinned-message-renderer:not([hidden]) #fade');
  8925. if (fade) {
  8926. Promise.resolve(fade).then(clickFade);
  8927. evt && evt.stopPropagation();
  8928. }
  8929. return;
  8930. }
  8931. if (is !== 'yt-live-chat-ticker-renderer') {
  8932. if (is.startsWith('yt-live-chat-ticker-')) return;
  8933. if (!is.endsWith('-renderer')) return;
  8934. }
  8935.  
  8936. } else {
  8937. if ((p.nodeName || '').includes('BUTTON')) return;
  8938. }
  8939.  
  8940. }
  8941. };
  8942.  
  8943. console.log("CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED - OK")
  8944.  
  8945. } else {
  8946. console.log("CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED - NG")
  8947. }
  8948.  
  8949.  
  8950. })();
  8951.  
  8952. console.log("[End]");
  8953.  
  8954. console.groupEnd();
  8955.  
  8956. }).catch(console.warn);
  8957.  
  8958.  
  8959.  
  8960. if (ENABLE_RAF_HACK_INPUT_RENDERER || DELAY_FOCUSEDCHANGED) {
  8961.  
  8962. customElements.whenDefined("yt-live-chat-message-input-renderer").then(() => {
  8963.  
  8964. mightFirstCheckOnYtInit();
  8965. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-message-input-renderer hacks");
  8966. console.log("[Begin]");
  8967. (() => {
  8968.  
  8969.  
  8970.  
  8971. const tag = "yt-live-chat-message-input-renderer"
  8972. const dummy = document.createElement(tag);
  8973.  
  8974. const cProto = getProto(dummy);
  8975. if (!cProto || !cProto.attached) {
  8976. console.warn(`proto.attached for ${tag} is unavailable.`);
  8977. return;
  8978. }
  8979.  
  8980.  
  8981. if (ENABLE_RAF_HACK_INPUT_RENDERER && rafHub !== null) {
  8982.  
  8983. let doHack = false;
  8984. if (typeof cProto.handleTimeout === 'function' && typeof cProto.updateTimeout === 'function') {
  8985.  
  8986. // not cancellable
  8987.  
  8988. // <<< to be reviewed cProto.updateTimeout --- isTimingFunctionHackable -- doHack >>>
  8989.  
  8990. doHack = fnIntegrity(cProto.handleTimeout, '1.27.16') && fnIntegrity(cProto.updateTimeout, '1.50.33');
  8991.  
  8992. if (!doHack) console.log('doHack = false')
  8993.  
  8994. }
  8995. // doHack = false; // M55
  8996.  
  8997. if (doHack) {
  8998.  
  8999. cProto.handleTimeout = function (a) {
  9000.  
  9001. const cnt = kRef(this);
  9002. if (!cnt) return;
  9003. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  9004.  
  9005. console.log('cProto.handleTimeout', tag)
  9006. if (!cnt.boundUpdateTimeout38_) cnt.boundUpdateTimeout38_ = cnt.updateTimeout.bind(mWeakRef(cnt));
  9007. cnt.timeoutDurationMs = cnt.timeoutMs = a;
  9008. cnt.countdownRatio = 1;
  9009. 0 === cnt.lastTimeoutTimeMs && rafHub.request(cnt.boundUpdateTimeout38_)
  9010. };
  9011. cProto.updateTimeout = function (a) {
  9012.  
  9013. const cnt = kRef(this);
  9014. if (!cnt) return;
  9015. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  9016.  
  9017. console.log('cProto.updateTimeout', tag)
  9018. if (!cnt.boundUpdateTimeout38_) cnt.boundUpdateTimeout38_ = cnt.updateTimeout.bind(mWeakRef(cnt));
  9019. cnt.lastTimeoutTimeMs && (cnt.timeoutMs = Math.max(0, cnt.timeoutMs - (a - cnt.lastTimeoutTimeMs)),
  9020. cnt.countdownRatio = cnt.timeoutMs / cnt.timeoutDurationMs);
  9021. cnt.isAttached && cnt.timeoutMs ? (cnt.lastTimeoutTimeMs = a,
  9022. rafHub.request(cnt.boundUpdateTimeout38_)) : cnt.lastTimeoutTimeMs = 0
  9023. };
  9024.  
  9025. console.log('RAF_HACK_INPUT_RENDERER', tag, "OK")
  9026. } else {
  9027.  
  9028. console.log('typeof handleTimeout', typeof cProto.handleTimeout)
  9029. console.log('typeof updateTimeout', typeof cProto.updateTimeout)
  9030.  
  9031. console.log('RAF_HACK_INPUT_RENDERER', tag, "NG")
  9032. }
  9033.  
  9034.  
  9035. }
  9036.  
  9037. if (DELAY_FOCUSEDCHANGED && typeof cProto.onFocusedChanged === 'function' && cProto.onFocusedChanged.length === 1 && !cProto.onFocusedChanged372) {
  9038. cProto.onFocusedChanged372 = cProto.onFocusedChanged;
  9039. cProto.onFocusedChanged = function (a) {
  9040. Promise.resolve(this).then((cnt) => {
  9041. if (cnt.isAttached === true) cnt.onFocusedChanged372(a);
  9042. cnt = null;
  9043. }).catch(console.warn);
  9044. }
  9045. }
  9046.  
  9047. })();
  9048.  
  9049. console.log("[End]");
  9050.  
  9051. console.groupEnd();
  9052.  
  9053.  
  9054. })
  9055.  
  9056. }
  9057.  
  9058.  
  9059. if (ENABLE_RAF_HACK_EMOJI_PICKER && rafHub !== null) {
  9060.  
  9061. customElements.whenDefined("yt-emoji-picker-renderer").then(() => {
  9062.  
  9063. mightFirstCheckOnYtInit();
  9064. groupCollapsed("YouTube Super Fast Chat", " | yt-emoji-picker-renderer hacks");
  9065. console.log("[Begin]");
  9066. (() => {
  9067.  
  9068. const tag = "yt-emoji-picker-renderer"
  9069. const dummy = document.createElement(tag);
  9070.  
  9071. const cProto = getProto(dummy);
  9072. if (!cProto || !cProto.attached) {
  9073. console.warn(`proto.attached for ${tag} is unavailable.`);
  9074. return;
  9075. }
  9076.  
  9077. let doHack = false;
  9078. if (typeof cProto.animateScroll_ === 'function') {
  9079.  
  9080. // not cancellable
  9081. console.log('animateScroll_', typeof cProto.animateScroll_)
  9082.  
  9083. doHack = fnIntegrity(cProto.animateScroll_, '1.102.49')
  9084.  
  9085. }
  9086.  
  9087. if (doHack) {
  9088.  
  9089. const querySelector = HTMLElement.prototype.querySelector;
  9090. const U = (element) => ({
  9091. querySelector: (selector) => querySelector.call(element, selector)
  9092. });
  9093.  
  9094. cProto.animateScroll_ = function (a) {
  9095.  
  9096. const cnt = kRef(this);
  9097. if (!cnt) return;
  9098. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  9099.  
  9100. // console.log('cProto.animateScroll_', tag) // yt-emoji-picker-renderer
  9101. if (!cnt.boundAnimateScroll39_) cnt.boundAnimateScroll39_ = cnt.animateScroll_.bind(mWeakRef(cnt));
  9102. cnt.lastAnimationTime_ || (cnt.lastAnimationTime_ = a);
  9103. a -= cnt.lastAnimationTime_;
  9104. 200 > a ? (U(cnt.hostElement).querySelector("#categories").scrollTop = cnt.animationStart_ + (cnt.animationEnd_ - cnt.animationStart_) * a / 200,
  9105. rafHub.request(cnt.boundAnimateScroll39_)) : (null != cnt.animationEnd_ && (U(cnt.hostElement).querySelector("#categories").scrollTop = cnt.animationEnd_),
  9106. cnt.animationEnd_ = cnt.animationStart_ = null,
  9107. cnt.lastAnimationTime_ = 0);
  9108. cnt.updateButtons_()
  9109. }
  9110.  
  9111. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "OK")
  9112. } else {
  9113.  
  9114. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "NG")
  9115. }
  9116.  
  9117. })();
  9118.  
  9119. console.log("[End]");
  9120.  
  9121. console.groupEnd();
  9122. });
  9123. }
  9124.  
  9125. if (ENABLE_RAF_HACK_DOCKED_MESSAGE && rafHub !== null) {
  9126.  
  9127. customElements.whenDefined("yt-live-chat-docked-message").then(() => {
  9128.  
  9129. mightFirstCheckOnYtInit();
  9130. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-docked-message hacks");
  9131. console.log("[Begin]");
  9132. (() => {
  9133.  
  9134. const tag = "yt-live-chat-docked-message"
  9135. const dummy = document.createElement(tag);
  9136.  
  9137. const cProto = getProto(dummy);
  9138. if (!cProto || !cProto.attached) {
  9139. console.warn(`proto.attached for ${tag} is unavailable.`);
  9140. return;
  9141. }
  9142.  
  9143. let doHack = false;
  9144. if (typeof cProto.detached === 'function' && typeof cProto.checkIntersections === 'function' && typeof cProto.onDockableMessagesChanged === 'function' && typeof cProto.boundCheckIntersections === 'undefined') {
  9145.  
  9146. // cancelable - this.intersectRAF <detached>
  9147. // yt-live-chat-docked-message
  9148. // boundCheckIntersections <-> checkIntersections
  9149. // onDockableMessagesChanged
  9150. // this.intersectRAF = window.requestAnimationFrame(this.boundCheckIntersections);
  9151.  
  9152. console.log('detached', typeof cProto.detached)
  9153. console.log('checkIntersections', typeof cProto.checkIntersections)
  9154. console.log('onDockableMessagesChanged', typeof cProto.onDockableMessagesChanged)
  9155.  
  9156. doHack = fnIntegrity(cProto.detached, '0.32.22') && fnIntegrity(cProto.checkIntersections, '0.128.85') && fnIntegrity(cProto.onDockableMessagesChanged, '0.20.11')
  9157.  
  9158. }
  9159.  
  9160. if (doHack) {
  9161.  
  9162. cProto.__boundCheckIntersectionsSubstitutionFn__ = function () {
  9163. const cnt = this;
  9164. if (!cnt.i5zmk && typeof cnt.boundCheckIntersections === 'function' && typeof cnt.checkIntersections === 'function') {
  9165. cnt.i5zmk = 1
  9166. cnt.boundCheckIntersections = cnt.checkIntersections.bind(mWeakRef(cnt));
  9167. }
  9168. }
  9169.  
  9170. cProto.checkIntersections = function () {
  9171.  
  9172. const cnt = kRef(this);
  9173. if (!cnt) return;
  9174. if (!cnt.hostElement) return; // memory leakage. to be reviewed
  9175.  
  9176. if(typeof cnt.__boundCheckIntersectionsSubstitutionFn__ === 'function') cnt.__boundCheckIntersectionsSubstitutionFn__();
  9177.  
  9178. // console.log('cProto.checkIntersections', tag)
  9179. if (cnt.dockableMessages.length) {
  9180. cnt.intersectRAF = rafHub.request(cnt.boundCheckIntersections);
  9181. let a = cnt.dockableMessages[0]
  9182. , b = cnt.hostElement.getBoundingClientRect();
  9183. a = a.getBoundingClientRect();
  9184. let c = a.top - b.top
  9185. , d = 8 >= c;
  9186. c = 8 >= c - cnt.hostElement.clientHeight;
  9187. if (d) {
  9188. let e;
  9189. for (; d;) {
  9190. e = cnt.dockableMessages.shift();
  9191. d = cnt.dockableMessages[0];
  9192. if (!d)
  9193. break;
  9194. d = d.getBoundingClientRect();
  9195. c = d.top - b.top;
  9196. let f = 8 >= c;
  9197. if (8 >= c - a.height)
  9198. if (f)
  9199. a = d;
  9200. else
  9201. return;
  9202. d = f
  9203. }
  9204. cnt.dock(e)
  9205. } else
  9206. c && cnt.dockedItem && cnt.clear()
  9207. } else
  9208. cnt.intersectRAF = 0
  9209. }
  9210.  
  9211. cProto.onDockableMessagesChanged = function () {
  9212. const cnt = this;
  9213. if(typeof cnt.__boundCheckIntersectionsSubstitutionFn__ === 'function') cnt.__boundCheckIntersectionsSubstitutionFn__();
  9214. // console.log('cProto.onDockableMessagesChanged', tag) // yt-live-chat-docked-message
  9215. cnt.dockableMessages.length && !cnt.intersectRAF && (cnt.intersectRAF = rafHub.request(cnt.boundCheckIntersections))
  9216. }
  9217.  
  9218. cProto.detached = function () {
  9219. this.intersectRAF && rafHub.cancel(this.intersectRAF)
  9220. }
  9221.  
  9222. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "OK")
  9223. } else {
  9224.  
  9225. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "NG")
  9226. }
  9227.  
  9228. })();
  9229.  
  9230. console.log("[End]");
  9231.  
  9232. console.groupEnd();
  9233.  
  9234. }).catch(console.warn);
  9235.  
  9236. }
  9237.  
  9238. if (FIX_SETSRC_AND_THUMBNAILCHANGE_) {
  9239.  
  9240. customElements.whenDefined("yt-img-shadow").then(() => {
  9241.  
  9242. mightFirstCheckOnYtInit();
  9243. groupCollapsed("YouTube Super Fast Chat", " | yt-img-shadow hacks");
  9244. console.log("[Begin]");
  9245. (() => {
  9246.  
  9247. const tag = "yt-img-shadow"
  9248. const dummy = document.createElement(tag);
  9249.  
  9250. const cProto = getProto(dummy);
  9251. if (!cProto || !cProto.attached) {
  9252. console.warn(`proto.attached for ${tag} is unavailable.`);
  9253. return;
  9254. }
  9255.  
  9256. if (typeof cProto.thumbnailChanged_ === 'function' && !cProto.thumbnailChanged66_) {
  9257.  
  9258. cProto.thumbnailChanged66_ = cProto.thumbnailChanged_;
  9259. cProto.thumbnailChanged_ = function (a) {
  9260.  
  9261. if (this.oldThumbnail_ && this.thumbnail && this.oldThumbnail_.thumbnails === this.thumbnail.thumbnails) return;
  9262. if (!this.oldThumbnail_ && !this.thumbnail) return;
  9263.  
  9264. return this.thumbnailChanged66_.apply(this, arguments)
  9265.  
  9266. }
  9267. console.log("cProto.thumbnailChanged_ - OK");
  9268.  
  9269. } else {
  9270. console.log("cProto.thumbnailChanged_ - NG");
  9271.  
  9272. }
  9273. if (typeof cProto.setSrc_ === 'function' && !cProto.setSrc66_) {
  9274.  
  9275. cProto.setSrc66_ = cProto.setSrc_;
  9276. cProto.setSrc_ = function (a) {
  9277. if ((((this || 0).$ || 0).img || 0).src === a) return;
  9278. return this.setSrc66_.apply(this, arguments)
  9279. }
  9280.  
  9281. console.log("cProto.setSrc_ - OK");
  9282. } else {
  9283.  
  9284. console.log("cProto.setSrc_ - NG");
  9285. }
  9286.  
  9287. })();
  9288.  
  9289. console.log("[End]");
  9290.  
  9291. console.groupEnd();
  9292.  
  9293. }).catch(console.warn);
  9294.  
  9295. }
  9296.  
  9297. if (FIX_THUMBNAIL_DATACHANGED) {
  9298.  
  9299. customElements.whenDefined("yt-live-chat-author-badge-renderer").then(() => {
  9300.  
  9301. mightFirstCheckOnYtInit();
  9302. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-author-badge-renderer hacks");
  9303. console.log("[Begin]");
  9304. (() => {
  9305.  
  9306. const tag = "yt-live-chat-author-badge-renderer"
  9307. const dummy = document.createElement(tag);
  9308.  
  9309. const cProto = getProto(dummy);
  9310. if (!cProto || !cProto.attached) {
  9311. console.warn(`proto.attached for ${tag} is unavailable.`);
  9312. return;
  9313. }
  9314.  
  9315. if (typeof cProto.dataChanged === 'function' && !cProto.dataChanged86 && '|0.169.106|'.includes(`|${fnIntegrity(cProto.dataChanged)}|`)) {
  9316.  
  9317. cProto.dataChanged86 = cProto.dataChanged;
  9318. cProto.dataChanged = function () {
  9319.  
  9320. /* 2024.12.15 */
  9321. /*
  9322. zO.prototype.dataChanged = function() {
  9323. for (var a = Ov(R(this.hostElement).querySelector("#image")); a.firstChild; )
  9324. a.removeChild(a.firstChild);
  9325. if (this.data)
  9326. if (this.data.icon) {
  9327. var b = document.createElement("yt-icon");
  9328. this.data.icon.iconType === "MODERATOR" && this.enableNewModeratorBadge ? (b.polymerController.icon = "yt-sys-icons:shield-filled",
  9329. b.polymerController.defaultToFilled = !0) : b.polymerController.icon = "live-chat-badges:" + this.data.icon.iconType.toLowerCase();
  9330. a.appendChild(b)
  9331. } else if (this.data.customThumbnail) {
  9332. b = document.createElement("img");
  9333. var c;
  9334. (c = (c = UA(this.data.customThumbnail.thumbnails, 16)) ? Yb(kc(c)) : null) ? (b.src = c,
  9335. a.appendChild(b),
  9336. b.setAttribute("alt", this.hostElement.ariaLabel || "")) : Fq(new Zn("Could not compute URL for thumbnail",this.data.customThumbnail))
  9337. }
  9338. }
  9339. */
  9340.  
  9341. const a = (this || 0).data;
  9342. const image = ((this || 0).$ || 0).image;
  9343. if (image && a && image.firstElementChild) {
  9344. const exisiting = image.firstElementChild;
  9345. if (exisiting === image.lastElementChild) {
  9346.  
  9347. if (a.icon && exisiting.nodeName.toUpperCase() === 'YT-ICON') {
  9348.  
  9349. const c = exisiting;
  9350. const t = insp(c);
  9351. const w = ('icon' in t || 'defaultToFilled' in t) ? t : c;
  9352. if ("MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge) {
  9353. if (w.icon !== "yt-sys-icons:shield-filled") w.icon = "yt-sys-icons:shield-filled";
  9354. if (w.defaultToFilled !== true) w.defaultToFilled = true;
  9355. } else {
  9356. const p = "live-chat-badges:" + a.icon.iconType.toLowerCase();;
  9357. if (w.icon !== p) w.icon = p;
  9358. if (w.defaultToFilled !== false) w.defaultToFilled = false;
  9359. }
  9360. return;
  9361.  
  9362.  
  9363. } else if (a.customThumbnail && exisiting.nodeName.toUpperCase() == 'IMG') {
  9364.  
  9365. const c = exisiting;
  9366. if (a.customThumbnail.thumbnails.map(e => e.url).includes(c.src)) {
  9367.  
  9368. c.setAttribute("alt", this.hostElement.ariaLabel || "");
  9369. return;
  9370. }
  9371. /*
  9372.  
  9373. var d;
  9374. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  9375.  
  9376. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail", a.customThumbnail))
  9377. */
  9378. }
  9379.  
  9380. }
  9381. }
  9382. return this.dataChanged86.apply(this, arguments)
  9383.  
  9384. }
  9385. console.log("cProto.dataChanged - OK");
  9386.  
  9387. } else if (typeof cProto.dataChanged === 'function' && !cProto.dataChanged86 && '|1.163.100|1.162.100|1.160.97|1.159.97|'.includes(`|${fnIntegrity(cProto.dataChanged)}|`)) {
  9388.  
  9389. cProto.dataChanged86 = cProto.dataChanged;
  9390. cProto.dataChanged = function (a) {
  9391.  
  9392. /*
  9393.  
  9394. for (var b = xC(Z(this.hostElement).querySelector("#image")); b.firstChild; )
  9395. b.removeChild(b.firstChild);
  9396. if (a)
  9397. if (a.icon) {
  9398. var c = document.createElement("yt-icon");
  9399. "MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge ? (c.icon = "yt-sys-icons:shield-filled",
  9400. c.defaultToFilled = !0) : c.icon = "live-chat-badges:" + a.icon.iconType.toLowerCase();
  9401. b.appendChild(c)
  9402. } else if (a.customThumbnail) {
  9403. c = document.createElement("img");
  9404. var d;
  9405. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  9406. b.appendChild(c),
  9407. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail",a.customThumbnail))
  9408. }
  9409.  
  9410. */
  9411.  
  9412.  
  9413. /* 2024.04.20 */
  9414. /*
  9415. for (var b = Tx(N(this.hostElement).querySelector("#image")); b.firstChild; )
  9416. b.removeChild(b.firstChild);
  9417. if (a)
  9418. if (a.icon) {
  9419. var c = document.createElement("yt-icon");
  9420. "MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge ? (c.polymerController.icon = "yt-sys-icons:shield-filled",
  9421. c.polymerController.defaultToFilled = !0) : c.polymerController.icon = "live-chat-badges:" + a.icon.iconType.toLowerCase();
  9422. b.appendChild(c)
  9423. } else if (a.customThumbnail) {
  9424. c = document.createElement("img");
  9425. var d;
  9426. (d = (d = WD(a.customThumbnail.thumbnails, 16)) ? Sb(ec(d)) : null) ? (c.src = d,
  9427. b.appendChild(c),
  9428. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : nr(new mn("Could not compute URL for thumbnail",a.customThumbnail))
  9429. }
  9430. */
  9431.  
  9432. const image = ((this || 0).$ || 0).image
  9433. if (image && a && image.firstElementChild) {
  9434. const exisiting = image.firstElementChild;
  9435. if (exisiting === image.lastElementChild) {
  9436.  
  9437. if (a.icon && exisiting.nodeName.toUpperCase() === 'YT-ICON') {
  9438.  
  9439. const c = exisiting;
  9440. const t = insp(c);
  9441. const w = ('icon' in t || 'defaultToFilled' in t) ? t : c;
  9442. if ("MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge) {
  9443. if (w.icon !== "yt-sys-icons:shield-filled") w.icon = "yt-sys-icons:shield-filled";
  9444. if (w.defaultToFilled !== true) w.defaultToFilled = true;
  9445. } else {
  9446. const p = "live-chat-badges:" + a.icon.iconType.toLowerCase();;
  9447. if (w.icon !== p) w.icon = p;
  9448. if (w.defaultToFilled !== false) w.defaultToFilled = false;
  9449. }
  9450. return;
  9451.  
  9452.  
  9453. } else if (a.customThumbnail && exisiting.nodeName.toUpperCase() == 'IMG') {
  9454.  
  9455. const c = exisiting;
  9456. if (a.customThumbnail.thumbnails.map(e => e.url).includes(c.src)) {
  9457.  
  9458. c.setAttribute("alt", this.hostElement.ariaLabel || "");
  9459. return;
  9460. }
  9461. /*
  9462.  
  9463. var d;
  9464. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  9465.  
  9466. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail", a.customThumbnail))
  9467. */
  9468. }
  9469.  
  9470. }
  9471. }
  9472. return this.dataChanged86.apply(this, arguments)
  9473.  
  9474. }
  9475. console.log("cProto.dataChanged - OK");
  9476.  
  9477. } else {
  9478. assertor(() => fnIntegrity(cProto.dataChanged, '0.169.106'));
  9479. console.log("cProto.dataChanged - NG");
  9480.  
  9481. }
  9482.  
  9483. })();
  9484.  
  9485. console.log("[End]");
  9486.  
  9487. console.groupEnd();
  9488.  
  9489. }).catch(console.warn);
  9490.  
  9491.  
  9492. }
  9493.  
  9494.  
  9495.  
  9496. if(USE_ADVANCED_TICKING){
  9497.  
  9498.  
  9499. customElements.whenDefined("yt-live-chat-renderer").then(() => {
  9500.  
  9501. const tag = "yt-live-chat-renderer"
  9502. const dummy = document.createElement(tag);
  9503.  
  9504.  
  9505. const cProto = getProto(dummy);
  9506.  
  9507. dummy.usePatchedLifecycles = false;
  9508. dummy.data = null;
  9509. dummy.__data = null;
  9510. Object.setPrototypeOf(dummy, Object.prototype);
  9511. if (!cProto || !cProto.attached) {
  9512. console.warn(`proto.attached for ${tag} is unavailable.`);
  9513. return;
  9514. }
  9515.  
  9516. /*
  9517. <tp-yt-paper-tooltip class="style-scope yt-live-chat-author-badge-renderer" role="tooltip" tabindex="-1" style="--paper-tooltip-delay-in: 0ms; inset: -63.3984px auto auto 0px;
  9518. */
  9519.  
  9520. if (cProto && typeof cProto.immediatelyApplyLiveChatActions === 'function' && cProto.immediatelyApplyLiveChatActions.length === 1 && !cProto.immediatelyApplyLiveChatActions82) {
  9521. cProto.immediatelyApplyLiveChatActions82 = cProto.immediatelyApplyLiveChatActions;
  9522. cProto.immediatelyApplyLiveChatActions = function(arr){
  9523.  
  9524. try{
  9525. preprocessChatLiveActions(arr);
  9526.  
  9527. }catch(e){
  9528. console.warn(e);
  9529. }
  9530. return this.immediatelyApplyLiveChatActions82(arr);
  9531. };
  9532. }
  9533.  
  9534.  
  9535. if (cProto && typeof cProto.preprocessActions_ === 'function' && cProto.preprocessActions_.length === 1 && !cProto.preprocessActions82_) {
  9536. cProto.preprocessActions82_ = cProto.preprocessActions_;
  9537. cProto.preprocessActions_ = function(arr){
  9538. arr = this.preprocessActions82_(arr);
  9539. preprocessChatLiveActions(arr);
  9540. return arr;
  9541. };
  9542. }
  9543.  
  9544.  
  9545. });
  9546. }
  9547.  
  9548.  
  9549. if (FIX_TOOLTIP_DISPLAY) {
  9550.  
  9551. // ----------------------------------------------------------------------------------------------------
  9552.  
  9553. const checkPDGet = (pd) => {
  9554. return pd && pd.get && !pd.set && pd.enumerable && pd.configurable;
  9555. }
  9556.  
  9557. const tooltipUIWM = new WeakMap();
  9558. const tooltipInitProps = {};
  9559. const createTooltipIfRequired_ = function () {
  9560. let r;
  9561. if (tooltipUIWM.get(this) === void 0) {
  9562. const w = document.createElement;
  9563. let EU = null;
  9564. tooltipUIWM.set(this, null);
  9565. document.createElement = function () {
  9566. let r = w.apply(this, arguments);
  9567. EU = r;
  9568. return r;
  9569. };
  9570. r = this.createTooltipIfRequired14_();
  9571. document.createElement = w;
  9572. if (EU instanceof HTMLElement && EU.is) {
  9573. tooltipUIWM.set(this, EU);
  9574. EU.setAttribute('__nogc__', ''); // avoid gc process script
  9575.  
  9576. if (typeof EU.offset === 'number') tooltipInitProps['offset'] = EU.offset;
  9577. if (typeof EU.fitToVisibleBounds === 'boolean') tooltipInitProps['fitToVisibleBounds'] = EU.fitToVisibleBounds;
  9578. if (typeof EU.position === 'string') tooltipInitProps['position'] = EU.position;
  9579. if (typeof EU.for === 'string') tooltipInitProps['for'] = EU.for;
  9580.  
  9581. // this.__mcT__ = EU.outerHTML;
  9582. // EU.__dataX = JSON.stringify(EU.__data);
  9583. // EU.__dataY = Object.entries(EU);
  9584.  
  9585. // <<< FOR DEBUG >>>
  9586. // let kx;
  9587. // Object.defineProperty(EU, '_target', {
  9588. // get(){
  9589. // return kx;
  9590. // },
  9591. // set(nv){
  9592. // kx= nv;
  9593. // debugger;
  9594. // return true;
  9595. // }
  9596. // });
  9597. // <<< FOR DEBUG >>>
  9598.  
  9599. if (typeof Polymer !== 'undefined' && Polymer.__fixedGetOwnerRoot__ && Polymer.__fixedQuerySelector__) {
  9600.  
  9601. } else {
  9602. let eProto = null;
  9603. const euCnt = insp(EU);
  9604. if (checkPDGet(Object.getOwnPropertyDescriptor(euCnt.constructor.prototype || {}, 'target'))) {
  9605.  
  9606. eProto = euCnt.constructor.prototype;
  9607. } else if (checkPDGet(Object.getOwnPropertyDescriptor(EU.constructor.prototype || {}, 'target'))) {
  9608.  
  9609. eProto = EU.constructor.prototype;
  9610. }
  9611. if (eProto) {
  9612. delete eProto.target;
  9613. /*
  9614.  
  9615. get target() {
  9616. var a = Pv(this).parentNode, b = Pv(this).getOwnerRoot(), c;
  9617. this.for ? c = Pv(b).querySelector("#" + this.for) : c = a.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? b.host : a;
  9618. return c
  9619. },
  9620. */
  9621. Object.defineProperty(eProto, 'target', {
  9622. get() {
  9623. let a = this.parentNode, b = this.getRootNode();
  9624. return (this.for ? b.querySelector("#" + this.for) : a)
  9625. }
  9626. })
  9627. }
  9628. }
  9629. // setInterval(()=>EU.updatePosition(), 100)
  9630.  
  9631. } else {
  9632. tooltipUIWM.set(this, null);
  9633. }
  9634. } else {
  9635. r = this.createTooltipIfRequired14_();
  9636. }
  9637.  
  9638. const EU = tooltipUIWM.get(this);
  9639. if (EU) {
  9640. EU.remove();
  9641. if (typeof tooltipInitProps.offset === 'number') EU['offset'] = tooltipInitProps.offset;
  9642. if (typeof tooltipInitProps.fitToVisibleBounds === 'boolean') EU['fitToVisibleBounds'] = tooltipInitProps.fitToVisibleBounds;
  9643. try {
  9644. if (typeof tooltipInitProps.position === 'string') EU['position'] = tooltipInitProps.position;
  9645. if (typeof tooltipInitProps.for === 'string') EU['for'] = tooltipInitProps.for; else delete EU.for;
  9646. } catch (e) { }
  9647. }
  9648. return r;
  9649. };
  9650.  
  9651.  
  9652. // added in 2024.05.02
  9653. getLCRDummy().then(async (lcrDummy) => {
  9654.  
  9655. // console.log(8171, 99);
  9656. const tag = "yt-live-chat-renderer"
  9657. const dummy = lcrDummy;
  9658.  
  9659. const cProto = getProto(dummy);
  9660. if (!cProto || !cProto.attached) {
  9661. console.warn(`proto.attached for ${tag} is unavailable.`);
  9662. return;
  9663. }
  9664.  
  9665. /*
  9666. <tp-yt-paper-tooltip class="style-scope yt-live-chat-author-badge-renderer" role="tooltip" tabindex="-1" style="--paper-tooltip-delay-in: 0ms; inset: -63.3984px auto auto 0px;
  9667. */
  9668.  
  9669. if (cProto && typeof cProto.createTooltipIfRequired_ === 'function' && cProto.createTooltipIfRequired_.length === 0 && !cProto.createTooltipIfRequired14_) {
  9670. cProto.createTooltipIfRequired14_ = cProto.createTooltipIfRequired_;
  9671. cProto.createTooltipIfRequired_ = createTooltipIfRequired_;
  9672. }
  9673.  
  9674. });
  9675.  
  9676. // ----------------------------------------------------------------------------------------------------
  9677.  
  9678. customElements.whenDefined("tp-yt-paper-tooltip").then(() => {
  9679.  
  9680. mightFirstCheckOnYtInit();
  9681. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-paper-tooltip hacks");
  9682. console.log("[Begin]");
  9683. (() => {
  9684.  
  9685. const tag = "tp-yt-paper-tooltip"
  9686. const dummy = document.createElement(tag);
  9687.  
  9688. const cProto = getProto(dummy);
  9689. if (!cProto || !cProto.attached) {
  9690. console.warn(`proto.attached for ${tag} is unavailable.`);
  9691. return;
  9692. }
  9693.  
  9694. if (typeof cProto.attached === 'function' && typeof cProto.detached === 'function' && cProto._readyClients && cProto._attachDom && cProto.ready && !cProto._readyClients43) {
  9695.  
  9696. cProto._readyClients43 = cProto._readyClients;
  9697. cProto._readyClients = function () {
  9698. // console.log(1238)
  9699.  
  9700. let r = cProto._readyClients43.apply(this, arguments);
  9701. if (this.$ && this.$$ && this.$.tooltip) this.root = null; // fix this.root = null != (b = a.root) ? b : this.host
  9702. return r;
  9703. }
  9704.  
  9705. console.log("_readyClients - OK");
  9706.  
  9707. } else {
  9708. console.log("_readyClients - NG");
  9709.  
  9710. }
  9711.  
  9712. if (typeof cProto.show === 'function' && !cProto.show17) {
  9713. cProto.show17 = cProto.show;
  9714. cProto.show = function () {
  9715.  
  9716. let r = this.show17.apply(this, arguments);
  9717. this._showing === true && Promise.resolve(this).then((cnt) => {
  9718. const tooltip = (cnt.$ || 0).tooltip;
  9719.  
  9720. if (tooltip && tooltip.firstElementChild === null) {
  9721. let text = tooltip.textContent;
  9722. if (typeof text === 'string' && text.length >= 2) {
  9723. tooltip.textContent = text.trim();
  9724. }
  9725. }
  9726. cnt = null;
  9727. }).catch(console.warn)
  9728. return r;
  9729. }
  9730.  
  9731. console.log("trim tooltip content - OK");
  9732.  
  9733. } else {
  9734. console.log("trim tooltip content - NG");
  9735.  
  9736. }
  9737.  
  9738.  
  9739. })();
  9740.  
  9741. console.log("[End]");
  9742.  
  9743. console.groupEnd();
  9744.  
  9745. }).catch(console.warn);
  9746.  
  9747. }
  9748.  
  9749.  
  9750. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK) {
  9751.  
  9752. const hookDocumentMouseDownSetupFn = () => {
  9753.  
  9754. let muzTimestamp = 0;
  9755. let nszDropdown = null;
  9756.  
  9757. const handlerObject = {
  9758.  
  9759. muHandler282: function (evt) {
  9760. // console.log(evt, 7, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  9761. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  9762. const dropdown = nszDropdown;
  9763. muzTimestamp = 0;
  9764. nszDropdown = null;
  9765.  
  9766. const kurMPCe = kRef(currentMenuPivotWR) || 0;
  9767. const hostElement = kurMPCe.hostElement || kurMPCe; // should be always hostElement === kurMPCe ?
  9768. if (!hostElement.hasAttribute('menu-visible')) return;
  9769.  
  9770. const chatBanner = HTMLElement.prototype.closest.call(hostElement, 'yt-live-chat-banner-renderer') || 0;
  9771. if (chatBanner) return;
  9772.  
  9773. if (dropdown && dropdown.positionTarget && hostElement.contains(dropdown.positionTarget)) {
  9774. muzTimestamp = Date.now();
  9775. evt.stopImmediatePropagation();
  9776. evt.stopPropagation();
  9777. Promise.resolve(dropdown).then((dropdown) => {
  9778. dropdown.cancel();
  9779. dropdown = null;
  9780. });
  9781. }
  9782.  
  9783. },
  9784.  
  9785. mlHandler282: function (evt) {
  9786. muzTimestamp = 0;
  9787. nszDropdown = null;
  9788. },
  9789.  
  9790. ckHandler282: function (evt) {
  9791. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  9792. if (Date.now() - muzTimestamp < 40) {
  9793. muzTimestamp = Date.now();
  9794. evt.stopImmediatePropagation();
  9795. evt.stopPropagation();
  9796. }
  9797. },
  9798.  
  9799. tapHandler282: function (evt) {
  9800. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  9801. if (Date.now() - muzTimestamp < 40) {
  9802. muzTimestamp = Date.now();
  9803. evt.stopImmediatePropagation();
  9804. evt.stopPropagation();
  9805. }
  9806. },
  9807.  
  9808. handleEvent(evt) {
  9809. if (evt) {
  9810. const kurMPCe = kRef(currentMenuPivotWR) || 0;
  9811. const kurMPCc = insp(kurMPCe);
  9812. const hostElement = kurMPCc.hostElement || kurMPCc;
  9813. if (!kurMPCc || kurMPCc.isAttached !== true || hostElement.isConnected !== true) return;
  9814. switch (evt.type) {
  9815. case 'mouseup':
  9816. return this.muHandler282(evt);
  9817. case 'mouseleave':
  9818. return this.mlHandler282(evt);
  9819. case 'tap':
  9820. return this.tapHandler282(evt);
  9821. case 'click':
  9822. return this.ckHandler282(evt);
  9823. }
  9824. }
  9825. }
  9826.  
  9827. }
  9828.  
  9829. document.addEventListener('mousedown', function (evt) {
  9830.  
  9831. if (!evt || !evt.isTrusted || !evt.target) return;
  9832.  
  9833. muzTimestamp = 0;
  9834. nszDropdown = null;
  9835.  
  9836. /** @type {HTMLElement | null} */
  9837. const kurMP = kRef(currentMenuPivotWR);
  9838. if (!kurMP) return;
  9839. const kurMPCe = HTMLElement.prototype.closest.call(kurMP, '[menu-visible]') || 0; // element
  9840.  
  9841. if (!kurMPCe || !kurMPCe.hasAttribute('whole-message-clickable')) return;
  9842.  
  9843. const kurMPCc = insp(kurMPCe); // controller
  9844.  
  9845. if (!kurMPCc.isClickableChatRow111 || !kurMPCc.isClickableChatRow111() || !HTMLElement.prototype.contains.call(kurMPCe, evt.target)) return;
  9846.  
  9847. const chatBanner = HTMLElement.prototype.closest.call(kurMPCe, 'yt-live-chat-banner-renderer') || 0;
  9848. if (chatBanner) return;
  9849.  
  9850. let targetDropDown = null;
  9851. for (const dropdown of document.querySelectorAll('tp-yt-iron-dropdown.style-scope.yt-live-chat-app')) {
  9852. if (dropdown && dropdown.positionTarget === kurMP) {
  9853. targetDropDown = dropdown;
  9854. }
  9855. }
  9856.  
  9857. if (!targetDropDown) return;
  9858.  
  9859. if ((nszDropdown = targetDropDown)) {
  9860. muzTimestamp = Date.now();
  9861. evt.stopImmediatePropagation();
  9862. evt.stopPropagation();
  9863. currentMenuPivotWR = mWeakRef(kurMPCe);
  9864.  
  9865. const listenOpts = { capture: true, passive: false, once: true };
  9866.  
  9867. // remove unexcecuted eventHandler
  9868. document.removeEventListener('mouseup', handlerObject, listenOpts);
  9869. document.removeEventListener('mouseleave', handlerObject, listenOpts);
  9870. document.removeEventListener('tap', handlerObject, listenOpts);
  9871. document.removeEventListener('click', handlerObject, listenOpts);
  9872.  
  9873. // inject one time eventHandler to by pass events
  9874. document.addEventListener('mouseup', handlerObject, listenOpts);
  9875. document.addEventListener('mouseleave', handlerObject, listenOpts);
  9876. document.addEventListener('tap', handlerObject, listenOpts);
  9877. document.addEventListener('click', handlerObject, listenOpts);
  9878.  
  9879. }
  9880.  
  9881. }, true);
  9882.  
  9883. }
  9884.  
  9885.  
  9886. // yt-live-chat-paid-message-renderer ??
  9887.  
  9888. /*
  9889.  
  9890. [...(new Set([...document.querySelectorAll('*')].filter(e=>e.is&&('shouldSupportWholeItemClick' in e)).map(e=>e.is))).keys()]
  9891.  
  9892.  
  9893. "yt-live-chat-ticker-paid-message-item-renderer"
  9894. "yt-live-chat-ticker-paid-sticker-item-renderer"
  9895. "yt-live-chat-paid-message-renderer"
  9896. "yt-live-chat-text-message-renderer"
  9897. "yt-live-chat-paid-sticker-renderer"
  9898.  
  9899. */
  9900.  
  9901.  
  9902. whenDefinedMultiple([
  9903.  
  9904. "yt-live-chat-paid-message-renderer",
  9905. "yt-live-chat-membership-item-renderer",
  9906. "yt-live-chat-paid-sticker-renderer",
  9907. "yt-live-chat-text-message-renderer",
  9908. "yt-live-chat-auto-mod-message-renderer",
  9909.  
  9910. /*
  9911. "yt-live-chat-ticker-paid-message-item-renderer",
  9912. "yt-live-chat-ticker-paid-sticker-item-renderer",
  9913. "yt-live-chat-paid-message-renderer",
  9914. "yt-live-chat-text-message-renderer",
  9915. "yt-live-chat-paid-sticker-renderer",
  9916.  
  9917. "yt-live-chat-ticker-sponsor-item-renderer",
  9918. "yt-live-chat-banner-header-renderer",
  9919. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  9920. "ytd-sponsorships-live-chat-header-renderer",
  9921. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  9922.  
  9923.  
  9924.  
  9925.  
  9926. "yt-live-chat-auto-mod-message-renderer",
  9927. "yt-live-chat-text-message-renderer",
  9928. "yt-live-chat-paid-message-renderer",
  9929.  
  9930. "yt-live-chat-legacy-paid-message-renderer",
  9931. "yt-live-chat-membership-item-renderer",
  9932. "yt-live-chat-paid-sticker-renderer",
  9933. "yt-live-chat-donation-announcement-renderer",
  9934. "yt-live-chat-moderation-message-renderer",
  9935. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  9936. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  9937. "yt-live-chat-viewer-engagement-message-renderer",
  9938.  
  9939. */
  9940.  
  9941.  
  9942. ]).then(sTags => {
  9943. // return; // M33
  9944.  
  9945. if (FLAG_001e) return;
  9946.  
  9947. mightFirstCheckOnYtInit();
  9948. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-message-renderer(s)... hacks");
  9949. console.log("[Begin]");
  9950. let doMouseHook = false;
  9951.  
  9952. const dProto = {
  9953. isClickableChatRow111: function () {
  9954. return (
  9955. this.data && typeof this.shouldSupportWholeItemClick === 'function' && typeof this.hasModerationOverlayVisible === 'function' &&
  9956. this.data.contextMenuEndpoint && this.wholeMessageClickable && this.shouldSupportWholeItemClick() && !this.hasModerationOverlayVisible()
  9957. ); // follow .onItemTap(a)
  9958. }
  9959. };
  9960.  
  9961. for (const sTag of sTags) { // ##tag##
  9962.  
  9963.  
  9964. (() => {
  9965.  
  9966. const tag = sTag;
  9967. const dummy = document.createElement(tag);
  9968.  
  9969. const cProto = getProto(dummy);
  9970. if (!cProto || !cProto.attached) {
  9971. console.warn(`proto.attached for ${tag} is unavailable.`);
  9972. return;
  9973. }
  9974.  
  9975. const dCnt = insp(dummy);
  9976. if ('wholeMessageClickable' in dCnt && typeof dCnt.hasModerationOverlayVisible === 'function' && typeof dCnt.shouldSupportWholeItemClick === 'function') {
  9977.  
  9978. cProto.isClickableChatRow111 = dProto.isClickableChatRow111;
  9979.  
  9980. const toHookDocumentMouseDown = typeof cProto.shouldSupportWholeItemClick === 'function' && typeof cProto.hasModerationOverlayVisible === 'function';
  9981.  
  9982. if (toHookDocumentMouseDown) {
  9983. doMouseHook = true;
  9984. }
  9985.  
  9986. console.log("shouldSupportWholeItemClick Y", tag);
  9987.  
  9988. } else {
  9989.  
  9990. console.log("shouldSupportWholeItemClick N", tag);
  9991. }
  9992.  
  9993.  
  9994. })();
  9995.  
  9996. }
  9997.  
  9998.  
  9999. if (doMouseHook) {
  10000.  
  10001. hookDocumentMouseDownSetupFn();
  10002.  
  10003. console.log("FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK - Doc MouseEvent OK");
  10004. }
  10005.  
  10006. console.log("[End]");
  10007.  
  10008. console.groupEnd();
  10009.  
  10010.  
  10011. }).catch(console.warn);
  10012.  
  10013.  
  10014. // https://www.youtube.com/watch?v=oQzFi1NO7io
  10015.  
  10016.  
  10017. }
  10018.  
  10019. if (NO_ITEM_TAP_FOR_NON_STATIONARY_TAP) {
  10020. let targetElementCntWR = null;
  10021. let _e0 = null;
  10022. document.addEventListener('mousedown', (e) => {
  10023. if (!e || !e.isTrusted) return;
  10024. let element = e.target;
  10025. for (; element instanceof HTMLElement; element = element.parentNode) {
  10026. if (element.is) break;
  10027. }
  10028. if (!element || !element.is) return;
  10029. const cnt = insp(element);
  10030. if (typeof cnt.onItemTap === 'function') {
  10031. cnt._onItemTap_isNonStationary = 0;
  10032. const cProto = getProto(element);
  10033. if (!cProto.onItemTap366 && typeof cProto.onItemTap === 'function' && cProto.onItemTap.length === 1) {
  10034. cProto.onItemTap366 = cProto.onItemTap; // note: [onItemTap] .some(function(){...})
  10035. cProto.onItemTap = function (a) {
  10036. const t = this._onItemTap_isNonStationary;
  10037. this._onItemTap_isNonStationary = 0;
  10038. if (t > Date.now()) return;
  10039. return this.onItemTap366.apply(this, arguments)
  10040. }
  10041. }
  10042. _e0 = e;
  10043. targetElementCntWR = mWeakRef(cnt);
  10044. } else {
  10045. _e0 = null;
  10046. targetElementCntWR = null;
  10047. }
  10048. }, { capture: true, passive: true });
  10049.  
  10050. document.addEventListener('mouseup', (e) => {
  10051. if (!e || !e.isTrusted) return;
  10052. const e0 = _e0;
  10053. _e0 = null;
  10054. if (!e0) return;
  10055. const cnt = kRef(targetElementCntWR);
  10056. targetElementCntWR = null;
  10057. if (!cnt) return;
  10058. if (e.timeStamp - e0.timeStamp > TAP_ACTION_DURATION) {
  10059. cnt._onItemTap_isNonStationary = Date.now() + 40;
  10060. } else if ((window.getSelection() + "").trim().replace(/[\u2000-\u200a\u202f\u2800\u200B\u200C\u200D\uFEFF]+/g, '').length >= 1) {
  10061. cnt._onItemTap_isNonStationary = Date.now() + 40;
  10062. } else {
  10063. const dx = e.clientX - e0.clientX;
  10064. const dy = e.clientY - e0.clientY;
  10065. const dd = Math.sqrt(dx * dx + dy * dy);
  10066. const ddmm = px2mm(dd);
  10067. if (ddmm > 1.0) {
  10068. cnt._onItemTap_isNonStationary = Date.now() + 40;
  10069. } else {
  10070. cnt._onItemTap_isNonStationary = 0;
  10071. }
  10072. }
  10073. }, { capture: true, passive: true });
  10074.  
  10075. }
  10076.  
  10077.  
  10078. const __showContextMenu_assign_lock_with_external_unlock_ = function (targetCnt) {
  10079.  
  10080. let rr = null;
  10081. const p1 = new Promise(resolve => {
  10082. rr = resolve;
  10083. });
  10084.  
  10085. const p1unlock = () => {
  10086. const f = rr;
  10087. if (f) {
  10088. rr = null;
  10089. f();
  10090. }
  10091. }
  10092.  
  10093. return {
  10094. p1,
  10095. p1unlock,
  10096. assignLock: (targetCnt, timeout) => {
  10097. targetCnt.__showContextMenu_assign_lock__(p1);
  10098. if (timeout) setTimeout(p1unlock, timeout);
  10099. }
  10100. }
  10101.  
  10102. }
  10103.  
  10104. if (PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN) {
  10105.  
  10106. document.addEventListener('mousedown', function (evt) {
  10107.  
  10108. const maxloopDOMTreeElements = 4;
  10109. const maxloopYtCompontents = 4;
  10110. let j1 = 0;
  10111. let j2 = 0;
  10112. let target = (evt || 0).target || 0;
  10113. if (!target) return;
  10114.  
  10115.  
  10116. while (target instanceof HTMLElement) {
  10117. if (++j1 > maxloopDOMTreeElements) break;
  10118. if (typeof (target.is || insp(target).is || null) === 'string') break;
  10119. target = nodeParent(target);
  10120. }
  10121. const components = [];
  10122. while (target instanceof HTMLElement) {
  10123. if (++j2 > maxloopYtCompontents) break;
  10124. const cnt = insp(target);
  10125. if (typeof (target.is || cnt.is || null) === 'string') {
  10126. components.push(target);
  10127. }
  10128. if (typeof cnt.showContextMenu === 'function') break;
  10129. target = target.parentComponent || cnt.parentComponent || null;
  10130. }
  10131. if (!(target instanceof HTMLElement)) return;
  10132. const targetCnt = insp(target);
  10133. if (typeof targetCnt.handleGetContextMenuResponse_ !== 'function' || typeof targetCnt.handleGetContextMenuError !== 'function') {
  10134. console.log('Error Found: handleGetContextMenuResponse_ OR handleGetContextMenuError is not defined on a component with showContextMenu')
  10135. return;
  10136. }
  10137.  
  10138. const endpoint = (targetCnt.data || 0).contextMenuEndpoint
  10139. if (!endpoint) return;
  10140. if (targetCnt.opened || !targetCnt.isAttached) return;
  10141.  
  10142. if (typeof targetCnt.__cacheResolvedEndpointData__ !== 'function') {
  10143. console.log(`preRequest for showContextMenu in ${targetCnt.is} is not yet supported.`)
  10144. }
  10145.  
  10146. const targetDollar = indr(target);
  10147.  
  10148. let doPreRequest = false;
  10149. if (components.length >= 2 && components[0].id === 'menu-button' && (targetDollar || 0)['menu-button'] === components[0]) {
  10150. doPreRequest = true;
  10151. } else if (components.length === 1 && components[0] === target) {
  10152. doPreRequest = true;
  10153. } else if (components.length >= 2 && components[0].id === 'author-photo' && (targetDollar || 0)['author-photo'] === components[0]) {
  10154. doPreRequest = true;
  10155. }
  10156. if (doPreRequest === false) {
  10157. console.log('doPreRequest = fasle on showContextMenu', components);
  10158. return;
  10159. }
  10160.  
  10161. if (typeof targetCnt.__getCachedEndpointData__ !== 'function' || targetCnt.__getCachedEndpointData__(endpoint)) return;
  10162.  
  10163. if ((typeof targetCnt.__showContextMenu_mutex_unlock_isEmpty__ === 'function') && !targetCnt.__showContextMenu_mutex_unlock_isEmpty__()) {
  10164. console.log('preRequest on showContextMenu aborted due to stacked network request');
  10165. return;
  10166. }
  10167.  
  10168.  
  10169. const onSuccess = (a) => {
  10170. /*
  10171.  
  10172. dQ() && (a = a.response);
  10173. a.liveChatItemContextMenuSupportedRenderers && a.liveChatItemContextMenuSupportedRenderers.menuRenderer && this.showContextMenu_(a.liveChatItemContextMenuSupportedRenderers.menuRenderer);
  10174. a.actions && Eu(this.hostElement, "yt-live-chat-actions", [a.actions])
  10175.  
  10176. */
  10177.  
  10178. a = a.response || a;
  10179.  
  10180. if (!a) {
  10181. console.log('unexpected error in prerequest for showContextMenu.onSuccess');
  10182. return;
  10183. }
  10184.  
  10185. let z = null;
  10186. a.liveChatItemContextMenuSupportedRenderers && a.liveChatItemContextMenuSupportedRenderers.menuRenderer && (z = a.liveChatItemContextMenuSupportedRenderers.menuRenderer);
  10187.  
  10188. if (z) {
  10189. a = z;
  10190. targetCnt.__cacheResolvedEndpointData__(endpoint, a, true);
  10191. }
  10192.  
  10193. };
  10194. const onFailure = (a) => {
  10195.  
  10196. /*
  10197.  
  10198. if (a instanceof Error || a instanceof Object || a instanceof String)
  10199. var b = a;
  10200. hq(new xm("Error encountered calling GetLiveChatItemContextMenu",b))
  10201.  
  10202. */
  10203.  
  10204. targetCnt.__cacheResolvedEndpointData__(endpoint, null);
  10205. // console.log('onFailure', a)
  10206.  
  10207. };
  10208.  
  10209. if (doPreRequest) {
  10210.  
  10211. let propertyCounter = 0;
  10212. const pm1 = __showContextMenu_assign_lock_with_external_unlock_(targetCnt);
  10213. const p1Timeout = 800;
  10214. const proxyKey = '__$$__proxy_to_this__$$__' + Date.now();
  10215.  
  10216. try {
  10217.  
  10218. const onSuccessHelperFn = function () {
  10219. pm1.p1unlock();
  10220. if (propertyCounter !== 5) {
  10221. console.log('Error in prerequest for showContextMenu.onSuccessHelperFn')
  10222. return;
  10223. }
  10224. if (this[proxyKey] !== targetCnt) {
  10225. console.log('Error in prerequest for showContextMenu.this');
  10226. return;
  10227. }
  10228. onSuccess(...arguments);
  10229. };
  10230. const onFailureHelperFn = function () {
  10231. pm1.p1unlock();
  10232. if (propertyCounter !== 5) {
  10233. console.log('Error in prerequest for showContextMenu.onFailureHelperFn')
  10234. return;
  10235. }
  10236. if (this[proxyKey] !== targetCnt) {
  10237. console.log('Error in prerequest for showContextMenu.this');
  10238. return;
  10239. }
  10240. onFailure(...arguments);
  10241.  
  10242. }
  10243. const fakeTargetCnt = new Proxy({
  10244. __showContextMenu_forceNativeRequest__: 1,
  10245. get handleGetContextMenuResponse_() {
  10246. propertyCounter += 2;
  10247. return onSuccessHelperFn;
  10248. },
  10249. get handleGetContextMenuError() {
  10250. propertyCounter += 3;
  10251. return onFailureHelperFn;
  10252. }
  10253. }, {
  10254. get(_, key, receiver) {
  10255. if (key in _) return _[key];
  10256. if (key === proxyKey) return targetCnt;
  10257.  
  10258. let giveNative = false;
  10259. if (key in targetCnt) {
  10260. if (key === 'data') giveNative = true;
  10261. else if (typeof targetCnt[key] === 'function') giveNative = true;
  10262. }
  10263. if (giveNative) return targetCnt[key];
  10264. }
  10265. });
  10266.  
  10267. const fakeEvent = (() => {
  10268. const { target, bubbles, cancelable, cancelBubble, srcElement, timeStamp, defaultPrevented, currentTarget, composed } = evt;
  10269. const nf = function () { }
  10270. const [stopPropagation, stopImmediatePropagation, preventDefault] = [nf, nf, nf];
  10271.  
  10272. return {
  10273. type: 'tap',
  10274. eventPhase: 0,
  10275. isTrusted: false,
  10276. __composed: true,
  10277. bubbles, cancelable, cancelBubble, timeStamp,
  10278. target, srcElement, defaultPrevented, currentTarget, composed,
  10279. stopPropagation, stopImmediatePropagation, preventDefault
  10280. };
  10281. })(evt);
  10282. targetCnt.showContextMenu.call(fakeTargetCnt, fakeEvent);
  10283.  
  10284.  
  10285. } catch (e) {
  10286. console.warn(e);
  10287. propertyCounter = 7;
  10288.  
  10289. }
  10290. if (propertyCounter !== 5) {
  10291. console.log('Error in prerequest for showContextMenu', propertyCounter);
  10292. return;
  10293. }
  10294.  
  10295. pm1.assignLock(targetCnt, p1Timeout);
  10296.  
  10297. }
  10298.  
  10299.  
  10300.  
  10301.  
  10302.  
  10303.  
  10304. }, true);
  10305.  
  10306.  
  10307. }
  10308.  
  10309.  
  10310.  
  10311. /*
  10312.  
  10313. const w=new Set(); for(const a of document.getElementsByTagName('*')) if(a.showContextMenu && a.showContextMenu_) w.add(a.is||''); console.log([...w.keys()])
  10314.  
  10315. */
  10316.  
  10317. whenDefinedMultiple([
  10318. "yt-live-chat-ticker-sponsor-item-renderer",
  10319. "yt-live-chat-ticker-paid-message-item-renderer",
  10320.  
  10321. "yt-live-chat-banner-header-renderer",
  10322. "yt-live-chat-text-message-renderer",
  10323. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  10324. "ytd-sponsorships-live-chat-header-renderer",
  10325. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  10326.  
  10327. "yt-live-chat-paid-sticker-renderer",
  10328. "yt-live-chat-viewer-engagement-message-renderer",
  10329. "yt-live-chat-paid-message-renderer"
  10330.  
  10331.  
  10332.  
  10333.  
  10334. ]).then(sTags => {
  10335.  
  10336. if (FLAG_001f) return;
  10337.  
  10338. mightFirstCheckOnYtInit();
  10339. groupCollapsed("YouTube Super Fast Chat", " | fixShowContextMenu");
  10340. console.log("[Begin]");
  10341.  
  10342.  
  10343. const __showContextMenu_mutex__ = new Mutex();
  10344. let __showContextMenu_mutex_unlock__ = null;
  10345. let lastShowMenuTarget = null;
  10346.  
  10347.  
  10348.  
  10349.  
  10350. const wm37 = new WeakMap();
  10351.  
  10352. const dProto = {
  10353.  
  10354.  
  10355. // CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN
  10356.  
  10357. __cacheResolvedEndpointData__: (endpoint, a, doDeepCopy) => {
  10358. if (a) {
  10359. if (doDeepCopy) a = deepCopy(a);
  10360. wm37.set(endpoint, a);
  10361. } else {
  10362. wm37.remove(endpoint);
  10363. }
  10364. },
  10365. __getCachedEndpointData__: function (endpoint) {
  10366. endpoint = endpoint || (this.data || 0).contextMenuEndpoint || 0;
  10367. if (endpoint) return wm37.get(endpoint);
  10368. return null;
  10369. },
  10370. /** @type {(resolvedEndpoint: any) => void 0} */
  10371. __showCachedContextMenu__: function (resolvedEndpoint) { // non-null
  10372.  
  10373. resolvedEndpoint = deepCopy(resolvedEndpoint);
  10374. // let b = deepCopy(resolvedEndpoint, ['trackingParams', 'clickTrackingParams'])
  10375. Promise.resolve(resolvedEndpoint).then((resolvedEndpoint) => {
  10376. this.__showContextMenu_skip_cacheResolvedEndpointData__ = 1;
  10377. this.showContextMenu_(resolvedEndpoint);
  10378. this.__showContextMenu_skip_cacheResolvedEndpointData__ = 0;
  10379. resolvedEndpoint = null;
  10380. });
  10381.  
  10382.  
  10383. },
  10384.  
  10385.  
  10386.  
  10387. showContextMenuForCacheReopen: function (a) {
  10388. if (this && this.__showContextMenu_forceNativeRequest__) return this.showContextMenu37(a);
  10389. if (!this || !this.isAttached) return; // in case; avoid Error: No provider for: InjectionToken(NETWORK_TOKEN) in _.showContextMenu
  10390. if (!this.__showContextMenu_forceNativeRequest__) {
  10391. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  10392. if (endpoint) {
  10393. const resolvedEndpoint = this.__getCachedEndpointData__(endpoint);
  10394. if (resolvedEndpoint) {
  10395. this.__showCachedContextMenu__(resolvedEndpoint);
  10396. a && a.stopPropagation()
  10397. return;
  10398. }
  10399. }
  10400. }
  10401. return this.showContextMenu37(a);
  10402. },
  10403.  
  10404. showContextMenuForCacheReopen_: function (a) {
  10405. if (this && this.__showContextMenu_forceNativeRequest__) return this.showContextMenu37_(a);
  10406. if (!this || !this.isAttached) return; // in case; avoid Error: No provider for: InjectionToken(NETWORK_TOKEN) in _.showContextMenu
  10407. if (!this.__showContextMenu_skip_cacheResolvedEndpointData__) {
  10408. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  10409. if (endpoint) {
  10410. const f = this.__cacheResolvedEndpointData__;
  10411. if (typeof f === 'function') f(endpoint, a, true);
  10412. }
  10413. }
  10414. return this.showContextMenu37_(a);
  10415. },
  10416.  
  10417. // ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU
  10418.  
  10419. showContextMenuWithDisableScroll: function (a) {
  10420.  
  10421. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  10422. if (endpoint && typeof this.is === 'string' && this.menuVisible === false && this.menuOpen === false) {
  10423.  
  10424. const parentComponent = this.parentComponent;
  10425. if (parentComponent && parentComponent.is === 'yt-live-chat-item-list-renderer' && parentComponent.contextMenuOpen === false && parentComponent.allowScroll === true) {
  10426. parentComponent.contextMenuOpen = true; // computeAllowScroll_(contextMenuOpen, moderationModeEnabled): allowScroll = !(contextMenuOpen || moderationModeEnabled)
  10427. }
  10428. }
  10429.  
  10430. return this.showContextMenu48.apply(this, arguments);
  10431.  
  10432. },
  10433.  
  10434. // ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU
  10435.  
  10436. __showContextMenu_mutex_unlock_isEmpty__: () => {
  10437. return __showContextMenu_mutex_unlock__ === null;
  10438. },
  10439.  
  10440. __showContextMenu_assign_lock__: function (p) {
  10441.  
  10442. const mutex = __showContextMenu_mutex__;
  10443.  
  10444. mutex.lockWith(unlock => {
  10445. p.then(unlock);
  10446. p = null;
  10447. unlock = null;
  10448. });
  10449.  
  10450. },
  10451.  
  10452. showContextMenuWithMutex: function (a) {
  10453. if (this.__showContextMenu_forceNativeRequest__) return this.showContextMenu47(a);
  10454. if (!this || !this.isAttached) return; // in case; avoid Error: No provider for: InjectionToken(NETWORK_TOKEN) in _.showContextMenu
  10455. lastShowMenuTarget = this;
  10456. const wNode = mWeakRef(this);
  10457.  
  10458.  
  10459. const mutex = __showContextMenu_mutex__;
  10460.  
  10461. mutex.lockWith(unlock => {
  10462. const cnt = kRef(wNode);
  10463. if (lastShowMenuTarget !== cnt || !cnt) {
  10464. unlock();
  10465. return;
  10466. }
  10467.  
  10468. setTimeout(unlock, 800); // in case network failure
  10469. __showContextMenu_mutex_unlock__ = unlock;
  10470. try {
  10471. cnt.showContextMenu47(a);
  10472. } catch (e) {
  10473. console.warn(e);
  10474. unlock(); // in case function script error
  10475. }
  10476.  
  10477. });
  10478.  
  10479.  
  10480. },
  10481.  
  10482. showContextMenuWithMutex_: function (a) {
  10483.  
  10484. if (__showContextMenu_mutex_unlock__ && this === lastShowMenuTarget) {
  10485. __showContextMenu_mutex_unlock__();
  10486. __showContextMenu_mutex_unlock__ = null;
  10487. }
  10488. return this.showContextMenu47_(a);
  10489.  
  10490. }
  10491.  
  10492. }
  10493.  
  10494. for (const tag of sTags) { // ##tag##
  10495.  
  10496. (() => {
  10497.  
  10498. const dummy = document.createElement(tag);
  10499.  
  10500. const cProto = getProto(dummy);
  10501. if (!cProto || !cProto.attached) {
  10502. console.warn(`proto.attached for ${tag} is unavailable.`);
  10503. return;
  10504. }
  10505.  
  10506.  
  10507. if (CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN && typeof cProto.showContextMenu === 'function' && typeof cProto.showContextMenu_ === 'function' && !cProto.showContextMenu37 && !cProto.showContextMenu37_ && cProto.showContextMenu.length === 1 && cProto.showContextMenu_.length === 1) {
  10508. cProto.showContextMenu37_ = cProto.showContextMenu_;
  10509. cProto.showContextMenu37 = cProto.showContextMenu;
  10510. cProto.__showContextMenu_forceNativeRequest__ = 0;
  10511. cProto.__cacheResolvedEndpointData__ = dProto.__cacheResolvedEndpointData__
  10512. cProto.__getCachedEndpointData__ = dProto.__getCachedEndpointData__
  10513. cProto.__showCachedContextMenu__ = dProto.__showCachedContextMenu__
  10514. cProto.showContextMenu = dProto.showContextMenuForCacheReopen;
  10515. cProto.showContextMenu_ = dProto.showContextMenuForCacheReopen_;
  10516. console.log("CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN - OK", tag);
  10517. } else {
  10518. console.log("CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN - NG", tag);
  10519. }
  10520.  
  10521. if (ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU && typeof cProto.showContextMenu === 'function' && typeof cProto.showContextMenu_ === 'function' && !cProto.showContextMenu48 && !cProto.showContextMenu48_ && cProto.showContextMenu.length === 1 && cProto.showContextMenu_.length === 1) {
  10522. cProto.showContextMenu48 = cProto.showContextMenu;
  10523. cProto.showContextMenu = dProto.showContextMenuWithDisableScroll;
  10524. console.log("ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU - OK", tag);
  10525. } else if (!ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU) {
  10526. console.log("ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU - N/A", tag);
  10527. } else {
  10528. console.log("ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU - NG", tag);
  10529. }
  10530.  
  10531.  
  10532. if (ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU && typeof cProto.showContextMenu === 'function' && typeof cProto.showContextMenu_ === 'function' && !cProto.showContextMenu47 && !cProto.showContextMenu47_ && cProto.showContextMenu.length === 1 && cProto.showContextMenu_.length === 1) {
  10533. cProto.showContextMenu47_ = cProto.showContextMenu_;
  10534. cProto.showContextMenu47 = cProto.showContextMenu;
  10535. cProto.__showContextMenu_mutex_unlock_isEmpty__ = dProto.__showContextMenu_mutex_unlock_isEmpty__;
  10536. cProto.__showContextMenu_assign_lock__ = dProto.__showContextMenu_assign_lock__;
  10537. cProto.showContextMenu = dProto.showContextMenuWithMutex;
  10538. cProto.showContextMenu_ = dProto.showContextMenuWithMutex_;
  10539. console.log("ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU - OK", tag);
  10540. } else {
  10541. console.log("ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU - NG", tag);
  10542. }
  10543.  
  10544. })();
  10545.  
  10546. }
  10547.  
  10548. console.log("[End]");
  10549.  
  10550. console.groupEnd();
  10551.  
  10552. }).catch(console.warn);
  10553.  
  10554.  
  10555.  
  10556. customElements.whenDefined('tp-yt-iron-dropdown').then(() => {
  10557.  
  10558. mightFirstCheckOnYtInit();
  10559. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-iron-dropdown hacks");
  10560. console.log("[Begin]");
  10561. (() => {
  10562.  
  10563. const tag = "tp-yt-iron-dropdown";
  10564. const dummy = document.createElement(tag);
  10565.  
  10566. const cProto = getProto(dummy);
  10567. if (!cProto || !cProto.attached) {
  10568. console.warn(`proto.attached for ${tag} is unavailable.`);
  10569. return;
  10570. }
  10571.  
  10572. if (USE_VANILLA_DEREF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf34 && fnIntegrity(cProto.__deraf) === '2.42.24') {
  10573. cProto.__deraf_hn__ = function (sId, fn) {
  10574. const rhKey = `_rafHandler_${sId}`;
  10575. const m = this[rhKey] || (this[rhKey] = new WeakMap());
  10576. if (m.has(fn)) return m.get(fn);
  10577. const resFn = () => {
  10578. this.__rafs[sId] = null;
  10579. fn.call(this)
  10580. };
  10581. m.set(fn, resFn);
  10582. m.set(resFn, resFn);
  10583. return resFn;
  10584. };
  10585. cProto.__deraf34 = cProto.__deraf;
  10586. cProto.__deraf = function (a, b) { // sId, fn
  10587. let c = this.__rafs;
  10588. null !== c[a] && cancelAnimationFrame(c[a]);
  10589. c[a] = requestAnimationFrame(this.__deraf_hn__(a, b));
  10590. };
  10591. console.log("USE_VANILLA_DEREF - OK");
  10592. } else {
  10593. console.log("USE_VANILLA_DEREF - NG");
  10594. }
  10595.  
  10596. if (FIX_DROPDOWN_DERAF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf66) {
  10597. cProto.__deraf66 = cProto.__deraf;
  10598. cProto.__deraf = function (sId, fn) {
  10599. if (this.__byPassRAF__) {
  10600. Promise.resolve(this).then((cnt) => {
  10601. fn.call(cnt);
  10602. cnt = null;
  10603. });
  10604. }
  10605. let r = this.__deraf66.apply(this, arguments);
  10606. return r;
  10607. }
  10608. console.log("FIX_DROPDOWN_DERAF - OK");
  10609. } else {
  10610. console.log("FIX_DROPDOWN_DERAF - NG");
  10611. }
  10612.  
  10613.  
  10614. if (BOOST_MENU_OPENCHANGED_RENDERING && typeof cProto.__openedChanged === 'function' && !cProto.__mtChanged__ && fnIntegrity(cProto.__openedChanged) === '0.46.20') {
  10615.  
  10616. let lastClose = null;
  10617. let lastOpen = null;
  10618. let cid = 0;
  10619.  
  10620. cProto.__mtChanged__ = function (b) {
  10621.  
  10622. Promise.resolve(this).then((cnt) => {
  10623. cnt._applyFocus();
  10624. return cnt;
  10625. }).then((cnt) => {
  10626. b ? cnt._renderOpened() : cnt._renderClosed();
  10627. cnt = null;
  10628. }).catch(console.warn);
  10629.  
  10630. };
  10631.  
  10632. const __moChanged__ = () => {
  10633. if (!cid) return;
  10634. // console.log(553, !!lastOpen, !!lastClose);
  10635. cid = 0;
  10636. if (lastOpen && !lastClose && lastOpen.isAttached) {
  10637. lastOpen.__mtChanged__(1)
  10638. } else if (lastClose && !lastOpen && lastClose.isAttached) {
  10639. lastClose.__mtChanged__(0);
  10640. }
  10641. lastOpen = null;
  10642. lastClose = null;
  10643. };
  10644.  
  10645.  
  10646. if (typeof cProto._openedChanged === 'function' && !cProto._openedChanged66) {
  10647. cProto._openedChanged66 = cProto._openedChanged;
  10648. cProto._openedChanged = function () {
  10649. // this.__byPassRAF__ = !lastOpen ? true : false; // or just true?
  10650. this.__byPassRAF__ = true;
  10651. let r = this._openedChanged66.apply(this, arguments);
  10652. this.__byPassRAF__ = false;
  10653. return r;
  10654. }
  10655. }
  10656.  
  10657. const pSetGet = (key, pdThis, pdBase) => {
  10658. // note: this is not really a standard way for the getOwnPropertyDescriptors; but it is sufficient to make the job done
  10659. return {
  10660. get: (pdThis[key] || 0).get || (pdBase[key] || 0).get,
  10661. set: (pdThis[key] || 0).set || (pdBase[key] || 0).set
  10662. };
  10663. };
  10664.  
  10665. cProto.__modifiedMenuPropsFn__ = function () {
  10666. const pdThis = Object.getOwnPropertyDescriptors(this.constructor.prototype)
  10667. const pdBase = Object.getOwnPropertyDescriptors(this)
  10668.  
  10669. const pdAutoFitOnAttach = pSetGet('autoFitOnAttach', pdThis, pdBase);
  10670. const pdExpandSizingTargetForScrollbars = pSetGet('expandSizingTargetForScrollbars', pdThis, pdBase);
  10671. const pdAllowOutsideScroll = pSetGet('allowOutsideScroll', pdThis, pdBase);
  10672.  
  10673. if (pdAutoFitOnAttach.get || pdAutoFitOnAttach.set) {
  10674. console.warn('there is setter/getter for autoFitOnAttach');
  10675. return;
  10676. }
  10677. if (pdExpandSizingTargetForScrollbars.get || pdExpandSizingTargetForScrollbars.set) {
  10678. console.warn('there is setter/getter for expandSizingTargetForScrollbars');
  10679. return;
  10680. }
  10681. if (!pdAllowOutsideScroll.get || !pdAllowOutsideScroll.set) {
  10682. console.warn('there is NO setter-getter for allowOutsideScroll');
  10683. return;
  10684. }
  10685.  
  10686. let { autoFitOnAttach, expandSizingTargetForScrollbars, allowOutsideScroll } = this;
  10687.  
  10688. this.__AllowOutsideScrollPD__ = pdAllowOutsideScroll;
  10689.  
  10690. const fitEnable = CHAT_MENU_REFIT_ALONG_SCROLLING === 2;
  10691.  
  10692. Object.defineProperties(this, {
  10693. autoFitOnAttach: {
  10694. get() {
  10695. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  10696. return autoFitOnAttach;
  10697. },
  10698. set(nv) {
  10699. autoFitOnAttach = nv;
  10700. return true;
  10701. },
  10702. enumerable: true,
  10703. configurable: true
  10704. }, expandSizingTargetForScrollbars: {
  10705. get() {
  10706. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  10707. return expandSizingTargetForScrollbars;
  10708. },
  10709. set(nv) {
  10710. expandSizingTargetForScrollbars = nv;
  10711. return true;
  10712. },
  10713. enumerable: true,
  10714. configurable: true
  10715. }, allowOutsideScroll: {
  10716. get() {
  10717. if (this._modifiedMenuPropOn062__) return true;
  10718. return allowOutsideScroll;
  10719. },
  10720. set(nv) {
  10721. allowOutsideScroll = nv;
  10722. this.__AllowOutsideScrollPD__.set.call(this, nv);
  10723. return true;
  10724. },
  10725. enumerable: true,
  10726. configurable: true
  10727. }
  10728. })
  10729. };
  10730.  
  10731. /*
  10732. // ***** position() to be changed. *****
  10733. tp-yt-iron-dropdown[class], tp-yt-iron-dropdown[class] #contentWrapper, tp-yt-iron-dropdown[class] ytd-menu-popup-renderer[class] {
  10734.  
  10735. overflow: visible !important;
  10736. min-width: max-content !important;
  10737. max-width: max-content !important;
  10738. max-height: max-content !important;
  10739. min-height: max-content !important;
  10740. white-space: nowrap;
  10741. }
  10742.  
  10743. */
  10744. if (FIX_MENU_POSITION_N_SIZING_ON_SHOWN && typeof cProto.position === 'function' && !cProto.position34 && typeof cProto.refit === 'function') {
  10745.  
  10746. let m34 = 0;
  10747. cProto.__refitByPosition__ = function () {
  10748. m34++;
  10749. if (m34 <= 0) m34 = 0;
  10750. if (m34 !== 1) return;
  10751. const hostElement = this.hostElement || this;
  10752. if (document.visibilityState === 'visible') {
  10753. const sizingTarget = this.sizingTarget;
  10754. if (!sizingTarget) {
  10755. m34 = 0;
  10756. return;
  10757. }
  10758. hostElement.setAttribute('rNgzQ', '');
  10759. sizingTarget.setAttribute('rNgzQ', '');
  10760.  
  10761. const gn = () => {
  10762. hostElement.removeAttribute('rNgzQ');
  10763. sizingTarget.removeAttribute('rNgzQ');
  10764. }
  10765.  
  10766. const an = async () => {
  10767. while (m34 >= 1) {
  10768. await renderReadyPn(sizingTarget);
  10769. if (this.opened && this.isAttached && sizingTarget.isConnected === true && sizingTarget === this.sizingTarget) {
  10770. if (sizingTarget.matches('ytd-menu-popup-renderer[slot="dropdown-content"].yt-live-chat-app')) this.refit();
  10771. }
  10772. m34--;
  10773. }
  10774. m34 = 0;
  10775. Promise.resolve().then(gn);
  10776. }
  10777. setTimeout(an, 4); // wait those resizing function calls
  10778.  
  10779.  
  10780. } else {
  10781. m34 = 0;
  10782. }
  10783. }
  10784. cProto.position34 = cProto.position
  10785. cProto.position = function () {
  10786. if (this._positionInitialize_) {
  10787. this._positionInitialize_ = 0;
  10788. this.__refitByPosition__();
  10789. }
  10790. let r = cProto.position34.apply(this, arguments);
  10791. return r;
  10792. }
  10793. console.log("FIX_MENU_POSITION_ON_SHOWN - OK");
  10794.  
  10795. } else {
  10796.  
  10797. console.log("FIX_MENU_POSITION_ON_SHOWN - NG");
  10798.  
  10799. }
  10800.  
  10801.  
  10802.  
  10803. cProto.__openedChanged = function () {
  10804. this._positionInitialize_ = 1;
  10805. // this.removeAttribute('horizontal-align')
  10806. // this.removeAttribute('vertical-align')
  10807. if (typeof this.__menuTypeCheck__ !== 'boolean') {
  10808. this.__menuTypeCheck__ = true;
  10809. if (CHAT_MENU_SCROLL_UNLOCKING) {
  10810. this._modifiedMenuPropOn062__ = false;
  10811. // console.log(513, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  10812. // this.autoFitOnAttach = true;
  10813. // this.expandSizingTargetForScrollbars = true;
  10814. // this.allowOutsideScroll = true;
  10815. // console.log(519,Object.getOwnPropertyDescriptors(this.constructor.prototype))
  10816. this.__modifiedMenuPropsFn__();
  10817. // this.constrain= function(){}
  10818. // this.position= function(){}
  10819.  
  10820. // this.autoFitOnAttach = true;
  10821. // this.expandSizingTargetForScrollbars = true;
  10822. // this.allowOutsideScroll = true;
  10823. }
  10824. }
  10825. if (CHAT_MENU_SCROLL_UNLOCKING && this.opened) {
  10826. let newValue = null;
  10827. const positionTarget = this.positionTarget;
  10828. if (positionTarget && positionTarget.classList.contains('yt-live-chat-text-message-renderer')) {
  10829. if (this._modifiedMenuPropOn062__ === false) {
  10830. newValue = true;
  10831. }
  10832. } else if (this._modifiedMenuPropOn062__ === true) {
  10833. newValue = false;
  10834. }
  10835. if (newValue !== null) {
  10836. const beforeAllowOutsideScroll = this.allowOutsideScroll;
  10837. this._modifiedMenuPropOn062__ = newValue;
  10838. const afterAllowOutsideScroll = this.allowOutsideScroll;
  10839. if (beforeAllowOutsideScroll !== afterAllowOutsideScroll) this.__AllowOutsideScrollPD__.set.call(this, afterAllowOutsideScroll);
  10840. }
  10841. }
  10842.  
  10843. if (this.opened) {
  10844.  
  10845. Promise.resolve().then(() => {
  10846.  
  10847. this._prepareRenderOpened();
  10848. }).then(() => {
  10849. this._manager.addOverlay(this);
  10850. if (this._manager._overlays.length === 1) {
  10851. lastOpen = this;
  10852. lastClose = null;
  10853. } else {
  10854. return 1;
  10855. }
  10856. // if (cid) {
  10857. // clearTimeout(cid);
  10858. // cid = -1;
  10859. // this.__moChanged__();
  10860. // cid = 0;
  10861. // } else {
  10862. // cid = -1;
  10863. // this.__moChanged__();
  10864. // cid = 0;
  10865. // }
  10866. // cid = cid > 0 ? clearTimeout(cid) : 0;
  10867. // console.log(580, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  10868. // cid = cid || setTimeout(__moChanged__, delay1);
  10869. cid = cid || requestAnimationFrame(__moChanged__);
  10870. }).then((r) => {
  10871.  
  10872. if (r) this.__mtChanged__(1);
  10873. }).catch(console.warn);
  10874.  
  10875. } else {
  10876. Promise.resolve().then(() => {
  10877. this._manager.removeOverlay(this);
  10878. if (this._manager._overlays.length === 0) {
  10879. lastClose = this;
  10880. lastOpen = null;
  10881. } else {
  10882. return 1;
  10883. }
  10884. // cid = cid > 0 ? clearTimeout(cid) : 0;
  10885. // console.log(581, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  10886. // cid = cid || setTimeout(__moChanged__, delay1);
  10887. cid = cid || requestAnimationFrame(__moChanged__);
  10888. }).then((r) => {
  10889. if (r) this.__mtChanged__(0);
  10890. }).catch(console.warn);
  10891.  
  10892. }
  10893.  
  10894. }
  10895. console.log("BOOST_MENU_OPENCHANGED_RENDERING - OK");
  10896.  
  10897. } else {
  10898.  
  10899. assertor(() => fnIntegrity(cProto.__openedChanged, '0.46.20'));
  10900. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANC_1 - NG");
  10901.  
  10902. }
  10903.  
  10904.  
  10905. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK && typeof cProto.__openedChanged === 'function' && !cProto.__openedChanged82) {
  10906.  
  10907. cProto.__openedChanged82 = cProto.__openedChanged;
  10908.  
  10909.  
  10910. cProto.__openedChanged = function () {
  10911. const positionTarget = this.positionTarget;
  10912. currentMenuPivotWR = positionTarget ? mWeakRef(positionTarget) : null;
  10913. return this.__openedChanged82.apply(this, arguments);
  10914. }
  10915. }
  10916.  
  10917.  
  10918. })();
  10919.  
  10920. console.log("[End]");
  10921.  
  10922. console.groupEnd();
  10923.  
  10924. }).catch(console.warn);
  10925.  
  10926.  
  10927.  
  10928. FIX_ToggleRenderPolymerControllerExtractionBug && customElements.whenDefined('yt-live-chat-toggle-renderer').then(() => {
  10929.  
  10930. mightFirstCheckOnYtInit();
  10931. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-toggle-renderer hacks");
  10932. console.log("[Begin]");
  10933. (() => {
  10934.  
  10935. const tag = "yt-live-chat-toggle-renderer";
  10936. const dummy = document.createElement(tag);
  10937.  
  10938. const cProto = getProto(dummy);
  10939. if (!cProto || !cProto.attached) {
  10940. console.warn(`proto.attached for ${tag} is unavailable.`);
  10941. return;
  10942. }
  10943.  
  10944. })();
  10945.  
  10946. console.log("[End]");
  10947. console.groupEnd();
  10948.  
  10949. });
  10950.  
  10951.  
  10952.  
  10953.  
  10954. /*
  10955.  
  10956.  
  10957.  
  10958.  
  10959.  
  10960. var FU = function() {
  10961. var a = this;
  10962. this.nextHandle_ = 1;
  10963. this.clients_ = {};
  10964. this.JSC$10323_callbacks_ = {};
  10965. this.unsubscribeAsyncHandles_ = {};
  10966. this.subscribe = vl(function(b, c, d) {
  10967. var e = Geb(b);
  10968. if (e in a.clients_)
  10969. e in a.unsubscribeAsyncHandles_ && Jq.cancel(a.unsubscribeAsyncHandles_[e]);
  10970. else {
  10971. a: {
  10972. var h = Geb(b), l;
  10973. for (l in a.unsubscribeAsyncHandles_) {
  10974. var m = a.clients_[l];
  10975. if (m instanceof KO) {
  10976. delete a.clients_[l];
  10977. delete a.JSC$10323_callbacks_[l];
  10978. Jq.cancel(a.unsubscribeAsyncHandles_[l]);
  10979. delete a.unsubscribeAsyncHandles_[l];
  10980. i6a(m);
  10981. m.objectId_ = new FQa(h);
  10982. m.register();
  10983. d = m;
  10984. break a
  10985. }
  10986. }
  10987. d.objectSource = b.invalidationId.objectSource;
  10988. d.objectId = h;
  10989. if (b = b.webAuthConfigurationData)
  10990. b.multiUserSessionIndex && (d.sessionIndex = parseInt(b.multiUserSessionIndex, 10)),
  10991. b.pageId && (d.pageId = b.pageId);
  10992. d = new KO(d,a.handleInvalidationData_.bind(a));
  10993. d.register()
  10994. }
  10995. a.clients_[e] = d;
  10996. a.JSC$10323_callbacks_[e] = {}
  10997. }
  10998. d = a.nextHandle_++;
  10999. a.JSC$10323_callbacks_[e][d] = c;
  11000. return d
  11001. })
  11002. };
  11003. FU.prototype.unsubscribe = function(a, b) {
  11004. var c = Geb(a);
  11005. if (c in this.JSC$10323_callbacks_ && (delete this.JSC$10323_callbacks_[c][b],
  11006. !this.JSC$10323_callbacks_[c].length)) {
  11007. var d = this.clients_[c];
  11008. b = Jq.run(function() {
  11009. ei(d);
  11010. delete this.clients_[c];
  11011. delete this.unsubscribeAsyncHandles_[c]
  11012. }
  11013. .bind(this));
  11014. this.unsubscribeAsyncHandles_[c] = b
  11015. }
  11016. }
  11017. ;
  11018.  
  11019.  
  11020. */
  11021.  
  11022.  
  11023. const onManagerFound = (dummyManager) => {
  11024. if (!dummyManager || typeof dummyManager !== 'object') return;
  11025.  
  11026. const mgrProto = dummyManager.constructor.prototype;
  11027.  
  11028. let keyCallbackStore = '';
  11029. for (const [key, v] of Object.entries(dummyManager)) {
  11030. if (key.includes('_callbacks_')) keyCallbackStore = key;
  11031. }
  11032.  
  11033. if (!keyCallbackStore || typeof mgrProto.unsubscribe !== 'function' || mgrProto.unsubscribe.length !== 2) return;
  11034.  
  11035. if (mgrProto.unsubscribe16) return;
  11036.  
  11037. mgrProto.unsubscribe16 = mgrProto.unsubscribe;
  11038.  
  11039. groupCollapsed("YouTube Super Fast Chat", " | *live-chat-manager* hacks");
  11040. console.log("[Begin]");
  11041.  
  11042. const isEmptyObject = ((obj) => (firstKey(obj) === null));
  11043.  
  11044. const idMapper = new Map();
  11045.  
  11046. const convertId = function (objectId) {
  11047. if (!objectId || typeof objectId !== 'string') return null;
  11048.  
  11049. let result = idMapper.get(objectId)
  11050. if (result) return result;
  11051. result = atob(objectId.replace(/-/g, "+").replace(/_/g, "/"));
  11052. idMapper.set(objectId, result)
  11053. return result;
  11054. }
  11055.  
  11056.  
  11057. const rafHandleHolder = [];
  11058.  
  11059. let pzw = 0;
  11060. let lza = 0;
  11061. const rafHandlerFn = () => {
  11062. pzw = 0;
  11063. if (rafHandleHolder.length === 1) {
  11064. const f = rafHandleHolder[0];
  11065. rafHandleHolder.length = 0;
  11066. f();
  11067. } else if (rafHandleHolder.length > 1) {
  11068. const arr = rafHandleHolder.slice(0);
  11069. rafHandleHolder.length = 0;
  11070. for (const fn of arr) fn();
  11071. }
  11072. };
  11073.  
  11074.  
  11075. if (CHANGE_MANAGER_UNSUBSCRIBE) {
  11076.  
  11077. const checkIntegrityForSubscribe = (mgr) => {
  11078. if (mgr
  11079. && typeof mgr.unsubscribe16 === 'function' && mgr.unsubscribe16.length === 2
  11080. && typeof mgr.subscribe18 === 'function' && (mgr.subscribe18.length === 0 || mgr.subscribe18.length === 3)) {
  11081.  
  11082. const ns = new Set(Object.keys(mgr));
  11083. const ms = new Set(Object.keys(mgr.constructor.prototype));
  11084.  
  11085. if (ns.size >= 6 && ms.size >= 4) {
  11086. // including 'subscribe18'
  11087. // 'unsubscribe16', 'subscribe19'
  11088.  
  11089. let r = 0;
  11090. for (const k of ['nextHandle_', 'clients_', keyCallbackStore, 'unsubscribeAsyncHandles_', 'subscribe', 'subscribe18']) {
  11091. r += ns.has(k) ? 1 : 0;
  11092. }
  11093. for (const k of ['unsubscribe', 'handleInvalidationData_', 'unsubscribe16', 'subscribe19']) {
  11094. r += ms.has(k) ? 1 : 0;
  11095. }
  11096. if (r === 10) {
  11097. const isObject = (c) => (c || 0).constructor === Object;
  11098.  
  11099. if (isObject(mgr['clients_']) && isObject(mgr[keyCallbackStore]) && isObject(mgr['unsubscribeAsyncHandles_'])) {
  11100.  
  11101. return true;
  11102. }
  11103.  
  11104.  
  11105. }
  11106.  
  11107. }
  11108.  
  11109.  
  11110. }
  11111. return false;
  11112. }
  11113.  
  11114. mgrProto.subscribe19 = function (o, f, opts) {
  11115.  
  11116. const ct_clients_ = this.clients_ || 0;
  11117. const ct_handles_ = this.unsubscribeAsyncHandles_ || 0;
  11118.  
  11119. if (this.__doCustomSubscribe__ !== true || !ct_clients_ || !ct_handles_) return this.subscribe18.apply(this, arguments);
  11120.  
  11121. let objectId = ((o || 0).invalidationId || 0).objectId;
  11122. if (!objectId) return this.subscribe18.apply(this, arguments);
  11123. objectId = convertId(objectId);
  11124.  
  11125. // console.log('subscribe', objectId, ct_clients_[objectId], arguments);
  11126.  
  11127. if (ct_clients_[objectId]) {
  11128. if (ct_handles_[objectId] < 0) delete ct_handles_[objectId];
  11129. }
  11130.  
  11131. return this.subscribe18.apply(this, arguments);
  11132. }
  11133.  
  11134. mgrProto.unsubscribe = function (o, d) {
  11135. if (!this.subscribe18 && typeof this.subscribe === 'function') {
  11136. this.subscribe18 = this.subscribe;
  11137. this.subscribe = this.subscribe19;
  11138. this.__doCustomSubscribe__ = checkIntegrityForSubscribe(this);
  11139. }
  11140. const ct_clients_ = this.clients_;
  11141. const ct_handles_ = this.unsubscribeAsyncHandles_;
  11142. if (this.__doCustomSubscribe__ !== true || !ct_clients_ || !ct_handles_) return this.unsubscribe16.apply(this, arguments);
  11143.  
  11144. let objectId = ((o || 0).invalidationId || 0).objectId;
  11145. if (!objectId) return this.unsubscribe16.apply(this, arguments);
  11146.  
  11147. objectId = convertId(objectId);
  11148.  
  11149.  
  11150. // console.log('unsubscribe', objectId, ct_clients_[objectId], arguments);
  11151.  
  11152. const callbacks = this[keyCallbackStore] || 0;
  11153. const callbackObj = callbacks[objectId] || 0;
  11154.  
  11155.  
  11156. if (callbackObj && (delete callbackObj[d], isEmptyObject(callbackObj))) {
  11157. const w = ct_clients_[objectId];
  11158. --lza;
  11159. if (lza < -1e9) lza = -1;
  11160. const qta = lza;
  11161. rafHandleHolder.push(() => {
  11162. if (qta === ct_handles_[objectId]) {
  11163. const o = {
  11164. callbacks, callbackObj,
  11165. client: ct_clients_[objectId],
  11166. handle: ct_handles_[objectId]
  11167. };
  11168. let p = 0;
  11169. try {
  11170. if (ct_clients_[objectId] === w) {
  11171. w && "function" === typeof w.dispose && w.dispose();
  11172. delete ct_clients_[objectId];
  11173. delete ct_handles_[objectId];
  11174. p = 1;
  11175. } else {
  11176. // w && "function" === typeof w.dispose && w.dispose();
  11177. // delete ct_clients_[objectId];
  11178. // delete ct_handles_[objectId];
  11179. p = 2;
  11180. }
  11181. } catch (e) {
  11182. console.warn(e);
  11183. }
  11184. console.log(`unsubscribed: ${p}`, this, o);
  11185. }
  11186. });
  11187. ct_handles_[objectId] = qta;
  11188. if (pzw === 0) {
  11189. pzw = requestAnimationFrame(rafHandlerFn);
  11190. }
  11191. }
  11192. }
  11193.  
  11194.  
  11195. console.log("CHANGE_MANAGER_UNSUBSCRIBE - OK")
  11196.  
  11197. } else {
  11198.  
  11199. console.log("CHANGE_MANAGER_UNSUBSCRIBE - NG")
  11200. }
  11201.  
  11202. console.log("[End]");
  11203.  
  11204. console.groupEnd();
  11205.  
  11206. }
  11207.  
  11208.  
  11209.  
  11210. /*
  11211.  
  11212.  
  11213. a.prototype.async = function(e, h) {
  11214. return 0 < h ? Iq.run(e.bind(this), h) : ~Kq.run(e.bind(this))
  11215. }
  11216. ;
  11217. a.prototype.cancelAsync = function(e) {
  11218. 0 > e ? Kq.cancel(~e) : Iq.cancel(e)
  11219. }
  11220.  
  11221. */
  11222.  
  11223.  
  11224. (FASTER_ICON_RENDERING && Promise.all(
  11225. [
  11226. customElements.whenDefined("yt-icon-shape"),
  11227. customElements.whenDefined("yt-icon")
  11228. // document.createElement('icon-shape'),
  11229. ]
  11230. )).then(() => {
  11231. let cq = 0;
  11232. let dummys = [document.createElement('yt-icon-shape'), document.createElement('yt-icon')]
  11233. for (const dummy of dummys) {
  11234. let cProto = getProto(dummy);
  11235. if (cProto && typeof cProto.shouldRenderIconShape === 'function' && !cProto.shouldRenderIconShape571 && cProto.shouldRenderIconShape.length === 1) {
  11236. assertor(() => fnIntegrity(cProto.shouldRenderIconShape, '1.70.38'));
  11237. cq++;
  11238. cProto.shouldRenderIconShape571 = cProto.shouldRenderIconShape;
  11239. cProto.shouldRenderIconShape = function (a) {
  11240. if (this.isAnimatedIcon) return this.shouldRenderIconShape571(a);
  11241. if (!this.iconType || !this.iconShapeData) return this.shouldRenderIconShape571(a);
  11242. if (!this.iconName) return this.shouldRenderIconShape571(a);
  11243. return false;
  11244. // console.log(1051, this.iconType)
  11245. // console.log(1052, this.iconShapeData)
  11246. // console.log(1053, this.isAnimatedIcon)
  11247. }
  11248. }
  11249. // if(cProto && cProto.switchTemplateAtRegistration){
  11250. // cProto.switchTemplateAtRegistration = false;
  11251. // }
  11252. }
  11253. if (cq === 1) {
  11254. console.log("modified shouldRenderIconShape - Y")
  11255. } else {
  11256. console.log("modified shouldRenderIconShape - N", cq)
  11257. }
  11258. });
  11259.  
  11260. customElements.whenDefined("yt-invalidation-continuation").then(() => {
  11261.  
  11262. let __dummyManager__ = null;
  11263.  
  11264. mightFirstCheckOnYtInit();
  11265. groupCollapsed("YouTube Super Fast Chat", " | yt-invalidation-continuation hacks");
  11266. console.log("[Begin]");
  11267. (() => {
  11268.  
  11269. const tag = "yt-invalidation-continuation"
  11270. const dummy = document.createElement(tag);
  11271.  
  11272. const cProto = getProto(dummy);
  11273. if (!cProto || !cProto.attached) {
  11274. console.warn(`proto.attached for ${tag} is unavailable.`);
  11275. return;
  11276. }
  11277.  
  11278. const dummyManager = insp(dummy).manager_ || 0;
  11279. __dummyManager__ = dummyManager;
  11280.  
  11281. if (CHANGE_DATA_FLUSH_ASYNC && typeof cProto.async === 'function' && !cProto.async71 && cProto.async.length === 2 && typeof cProto.cancelAsync === 'function' && !cProto.cancelAsync71 && cProto.cancelAsync.length === 1) {
  11282.  
  11283.  
  11284. const rafHub = new RAFHub();
  11285.  
  11286. rafHub.keepRAF = true;
  11287. cProto.async71 = cProto.async;
  11288. cProto.cancelAsync71 = cProto.cancelAsync;
  11289.  
  11290. // mostly for subscription timeoutMs 10000ms
  11291. let mcw = 1; // 1, 3, 5, ...
  11292. let arr = new Map();
  11293.  
  11294. let __asyncInited__ = 0;
  11295. let __timeoutStartId__ = null;
  11296. const __asyncInit__ = () => {
  11297.  
  11298. if (__asyncInited__) return;
  11299. __asyncInited__ = 1;
  11300.  
  11301. __timeoutStartId__ = setTimeout(() => { });
  11302. mcw = __timeoutStartId__ * 2 + 1;
  11303.  
  11304. setInterval(() => {
  11305.  
  11306. if (!arr.length) return;
  11307.  
  11308. const p = Date.now();
  11309. let deleteKeys = [];
  11310. arr.forEach((entry, key) => {
  11311.  
  11312.  
  11313. if (entry.cid === -1) {
  11314. entry.cid = -2;
  11315. } else if (entry.cid === -2) {
  11316.  
  11317. let offset = p - entry.add
  11318. if (offset < 0) offset = 0;
  11319. let delay2 = entry.delay - offset;
  11320. if (delay2 < 0) delay2 = 0;
  11321. entry.cid = setTimeout(entry.q(), delay2);
  11322. entry.q = null;
  11323.  
  11324. } else if (entry.add + entry.delay < p) {
  11325. deleteKeys.push(key);
  11326.  
  11327. }
  11328.  
  11329. })
  11330.  
  11331. for (const key of deleteKeys) arr.delete(key);
  11332.  
  11333. }, 2000)
  11334.  
  11335. }
  11336.  
  11337.  
  11338. cProto.async = function (e, h) {
  11339.  
  11340. if (!(0 < h)) return this.async71(e, h); // unknown timing Fn
  11341.  
  11342. if (h < 8000) return this.async71(e, h) * 2; // native setTimeout
  11343.  
  11344. if (typeof h !== 'number') return this.async71(e, h); // exceptional case
  11345.  
  11346.  
  11347. if (!this.__asyncInited__) {
  11348. this.__asyncInited__ = 1;
  11349. __asyncInit__();
  11350. }
  11351. mcw += 2; // 2K+3, 2K+4, ...
  11352. if (mcw > 1e9) mcw = mcw % 1e4;
  11353. const cid = mcw;
  11354. const q = () => {
  11355. return () => {
  11356. console.log('async h > 8000');
  11357. e.call(this);
  11358. }
  11359. }
  11360. // setTimeout(q, delay)
  11361. arr.set(cid, {
  11362. cid: -1, // -1 -> -2 -> cid
  11363. add: Date.now(),
  11364. q,
  11365. delay: h
  11366. });
  11367. // console.log('cid-async', cid)
  11368. return cid;
  11369.  
  11370. }
  11371.  
  11372.  
  11373. cProto.cancelAsync = function (e) {
  11374.  
  11375. if (typeof e !== 'number') return this.cancelAsync71(e); // exceptional case
  11376.  
  11377. // console.log('cid-unasync', e)
  11378.  
  11379. if (0 > e) return this.cancelAsync71(e); // unknown timing fn
  11380.  
  11381. if (e > __timeoutStartId__ * 2) { // __timeoutStartId__ is recorded and min is 2K+1
  11382.  
  11383. if ((e % 2) === 0) return this.cancelAsync71(e / 2); // 2(K+1), 2(K+2), ...
  11384.  
  11385. if (!arr.has(e)) return; // duplciated cancel
  11386.  
  11387. const entry = arr.get(e);
  11388. if (entry.cid < 0) {
  11389. entry.cid = 0;
  11390. arr.delete(e);
  11391. } else {
  11392. clearTimeout(entry.cid); // cid >= 1
  11393. entry.cid = 0;
  11394. arr.delete(e);
  11395. }
  11396.  
  11397. } else {
  11398.  
  11399. return this.cancelAsync71(e);
  11400.  
  11401. }
  11402.  
  11403. }
  11404.  
  11405. console.log("CHANGE_DATA_FLUSH_ASYNC - OK");
  11406.  
  11407. } else if(!CHANGE_DATA_FLUSH_ASYNC){
  11408. console.log("CHANGE_DATA_FLUSH_ASYNC - N/A");
  11409. } else {
  11410. console.log("CHANGE_DATA_FLUSH_ASYNC - NG");
  11411.  
  11412. }
  11413.  
  11414. })();
  11415.  
  11416. console.log("[End]");
  11417.  
  11418. console.groupEnd();
  11419.  
  11420.  
  11421.  
  11422. onManagerFound(__dummyManager__);
  11423.  
  11424. }).catch(console.warn);
  11425.  
  11426.  
  11427. if (INTERACTIVITY_BACKGROUND_ANIMATION >= 1) {
  11428.  
  11429. customElements.whenDefined("yt-live-interactivity-component-background").then(() => {
  11430.  
  11431. mightFirstCheckOnYtInit();
  11432. groupCollapsed("YouTube Super Fast Chat", " | yt-live-interactivity-component-background hacks");
  11433. console.log("[Begin]");
  11434. (() => {
  11435.  
  11436. const tag = "yt-live-interactivity-component-background"
  11437. const dummy = document.createElement(tag);
  11438.  
  11439. const cProto = getProto(dummy);
  11440. if (!cProto || !cProto.attached) {
  11441. console.warn(`proto.attached for ${tag} is unavailable.`);
  11442. return;
  11443. }
  11444.  
  11445. cProto.__toStopAfterRun__ = function (hostElement) {
  11446. let mo = new MutationObserver(() => {
  11447. mo.disconnect();
  11448. mo.takeRecords();
  11449. mo = null;
  11450. this.lottieAnimation && this.lottieAnimation.stop(); // primary
  11451. foregroundPromiseFn().then(() => { // if the lottieAnimation is started with rAf triggering
  11452. this.lottieAnimation && this.lottieAnimation.stop(); // fallback
  11453. });
  11454. });
  11455. mo.observe(hostElement, { subtree: true, childList: true });
  11456. }
  11457.  
  11458. if (INTERACTIVITY_BACKGROUND_ANIMATION >= 1 && typeof cProto.maybeLoadAnimationBackground === 'function' && !cProto.maybeLoadAnimationBackground77 && cProto.maybeLoadAnimationBackground.length === 0) {
  11459.  
  11460. cProto.maybeLoadAnimationBackground77 = cProto.maybeLoadAnimationBackground;
  11461. cProto.maybeLoadAnimationBackground = function () {
  11462. let toRun = true;
  11463. let stopAfterRun = false;
  11464. if (!this.__bypassDisableAnimationBackground__) {
  11465. let doFix = false;
  11466. if (INTERACTIVITY_BACKGROUND_ANIMATION === 1) {
  11467. if (!this.lottieAnimation) {
  11468. doFix = true;
  11469. }
  11470. } else if (INTERACTIVITY_BACKGROUND_ANIMATION === 2) {
  11471. doFix = true;
  11472. }
  11473. if (doFix) {
  11474. if (this.useAnimationBackground === true) {
  11475. console.log('DISABLE_INTERACTIVITY_BACKGROUND_ANIMATION', this.lottieAnimation);
  11476. }
  11477. toRun = true;
  11478. stopAfterRun = true;
  11479. }
  11480. }
  11481. if (toRun) {
  11482. if (stopAfterRun && (this.hostElement instanceof HTMLElement)) {
  11483. this.__toStopAfterRun__(this.hostElement); // primary
  11484. }
  11485. const r = this.maybeLoadAnimationBackground77.apply(this, arguments);
  11486. if (stopAfterRun && this.lottieAnimation) {
  11487. this.lottieAnimation.stop(); // fallback if no mutation
  11488. }
  11489. return r;
  11490. }
  11491. }
  11492.  
  11493. console.log(`INTERACTIVITY_BACKGROUND_ANIMATION(${INTERACTIVITY_BACKGROUND_ANIMATION}) - OK`);
  11494.  
  11495. } else {
  11496. console.log(`INTERACTIVITY_BACKGROUND_ANIMATION(${INTERACTIVITY_BACKGROUND_ANIMATION}) - NG`);
  11497.  
  11498. }
  11499.  
  11500. })();
  11501.  
  11502. console.log("[End]");
  11503.  
  11504. console.groupEnd();
  11505.  
  11506.  
  11507. }).catch(console.warn);
  11508.  
  11509. }
  11510.  
  11511.  
  11512. if (DELAY_FOCUSEDCHANGED) {
  11513.  
  11514. customElements.whenDefined("yt-live-chat-text-input-field-renderer").then(() => {
  11515.  
  11516.  
  11517. mightFirstCheckOnYtInit();
  11518. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-text-input-field-renderer hacks");
  11519. console.log("[Begin]");
  11520. (() => {
  11521.  
  11522. const tag = "yt-live-chat-text-input-field-renderer"
  11523. const dummy = document.createElement(tag);
  11524.  
  11525. const cProto = getProto(dummy);
  11526. if (!cProto || !cProto.attached) {
  11527. console.warn(`proto.attached for ${tag} is unavailable.`);
  11528. return;
  11529. }
  11530.  
  11531. if (DELAY_FOCUSEDCHANGED && typeof cProto.focusedChanged === 'function' && cProto.focusedChanged.length === 0 && !cProto.focusedChanged372) {
  11532. cProto.focusedChanged372 = cProto.focusedChanged;
  11533. cProto.focusedChanged = function () {
  11534. Promise.resolve(this).then((cnt) => {
  11535. if (cnt.isAttached === true) cnt.focusedChanged372();
  11536. });
  11537. }
  11538. }
  11539.  
  11540. })();
  11541.  
  11542. console.log("[End]");
  11543.  
  11544. console.groupEnd();
  11545.  
  11546. });
  11547.  
  11548. }
  11549.  
  11550.  
  11551. }
  11552.  
  11553.  
  11554.  
  11555.  
  11556. promiseForCustomYtElementsReady.then(onRegistryReadyForDOMOperations);
  11557.  
  11558. const fixJsonParse = () => {
  11559.  
  11560. let p1 = window.onerror;
  11561.  
  11562. try {
  11563. JSON.parse("{}");
  11564. } catch (e) {
  11565. console.warn(e);
  11566. }
  11567.  
  11568. let p2 = window.onerror;
  11569.  
  11570. if (p1 !== p2) {
  11571.  
  11572.  
  11573. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | JS Engine Issue Found"}`,
  11574. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  11575. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  11576. );
  11577.  
  11578. console.warn("\nJSON.parse is hacked (e.g. Brave's script injection) which causes window.onerror changes on every JSON.parse call.\nPlease install https://greasyfork.org/scripts/473972-youtube-js-engine-tamer to fix the issue.\n");
  11579.  
  11580. console.groupEnd();
  11581.  
  11582. }
  11583.  
  11584. }
  11585.  
  11586. if (CHECK_JSONPRUNE) {
  11587. promiseForCustomYtElementsReady.then(fixJsonParse);
  11588. }
  11589.  
  11590. if(END_ANIMATING_TICKERS){
  11591.  
  11592. let lastElmW = null;
  11593.  
  11594. document.addEventListener('transitionstart', (evt) => {
  11595.  
  11596. if (evt.propertyName === 'width' && !evt.pseudoElement) {
  11597.  
  11598. const elm = evt.target;
  11599. let act = false;
  11600. /*
  11601. switch(elm.nodeName.toLowerCase()){
  11602.  
  11603. case 'yt-live-chat-ticker-creator-goal-view-model':
  11604. case 'yt-live-chat-ticker-paid-message-item-renderer':
  11605. case 'yt-live-chat-ticker-paid-sticker-item-renderer':
  11606.  
  11607. case 'yt-live-chat-ticker-sponsor-item-renderer':
  11608. act =true;
  11609. break;
  11610.  
  11611.  
  11612. }
  11613. */
  11614. if (elm instanceof HTMLElement && ((elm || 0).parentElement || 0).id === 'ticker-items' && elm.classList.contains('yt-live-chat-ticker-renderer')) {
  11615. act = true;
  11616. }
  11617. if (act) {
  11618. const lastElm = kRef(lastElmW);
  11619. if (elm !== lastElm) {
  11620.  
  11621. if (lastElm instanceof HTMLElement) {
  11622. lastElm.classList.add('ticker-no-transition-time');
  11623. }
  11624. lastElmW = mWeakRef(elm);
  11625.  
  11626. }
  11627.  
  11628.  
  11629. }
  11630. }
  11631.  
  11632. }, true);
  11633.  
  11634.  
  11635.  
  11636. document.addEventListener('transitionend', (evt) => {
  11637.  
  11638. if (evt.propertyName && !evt.pseudoElement) {
  11639.  
  11640. const elm = evt.target;
  11641. const f = transitionEndAfterFnSimple.get(elm);
  11642. if (f) {
  11643. transitionEndAfterFnSimple.delete(elm);
  11644. f.resolve(evt.propertyName);
  11645. }
  11646. }
  11647.  
  11648. }, true);
  11649.  
  11650. /*
  11651.  
  11652. document.addEventListener('transitionend', (evt) => {
  11653.  
  11654. if (evt.propertyName === 'width' && !evt.pseudoElement) {
  11655.  
  11656. const elm = evt.target;
  11657. let act = false;
  11658. /-*
  11659. switch(elm.nodeName.toLowerCase()){
  11660.  
  11661. case 'yt-live-chat-ticker-creator-goal-view-model':
  11662. case 'yt-live-chat-ticker-paid-message-item-renderer':
  11663. case 'yt-live-chat-ticker-paid-sticker-item-renderer':
  11664.  
  11665. case 'yt-live-chat-ticker-sponsor-item-renderer':
  11666. act =true;
  11667. break;
  11668.  
  11669.  
  11670. }
  11671. *-/
  11672. if (elm instanceof HTMLElement && ((elm || 0).parentElement || 0).id === 'ticker-items' && elm.classList.contains('yt-live-chat-ticker-renderer')) {
  11673. act = true;
  11674. }
  11675. if (act) {
  11676. elm.style.transitionDuration = '0s';
  11677.  
  11678. }
  11679. }
  11680.  
  11681. }, true);
  11682.  
  11683.  
  11684. document.addEventListener('transitioncancel', (evt) => {
  11685.  
  11686. if (evt.propertyName === 'width' && !evt.pseudoElement) {
  11687.  
  11688. const elm = evt.target;
  11689. let act = false;
  11690. /-*
  11691. switch(elm.nodeName.toLowerCase()){
  11692.  
  11693. case 'yt-live-chat-ticker-creator-goal-view-model':
  11694. case 'yt-live-chat-ticker-paid-message-item-renderer':
  11695. case 'yt-live-chat-ticker-paid-sticker-item-renderer':
  11696.  
  11697. case 'yt-live-chat-ticker-sponsor-item-renderer':
  11698. act =true;
  11699. break;
  11700.  
  11701.  
  11702. }
  11703. *-/
  11704. if (elm instanceof HTMLElement && ((elm || 0).parentElement || 0).id === 'ticker-items' && elm.classList.contains('yt-live-chat-ticker-renderer')) {
  11705. act = true;
  11706. }
  11707. if (act) {
  11708. elm.style.transitionDuration = '0s';
  11709.  
  11710. }
  11711. }
  11712.  
  11713. }, true);
  11714.  
  11715. */
  11716.  
  11717.  
  11718. }
  11719.  
  11720. });
  11721.  
  11722.  
  11723.  
  11724. })({ IntersectionObserver });