YouTube 超快聊天

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

当前为 2024-06-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Super Fast Chat
  3. // @version 0.64.0
  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. const FIX_MEMORY_LEAKAGE_TICKER_ACTIONMAP = true; // To fix Memory Leakage in yt-live-chat-ticker-...-item-renderer
  44.  
  45. 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
  46. 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.
  47. 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
  48.  
  49. const ENABLE_NO_SMOOTH_TRANSFORM = true; // Depends on whether you want the animation effect for new chat messages
  50. const USE_OPTIMIZED_ON_SCROLL_ITEMS = true; // TRUE for the majority
  51. const ENABLE_OVERFLOW_ANCHOR_PREFERRED = true; // Enable `overflow-anchor: auto` to lock the scroll list at the bottom for no smooth transform.
  52.  
  53. const FIX_SHOW_MORE_BUTTON_LOCATION = true; // When there are voting options (bottom panel), move the "show more" button to the top.
  54. const FIX_INPUT_PANEL_OVERFLOW_ISSUE = true; // When the super chat button is flicking with color, the scrollbar might come out.
  55. const FIX_INPUT_PANEL_BORDER_ISSUE = true; // No border should be allowed if there is an empty input panel.
  56. const SET_CONTAIN_FOR_CHATROOM = true; // Rendering hacks (`contain`) for chatroom elements. [ General ]
  57.  
  58. const FORCE_CONTENT_VISIBILITY_UNSET = true; // Content-visibility should be always VISIBLE for high performance and great rendering.
  59. const FORCE_WILL_CHANGE_UNSET = true; // Will-change should be always UNSET (auto) for high performance and low energy impact.
  60.  
  61. // Replace requestAnimationFrame timers with custom implementation
  62. const ENABLE_RAF_HACK_TICKERS = true; // When there is a ticker
  63. const ENABLE_RAF_HACK_DOCKED_MESSAGE = true; // To be confirmed
  64. const ENABLE_RAF_HACK_INPUT_RENDERER = true; // To be confirmed
  65. const ENABLE_RAF_HACK_EMOJI_PICKER = true; // When changing the page of the emoji picker
  66.  
  67. // Force rendering all the character subsets of the designated font(s) before messages come (Pre-Rendering of Text)
  68. const ENABLE_FONT_PRE_RENDERING_PREFERRED = 1 | 2 | 4 | 8 | 16;
  69.  
  70. // Backdrop `filter: blur(4px)` inside the iframe can extend to the whole page, causing a negative visual impact on the video you are watching.
  71. const NO_BACKDROP_FILTER_WHEN_MENU_SHOWN = true;
  72.  
  73. // Data Manipulation for Participants (Participant List)
  74. // << if DO_PARTICIPANT_LIST_HACKS >>
  75. const DO_PARTICIPANT_LIST_HACKS = true; // TRUE for the majority
  76. const SHOW_PARTICIPANT_CHANGES_IN_CONSOLE = false; // Just too annoying to show them all in popular chat
  77. const CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = true; // Only consider changes in renderable content (not concerned with the last chat message of the participants)
  78. const PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED = true;
  79. // << end >>
  80.  
  81. // show more button
  82. const ENABLE_SHOW_MORE_BLINKER = true; // BLINK WHEN NEW MESSAGES COME
  83.  
  84. // faster stampDomArray_ for participants list creation
  85. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL = 1; // 0 - OFF; 1 - ON; 2 - ON(PARTICIPANTS_LIST ONLY)
  86. const USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET = false;
  87.  
  88. // reuse yt components
  89. const ENABLE_FLAGS_REUSE_COMPONENTS = true;
  90.  
  91. // ShadyDom Free is buggy
  92. const DISABLE_FLAGS_SHADYDOM_FREE = true;
  93.  
  94. // images <Group#I01>
  95. const AUTHOR_PHOTO_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  96. const EMOJI_IMAGE_SINGLE_THUMBNAIL = 1; // 0 - disable; 1- smallest; 2- largest
  97. const LEAST_IMAGE_SIZE = 48; // minium size = 48px
  98.  
  99. const DO_LINK_PREFETCH = true; // DO NOT CHANGE
  100. // << if DO_LINK_PREFETCH >>
  101. const ENABLE_BASE_PREFETCHING = true; // (SUB-)DOMAIN | dns-prefetch & preconnect
  102. const ENABLE_PRELOAD_THUMBNAIL = true; // subresource (prefetch) [LINK for Images]
  103. const SKIP_PRELOAD_EMOJI = true;
  104. const PREFETCH_LIMITED_SIZE_EMOJI = 512; // DO NOT CHANGE THIS
  105. const PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO = 68; // DO NOT CHANGE THIS
  106. // << end >>
  107.  
  108. const FIX_SETSRC_AND_THUMBNAILCHANGE_ = true; // Function Replacement for yt-img-shadow....
  109. const FIX_THUMBNAIL_DATACHANGED = true; // Function Replacement for yt-live-chat-author-badge-renderer..dataChanged
  110. // const REMOVE_PRELOADAVATARFORADDACTION = false; // Function Replacement for yt-live-chat-renderer..preloadAvatarForAddAction
  111.  
  112. const FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION = true; // important [depends on <Group#I01>]
  113. const FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT = true; // [depends on <Group#I01>]
  114.  
  115. const ATTEMPT_ANIMATED_TICKER_BACKGROUND = 'steps' // false OR '' for disabled, 'linear', 'steps' for easing-function
  116. // << if ATTEMPT_ANIMATED_TICKER_BACKGROUND >>
  117. // BROWSER SUPPORT: Chrome 75+, Edge 79+, Safari 13.1+, Firefox 63+, Opera 62+
  118. const TICKER_MAX_STEPS_LIMIT = 500; // NOT LESS THAN 5 STEPS!!
  119. // [limiting 500 max steps] is recommended for "confortable visual change"
  120. // min. step increment 0.2% => max steps: 500 => 800ms per each update
  121. // min. step increment 0.5% => max steps: 200 => 1000ms per each update
  122. // min. step increment 1.0% => max steps: 100 => 1000ms per each update
  123. // min. step increment 2.5% => max steps: 40 => 1000ms per each update
  124. // min. step increment 5.0% => max steps: 20 => 1250ms per each update
  125. const ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX = true; // for video playback's ticker issue. [ Playback Replay - Pause at Middle - Backwards Seeking ]
  126. // << end >>
  127.  
  128. const FIX_TOOLTIP_DISPLAY = true; // changed in 2024.05.02
  129. const USE_VANILLA_DEREF = true;
  130. const FIX_DROPDOWN_DERAF = true; // DONT CHANGE
  131.  
  132.  
  133. const CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true; // cache the menu data and used for the next reopen
  134. const ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU = false; // pause auto scroll faster when the context menu is about to show
  135. const ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU = true; // avoid multiple requests on the same time
  136.  
  137. const BOOST_MENU_OPENCHANGED_RENDERING = true;
  138. const FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK = true; // click again = close
  139. const NO_ITEM_TAP_FOR_NON_STATIONARY_TAP = true; // dont open the menu (e.g. text message) if cursor is moved or long press
  140. const TAP_ACTION_DURATION = 280; // exceeding 280ms would not consider as a tap action
  141. const PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN = true; // require CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true
  142. // const FIX_MENU_CAPTURE_SCROLL = true;
  143. const CHAT_MENU_REFIT_ALONG_SCROLLING = 0; // 0 for locking / default; 1 for unlocking only; 2 for unlocking and refit
  144.  
  145. const RAF_FIX_keepScrollClamped = true;
  146. const RAF_FIX_scrollIncrementally = 2; // 0: no action; 1: basic fix; 2: also fix scroll position
  147.  
  148. // << if BOOST_MENU_OPENCHANGED_RENDERING >>
  149. const FIX_MENU_POSITION_N_SIZING_ON_SHOWN = 1; // correct size and position when the menu dropdown opens
  150.  
  151. const CHECK_JSONPRUNE = true; // This is a bug in Brave
  152. // << end >>
  153.  
  154. // const LIVE_CHAT_FLUSH_ON_FOREGROUND_ONLY = false;
  155.  
  156. const CHANGE_DATA_FLUSH_ASYNC = false;
  157. // CHANGE_DATA_FLUSH_ASYNC is disabled due to bug report: https://greasyfork.org/scripts/469878-youtube-super-fast-chat/discussions/199479
  158. // to be further investigated
  159.  
  160. const CHANGE_MANAGER_UNSUBSCRIBE = true;
  161.  
  162. const INTERACTIVITY_BACKGROUND_ANIMATION = 1; // mostly for pinned message
  163. // 0 = default Yt animation background [= no fix];
  164. // 1 = disable default animation background [= keep special animation];
  165. // 2 = disable all animation backgrounds [= no animation backbround]
  166.  
  167. const CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED = true;
  168.  
  169. const MAX_TOOLTIP_NO_WRAP_WIDTH = '72vw'; // '' for disable; accept values like '60px', '25vw'
  170.  
  171. const AMEND_TICKER_handleLiveChatAction = false; // to fix ticker duplication and unresponsively fast ticker generation
  172. // AMEND_TICKER_handleLiveChatAction to be fixed (2024.05.21)
  173.  
  174. const AMEND_TICKER_handleLiveChatAction_v3 = true; // responsiveness fix (Major Feature)
  175.  
  176. const ATTEMPT_TICKER_ANIMATION_START_TIME_DETECTION = true;
  177. const ADJUST_TICKER_DURATION_ALIGN_RENDER_TIME = true;
  178. const FIX_BATCH_TICKER_ORDER = true;
  179.  
  180. const DISABLE_Translation_By_Google = true;
  181.  
  182. const FASTER_ICON_RENDERING = true;
  183.  
  184. const DELAY_FOCUSEDCHANGED = true;
  185.  
  186. const skipErrorForhandleAddChatItemAction_ = true; // currently depends on ENABLE_NO_SMOOTH_TRANSFORM
  187. const fixChildrenIssue801 = true; // if __children801__ is set [fix polymer controller method extration for `.set()`]
  188.  
  189. const SUPPRESS_refreshOffsetContainerHeight_ = true; // added in FEB 2024; true for default layout options
  190.  
  191. const NO_FILTER_DROPDOWN_BORDER = true; // added in 2024.03.02
  192.  
  193. const FIX_ANIMATION_TICKER_TEXT_POSITION = true; // CSS fix; experimental; added in 2024.04.07
  194. const FIX_AUTHOR_CHIP_BADGE_POSITION = true;
  195.  
  196. const FIX_ToggleRenderPolymerControllerExtractionBug = false; // to be reviewed
  197.  
  198. const REACTION_ANIMATION_PANEL_CSS_FIX = true;
  199.  
  200. // ========= EXPLANTION FOR 0.2% @ step timing [min. 0.2%] ===========
  201. /*
  202.  
  203. ### Time Approach
  204.  
  205. // all below values can make the time interval > 250ms
  206. // 250ms (practical value) refers to the minimum frequency for timeupdate in most browsers (typically, shorter timeupdate interval in modern browsers)
  207. if (totalDuration > 400000) stepInterval = 0.2; // 400000ms with 0.2% increment => 800ms
  208. else if (totalDuration > 200000) stepInterval = 0.5; // 200000ms with 0.5% increment => 1000ms
  209. else if (totalDuration > 100000) stepInterval = 1; // 100000ms with 1% increment => 1000ms
  210. else if (totalDuration > 50000) stepInterval = 2; // 50000ms with 2% increment => 1000ms
  211. else if (totalDuration > 25000) stepInterval = 5; // 25000ms with 5% increment => 1250ms
  212.  
  213. ### Pixel Check
  214. // Target Max Pixel Increment < 5px for Short Period Ticker (Rapid Background Change)
  215. // Assume total width <= 99px for short period ticker, like small donation & member welcome
  216. 99px * 5% = 4.95px < 5px [Condition Fulfilled]
  217.  
  218. ### Example - totalDuration = 280000
  219. totalDuration 280000
  220. stepInterval 0.5
  221. numOfSteps = Math.round(100 / stepInterval) = 200
  222. time interval = 280000 / 200 = 1400ms <acceptable>
  223.  
  224. ### Example - totalDuration = 18000
  225. totalDuration 18000
  226. stepInterval 5
  227. numOfSteps = Math.round(100 / stepInterval) = 20
  228. time interval = 18000 / 20 = 900ms <acceptable>
  229.  
  230. ### Example - totalDuration = 5000
  231. totalDuration 5000
  232. stepInterval 5
  233. numOfSteps = Math.round(100 / stepInterval) = 20
  234. time interval = 5000 / 20 = 250ms <threshold value>
  235.  
  236. ### Example - totalDuration = 3600
  237. totalDuration 3600
  238. stepInterval 5
  239. numOfSteps = Math.round(100 / stepInterval) = 20
  240. time interval = 3600 / 20 = 180ms <reasonable for 3600ms ticker>
  241.  
  242. */
  243.  
  244. // =======================================================================================================
  245.  
  246. // AUTOMAICALLY DETERMINED
  247. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL === 1;
  248. const ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST = ENABLE_FLAGS_MAINTAIN_STABLE_LIST_VAL >= 1;
  249. const CHAT_MENU_SCROLL_UNLOCKING = CHAT_MENU_REFIT_ALONG_SCROLLING >= 1;
  250. let runTickerClassName = 'run-ticker';
  251.  
  252. const dummyImgURL = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  253. /*
  254. WebP: data:image/webp;base64,UklGRjAB
  255. PNG: data:image/png;base64,iVBORw0KGg==
  256. JPEG: data:image/jpeg;base64,/9j/4AA=
  257. GIF: data:image/gif;base64,R0lGODlhAQABAIA=
  258. BMP: data:image/bmp;base64,Qk1oAAAA
  259. SVG: data:image/svg+xml;base64,PHN2Zy8+Cg==
  260.  
  261. WebP: data:image/webp;base64,AAAAAAA=
  262. PNG: data:image/png;base64,AAAAAAA=
  263. JPEG: data:image/jpeg;base64,AAAAAAA=
  264. GIF: data:image/gif;base64,AAAAAAA=
  265. BMP: data:image/bmp;base64,AAAAAAA=
  266.  
  267. data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  268.  
  269.  
  270. */
  271.  
  272. // image sizing code
  273. // (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null)
  274.  
  275.  
  276. // function KC(a, b, c, d) {
  277. // d = void 0 === d ? "width" : d;
  278. // if (!a || !a.length)
  279. // return null;
  280. // if (z("kevlar_tuner_should_always_use_device_pixel_ratio")) {
  281. // var e = window.devicePixelRatio;
  282. // 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"));
  283. // HC = e
  284. // } else
  285. // HC || (HC = window.devicePixelRatio);
  286. // e = HC;
  287. // z("kevlar_tuner_should_always_use_device_pixel_ratio") ? b *= e : 1 < e && (b *= e);
  288. // if (z("kevlar_tuner_min_thumbnail_quality"))
  289. // return a[0].url || null;
  290. // e = a.length;
  291. // if (z("kevlar_tuner_max_thumbnail_quality"))
  292. // return a[e - 1].url || null;
  293. // if (c)
  294. // for (var h = 0; h < e; h++)
  295. // if (0 <= a[h].url.indexOf(c))
  296. // return a[h].url || null;
  297. // for (c = 0; c < e; c++)
  298. // if (a[c][d] >= b)
  299. // return a[c].url || null;
  300. // for (b = e - 1; 0 < b; b--)
  301. // if (a[b][d])
  302. // return a[b].url || null;
  303. // return a[0].url || null
  304. // }
  305.  
  306. const { IntersectionObserver } = __CONTEXT__;
  307. let _x69;
  308. try {
  309. _x69 = document.createAttributeNS("http://www.w3.org/2000/svg", "nil").addEventListener;
  310. } catch (e) { }
  311. const pureAddEventListener = _x69;
  312. if (!pureAddEventListener) return console.warn("pureAddEventListener cannot be obtained.");
  313.  
  314. /** @type {globalThis.PromiseConstructor} */
  315. const Promise = (async () => { })().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  316.  
  317. // let jsonParseFix = null;
  318.  
  319. if (!IntersectionObserver) return console.warn("Your browser does not support IntersectionObserver.\nPlease upgrade to the latest version.");
  320. if (typeof WebAssembly !== 'object') return console.warn("Your browser is too old.\nPlease upgrade to the latest version."); // for passive and once
  321.  
  322. // necessity of cssText3_smooth_transform_position to be checked.
  323. const cssText3_smooth_transform_position = ENABLE_NO_SMOOTH_TRANSFORM ? `
  324.  
  325. #item-offset.style-scope.yt-live-chat-item-list-renderer > #items.style-scope.yt-live-chat-item-list-renderer {
  326. position: static !important;
  327. }
  328.  
  329. `: '';
  330.  
  331. // fallback if dummy style fn fails
  332. const cssText4_smooth_transform_forced_props = ENABLE_NO_SMOOTH_TRANSFORM ? `
  333.  
  334. /* optional */
  335. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  336. height: auto !important;
  337. min-height: unset !important;
  338. }
  339.  
  340. #items.style-scope.yt-live-chat-item-list-renderer {
  341. transform: translateY(0px) !important;
  342. }
  343.  
  344. /* optional */
  345.  
  346. `: '';
  347.  
  348. const cssText5 = SET_CONTAIN_FOR_CHATROOM ? `
  349.  
  350. /* ------------------------------------------------------------------------------------------------------------- */
  351.  
  352. 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 {
  353. contain: layout style;
  354. }
  355.  
  356. #items.style-scope.yt-live-chat-item-list-renderer {
  357. contain: layout paint style;
  358. }
  359.  
  360. #item-offset.style-scope.yt-live-chat-item-list-renderer {
  361. contain: style;
  362. }
  363.  
  364. #item-scroller.style-scope.yt-live-chat-item-list-renderer {
  365. contain: size style;
  366. }
  367.  
  368. #contents.style-scope.yt-live-chat-item-list-renderer, #chat.style-scope.yt-live-chat-renderer, img.style-scope.yt-img-shadow[width][height] {
  369. contain: size layout paint style;
  370. }
  371.  
  372. .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label], .style-scope.yt-live-chat-ticker-renderer[role="button"][aria-label] > #container {
  373. contain: layout paint style;
  374. }
  375.  
  376. 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 {
  377. contain: layout style;
  378. }
  379.  
  380. tp-yt-paper-tooltip[style*="inset"][role="tooltip"] {
  381. contain: layout paint style;
  382. }
  383.  
  384. /* ------------------------------------------------------------------------------------------------------------- */
  385.  
  386. ` : '';
  387.  
  388. const cssText6b_show_more_button = FIX_SHOW_MORE_BUTTON_LOCATION ? `
  389.  
  390. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer{
  391. top: 4px;
  392. transition-property: top;
  393. bottom: unset;
  394. }
  395.  
  396. yt-live-chat-renderer[has-action-panel-renderer] #show-more.yt-live-chat-item-list-renderer[disabled]{
  397. top: -42px;
  398. }
  399.  
  400. `: '';
  401.  
  402. const cssText6c_input_panel_overflow = FIX_INPUT_PANEL_OVERFLOW_ISSUE ? `
  403.  
  404. #input-panel #picker-buttons yt-live-chat-icon-toggle-button-renderer#product-picker {
  405. contain: layout style;
  406. }
  407.  
  408. #chat.yt-live-chat-renderer ~ #panel-pages.yt-live-chat-renderer {
  409. overflow: visible;
  410. }
  411.  
  412. `: '';
  413.  
  414. const cssText6d_input_panel_border = FIX_INPUT_PANEL_BORDER_ISSUE ? `
  415.  
  416. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer:not(:empty) {
  417. --yt-live-chat-action-panel-top-border: none;
  418. }
  419.  
  420. html #panel-pages.yt-live-chat-renderer > #input-panel.yt-live-chat-renderer.iron-selected > *:first-child {
  421. border-top: 1px solid var(--yt-live-chat-panel-pages-border-color);
  422. }
  423.  
  424. html #panel-pages.yt-live-chat-renderer {
  425. border-top: 0;
  426. border-bottom: 0;
  427. }
  428.  
  429. `: '';
  430.  
  431. const cssText7b_content_visibility_unset = FORCE_CONTENT_VISIBILITY_UNSET ? `
  432.  
  433. img,
  434. yt-img-shadow[height][width],
  435. yt-img-shadow {
  436. content-visibility: visible !important;
  437. }
  438.  
  439. ` : '';
  440.  
  441. const cssText7c_will_change_unset = FORCE_WILL_CHANGE_UNSET ? `
  442.  
  443. /* remove YouTube constant will-change */
  444. /* constant value will slow down the performance; default auto */
  445.  
  446. /* www-player.css */
  447. html .ytp-contextmenu,
  448. html .ytp-settings-menu {
  449. will-change: unset;
  450. }
  451.  
  452. /* frequently matched elements */
  453. html .fill.yt-interaction,
  454. html .stroke.yt-interaction,
  455. html .yt-spec-touch-feedback-shape__fill,
  456. html .yt-spec-touch-feedback-shape__stroke {
  457. will-change: unset;
  458. }
  459.  
  460. /* live_chat_polymer.js */
  461. /*
  462. html .toggle-button.tp-yt-paper-toggle-button,
  463. html #primaryProgress.tp-yt-paper-progress,
  464. html #secondaryProgress.tp-yt-paper-progress,
  465. html #onRadio.tp-yt-paper-radio-button,
  466. html .fill.yt-interaction,
  467. html .stroke.yt-interaction,
  468. html .yt-spec-touch-feedback-shape__fill,
  469. html .yt-spec-touch-feedback-shape__stroke {
  470. will-change: unset;
  471. }
  472. */
  473.  
  474. /* desktop_polymer_enable_wil_icons.js */
  475. /* html .fill.yt-interaction,
  476. html .stroke.yt-interaction, */
  477. html tp-yt-app-header::before,
  478. html tp-yt-iron-list,
  479. html #items.tp-yt-iron-list > *,
  480. html #onRadio.tp-yt-paper-radio-button,
  481. html .toggle-button.tp-yt-paper-toggle-button,
  482. html ytd-thumbnail-overlay-toggle-button-renderer[use-expandable-tooltip] #label.ytd-thumbnail-overlay-toggle-button-renderer,
  483. html #items.ytd-post-multi-image-renderer,
  484. html #items.ytd-horizontal-card-list-renderer,
  485. html #items.yt-horizontal-list-renderer,
  486. html #left-arrow.yt-horizontal-list-renderer,
  487. html #right-arrow.yt-horizontal-list-renderer,
  488. html #items.ytd-video-description-infocards-section-renderer,
  489. html #items.ytd-video-description-music-section-renderer,
  490. html #chips.ytd-feed-filter-chip-bar-renderer,
  491. html #chips.yt-chip-cloud-renderer,
  492. html #items.ytd-merch-shelf-renderer,
  493. html #items.ytd-product-details-image-carousel-renderer,
  494. html ytd-video-preview,
  495. html #player-container.ytd-video-preview,
  496. html #primaryProgress.tp-yt-paper-progress,
  497. html #secondaryProgress.tp-yt-paper-progress,
  498. html ytd-miniplayer[enabled] /* ,
  499. html .yt-spec-touch-feedback-shape__fill,
  500. html .yt-spec-touch-feedback-shape__stroke */ {
  501. will-change: unset;
  502. }
  503.  
  504. /* other */
  505. .ytp-videowall-still-info-content[class],
  506. .ytp-suggestion-image[class] {
  507. will-change: unset !important;
  508. }
  509.  
  510. ` : '';
  511.  
  512. const ENABLE_FONT_PRE_RENDERING = typeof HTMLElement.prototype.append === 'function' ? (ENABLE_FONT_PRE_RENDERING_PREFERRED || 0) : 0;
  513. const cssText8_fonts_pre_render = ENABLE_FONT_PRE_RENDERING ? `
  514.  
  515. elzm-fonts {
  516. visibility: collapse;
  517. position: fixed;
  518. top: -10px;
  519. left: -10px;
  520. font-size: 10pt;
  521. line-height: 100%;
  522. width: 100px;
  523. height: 100px;
  524. transform: scale(0.1);
  525. transform: scale(0.01);
  526. transform: scale(0.001);
  527. transform-origin: 0 0;
  528. contain: strict;
  529. display: block;
  530.  
  531. pointer-events: none !important;
  532. user-select: none !important;
  533. }
  534.  
  535. elzm-fonts[id]#elzm-fonts-yk75g {
  536. user-select: none !important;
  537. pointer-events: none !important;
  538. }
  539.  
  540. elzm-font {
  541. visibility: collapse;
  542. position: absolute;
  543. line-height: 100%;
  544. width: 100px;
  545. height: 100px;
  546. contain: strict;
  547. display: block;
  548.  
  549. user-select: none !important;
  550. pointer-events: none !important;
  551. }
  552.  
  553. elzm-font::before {
  554. visibility: collapse;
  555. position: absolute;
  556. line-height: 100%;
  557. width: 100px;
  558. height: 100px;
  559. contain: strict;
  560. display: block;
  561.  
  562. 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';
  563.  
  564. user-select: none !important;
  565. pointer-events: none !important;
  566. }
  567.  
  568. `: '';
  569.  
  570. const cssText9_no_backdrop_filter_when_menu_shown = NO_BACKDROP_FILTER_WHEN_MENU_SHOWN ? `
  571. tp-yt-iron-dropdown.yt-live-chat-app ytd-menu-popup-renderer {
  572. -webkit-backdrop-filter: none;
  573. backdrop-filter: none;
  574. }
  575. `: '';
  576.  
  577. const cssText10_show_more_blinker = ENABLE_SHOW_MORE_BLINKER ? `
  578.  
  579. @keyframes blinker-miuzp {
  580. 0%, 60%, 100% {
  581. opacity: 1;
  582. }
  583. 30% {
  584. opacity: 0.6;
  585. }
  586. }
  587.  
  588. yt-icon-button#show-more.has-new-messages-miuzp {
  589. animation: blinker-miuzp 1.74s linear infinite;
  590. }
  591.  
  592. `: '';
  593.  
  594. const cssText11_entire_message_clickable = FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK ? `
  595.  
  596. yt-live-chat-paid-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  597. pointer-events: none !important;
  598. }
  599.  
  600. yt-live-chat-membership-item-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  601. pointer-events: none !important;
  602. }
  603.  
  604. yt-live-chat-paid-sticker-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  605. pointer-events: none !important;
  606. }
  607.  
  608. yt-live-chat-text-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  609. pointer-events: none !important; /* TO_BE_REVIEWED */
  610. }
  611.  
  612. yt-live-chat-auto-mod-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
  613. pointer-events: none !important;
  614. }
  615.  
  616. `: '';
  617.  
  618. const cssText12_nowrap_tooltip = MAX_TOOLTIP_NO_WRAP_WIDTH && typeof MAX_TOOLTIP_NO_WRAP_WIDTH === 'string' ? `
  619.  
  620.  
  621. tp-yt-paper-tooltip[role="tooltip"] {
  622. box-sizing: content-box !important;
  623. margin: 0px !important;
  624. padding: 0px !important;
  625. contain: none !important;
  626. }
  627.  
  628. tp-yt-paper-tooltip[role="tooltip"] #tooltip[style-target="tooltip"] {
  629. box-sizing: content-box !important;
  630. display: inline-block;
  631. contain: none !important;
  632. }
  633.  
  634.  
  635. tp-yt-paper-tooltip[role="tooltip"] #tooltip[style-target="tooltip"]{
  636. max-width: ${MAX_TOOLTIP_NO_WRAP_WIDTH};
  637. width: max-content;
  638. text-overflow: ellipsis;
  639. overflow: hidden;
  640. white-space: nowrap;
  641. }
  642.  
  643.  
  644. `: '';
  645.  
  646.  
  647. const cssText13_no_text_select_when_menu_visible = `
  648. [menu-visible] {
  649. --sfc47-text-select: none;
  650. }
  651. [menu-visible] #header[id][class],
  652. [menu-visible] #content[id][class],
  653. [menu-visible] #header[id][class] *,
  654. [menu-visible] #content[id][class] * {
  655. user-select: var(--sfc47-text-select) !important;
  656. }
  657. [menu-visible] #menu {
  658. --sfc47-text-select: inherit;
  659. }
  660. `;
  661.  
  662. const cssText14_NO_FILTER_DROPDOWN_BORDER = NO_FILTER_DROPDOWN_BORDER ? `
  663. yt-live-chat-header-renderer.yt-live-chat-renderer #label.yt-dropdown-menu::before {
  664. border:0;
  665. }
  666. ` : '';
  667.  
  668. const cssText15_FIX_ANIMATION_TICKER_TEXT_POSITION = FIX_ANIMATION_TICKER_TEXT_POSITION ? `
  669. .style-scope.yt-live-chat-ticker-renderer #animation-container[id][class] {
  670. position: relative;
  671. display: grid;
  672. grid-auto-columns: 1fr;
  673. grid-auto-rows: 1fr;
  674. grid-template-columns: repeat(1, 1fr);
  675. gap: 7px;
  676. padding-bottom: 0;
  677. margin-bottom: 0;
  678. padding-top: 0;
  679. align-self: flex-start;
  680. flex-wrap: nowrap;
  681. margin-top: 1px;
  682. }
  683.  
  684. .style-scope.yt-live-chat-ticker-renderer #animation-container > [id][class] {
  685. margin-top: 0px;
  686. margin-bottom: 0px;
  687. flex-direction: row;
  688. flex-wrap: nowrap;
  689. align-items: center;
  690. justify-content: flex-start;
  691. }
  692.  
  693. .style-scope.yt-live-chat-ticker-renderer #animation-container > [id][class]:first-child::after {
  694. content: '補';
  695. visibility: collapse;
  696. display: inline-block;
  697. position: relative;
  698. width: 0;
  699. line-height: 22px;
  700. }
  701.  
  702. ` : '';
  703.  
  704. const cssText16_FIX_AUTHOR_CHIP_BADGE_POSITION = FIX_AUTHOR_CHIP_BADGE_POSITION ? `
  705. #card #author-name-chip > yt-live-chat-author-chip[single-line] {
  706. flex-wrap: nowrap;
  707. white-space: nowrap;
  708. display: inline-flex;
  709. flex-direction: row;
  710. text-wrap: nowrap;
  711. flex-shrink: 0;
  712. align-items: center;
  713. }
  714.  
  715. #card #author-name-chip {
  716. display: inline-flex;
  717. flex-direction: row;
  718. align-items: flex-start;
  719. }
  720. `: '';
  721.  
  722.  
  723. // Example: https://www.youtube.com/watch?v=Xfytz-igsuc
  724. const cssText17_FIX_overwidth_banner_message = `
  725. yt-live-chat-banner-manager#live-chat-banner.style-scope.yt-live-chat-item-list-renderer {
  726. max-width: 100%;
  727. box-sizing: border-box;
  728. }
  729. `;
  730.  
  731.  
  732. const cssText18_REACTION_ANIMATION_PANEL_CSS_FIX = REACTION_ANIMATION_PANEL_CSS_FIX ? `
  733. #reaction-control-panel-overlay[class] {
  734. contain: strict;
  735. margin: 0;
  736. padding: 0;
  737. border: 0;
  738. box-sizing: border-box;
  739. will-change: initial;
  740. }
  741. #reaction-control-panel-overlay[class] *[class] {
  742. will-change: initial;
  743. }
  744. `: ''
  745.  
  746. const addCss = () => `
  747.  
  748. @property --ticker-rtime {
  749. syntax: "<percentage>";
  750. inherits: false;
  751. initial-value: 0%;
  752. }
  753.  
  754. /*
  755. .run-ticker {
  756. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  757. }
  758.  
  759. .run-ticker-test {
  760. background: #00000001;
  761. }
  762.  
  763. .run-ticker-forced,
  764. yt-live-chat-ticker-renderer #items > * > #container.run-ticker-forced,
  765. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker-forced[class]
  766. {
  767. background:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2)) !important;
  768. }
  769. */
  770.  
  771. .run-ticker {
  772. --ticker-bg:linear-gradient(90deg, var(--ticker-c1),var(--ticker-c1) var(--ticker-rtime),var(--ticker-c2) var(--ticker-rtime),var(--ticker-c2));
  773. }
  774.  
  775. .run-ticker,
  776. yt-live-chat-ticker-renderer #items > * > #container.run-ticker,
  777. yt-live-chat-ticker-renderer[class] #items[class] > *[class] > #container.run-ticker[class]
  778. {
  779. background: var(--ticker-bg) !important;
  780. }
  781.  
  782. yt-live-chat-ticker-dummy777-item-renderer {
  783. background: #00000001;
  784. }
  785.  
  786. yt-live-chat-ticker-dummy777-item-renderer[dummy777] {
  787. position: fixed !important;
  788. top: -1000px !important;
  789. left: -1000px !important;
  790. font-size: 1px !important;
  791. color: transparent !important;
  792. pointer-events: none !important;
  793. z-index: -1 !important;
  794. contain: strict !important;
  795. box-sizing: border-box !important;
  796. pointer-events: none !important;
  797. user-select: none !important;
  798. max-width: 1px !important;
  799. max-height: 1px !important;
  800. overflow: hidden !important;
  801. visibility: collapse !important;
  802. display: none !important;
  803. }
  804.  
  805. yt-live-chat-ticker-dummy777-item-renderer #container {
  806. background: inherit;
  807. }
  808.  
  809.  
  810. ${cssText8_fonts_pre_render}
  811.  
  812. ${cssText9_no_backdrop_filter_when_menu_shown}
  813.  
  814. @supports (contain: layout paint style) {
  815.  
  816. ${cssText5}
  817.  
  818. }
  819.  
  820. @supports (color: var(--general)) {
  821.  
  822. html {
  823. --yt-live-chat-item-list-renderer-padding: 0px 0px;
  824. }
  825.  
  826. ${cssText3_smooth_transform_position}
  827.  
  828. ${cssText7c_will_change_unset}
  829.  
  830. ${cssText7b_content_visibility_unset}
  831.  
  832. yt-live-chat-item-list-renderer:not([allow-scroll]) #item-scroller.yt-live-chat-item-list-renderer {
  833. overflow-y: scroll;
  834. padding-right: 0;
  835. }
  836.  
  837. ${cssText4_smooth_transform_forced_props}
  838.  
  839. yt-icon[icon="down_arrow"] > *, yt-icon-button#show-more > * {
  840. pointer-events: none !important;
  841. }
  842.  
  843. #continuations, #continuations * {
  844. contain: strict;
  845. position: fixed;
  846. top: 2px;
  847. height: 1px;
  848. width: 2px;
  849. height: 1px;
  850. visibility: collapse;
  851. }
  852.  
  853. ${cssText6b_show_more_button}
  854.  
  855. ${cssText6d_input_panel_border}
  856.  
  857. ${cssText6c_input_panel_overflow}
  858.  
  859. }
  860.  
  861.  
  862. @supports (overflow-anchor: auto) {
  863.  
  864. .no-anchor * {
  865. overflow-anchor: none;
  866. }
  867. .no-anchor > item-anchor {
  868. overflow-anchor: auto;
  869. }
  870.  
  871. item-anchor {
  872.  
  873. height:1px;
  874. width: 100%;
  875. transform: scaleY(0.00001);
  876. transform-origin:0 0;
  877. contain: strict;
  878. opacity:0;
  879. display:flex;
  880. position:relative;
  881. flex-shrink:0;
  882. flex-grow:0;
  883. margin-bottom:0;
  884. overflow:hidden;
  885. box-sizing:border-box;
  886. visibility: visible;
  887. content-visibility: visible;
  888. contain-intrinsic-size: auto 1px;
  889. pointer-events:none !important;
  890.  
  891. }
  892.  
  893. #item-scroller.style-scope.yt-live-chat-item-list-renderer[class] {
  894. overflow-anchor: initial !important; /* whenever ENABLE_OVERFLOW_ANCHOR or not */
  895. }
  896.  
  897. html item-anchor {
  898.  
  899. height: 1px;
  900. width: 1px;
  901. top: auto;
  902. left: auto;
  903. right: auto;
  904. bottom: auto;
  905. transform: translateY(-1px);
  906. position: absolute;
  907. z-index: -1;
  908.  
  909. }
  910.  
  911. }
  912.  
  913. @supports (color: var(--pre-rendering)) {
  914.  
  915. @keyframes dontRenderAnimation {
  916. 0% {
  917. background-position-x: 3px;
  918. }
  919. 100% {
  920. background-position-x: 4px;
  921. }
  922. }
  923.  
  924. .dont-render[class] {
  925. /* visibility: collapse !important; */
  926. /* visibility: collapse will make innerText become "" which conflicts with BetterStreamChat; see https://greasyfork.org/scripts/469878/discussions/197267 */
  927.  
  928. transform: scale(0.01) !important;
  929. transform: scale(0.00001) !important;
  930. transform: scale(0.0000001) !important;
  931. transform-origin: 0 0 !important;
  932. z-index: -1 !important;
  933. contain: strict !important;
  934. box-sizing: border-box !important;
  935.  
  936. height: 1px !important;
  937. height: 0.1px !important;
  938. height: 0.01px !important;
  939. height: 0.0001px !important;
  940. height: 0.000001px !important;
  941.  
  942. animation: dontRenderAnimation 1ms linear 80ms 1 normal forwards !important;
  943.  
  944. pointer-events: none !important;
  945. user-select: none !important;
  946.  
  947. }
  948.  
  949. #sk35z {
  950. display: block !important;
  951.  
  952. visibility: collapse !important;
  953.  
  954. transform: scale(0.01) !important;
  955. transform: scale(0.00001) !important;
  956. transform: scale(0.0000001) !important;
  957. transform-origin: 0 0 !important;
  958. z-index: -1 !important;
  959. contain: strict !important;
  960. box-sizing: border-box !important;
  961.  
  962. height: 1px !important;
  963. height: 0.1px !important;
  964. height: 0.01px !important;
  965. height: 0.0001px !important;
  966. height: 0.000001px !important;
  967.  
  968. position: absolute !important;
  969. top: -1000px !important;
  970. left: -1000px !important;
  971.  
  972. }
  973.  
  974. }
  975.  
  976. [rNgzQ] {
  977. opacity: 0 !important;
  978. pointer-events: none !important;
  979. }
  980.  
  981.  
  982. ${cssText10_show_more_blinker}
  983.  
  984. ${cssText11_entire_message_clickable}
  985.  
  986. ${cssText12_nowrap_tooltip}
  987.  
  988. ${cssText13_no_text_select_when_menu_visible}
  989.  
  990. ${cssText14_NO_FILTER_DROPDOWN_BORDER}
  991.  
  992. ${cssText15_FIX_ANIMATION_TICKER_TEXT_POSITION}
  993.  
  994. ${cssText16_FIX_AUTHOR_CHIP_BADGE_POSITION}
  995.  
  996. ${cssText17_FIX_overwidth_banner_message}
  997.  
  998. ${cssText18_REACTION_ANIMATION_PANEL_CSS_FIX}
  999.  
  1000. `;
  1001.  
  1002.  
  1003. const konsole = {
  1004. nil: Symbol(),
  1005. logs: [],
  1006. style: '',
  1007. log(...args) {
  1008. konsole.logs.push({
  1009. type: 'log',
  1010. msg: [konsole.tag || konsole.nil, ...args, konsole.style || konsole.nil].filter(e => e !== konsole.nil)
  1011. });
  1012. },
  1013. setTag(tag) {
  1014. konsole.tag = tag;
  1015. },
  1016. setStyle(style) {
  1017. konsole.style = style;
  1018. },
  1019. groupCollapsed(...args) {
  1020.  
  1021. konsole.logs.push({
  1022. type: 'groupCollapsed',
  1023. msg: [...args].filter(e => e !== konsole.nil)
  1024. });
  1025. },
  1026. groupEnd() {
  1027.  
  1028. konsole.logs.push({
  1029. type: 'groupEnd'
  1030. })
  1031. },
  1032. print() {
  1033. const copy = konsole.logs.slice(0);
  1034. konsole.logs.length = 0;
  1035. for (const { type, msg } of copy) {
  1036. if (type === 'log') {
  1037. console.log(...msg)
  1038. } else if (type === 'groupCollapsed') {
  1039.  
  1040. console.groupCollapsed(...msg)
  1041. } else if (type === 'groupEnd') {
  1042. console.groupEnd();
  1043. }
  1044.  
  1045. }
  1046.  
  1047. }
  1048. };
  1049.  
  1050. /*
  1051. konsole.groupCollapsedX = (text1, text2) => {
  1052.  
  1053. if(!text2){
  1054.  
  1055. konsole.groupCollapsed(`%c${text1}`,
  1056. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;"
  1057. );
  1058. }else{
  1059.  
  1060. konsole.groupCollapsed(`%c${text1}%c${text2}`,
  1061. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;",
  1062. "background-color: #010502; color: #6ad9fe; font-weight: 300; padding: 2px;"
  1063. );
  1064. }
  1065. }
  1066.  
  1067. konsole.groupCollapsedX('YouTube Super Fast Chat');
  1068.  
  1069. setTimeout(()=>{
  1070.  
  1071. konsole.setTag('[[Fonts Pre-Rendering]]');
  1072. konsole.log(123);
  1073. konsole.log('wsd',332, 'ssa');
  1074. konsole.setTag('');
  1075. }, 100);
  1076.  
  1077. setTimeout(()=>{
  1078.  
  1079. konsole.setTag('[[Fonts Pre-Rendering 2]]');
  1080. konsole.log(123);
  1081. konsole.log('wsd',332, 'ssa');
  1082. konsole.setTag('');
  1083. }, 300);
  1084.  
  1085. setTimeout(()=>{
  1086.  
  1087. konsole.groupEnd();
  1088. konsole.print();
  1089. }, 1000);
  1090.  
  1091. */
  1092.  
  1093. const win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : (this instanceof Window ? this : window);
  1094.  
  1095. // Create a unique key for the script and check if it is already running
  1096. const hkey_script = 'mchbwnoasqph';
  1097. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  1098. win[hkey_script] = true;
  1099.  
  1100. let unexpectedErr = "";
  1101.  
  1102. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  1103.  
  1104. let te4 = setTimeout(() => { }); // dummy; skip timerId only;
  1105. if (te4 < 3) {
  1106. setTimeout(() => { });
  1107. setTimeout(() => { });
  1108. }
  1109.  
  1110. }
  1111.  
  1112. const firstKey = (obj) => {
  1113. for (const key in obj) {
  1114. if (obj.hasOwnProperty(key)) return key;
  1115. }
  1116. return null;
  1117. }
  1118.  
  1119. const firstObjectKey = (obj) => {
  1120. for (const key in obj) {
  1121. if (obj.hasOwnProperty(key) && typeof obj[key] === 'object') return key;
  1122. }
  1123. return null;
  1124. }
  1125.  
  1126. /**
  1127. * Takes in a __SORTED__ array and inserts the provided value into
  1128. * the correct, sorted, position.
  1129. * > https://github.com/bhowell2/binary-insert-js/
  1130. * @param array the sorted array where the provided value needs to be inserted (in order)
  1131. * @param insertValue value to be added to the array
  1132. * @param comparator function that helps determine where to insert the value (
  1133. */
  1134. function binaryInsert(array, insertValue, comparator) {
  1135. let left = 0;
  1136. let right = array.length;
  1137.  
  1138. let z;
  1139. // Directly return if array is empty or the insertValue should be at the end
  1140. if (right === 0 || (z = comparator(array[right - 1], insertValue)) <= 0) {
  1141. array.push(insertValue);
  1142. return array;
  1143. }
  1144.  
  1145. // Check if the insertValue should be at the beginning
  1146. if ((right === 1 ? z : comparator(array[0], insertValue)) >= 0) {
  1147. array.unshift(insertValue);
  1148. return array;
  1149. }
  1150. ++left; --right;
  1151.  
  1152. // Main binary search loop to find the insertion position
  1153. while (left < right) {
  1154. const mid = Math.floor((right + left) / 2);
  1155. const compared = comparator(array[mid], insertValue);
  1156. if (compared < 0) {
  1157. left = mid + 1;
  1158. } else if (compared > 0) {
  1159. right = mid;
  1160. } else {
  1161. // If equal, insert at the mid position
  1162. left = right = mid;
  1163. break;
  1164. }
  1165. }
  1166.  
  1167. // Insertion is always at the right position due to the nature of the binary search
  1168. array.splice(right, 0, insertValue);
  1169. return array;
  1170. }
  1171.  
  1172.  
  1173.  
  1174.  
  1175. class LimitedSizeSet extends Set {
  1176. constructor(n) {
  1177. super();
  1178. this.limit = n;
  1179. }
  1180.  
  1181. add(key) {
  1182. if (!super.has(key)) {
  1183. super.add(key);
  1184. let n = super.size - this.limit;
  1185. if (n > 0) {
  1186. const iterator = super.values();
  1187. do {
  1188. const firstKey = iterator.next().value; // Get the first (oldest) key
  1189. super.delete(firstKey); // Delete the oldest key
  1190. } while (--n > 0)
  1191. }
  1192. }
  1193. }
  1194.  
  1195. removeAdd(key) {
  1196. super.delete(key);
  1197. super.add(key);
  1198. }
  1199.  
  1200. }
  1201.  
  1202. // function removeElementFromArray(arr, index) {
  1203. // if (index >= 0 && index < arr.length) {
  1204. // arr.splice(index, 1);
  1205. // }
  1206. // }
  1207.  
  1208. // function getRandomInt(a, b) {
  1209. // // Ensure that 'a' and 'b' are integers
  1210. // a = Math.ceil(a);
  1211. // b = Math.floor(b);
  1212.  
  1213. // // Generate a random integer in the range [a, b]
  1214. // return Math.floor(Math.random() * (b - a + 1)) + a;
  1215. // }
  1216.  
  1217. function deepCopy(obj, skipKeys) {
  1218. skipKeys = skipKeys || [];
  1219. if (!obj || typeof obj !== 'object') return obj;
  1220. if (Array.isArray(obj)) {
  1221. return obj.map(item => deepCopy(item, skipKeys));
  1222. }
  1223. const copy = {};
  1224. for (let key in obj) {
  1225. if (!skipKeys.includes(key)) {
  1226. copy[key] = deepCopy(obj[key], skipKeys);
  1227. }
  1228. }
  1229. return copy;
  1230. }
  1231.  
  1232. class Mutex {
  1233.  
  1234. constructor() {
  1235. this.p = Promise.resolve()
  1236. }
  1237.  
  1238. /**
  1239. * @param {(lockResolve: () => void)} f
  1240. */
  1241. lockWith(f) {
  1242. this.p = this.p.then(() => new Promise(f).catch(console.warn))
  1243. }
  1244.  
  1245. }
  1246.  
  1247. const PromiseExternal = ((resolve_, reject_) => {
  1248. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  1249. return class PromiseExternal extends Promise {
  1250. constructor(cb = h) {
  1251. super(cb);
  1252. if (cb === h) {
  1253. /** @type {(value: any) => void} */
  1254. this.resolve = resolve_;
  1255. /** @type {(reason?: any) => void} */
  1256. this.reject = reject_;
  1257. }
  1258. }
  1259. };
  1260. })();
  1261.  
  1262.  
  1263. const createPipeline = () => {
  1264. let pipelineMutex = Promise.resolve();
  1265. const pipelineExecution = fn => {
  1266. return new Promise((resolve, reject) => {
  1267. pipelineMutex = pipelineMutex.then(async () => {
  1268. let res;
  1269. try {
  1270. res = await fn();
  1271. } catch (e) {
  1272. console.log('error_F1', e);
  1273. reject(e);
  1274. }
  1275. resolve(res);
  1276. }).catch(console.warn);
  1277. });
  1278. };
  1279. return pipelineExecution;
  1280. };
  1281.  
  1282. const tickerPE = createPipeline();
  1283.  
  1284. /** @type {typeof PromiseExternal.prototype | null} */
  1285. let relayPromise = null;
  1286.  
  1287.  
  1288. /** @type {typeof PromiseExternal.prototype | null} */
  1289. let onPlayStateChangePromise = null;
  1290.  
  1291.  
  1292.  
  1293. let playEventsStack = Promise.resolve();
  1294.  
  1295.  
  1296. let playerProgressChangedArg1 = null;
  1297. let playerProgressChangedArg2 = null;
  1298. let playerProgressChangedArg3 = null;
  1299.  
  1300.  
  1301. function dr(s) {
  1302. // reserved for future use
  1303. return s;
  1304. // return window.deWeakJS ? window.deWeakJS(s) : s;
  1305. }
  1306.  
  1307. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  1308. const indr = o => insp(o).$ || o.$ || 0;
  1309.  
  1310. const getProto = (element) => {
  1311. if (element) {
  1312. const cnt = insp(element);
  1313. return cnt.constructor.prototype || null;
  1314. }
  1315. return null;
  1316. }
  1317.  
  1318. const assertor = (f) => f() || console.assert(false, f + "");
  1319.  
  1320. const fnIntegrity = (f, d) => {
  1321. if (!f || typeof f !== 'function') {
  1322. console.warn('f is not a function', f);
  1323. return;
  1324. }
  1325. let p = f + "", s = 0, j = -1, w = 0;
  1326. for (let i = 0, l = p.length; i < l; i++) {
  1327. const t = p[i];
  1328. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  1329. if (j < i - 1) w++;
  1330. j = i;
  1331. } else {
  1332. s++;
  1333. }
  1334. }
  1335. let itz = `${f.length}.${s}.${w}`;
  1336. if (!d) {
  1337. return itz;
  1338. } else if (itz !== d) {
  1339. console.warn('fnIntegrity=false', itz);
  1340. return false;
  1341. } else {
  1342. return true;
  1343. }
  1344. }
  1345.  
  1346.  
  1347. const px2cm = (px) => px * window.devicePixelRatio * 0.026458333;
  1348. const px2mm = (px) => px * window.devicePixelRatio * 0.26458333;
  1349.  
  1350.  
  1351. ; (ENABLE_FLAGS_MAINTAIN_STABLE_LIST || ENABLE_FLAGS_REUSE_COMPONENTS || DISABLE_FLAGS_SHADYDOM_FREE) && (() => {
  1352.  
  1353. const _config_ = () => {
  1354. try {
  1355. return ytcfg.data_;
  1356. } catch (e) { }
  1357. return null;
  1358. };
  1359.  
  1360. const flagsFn = (EXPERIMENT_FLAGS) => {
  1361.  
  1362. // console.log(700)
  1363.  
  1364. if (!EXPERIMENT_FLAGS) return;
  1365.  
  1366. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST) {
  1367. if (USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true : true) {
  1368. // EXPERIMENT_FLAGS.kevlar_tuner_should_test_maintain_stable_list = true; // timestamp toggle issue
  1369. EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list = true;
  1370. // console.log(701)
  1371. }
  1372. }
  1373.  
  1374. if (ENABLE_FLAGS_REUSE_COMPONENTS) {
  1375. EXPERIMENT_FLAGS.kevlar_tuner_should_test_reuse_components = true;
  1376. EXPERIMENT_FLAGS.kevlar_tuner_should_reuse_components = true;
  1377. // console.log(702);
  1378. }
  1379.  
  1380. if (DISABLE_FLAGS_SHADYDOM_FREE) {
  1381. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_node_methods = false;
  1382. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_query_methods = false;
  1383. EXPERIMENT_FLAGS.enable_shadydom_free_scoped_readonly_properties_batch_one = false;
  1384. EXPERIMENT_FLAGS.enable_shadydom_free_parent_node = false;
  1385. EXPERIMENT_FLAGS.enable_shadydom_free_children = false;
  1386. EXPERIMENT_FLAGS.enable_shadydom_free_last_child = false;
  1387. }
  1388.  
  1389. // EXPERIMENT_FLAGS.enable_button_behavior_reuse = false;
  1390.  
  1391. };
  1392.  
  1393. const uf = (config_) => {
  1394. config_ = config_ || _config_();
  1395. if (config_) {
  1396. const { EXPERIMENT_FLAGS, EXPERIMENTS_FORCED_FLAGS } = config_;
  1397. if (EXPERIMENT_FLAGS) {
  1398. flagsFn(EXPERIMENT_FLAGS);
  1399. if (EXPERIMENTS_FORCED_FLAGS) flagsFn(EXPERIMENTS_FORCED_FLAGS);
  1400. }
  1401. }
  1402. }
  1403.  
  1404. window._ytConfigHacks.add((config_) => {
  1405. uf(config_);
  1406. });
  1407.  
  1408. uf();
  1409.  
  1410. })();
  1411.  
  1412. if (DISABLE_Translation_By_Google) {
  1413.  
  1414. let mo = new MutationObserver(() => {
  1415.  
  1416. if (!mo) return;
  1417. let h = document.head;
  1418. if (!h) return;
  1419. mo.disconnect();
  1420. mo.takeRecords();
  1421. mo = null;
  1422.  
  1423. let meta = document.createElement('meta');
  1424. meta.setAttribute('name', 'google');
  1425. meta.setAttribute('content', 'notranslate');
  1426. h.appendChild(meta);
  1427.  
  1428.  
  1429. });
  1430. mo.observe(document, { subtree: true, childList: true });
  1431. }
  1432.  
  1433.  
  1434. console.assert(MAX_ITEMS_FOR_TOTAL_DISPLAY > 0 && MAX_ITEMS_FOR_FULL_FLUSH > 0 && MAX_ITEMS_FOR_TOTAL_DISPLAY > MAX_ITEMS_FOR_FULL_FLUSH)
  1435.  
  1436. const isContainSupport = CSS.supports('contain', 'layout paint style');
  1437. if (!isContainSupport) {
  1438. console.warn("Your browser does not support css property 'contain'.\nPlease upgrade to the latest version.".trim());
  1439. }
  1440.  
  1441. const isOverflowAnchorSupport = CSS.supports('overflow-anchor', 'auto');
  1442. if (!isOverflowAnchorSupport) {
  1443. console.warn("Your browser does not support css property 'overflow-anchor'.\nPlease upgrade to the latest version.".trim());
  1444. }
  1445.  
  1446. const ENABLE_OVERFLOW_ANCHOR = ENABLE_OVERFLOW_ANCHOR_PREFERRED && isOverflowAnchorSupport && ENABLE_NO_SMOOTH_TRANSFORM;
  1447.  
  1448. let hasTimerModified = null;
  1449. const DO_CHECK_TICKER_BACKGROUND_OVERRIDED = !!ATTEMPT_ANIMATED_TICKER_BACKGROUND || ENABLE_RAF_HACK_TICKERS;
  1450.  
  1451. const fxOperator = (proto, propertyName) => {
  1452. let propertyDescriptorGetter = null;
  1453. try {
  1454. propertyDescriptorGetter = Object.getOwnPropertyDescriptor(proto, propertyName).get;
  1455. } catch (e) { }
  1456. return typeof propertyDescriptorGetter === 'function' ? (e) => {
  1457. try {
  1458.  
  1459. return propertyDescriptorGetter.call(dr(e));
  1460. } catch (e) { }
  1461. return e[propertyName];
  1462. } : (e) => e[propertyName];
  1463. };
  1464.  
  1465. const nodeParent = fxOperator(Node.prototype, 'parentNode');
  1466. // const nFirstElem = fxOperator(HTMLElement.prototype, 'firstElementChild');
  1467. const nPrevElem = fxOperator(HTMLElement.prototype, 'previousElementSibling');
  1468. const nNextElem = fxOperator(HTMLElement.prototype, 'nextElementSibling');
  1469. const nLastElem = fxOperator(HTMLElement.prototype, 'lastElementChild');
  1470.  
  1471. const groupCollapsed = (text1, text2) => {
  1472.  
  1473. console.groupCollapsed(`%c${text1}%c${text2}`,
  1474. "background-color: #010502; color: #6acafe; font-weight: 700; padding: 2px;",
  1475. "background-color: #010502; color: #6ad9fe; font-weight: 300; padding: 2px;"
  1476. );
  1477. }
  1478.  
  1479. // const microNow = () => performance.now() + (performance.timeOrigin || performance.timing.navigationStart);
  1480.  
  1481.  
  1482. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  1483. const onRegistryReady = (callback) => {
  1484. if (typeof customElements === 'undefined') {
  1485. if (!('__CE_registry' in document)) {
  1486. // https://github.com/webcomponents/polyfills/
  1487. Object.defineProperty(document, '__CE_registry', {
  1488. get() {
  1489. // return undefined
  1490. },
  1491. set(nv) {
  1492. if (typeof nv == 'object') {
  1493. delete this.__CE_registry;
  1494. this.__CE_registry = nv;
  1495. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  1496. }
  1497. return true;
  1498. },
  1499. enumerable: false,
  1500. configurable: true
  1501. })
  1502. }
  1503. let eventHandler = (evt) => {
  1504. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1505. const f = callback;
  1506. callback = null;
  1507. eventHandler = null;
  1508. f();
  1509. };
  1510. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1511. } else {
  1512. callback();
  1513. }
  1514. };
  1515.  
  1516. const promiseForCustomYtElementsReady = new Promise(onRegistryReady);
  1517.  
  1518. const renderReadyPn = typeof ResizeObserver !== 'undefined' ? (sizingTarget) => {
  1519.  
  1520. return new Promise(resolve => {
  1521.  
  1522. let ro = new ResizeObserver(entries => {
  1523. if (entries && entries.length >= 1) {
  1524. resolve();
  1525. ro.disconnect();
  1526. ro = null;
  1527. }
  1528. });
  1529. ro.observe(sizingTarget);
  1530.  
  1531.  
  1532.  
  1533. });
  1534.  
  1535. } : (sizingTarget) => {
  1536.  
  1537.  
  1538. return new Promise(resolve => {
  1539.  
  1540. let io = new IntersectionObserver(entries => {
  1541. if (entries && entries.length >= 1) {
  1542. resolve();
  1543. io.disconnect();
  1544. io = null;
  1545. }
  1546. });
  1547. io.observe(sizingTarget);
  1548.  
  1549.  
  1550.  
  1551. });
  1552.  
  1553. };
  1554.  
  1555. /* globals WeakRef:false */
  1556.  
  1557. /** @type {(o: Object | null) => WeakRef | null} */
  1558. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  1559.  
  1560. /** @type {(wr: Object | null) => Object | null} */
  1561. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  1562.  
  1563. const getLCRDummy = () => {
  1564. // direct createElement or createComponent_ will make the emoji rendering crashed. reason TBC
  1565.  
  1566. return Promise.all([customElements.whenDefined('yt-live-chat-app'), customElements.whenDefined('yt-live-chat-renderer')]).then(async () => {
  1567.  
  1568. const tag = "yt-live-chat-renderer"
  1569. let dummy = document.querySelector(tag);
  1570. if (!dummy) {
  1571.  
  1572. let mo = null;
  1573.  
  1574. const ytLiveChatApp = document.querySelector('yt-live-chat-app') || document.createElement('yt-live-chat-app');
  1575.  
  1576. const lcaProto = getProto(ytLiveChatApp);
  1577.  
  1578. dummy = await new Promise(resolve => {
  1579.  
  1580. if (typeof lcaProto.createComponent_ === 'function' && !lcaProto.createComponent99_) {
  1581.  
  1582. lcaProto.createComponent99_ = lcaProto.createComponent_;
  1583. lcaProto.createComponent98_ = function (a, b, c) {
  1584. // (3) ['yt-live-chat-renderer', {…}, true]
  1585. const r = this.createComponent99_.apply(this, arguments);
  1586. if (a === 'yt-live-chat-renderer') {
  1587. resolve(r);
  1588. }
  1589. return r;
  1590. };
  1591. lcaProto.createComponent_ = lcaProto.createComponent98_;
  1592.  
  1593. } else {
  1594.  
  1595. mo = new MutationObserver(() => {
  1596. const t = document.querySelector(tag);
  1597. if (t) {
  1598. resolve(t);
  1599. }
  1600. });
  1601. mo.observe(document, { subtree: true, childList: true })
  1602. }
  1603.  
  1604. });
  1605.  
  1606. if (mo) {
  1607. mo.disconnect();
  1608. mo.takeRecords();
  1609. mo = null;
  1610. }
  1611.  
  1612. if (lcaProto.createComponent99_ && lcaProto.createComponent_ && lcaProto.createComponent98_ === lcaProto.createComponent_) {
  1613. lcaProto.createComponent_ = lcaProto.createComponent99_;
  1614. lcaProto.createComponent99_ = null;
  1615. lcaProto.createComponent98_ = null;
  1616. }
  1617.  
  1618. }
  1619. return dummy;
  1620.  
  1621. });
  1622. }
  1623.  
  1624. const { addCssManaged } = (() => {
  1625.  
  1626. const addFontPreRendering = () => {
  1627.  
  1628. groupCollapsed("YouTube Super Fast Chat", " | Fonts Pre-Rendering");
  1629.  
  1630. let efsContainer = document.createElement('elzm-fonts');
  1631. efsContainer.id = 'elzm-fonts-yk75g'
  1632.  
  1633. const arr = [];
  1634. let p = document.createElement('elzm-font');
  1635. arr.push(p);
  1636.  
  1637. if (ENABLE_FONT_PRE_RENDERING & 1) {
  1638. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1639.  
  1640. p = document.createElement('elzm-font');
  1641. p.style.fontWeight = size;
  1642. arr.push(p);
  1643. }
  1644. }
  1645.  
  1646. if (ENABLE_FONT_PRE_RENDERING & 2) {
  1647. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1648.  
  1649. p = document.createElement('elzm-font');
  1650. p.style.fontFamily = 'Roboto';
  1651. p.style.fontWeight = size;
  1652. arr.push(p);
  1653. }
  1654. }
  1655.  
  1656. if (ENABLE_FONT_PRE_RENDERING & 4) {
  1657. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1658.  
  1659. p = document.createElement('elzm-font');
  1660. p.style.fontFamily = '"YouTube Noto",Roboto,Arial,Helvetica,sans-serif';
  1661. p.style.fontWeight = size;
  1662. arr.push(p);
  1663. }
  1664. }
  1665.  
  1666.  
  1667. if (ENABLE_FONT_PRE_RENDERING & 8) {
  1668. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1669.  
  1670. p = document.createElement('elzm-font');
  1671. p.style.fontFamily = '"Noto",Roboto,Arial,Helvetica,sans-serif';
  1672. p.style.fontWeight = size;
  1673. arr.push(p);
  1674. }
  1675. }
  1676.  
  1677.  
  1678. if (ENABLE_FONT_PRE_RENDERING & 16) {
  1679. for (const size of [100, 200, 300, 400, 500, 600, 700, 800, 900]) {
  1680.  
  1681. p = document.createElement('elzm-font');
  1682. p.style.fontFamily = 'sans-serif';
  1683. p.style.fontWeight = size;
  1684. arr.push(p);
  1685. }
  1686. }
  1687.  
  1688. console.log('number of elzm-font elements', arr.length);
  1689.  
  1690. HTMLElement.prototype.append.apply(efsContainer, arr);
  1691.  
  1692. (document.body || document.documentElement).appendChild(efsContainer);
  1693.  
  1694.  
  1695. console.log('elzm-font elements have been added to the page for rendering.');
  1696.  
  1697. console.groupEnd();
  1698.  
  1699. }
  1700.  
  1701. let isCssAdded = false;
  1702.  
  1703. function addCssElement() {
  1704. let s = document.createElement('style');
  1705. s.id = 'ewRvC';
  1706. return s;
  1707. }
  1708.  
  1709. const addCssManaged = () => {
  1710. if (!isCssAdded && document.documentElement && document.head) {
  1711. isCssAdded = true;
  1712. document.head.appendChild(dr(addCssElement())).textContent = addCss();
  1713. if (ENABLE_FONT_PRE_RENDERING) {
  1714. Promise.resolve().then(addFontPreRendering)
  1715. }
  1716. }
  1717. }
  1718.  
  1719. return { addCssManaged };
  1720. })();
  1721.  
  1722.  
  1723. const { setupStyle } = (() => {
  1724.  
  1725. const sp7 = Symbol();
  1726.  
  1727. const proxyHelperFn = (dummy) => ({
  1728.  
  1729. get(target, prop) {
  1730. return (prop in dummy) ? dummy[prop] : prop === sp7 ? target : target[prop];
  1731. },
  1732. set(target, prop, value) {
  1733. if (!(prop in dummy)) {
  1734. target[prop] = value;
  1735. }
  1736. return true;
  1737. },
  1738. has(target, prop) {
  1739. return (prop in target);
  1740. },
  1741. deleteProperty(target, prop) {
  1742. return true;
  1743. },
  1744. ownKeys(target) {
  1745. return Object.keys(target);
  1746. },
  1747. defineProperty(target, key, descriptor) {
  1748. return Object.defineProperty(target, key, descriptor);
  1749. },
  1750. getOwnPropertyDescriptor(target, key) {
  1751. return Object.getOwnPropertyDescriptor(target, key);
  1752. },
  1753.  
  1754. });
  1755.  
  1756. const setupStyle = (m1, m2) => {
  1757. if (!ENABLE_NO_SMOOTH_TRANSFORM) return;
  1758.  
  1759. const dummy1v = {
  1760. transform: '',
  1761. height: '',
  1762. minHeight: '',
  1763. paddingBottom: '',
  1764. paddingTop: ''
  1765. };
  1766.  
  1767. const dummyStyleFn = (k) => (function () { const style = this[sp7]; return style[k](...arguments); });
  1768. for (const k of ['toString', 'getPropertyPriority', 'getPropertyValue', 'item', 'removeProperty', 'setProperty']) {
  1769. dummy1v[k] = dummyStyleFn(k);
  1770. }
  1771.  
  1772. const dummy1p = proxyHelperFn(dummy1v);
  1773. const sp1v = new Proxy(m1.style, dummy1p);
  1774. const sp2v = new Proxy(m2.style, dummy1p);
  1775. Object.defineProperty(m1, 'style', { get() { return sp1v }, set() { }, enumerable: true, configurable: true });
  1776. Object.defineProperty(m2, 'style', { get() { return sp2v }, set() { }, enumerable: true, configurable: true });
  1777. m1.removeAttribute("style");
  1778. m2.removeAttribute("style");
  1779.  
  1780. }
  1781.  
  1782. return { setupStyle };
  1783.  
  1784. })();
  1785.  
  1786.  
  1787.  
  1788. function setThumbnails(config) {
  1789.  
  1790. const { baseObject, thumbnails, flag0, imageLinks } = config;
  1791.  
  1792. if (flag0 || (ENABLE_PRELOAD_THUMBNAIL && imageLinks)) {
  1793.  
  1794.  
  1795. if (thumbnails && thumbnails.length > 0) {
  1796. if (flag0 > 0 && thumbnails.length > 1) {
  1797. let pSize = 0;
  1798. let newThumbnails = [];
  1799. for (const thumbnail of thumbnails) {
  1800. if (!thumbnail || !thumbnail.url) continue;
  1801. const squarePhoto = thumbnail.width === thumbnail.height && typeof thumbnail.width === 'number';
  1802. const condSize = pSize <= 0 || (flag0 === 1 ? pSize > thumbnail.width : pSize < thumbnail.width);
  1803. const leastSizeFulfilled = squarePhoto ? thumbnail.width >= LEAST_IMAGE_SIZE : true;
  1804. if ((!squarePhoto || condSize) && leastSizeFulfilled) {
  1805. newThumbnails.push(thumbnail);
  1806. if (imageLinks) imageLinks.add(thumbnail.url);
  1807. }
  1808. if (squarePhoto && condSize && leastSizeFulfilled) {
  1809. pSize = thumbnail.width;
  1810. }
  1811. }
  1812. if (thumbnails.length !== newThumbnails.length && thumbnails === baseObject.thumbnails && newThumbnails.length > 0) {
  1813. baseObject.thumbnails = newThumbnails;
  1814. } else {
  1815. newThumbnails.length = 0;
  1816. }
  1817. newThumbnails = null;
  1818. } else {
  1819. for (const thumbnail of thumbnails) {
  1820. if (thumbnail && thumbnail.url) {
  1821. if (imageLinks) imageLinks.add(thumbnail.url);
  1822. }
  1823. }
  1824. }
  1825. }
  1826.  
  1827. }
  1828. }
  1829.  
  1830. function fixLiveChatItem(item, imageLinks) {
  1831. const liveChatTextMessageRenderer = (item || 0).liveChatTextMessageRenderer || 0;
  1832. if (liveChatTextMessageRenderer) {
  1833. const messageRuns = (liveChatTextMessageRenderer.message || 0).runs || 0;
  1834. if (messageRuns && messageRuns.length > 0) {
  1835. for (const run of messageRuns) {
  1836. const emojiImage = (((run || 0).emoji || 0).image || 0);
  1837. setThumbnails({
  1838. baseObject: emojiImage,
  1839. thumbnails: emojiImage.thumbnails,
  1840. flag0: EMOJI_IMAGE_SINGLE_THUMBNAIL,
  1841. imageLinks
  1842. });
  1843. }
  1844. }
  1845. const authorPhoto = liveChatTextMessageRenderer.authorPhoto || 0;
  1846. setThumbnails({
  1847. baseObject: authorPhoto,
  1848. thumbnails: authorPhoto.thumbnails,
  1849. flag0: AUTHOR_PHOTO_SINGLE_THUMBNAIL,
  1850. imageLinks
  1851. });
  1852. }
  1853. }
  1854.  
  1855.  
  1856.  
  1857. let kptPF = null;
  1858. const emojiPrefetched = new LimitedSizeSet(PREFETCH_LIMITED_SIZE_EMOJI);
  1859. const authorPhotoPrefetched = new LimitedSizeSet(PREFETCH_LIMITED_SIZE_AUTHOR_PHOTO);
  1860.  
  1861. function linker(link, rel, href, _as) {
  1862. return new Promise(resolve => {
  1863. if (!link) link = document.createElement('link');
  1864. link.rel = rel;
  1865. if (_as) link.setAttribute('as', _as);
  1866. link.onload = function () {
  1867. resolve({
  1868. link: this,
  1869. success: true
  1870. })
  1871. this.remove();
  1872. };
  1873. link.onerror = function () {
  1874. resolve({
  1875. link: this,
  1876. success: false
  1877. });
  1878. this.remove();
  1879. };
  1880. link.href = href;
  1881. document.head.appendChild(link);
  1882. link = null;
  1883. });
  1884. }
  1885.  
  1886.  
  1887.  
  1888. const cleanContext = async (win) => {
  1889. const waitFn = requestAnimationFrame; // shall have been binded to window
  1890. try {
  1891. let mx = 16; // MAX TRIAL
  1892. const frameId = 'vanillajs-iframe-v1';
  1893. /** @type {HTMLIFrameElement | null} */
  1894. let frame = document.getElementById(frameId);
  1895. let removeIframeFn = null;
  1896. if (!frame) {
  1897. frame = document.createElement('iframe');
  1898. frame.id = frameId;
  1899. const blobURL = typeof webkitCancelAnimationFrame === 'function' && typeof kagi === 'undefined' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  1900. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  1901. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  1902. n.appendChild(frame);
  1903. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  1904. const root = document.documentElement;
  1905. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  1906. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  1907.  
  1908. removeIframeFn = (setTimeout) => {
  1909. const removeIframeOnDocumentReady = (e) => {
  1910. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  1911. e = n;
  1912. n = win = removeIframeFn = 0;
  1913. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  1914. }
  1915. if (!setTimeout || document.readyState !== 'loading') {
  1916. removeIframeOnDocumentReady();
  1917. } else {
  1918. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  1919. }
  1920. }
  1921. }
  1922. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  1923. const fc = frame.contentWindow;
  1924. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  1925. try {
  1926. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, getComputedStyle } = fc;
  1927. const res = { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, getComputedStyle };
  1928. for (let k in res) res[k] = res[k].bind(win); // necessary
  1929. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  1930.  
  1931. /** @type {HTMLElement} */
  1932. const HTMLElementProto = fc.HTMLElement.prototype;
  1933. /** @type {EventTarget} */
  1934. const EventTargetProto = fc.EventTarget.prototype;
  1935. // jsonParseFix = {
  1936. // _JSON: fc.JSON, _parse: fc.JSON.parse
  1937. // }
  1938. return {
  1939. ...res,
  1940. animate: HTMLElementProto.animate,
  1941. addEventListener: EventTargetProto.addEventListener,
  1942. removeEventListener: EventTargetProto.removeEventListener
  1943. };
  1944. } catch (e) {
  1945. if (removeIframeFn) removeIframeFn();
  1946. return null;
  1947. }
  1948. } catch (e) {
  1949. console.warn(e);
  1950. return null;
  1951. }
  1952. };
  1953.  
  1954.  
  1955. let xoIcjPr = null;
  1956. window.addEventListener('message', (evt) => {
  1957. if ((evt || 0).data === 'xoIcj' && xoIcjPr !== null) xoIcjPr.resolve();
  1958. });
  1959. const timelineResolve = async () => {
  1960. if (xoIcjPr !== null) {
  1961. await xoIcjPr.then();
  1962. return;
  1963. }
  1964. xoIcjPr = new PromiseExternal();
  1965. window.postMessage('xoIcj');
  1966. await xoIcjPr.then();
  1967. xoIcjPr = null;
  1968. }
  1969.  
  1970. cleanContext(win).then(__CONTEXT__ => {
  1971. if (!__CONTEXT__) return null;
  1972.  
  1973. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, getComputedStyle, addEventListener, removeEventListener } = __CONTEXT__;
  1974.  
  1975. const wmComputedStyle = new WeakMap();
  1976. const getComputedStyleCached = (elem) => {
  1977. let cs = wmComputedStyle.get(elem);
  1978. if (!cs) {
  1979. cs = getComputedStyle(elem);
  1980. wmComputedStyle.set(elem, cs);
  1981. }
  1982. return cs;
  1983. }
  1984.  
  1985.  
  1986. const isGPUAccelerationAvailable = (() => {
  1987. // https://gist.github.com/cvan/042b2448fcecefafbb6a91469484cdf8
  1988. try {
  1989. const canvas = document.createElement('canvas');
  1990. return !!(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
  1991. } catch (e) {
  1992. return false;
  1993. }
  1994. })();
  1995.  
  1996. const foregroundPromiseFn_noGPU = (() => {
  1997.  
  1998. if (isGPUAccelerationAvailable) return null;
  1999.  
  2000. const pd = Object.getOwnPropertyDescriptor(Document.prototype, 'visibilityState');
  2001. if (!pd || typeof pd.get !== 'function') return null;
  2002. const pdGet = pd.get;
  2003.  
  2004. let pr = null;
  2005.  
  2006. let hState = pdGet.call(document) === 'hidden';
  2007. // let cid = 0;
  2008. pureAddEventListener.call(document, 'visibilitychange', (evt) => {
  2009. const newHState = pdGet.call(document) === 'hidden';
  2010. if (hState !== newHState) {
  2011. // if (cid > 0) cid = clearInterval(cid);
  2012. hState = newHState;
  2013. if (!hState && pr) pr = pr.resolve();
  2014. }
  2015. });
  2016.  
  2017. // cid = setInterval(() => {
  2018. // const newHState = document.visibilityState === 'hidden';
  2019. // if (hState !== newHState) {
  2020. // hState = newHState;
  2021. // if (!hState && pr) pr = pr.resolve();
  2022. // }
  2023. // }, 100);
  2024.  
  2025.  
  2026. return (() => {
  2027. if (pr) return pr;
  2028. const w = ((!hState && setTimeout(() => {
  2029. if (!hState && pr === w) pr = pr.resolve();
  2030. })), (pr = new PromiseExternal()));
  2031. return w;
  2032. });
  2033.  
  2034. })();
  2035.  
  2036. // window.foregroundPromiseFn_noGPU = foregroundPromiseFn_noGPU;
  2037.  
  2038. let rafPromise = null;
  2039. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  2040. requestAnimationFrame(hRes => {
  2041. rafPromise = null;
  2042. resolve(hRes);
  2043. });
  2044. }));
  2045. const foregroundPromiseFn = foregroundPromiseFn_noGPU || getRafPromise;
  2046.  
  2047. const iAFP = foregroundPromiseFn_noGPU ? foregroundPromiseFn_noGPU : typeof IntersectionObserver === 'undefined' ? getRafPromise : (() => {
  2048.  
  2049. const ioWM = new WeakMap();
  2050. const ek = Symbol();
  2051. /** @type {IntersectionObserverCallback} */
  2052. const ioCb = (entries, observer) => {
  2053. /** @type {PromiseExternal} */
  2054. const pr = observer[ek];
  2055. const resolve = pr.resolve;
  2056. let target;
  2057. if (resolve && (target = ((entries ? entries[0] : 0) || 0).target) instanceof Element) {
  2058. pr.resolve = null;
  2059. observer.unobserve(target);
  2060. resolve();
  2061. }
  2062. };
  2063. /**
  2064. *
  2065. * @param {Element} elm
  2066. * @returns {Promise<void>}
  2067. */
  2068. const iAFP = (elm) => {
  2069. let io = ioWM.get(elm);
  2070. if (!io) {
  2071. io = new IntersectionObserver(ioCb);
  2072. ioWM.set(elm, io); // strong reference
  2073. }
  2074. let pr = io[ek];
  2075. if (!pr) {
  2076. pr = io[ek] = new PromiseExternal();
  2077. io.observe(elm);
  2078. }
  2079. return pr;
  2080. }
  2081.  
  2082. return iAFP;
  2083.  
  2084. })();
  2085.  
  2086. let playerState = null;
  2087. let _playerState = null;
  2088. let lastPlayerProgress = null;
  2089. let relayCount = 0;
  2090. let playerEventsByIframeRelay = false;
  2091. let isPlayProgressTriggered = false;
  2092. let waitForInitialDataCompletion = 0;
  2093.  
  2094.  
  2095.  
  2096. let aeConstructor = null;
  2097.  
  2098. // << __openedChanged82 >>
  2099. let currentMenuPivotWR = null;
  2100.  
  2101. // << if DO_PARTICIPANT_LIST_HACKS >>
  2102. const beforeParticipantsMap = new WeakMap();
  2103. // << end >>
  2104.  
  2105.  
  2106.  
  2107. // << if onRegistryReadyForDOMOperations >>
  2108.  
  2109. let dt0 = Date.now() - 2000;
  2110. const dateNow = () => Date.now() - dt0;
  2111. // let lastScroll = 0;
  2112. // let lastLShow = 0;
  2113. let lastWheel = 0;
  2114. let lastMouseDown = 0;
  2115. let lastMouseUp = 0;
  2116. let currentMouseDown = false;
  2117. let lastTouchDown = 0;
  2118. let lastTouchUp = 0;
  2119. let currentTouchDown = false;
  2120. let lastUserInteraction = 0;
  2121.  
  2122. let scrollChatFn = null;
  2123.  
  2124. let skipDontRender = true; // true first; false by flushActiveItems_
  2125. let allowDontRender = null;
  2126.  
  2127. // ---- #items mutation ----
  2128. let sk35zResolveFn = null;
  2129. let firstList = true;
  2130.  
  2131. // << end >>
  2132.  
  2133. class RAFHub {
  2134. constructor() {
  2135. /** @type {number} */
  2136. this.startAt = 8170;
  2137. /** @type {number} */
  2138. this.counter = 0;
  2139. /** @type {number} */
  2140. this.rid = 0;
  2141. /** @type {Map<number, FrameRequestCallback>} */
  2142. this.funcs = new Map();
  2143. const funcs = this.funcs;
  2144. /** @type {FrameRequestCallback} */
  2145. this.bCallback = this.mCallback.bind(this);
  2146. this.pClear = () => funcs.clear();
  2147. this.keepRAF = false;
  2148. }
  2149. /** @param {DOMHighResTimeStamp} highResTime */
  2150. mCallback(highResTime) {
  2151. this.rid = 0;
  2152. Promise.resolve().then(this.pClear);
  2153. this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  2154. }
  2155. /** @param {FrameRequestCallback} f */
  2156. request(f) {
  2157. if (this.counter > 1e9) this.counter = 9;
  2158. let cid = this.startAt + (++this.counter);
  2159. this.funcs.set(cid, f);
  2160. if (this.rid === 0) this.rid = requestAnimationFrame(this.bCallback);
  2161. return cid;
  2162. }
  2163. /** @param {number} cid */
  2164. cancel(cid) {
  2165. cid = +cid;
  2166. if (cid > 0) {
  2167. if (cid <= this.startAt) {
  2168. return cancelAnimationFrame(cid);
  2169. }
  2170. if (this.rid > 0) {
  2171. this.funcs.delete(cid);
  2172. if (this.funcs.size === 0 && !this.keepRAF) {
  2173. cancelAnimationFrame(this.rid);
  2174. this.rid = 0;
  2175. }
  2176. }
  2177. }
  2178. }
  2179. }
  2180.  
  2181. function basePrefetching() {
  2182.  
  2183. new Promise(resolve => {
  2184.  
  2185. if (document.readyState !== 'loading') {
  2186. resolve();
  2187. } else {
  2188. win.addEventListener("DOMContentLoaded", resolve, false);
  2189. }
  2190.  
  2191. }).then(() => {
  2192. const hostL1 = [
  2193. 'https://www.youtube.com', 'https://googlevideo.com',
  2194. 'https://googleapis.com', 'https://accounts.youtube.com',
  2195. 'https://www.gstatic.com', 'https://ggpht.com',
  2196. 'https://yt3.ggpht.com', 'https://yt4.ggpht.com'
  2197. ];
  2198.  
  2199. const hostL2 = [
  2200. 'https://youtube.com',
  2201. 'https://fonts.googleapis.com', 'https://fonts.gstatic.com'
  2202. ];
  2203.  
  2204. let link = null;
  2205.  
  2206. function kn() {
  2207.  
  2208. link = document.createElement('link');
  2209. if (link.relList && link.relList.supports) {
  2210. 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)
  2211. } else {
  2212. kptPF = 0;
  2213. }
  2214.  
  2215. groupCollapsed("YouTube Super Fast Chat", " | PREFETCH SUPPORTS");
  2216. if (ENABLE_BASE_PREFETCHING) console.log('dns-prefetch', (kptPF & 1) ? 'OK' : 'NG');
  2217. if (ENABLE_BASE_PREFETCHING) console.log('preconnect', (kptPF & 2) ? 'OK' : 'NG');
  2218. if (ENABLE_PRELOAD_THUMBNAIL) console.log('prefetch', (kptPF & 4) ? 'OK' : 'NG');
  2219. // console.log('subresource', (kptPF & 8) ? 'OK' : 'NG');
  2220. if (ENABLE_PRELOAD_THUMBNAIL) console.log('preload', (kptPF & 16) ? 'OK' : 'NG');
  2221. console.groupEnd();
  2222.  
  2223. }
  2224.  
  2225. for (const h of hostL1) {
  2226.  
  2227. if (kptPF === null) kn();
  2228. if (ENABLE_BASE_PREFETCHING) {
  2229. // if (kptPF & 1) {
  2230. // linker(link, 'dns-prefetch', h);
  2231. // link = null;
  2232. // }
  2233. if (kptPF & 2) {
  2234. linker(link, 'preconnect', h);
  2235. link = null;
  2236. }
  2237. }
  2238. }
  2239.  
  2240. for (const h of hostL2) {
  2241. if (kptPF === null) kn();
  2242. if (ENABLE_BASE_PREFETCHING) {
  2243. if (kptPF & 1) {
  2244. linker(link, 'dns-prefetch', h);
  2245. link = null;
  2246. }
  2247. }
  2248. }
  2249.  
  2250. })
  2251.  
  2252.  
  2253. }
  2254.  
  2255. if (DO_LINK_PREFETCH) basePrefetching();
  2256.  
  2257. const { notifyPath7081 } = (() => {
  2258. // DO_PARTICIPANT_LIST_HACKS
  2259.  
  2260. const mutexParticipants = new Mutex();
  2261.  
  2262. let uvid = 0;
  2263. let r95dm = 0;
  2264. let c95dm = -1;
  2265.  
  2266. const foundMap = (base, content) => {
  2267. /*
  2268. let lastSearch = 0;
  2269. let founds = base.map(baseEntry => {
  2270. let search = content.indexOf(baseEntry, lastSearch);
  2271. if (search < 0) return false;
  2272. lastSearch = search + 1;
  2273. return true;
  2274. });
  2275. return founds;
  2276. */
  2277. const contentSet = new Set(content);
  2278. return base.map(baseEntry => contentSet.has(baseEntry));
  2279.  
  2280. }
  2281.  
  2282.  
  2283.  
  2284. let participantsForSpliceWR = null;
  2285.  
  2286. class IndexSpliceEntry {
  2287. /**
  2288. *
  2289. * @param {number} _index
  2290. * @param {number} _addedCount
  2291. * @param {any[]} _removed
  2292. */
  2293. constructor(_index, _addedCount, _removed) {
  2294. this.index = _index;
  2295. this.addedCount = _addedCount;
  2296. this.removed = _removed;
  2297. }
  2298. get __proxy312__() {
  2299. return 1
  2300. }
  2301. get type() {
  2302. return 'splice'
  2303. }
  2304. get object() {
  2305. return kRef(participantsForSpliceWR); // avoid memory leakage
  2306. }
  2307. }
  2308.  
  2309. const spliceIndicesFunc = (beforeParticipants, participants, idsBefore, idsAfter) => {
  2310.  
  2311. let foundsForAfter = foundMap(idsAfter, idsBefore);
  2312. let foundsForBefore = foundMap(idsBefore, idsAfter);
  2313.  
  2314. const nAfter = foundsForAfter.length;
  2315. const nBefore = foundsForBefore.length;
  2316.  
  2317. const indexSplices = [];
  2318. const contentUpdates = [];
  2319. participantsForSpliceWR = null;
  2320. for (let i = 0, j = 0; i < nBefore || j < nAfter;) {
  2321. if (beforeParticipants[i] === participants[j]) {
  2322. i++; j++;
  2323. } else if (idsBefore[i] === idsAfter[j]) {
  2324. // content changed
  2325. contentUpdates.push({ indexI: i, indexJ: j })
  2326. i++; j++;
  2327. } else {
  2328. let addedCount = 0;
  2329. for (let q = j; q < nAfter; q++) {
  2330. if (foundsForAfter[q] === false) addedCount++;
  2331. else break;
  2332. }
  2333. let removedCount = 0;
  2334. for (let q = i; q < nBefore; q++) {
  2335. if (foundsForBefore[q] === false) removedCount++;
  2336. else break;
  2337. }
  2338. if (!addedCount && !removedCount) {
  2339. throw 'ERROR(0xFF32): spliceIndicesFunc';
  2340. }
  2341. const entry = new IndexSpliceEntry(
  2342. j,
  2343. addedCount,
  2344. removedCount >= 1 ? beforeParticipants.slice(i, i + removedCount) : []
  2345. );
  2346. indexSplices.push(entry);
  2347. i += removedCount;
  2348. j += addedCount;
  2349. }
  2350. }
  2351. foundsForBefore = null;
  2352. foundsForAfter = null;
  2353. idsBefore = null;
  2354. idsAfter = null;
  2355. beforeParticipants = null;
  2356. participantsForSpliceWR = indexSplices.length > 0 ? mWeakRef(participants) : null;
  2357. participants = null;
  2358. return { indexSplices, contentUpdates };
  2359.  
  2360. }
  2361.  
  2362. /*
  2363.  
  2364. customElements.get("yt-live-chat-participant-renderer").prototype.notifyPath=function(){ console.log(123); console.log(new Error().stack)}
  2365.  
  2366. VM63631:1 Error
  2367. at customElements.get.notifyPath (<anonymous>:1:122)
  2368. at e.forwardRendererStamperChanges_ (live_chat_polymer.js:4453:35)
  2369. at e.rendererStamperApplyChangeRecord_ (live_chat_polymer.js:4451:12)
  2370. at e.rendererStamperObserver_ (live_chat_polymer.js:4448:149)
  2371. at Object.pu [as fn] (live_chat_polymer.js:1692:118)
  2372. at ju (live_chat_polymer.js:1674:217)
  2373. at a._propertiesChanged (live_chat_polymer.js:1726:122)
  2374. at b._flushProperties (live_chat_polymer.js:1597:200)
  2375. at a._invalidateProperties (live_chat_polymer.js:1718:69)
  2376. at a.notifyPath (live_chat_polymer.js:1741:182)
  2377.  
  2378. */
  2379.  
  2380. function convertToIds(participants) {
  2381. return participants.map(participant => {
  2382. if (!participant || typeof participant !== 'object') {
  2383. console.warn('Error(0xFA41): convertToIds', participant);
  2384. return participant; // just in case
  2385. }
  2386. let keys = Object.keys(participant);
  2387. // liveChatTextMessageRenderer
  2388. // liveChatParticipantRenderer - livestream channel owner [no authorExternalChannelId]
  2389. // liveChatPaidMessageRenderer
  2390. /*
  2391.  
  2392. 'yt-live-chat-participant-renderer' utilizes the following:
  2393. authorName.simpleText: string
  2394. authorPhoto.thumbnails: Object{url:string, width:int, height:int} []
  2395. authorBadges[].liveChatAuthorBadgeRenderer.icon.iconType: string
  2396. authorBadges[].liveChatAuthorBadgeRenderer.tooltip: string
  2397. authorBadges[].liveChatAuthorBadgeRenderer.accessibility.accessibilityData: Object{label:string}
  2398.  
  2399. */
  2400. if (keys.length !== 1) {
  2401. console.warn('Error(0xFA42): convertToIds', participant);
  2402. return participant; // just in case
  2403. }
  2404. let key = keys[0];
  2405. let renderer = (participant[key] || 0);
  2406. let authorName = (renderer.authorName || 0);
  2407. let text = `${authorName.simpleText || authorName.text}`
  2408. let res = participant; // fallback if it is not a vaild entry
  2409. if (typeof text !== 'string') {
  2410. console.warn('Error(0xFA53): convertToIds', participant);
  2411. } else {
  2412. text = `${renderer.authorExternalChannelId || 'null'}|${text || ''}`;
  2413. if (text.length > 1) res = text;
  2414. }
  2415. return res;
  2416. // return renderer?`${renderer.id}|${renderer.authorExternalChannelId}`: '';
  2417. // note: renderer.id will be changed if the user typed something to trigger the update of the participants' record.
  2418. });
  2419. }
  2420.  
  2421. const checkChangeToParticipantRendererContent = CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT ? (p1, p2) => {
  2422. // just update when content is changed.
  2423. if (p1.authorName !== p2.authorName) return true;
  2424. if (p1.authorPhoto !== p2.authorPhoto) return true;
  2425. if (p1.authorBadges !== p2.authorBadges) return true;
  2426. return false;
  2427. } : (p1, p2) => {
  2428. // keep integrity all the time.
  2429. return p1 !== p2; // always true
  2430. }
  2431.  
  2432. function notifyPath7081(path) { // cnt "yt-live-chat-participant-list-renderer"
  2433.  
  2434. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  2435. if (path !== "participantsManager.participants") {
  2436. return this.__notifyPath5036__.apply(this, arguments);
  2437. }
  2438. if (c95dm === r95dm) return;
  2439. } else {
  2440. const stack = new Error().stack;
  2441. if (path !== "participantsManager.participants" || stack.indexOf('.onParticipantsChanged') < 0) {
  2442. return this.__notifyPath5036__.apply(this, arguments);
  2443. }
  2444. }
  2445.  
  2446. if (uvid > 1e8) uvid = uvid % 100;
  2447. let tid = ++uvid;
  2448.  
  2449. const cnt = this; // "yt-live-chat-participant-list-renderer"
  2450. mutexParticipants.lockWith(lockResolve => {
  2451.  
  2452. const participants00 = cnt.participantsManager.participants;
  2453.  
  2454. if (tid !== uvid || typeof (participants00 || 0).splice !== 'function') {
  2455. lockResolve();
  2456. return;
  2457. }
  2458.  
  2459. let doUpdate = false;
  2460.  
  2461. if (PARTICIPANT_UPDATE_ONLY_ONLY_IF_MODIFICATION_DETECTED) {
  2462.  
  2463. if (!participants00.r94dm) {
  2464. participants00.r94dm = 1;
  2465. if (++r95dm > 1e9) r95dm = 9;
  2466. participants00.push = function () {
  2467. if (++r95dm > 1e9) r95dm = 9;
  2468. return Array.prototype.push.apply(this, arguments);
  2469. }
  2470. participants00.pop = function () {
  2471. if (++r95dm > 1e9) r95dm = 9;
  2472. return Array.prototype.pop.apply(this, arguments);
  2473. }
  2474. participants00.shift = function () {
  2475. if (++r95dm > 1e9) r95dm = 9;
  2476. return Array.prototype.shift.apply(this, arguments);
  2477. }
  2478. participants00.unshift = function () {
  2479. if (++r95dm > 1e9) r95dm = 9;
  2480. return Array.prototype.unshift.apply(this, arguments);
  2481. }
  2482. participants00.splice = function () {
  2483. if (++r95dm > 1e9) r95dm = 9;
  2484. return Array.prototype.splice.apply(this, arguments);
  2485. }
  2486. participants00.sort = function () {
  2487. if (++r95dm > 1e9) r95dm = 9;
  2488. return Array.prototype.sort.apply(this, arguments);
  2489. }
  2490. participants00.reverse = function () {
  2491. if (++r95dm > 1e9) r95dm = 9;
  2492. return Array.prototype.reverse.apply(this, arguments);
  2493. }
  2494. }
  2495.  
  2496. if (c95dm !== r95dm) {
  2497. c95dm = r95dm;
  2498. doUpdate = true;
  2499. }
  2500.  
  2501. } else {
  2502. doUpdate = true;
  2503. }
  2504.  
  2505. if (!doUpdate) {
  2506. lockResolve();
  2507. return;
  2508. }
  2509.  
  2510. const participants = participants00.slice(0);
  2511. const beforeParticipants = beforeParticipantsMap.get(cnt) || [];
  2512. beforeParticipantsMap.set(cnt, participants);
  2513.  
  2514. const resPromise = (async () => {
  2515.  
  2516. if (beforeParticipants.length === 0) {
  2517. // not error
  2518. return 0;
  2519. }
  2520.  
  2521. let countOfElements = cnt.__getAllParticipantsDOMRenderedLength__()
  2522.  
  2523. // console.log(participants.length, doms.length) // different if no requestAnimationFrame
  2524. if (beforeParticipants.length !== countOfElements) {
  2525. // there is somewrong for the cache. - sometimes happen
  2526. return 0;
  2527. }
  2528.  
  2529. const idsBefore = convertToIds(beforeParticipants);
  2530. const idsAfter = convertToIds(participants);
  2531.  
  2532. let { indexSplices, contentUpdates } = spliceIndicesFunc(beforeParticipants, participants, idsBefore, idsAfter);
  2533.  
  2534. let res = 1; // default 1 for no update
  2535.  
  2536. if (indexSplices.length >= 1) {
  2537.  
  2538.  
  2539. // let p2 = participants.slice(indexSplices[0].index, indexSplices[0].index+indexSplices[0].addedCount);
  2540. // let p1 = indexSplices[0].removed;
  2541. // console.log(indexSplices.length, indexSplices ,p1,p2, convertToIds(p1),convertToIds(p2))
  2542.  
  2543. /* folllow
  2544. a.notifyPath(c + ".splices", d);
  2545. a.notifyPath(c + ".length", b.length);
  2546. */
  2547. // stampDomArraySplices_
  2548.  
  2549.  
  2550. await new Promise(resolve => {
  2551. cnt.resolveForDOMRendering781 = resolve;
  2552.  
  2553. cnt.__notifyPath5036__("participantsManager.participants.splices", {
  2554. indexSplices
  2555. });
  2556. indexSplices = null;
  2557. participantsForSpliceWR = null;
  2558. cnt.__notifyPath5036__("participantsManager.participants.length",
  2559. participants.length
  2560. );
  2561.  
  2562. });
  2563.  
  2564. // play safe for the change of 'length'
  2565. if (typeof nextBrowserTick !== 'function') {
  2566. await Promise.resolve(0);
  2567. } else {
  2568. await new Promise(resolve => nextBrowserTick(resolve)).then();
  2569. }
  2570.  
  2571. countOfElements = cnt.__getAllParticipantsDOMRenderedLength__();
  2572.  
  2573. const wrongSize = participants.length !== countOfElements
  2574. if (wrongSize) {
  2575. console.warn("ERROR(0xE2C3): notifyPath7081", beforeParticipants.length, participants.length, doms.length)
  2576. return 0;
  2577. }
  2578.  
  2579. res = 2 | 4;
  2580.  
  2581. } else {
  2582.  
  2583. indexSplices = null;
  2584. participantsForSpliceWR = null;
  2585.  
  2586. if (participants.length !== countOfElements) {
  2587. // other unhandled cases
  2588. return 0;
  2589. }
  2590.  
  2591. }
  2592.  
  2593. // participants.length === countOfElements before contentUpdates
  2594. if (contentUpdates.length >= 1) {
  2595. for (const contentUpdate of contentUpdates) {
  2596. let isChanged = checkChangeToParticipantRendererContent(beforeParticipants[contentUpdate.indexI], participants[contentUpdate.indexJ]);
  2597. if (isChanged) {
  2598. cnt.__notifyPath5036__(`participantsManager.participants[${contentUpdate.indexJ}]`);
  2599. res |= 4 | 8;
  2600. }
  2601. }
  2602. }
  2603. contentUpdates = null;
  2604.  
  2605. return res;
  2606.  
  2607.  
  2608. })();
  2609.  
  2610.  
  2611. resPromise.then(resValue => {
  2612.  
  2613. const isLogRequired = SHOW_PARTICIPANT_CHANGES_IN_CONSOLE && ((resValue === 0) || ((resValue & 4) === 4));
  2614. isLogRequired && groupCollapsed("Participant List Change", `tid = ${tid}; res = ${resValue}`);
  2615. if (resValue === 0) {
  2616. new Promise(resolve => {
  2617. cnt.resolveForDOMRendering781 = resolve;
  2618. isLogRequired && console.log("Full Refresh begins");
  2619. cnt.__notifyPath5036__("participantsManager.participants"); // full refresh
  2620. }).then(() => {
  2621. isLogRequired && console.log("Full Refresh ends");
  2622. console.groupEnd();
  2623. }).then(lockResolve);
  2624. return;
  2625. }
  2626.  
  2627. const delayLockResolve = (resValue & 4) === 4;
  2628.  
  2629. if (delayLockResolve) {
  2630. isLogRequired && console.log(`Number of participants (before): ${beforeParticipants.length}`);
  2631. isLogRequired && console.log(`Number of participants (after): ${participants.length}`);
  2632. isLogRequired && console.log(`Total number of rendered participants: ${cnt.__getAllParticipantsDOMRenderedLength__()}`);
  2633. isLogRequired && console.log(`Participant Renderer Content Updated: ${(resValue & 8) === 8}`);
  2634. isLogRequired && console.groupEnd();
  2635. // requestAnimationFrame is required to avoid particiant update during DOM changing (stampDomArraySplices_)
  2636. // mutex lock with requestAnimationFrame can also disable participants update in background
  2637. requestAnimationFrame(lockResolve);
  2638. } else {
  2639. lockResolve();
  2640. }
  2641.  
  2642. });
  2643.  
  2644. });
  2645.  
  2646. }
  2647.  
  2648. return { notifyPath7081 };
  2649.  
  2650. })();
  2651.  
  2652. const whenDefinedMultiple = async (tags) => {
  2653.  
  2654. const sTags = [...new Set(tags)];
  2655. const len = sTags.length;
  2656.  
  2657. const pTags = new Array(len);
  2658. for (let i = 0; i < len; i++) {
  2659. pTags[i] = customElements.whenDefined(sTags[i]);
  2660. }
  2661.  
  2662. await Promise.all(pTags);
  2663. pTags.length = 0;
  2664.  
  2665. return sTags;
  2666.  
  2667. }
  2668.  
  2669. const onRegistryReadyForDataManipulation = () => {
  2670.  
  2671. function dummy5035(a, b, c) { }
  2672. function dummy411(a, b, c) { }
  2673.  
  2674.  
  2675.  
  2676. customElements.whenDefined("yt-live-chat-participant-list-renderer").then(() => {
  2677.  
  2678. if (!DO_PARTICIPANT_LIST_HACKS) return;
  2679.  
  2680. const tag = "yt-live-chat-participant-list-renderer";
  2681. const cProto = getProto(document.createElement(tag));
  2682. if (!cProto || typeof cProto.attached !== 'function') {
  2683. // for _registered, proto.attached shall exist when the element is defined.
  2684. // for controller extraction, attached shall exist when instance creates.
  2685. console.warn(`proto.attached for ${tag} is unavailable.`);
  2686. return;
  2687. }
  2688.  
  2689.  
  2690. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-participant-list-renderer hacks");
  2691.  
  2692. 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'];
  2693. const fgs = {};
  2694. for (const key of fgsArr) fgs[key] = undefined;
  2695.  
  2696. try {
  2697. const EXPERIMENT_FLAGS = ytcfg.data_.EXPERIMENT_FLAGS;
  2698. for (const key of fgsArr) fgs[key] = EXPERIMENT_FLAGS[key];
  2699. } catch (e) { }
  2700. console.log(`EXPERIMENT_FLAGS: ${JSON.stringify(fgs, null, 2)}`);
  2701.  
  2702. const canDoReplacement = (() => {
  2703. if (typeof cProto.__notifyPath5035__ === 'function' && cProto.__notifyPath5035__.name !== 'dummy5035') {
  2704. console.warn('YouTube Live Chat Tamer is running.');
  2705. return;
  2706. }
  2707.  
  2708. if (typeof cProto.__attached411__ === 'function' && cProto.__attached411__.name !== 'dummy411') {
  2709. console.warn('YouTube Live Chat Tamer is running.');
  2710. return;
  2711. }
  2712.  
  2713. cProto.__notifyPath5035__ = dummy5035 // just to against Live Chat Tamer
  2714. cProto.__attached411__ = dummy411 // just to against Live Chat Tamer
  2715.  
  2716. if (typeof cProto.flushRenderStamperComponentBindings_ !== 'function' || cProto.flushRenderStamperComponentBindings_.length !== 0) {
  2717. console.warn("ERROR(0xE355): cProto.flushRenderStamperComponentBindings_ not found");
  2718. return;
  2719. }
  2720.  
  2721. if (typeof cProto.flushRenderStamperComponentBindings66_ === 'function') {
  2722. console.warn("ERROR(0xE356): cProto.flushRenderStamperComponentBindings66_");
  2723. return;
  2724. }
  2725.  
  2726. if (typeof cProto.__getAllParticipantsDOMRenderedLength__ === 'function') {
  2727. console.warn("ERROR(0xE357): cProto.__getAllParticipantsDOMRenderedLength__");
  2728. return;
  2729. }
  2730. return true;
  2731. })();
  2732.  
  2733. console.log(`Data Manipulation Boost = ${canDoReplacement}`);
  2734.  
  2735. assertor(() => fnIntegrity(cProto.attached, '0.32.22')) // just warning
  2736. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  2737. const fiRSCB = fnIntegrity(cProto.flushRenderStamperComponentBindings_);
  2738. const s = fiRSCB.split('.');
  2739. // Feb 2024: 0.403.247 => NG
  2740. // if (s[0] === '0' && +s[1] > 381 && +s[1] < 391 && +s[2] > 228 && +s[2] < 238) {
  2741. // console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - OK`);
  2742. // } else {
  2743. // console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ### - NG`);
  2744. // }
  2745. console.log(`flushRenderStamperComponentBindings_ ### ${fiRSCB} ###`);
  2746. } else {
  2747. console.log("flushRenderStamperComponentBindings_ - not found");
  2748. }
  2749. // assertor(() => fnIntegrity(cProto.flushRenderStamperComponentBindings_, '0.386.233')) // just warning
  2750.  
  2751. if (typeof cProto.flushRenderStamperComponentBindings_ === 'function') {
  2752. cProto.flushRenderStamperComponentBindings66_ = cProto.flushRenderStamperComponentBindings_;
  2753. cProto.flushRenderStamperComponentBindings_ = function () {
  2754. // console.log('flushRenderStamperComponentBindings_')
  2755. this.flushRenderStamperComponentBindings66_();
  2756. if (this.resolveForDOMRendering781) {
  2757. this.resolveForDOMRendering781();
  2758. this.resolveForDOMRendering781 = null;
  2759. }
  2760. };
  2761. }
  2762.  
  2763. cProto.__getAllParticipantsDOMRenderedLength__ = function () {
  2764. const container = ((this || 0).$ || 0).participants;
  2765. if (!container) return 0;
  2766. return HTMLElement.prototype.querySelectorAll.call(container, 'yt-live-chat-participant-renderer').length;
  2767. }
  2768.  
  2769. const onPageElements = [...document.querySelectorAll('yt-live-chat-participant-list-renderer:not(.n9fJ3)')];
  2770.  
  2771. cProto.__attached412__ = cProto.attached;
  2772. const fpPList = function (hostElement) {
  2773. const cnt = insp(hostElement);
  2774. if (beforeParticipantsMap.has(cnt)) return;
  2775. hostElement.classList.add('n9fJ3');
  2776.  
  2777. assertor(() => (cnt.__dataEnabled === true && cnt.__dataReady === true));
  2778. if (typeof cnt.notifyPath !== 'function' || typeof cnt.__notifyPath5036__ !== 'undefined') {
  2779. console.warn("ERROR(0xE318): yt-live-chat-participant-list-renderer")
  2780. return;
  2781. }
  2782.  
  2783. groupCollapsed("Participant List attached", "");
  2784. // cnt.$.participants.appendChild = cnt.$.participants.__shady_native_appendChild = function(){
  2785. // console.log(123, 'appendChild');
  2786. // return HTMLElement.prototype.appendChild.apply(this, arguments)
  2787. // }
  2788.  
  2789. // cnt.$.participants.insertBefore =cnt.$.participants.__shady_native_insertBefore = function(){
  2790. // console.log(123, 'insertBefore');
  2791. // return HTMLElement.prototype.insertBefore.apply(this, arguments)
  2792. // }
  2793.  
  2794. cnt.__notifyPath5036__ = cnt.notifyPath
  2795. const participants = ((cnt.participantsManager || 0).participants || 0);
  2796. assertor(() => (participants.length > -1 && typeof participants.slice === 'function'));
  2797. console.log(`initial number of participants: ${participants.length}`);
  2798. const newParticipants = (participants.length >= 1 && typeof participants.slice === 'function') ? participants.slice(0) : [];
  2799. beforeParticipantsMap.set(cnt, newParticipants);
  2800. cnt.notifyPath = notifyPath7081;
  2801. console.log(`CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT = ${CHECK_CHANGE_TO_PARTICIPANT_RENDERER_CONTENT}`);
  2802. console.groupEnd();
  2803. }
  2804. cProto.attached = function () {
  2805. fpPList(this.hostElement || this);
  2806. this.__attached412__.apply(this, arguments);
  2807. };
  2808.  
  2809.  
  2810. if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST) {
  2811.  
  2812. /** @type {boolean | (()=>boolean)} */
  2813. let toUseMaintainStableList = USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? (() => ytcfg.data_.EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true) : true;
  2814. if (typeof cProto.stampDomArray_ === 'function' && cProto.stampDomArray_.length === 6 && !cProto.stampDomArray_.nIegT && !cProto.stampDomArray66_) {
  2815.  
  2816. let lastMessageDate = 0;
  2817. cProto.stampDomArray66_ = cProto.stampDomArray_;
  2818.  
  2819. cProto.stampDomArray_ = function (...args) {
  2820. if (args[0] && args[0].length > 0 && args[1] === "participants" && args[2] && args[3] === true && !args[5]) {
  2821. if (typeof toUseMaintainStableList === 'function') {
  2822. toUseMaintainStableList = toUseMaintainStableList();
  2823. }
  2824. args[5] = toUseMaintainStableList;
  2825. let currentDate = Date.now();
  2826. if (currentDate - lastMessageDate > 440) {
  2827. lastMessageDate = currentDate;
  2828. console.log('maintain_stable_list for participants list', toUseMaintainStableList);
  2829. }
  2830. }
  2831. return this.stampDomArray66_.apply(this, args);
  2832. }
  2833.  
  2834. cProto.stampDomArray_.nIegT = 1;
  2835.  
  2836. }
  2837. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - YES`);
  2838. } else {
  2839. console.log(`ENABLE_FLAGS_MAINTAIN_STABLE_LIST_FOR_PARTICIPANTS_LIST - NO`);
  2840. }
  2841.  
  2842. console.groupEnd();
  2843.  
  2844. if (onPageElements.length >= 1) {
  2845. for (const s of onPageElements) {
  2846. if (insp(s).isAttached === true) {
  2847. fpPList(s);
  2848. }
  2849. }
  2850. }
  2851.  
  2852. }).catch(console.warn);
  2853.  
  2854. };
  2855.  
  2856. if (DO_PARTICIPANT_LIST_HACKS) {
  2857. promiseForCustomYtElementsReady.then(onRegistryReadyForDataManipulation);
  2858. }
  2859.  
  2860.  
  2861.  
  2862. const rafHub = (ENABLE_RAF_HACK_TICKERS || ENABLE_RAF_HACK_DOCKED_MESSAGE || ENABLE_RAF_HACK_INPUT_RENDERER || ENABLE_RAF_HACK_EMOJI_PICKER) ? new RAFHub() : null;
  2863.  
  2864.  
  2865. const fixChildrenIssue = !!fixChildrenIssue801;
  2866. if (fixChildrenIssue && typeof Object.getOwnPropertyDescriptor === 'function' && typeof Proxy !== 'undefined') {
  2867. const divProto = HTMLDivElement.prototype;
  2868. const polymerControllerSetData3 = function (c, d, e) {
  2869. return insp(this).set(c, d, e);
  2870. }
  2871. const polymerControllerSetData2 = function (c, d) {
  2872. return insp(this).set(c, d);
  2873. }
  2874. const dummyFn = function () {
  2875. console.log('dummyFn', ...arguments);
  2876. };
  2877.  
  2878. const wm44 = new Map();
  2879. function unPolymerSet(elem) {
  2880. const is = elem.is;
  2881. if (is && !elem.set) {
  2882. let rt = wm44.get(is);
  2883. if (!rt) {
  2884. rt = 1;
  2885. const cnt = insp(elem);
  2886. if (cnt !== elem && cnt && typeof cnt.set === 'function') {
  2887. const pcSet = cnt.constructor.prototype.set;
  2888. if (pcSet && typeof pcSet === 'function' && pcSet.length === 3) {
  2889. rt = polymerControllerSetData3;
  2890. } else if (pcSet && typeof pcSet === 'function' && pcSet.length === 2) {
  2891. rt = polymerControllerSetData2;
  2892. }
  2893. }
  2894. wm44.set(is, rt);
  2895. }
  2896. if (typeof rt === 'function') {
  2897. elem.set = rt;
  2898. } else {
  2899. elem.set = dummyFn;
  2900. }
  2901. }
  2902. }
  2903. if (!divProto.__children577__ && !divProto.__children578__) {
  2904.  
  2905. const dp = Object.getOwnPropertyDescriptor(Element.prototype, 'children');
  2906. const dp2 = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'children');
  2907. const dp3 = Object.getOwnPropertyDescriptor(divProto, 'children');
  2908.  
  2909. if (dp && dp.configurable === true && dp.enumerable === true && typeof dp.get === 'function' && !dp2 && !dp3) {
  2910.  
  2911. if (divProto instanceof HTMLElement && divProto instanceof Element) {
  2912.  
  2913. let m = Object.assign({}, dp);
  2914. divProto.__children577__ = dp.get;
  2915. divProto.__children578__ = function () {
  2916. if (this.__children803__) return this.__children803__;
  2917. if (this.__children801__) {
  2918. let arr = [];
  2919. for (let elem = this.firstElementChild; elem !== null; elem = elem.nextElementSibling) {
  2920. if (elem.is) {
  2921. unPolymerSet(elem);
  2922. arr.push(elem);
  2923. }
  2924. }
  2925. if (this.__children801__ === 2) this.__children803__ = arr;
  2926. return arr;
  2927. }
  2928. return 577;
  2929. };
  2930. m.get = function () {
  2931. const r = this.__children578__();
  2932. if (r !== 577) return r;
  2933. return this.__children577__();
  2934. };
  2935. Object.defineProperty(divProto, 'children', m);
  2936.  
  2937. console.log('fixChildrenIssue - set OK')
  2938.  
  2939. }
  2940. }
  2941.  
  2942. }
  2943.  
  2944.  
  2945. }
  2946.  
  2947.  
  2948. const bnForDelayChatOccurrence = () => {
  2949.  
  2950. document.addEventListener('animationstart', (evt) => {
  2951.  
  2952. if (evt.animationName === 'dontRenderAnimation') {
  2953. evt.target.classList.remove('dont-render');
  2954. if (scrollChatFn) scrollChatFn();
  2955. }
  2956.  
  2957. }, true);
  2958.  
  2959. const f = (elm) => {
  2960. if (elm && elm.nodeType === 1) {
  2961. if (!skipDontRender && allowDontRender === true) {
  2962. // innerTextFixFn();
  2963. elm.classList.add('dont-render');
  2964. }
  2965. }
  2966. }
  2967.  
  2968. Node.prototype.__appendChild931__ = function (a) {
  2969. a = dr(a);
  2970. if (this.id === 'items' && this.classList.contains('yt-live-chat-item-list-renderer')) {
  2971. if (a && a.nodeType === 1) f(a);
  2972. else if (a instanceof DocumentFragment) {
  2973. for (let n = a.firstChild; n; n = n.nextSibling) {
  2974. f(n);
  2975. }
  2976. }
  2977. }
  2978. }
  2979.  
  2980. Node.prototype.__appendChild932__ = function () {
  2981. this.__appendChild931__.apply(this, arguments);
  2982. return Node.prototype.appendChild.apply(this, arguments);
  2983. }
  2984.  
  2985.  
  2986. };
  2987.  
  2988. const watchUserCSS = () => {
  2989.  
  2990. // if (!CSS.supports('contain-intrinsic-size', 'auto var(--wsr94)')) return;
  2991.  
  2992. const getElemFromWR = (nr) => {
  2993. const n = kRef(nr);
  2994. if (n && n.isConnected) return n;
  2995. return null;
  2996. }
  2997.  
  2998. const clearContentVisibilitySizing = () => {
  2999. Promise.resolve().then(() => {
  3000.  
  3001. const e = document.querySelector('#show-more[disabled]');
  3002. let btnShowMoreWR = e ? mWeakRef(e) : null;
  3003.  
  3004. let lastVisibleItemWR = null;
  3005. for (const elm of document.querySelectorAll('[wSr93]')) {
  3006. if (elm.getAttribute('wSr93') === 'visible') lastVisibleItemWR = mWeakRef(elm);
  3007. elm.setAttribute('wSr93', '');
  3008. // custom CSS property --wsr94 not working when attribute wSr93 removed
  3009. }
  3010. foregroundPromiseFn().then(() => {
  3011. const btnShowMore = getElemFromWR(btnShowMoreWR); btnShowMoreWR = null;
  3012. if (btnShowMore) btnShowMore.click();
  3013. else {
  3014. // would not work if switch it frequently
  3015. const lastVisibleItem = getElemFromWR(lastVisibleItemWR); lastVisibleItemWR = null;
  3016. if (lastVisibleItem) {
  3017.  
  3018. Promise.resolve()
  3019. .then(() => lastVisibleItem.scrollIntoView())
  3020. .then(() => lastVisibleItem.scrollIntoView(false))
  3021. .then(() => lastVisibleItem.scrollIntoView({ behavior: "instant", block: "end", inline: "nearest" }))
  3022. .catch(e => { }) // break the chain when method not callable
  3023.  
  3024. }
  3025. }
  3026. });
  3027.  
  3028. });
  3029.  
  3030. }
  3031.  
  3032. const mutObserver = new MutationObserver((mutations) => {
  3033. for (const mutation of mutations) {
  3034. if ((mutation.addedNodes || 0).length >= 1) {
  3035. for (const addedNode of mutation.addedNodes) {
  3036. if (addedNode.nodeName === 'STYLE') {
  3037. clearContentVisibilitySizing();
  3038. return;
  3039. }
  3040. }
  3041. }
  3042. if ((mutation.removedNodes || 0).length >= 1) {
  3043. for (const removedNode of mutation.removedNodes) {
  3044. if (removedNode.nodeName === 'STYLE') {
  3045. clearContentVisibilitySizing();
  3046. return;
  3047. }
  3048. }
  3049. }
  3050. }
  3051. });
  3052.  
  3053. mutObserver.observe(document.documentElement, {
  3054. childList: true,
  3055. subtree: false
  3056. });
  3057. mutObserver.observe(document.head, {
  3058. childList: true,
  3059. subtree: false
  3060. });
  3061. mutObserver.observe(document.body, {
  3062. childList: true,
  3063. subtree: false
  3064. });
  3065.  
  3066. }
  3067.  
  3068.  
  3069. class WillChangeController {
  3070. constructor(itemScroller, willChangeValue) {
  3071. this.element = itemScroller;
  3072. this.counter = 0;
  3073. this.active = false;
  3074. this.willChangeValue = willChangeValue;
  3075. }
  3076.  
  3077. beforeOper() {
  3078. if (!this.active) {
  3079. this.active = true;
  3080. this.element.style.willChange = this.willChangeValue;
  3081. }
  3082. this.counter++;
  3083. }
  3084.  
  3085. afterOper() {
  3086. const c = this.counter;
  3087. foregroundPromiseFn().then(() => {
  3088. if (c === this.counter) {
  3089. this.active = false;
  3090. this.element.style.willChange = '';
  3091. }
  3092. });
  3093. }
  3094.  
  3095. release() {
  3096. const element = this.element;
  3097. this.element = null;
  3098. this.counter = 1e16;
  3099. this.active = false;
  3100. try {
  3101. element.style.willChange = '';
  3102. } catch (e) { }
  3103. }
  3104.  
  3105. }
  3106.  
  3107.  
  3108. const skzData = (skz) => skz.data = {
  3109. "message": {
  3110. "runs": [
  3111. {
  3112. "text": "em2o"
  3113. },
  3114. {
  3115. "emoji": {
  3116. "emojiId": "cm35z",
  3117. "shortcuts": [
  3118. ":_s:",
  3119. ":s:"
  3120. ],
  3121. "searchTerms": [
  3122. "_s",
  3123. "s"
  3124. ],
  3125. "image": {
  3126. "thumbnails": [
  3127. {
  3128. "url": dummyImgURL,
  3129. "width": 48,
  3130. "height": 48
  3131. }
  3132. ],
  3133. "accessibility": {
  3134. "accessibilityData": {
  3135. "label": "s"
  3136. }
  3137. }
  3138. },
  3139. "isCustomEmoji": true
  3140. }
  3141. },
  3142. {
  3143. "text": "ji"
  3144. }
  3145. ]
  3146. },
  3147. "authorName": {
  3148. "simpleText": "N"
  3149. },
  3150. "authorPhoto": {
  3151. "thumbnails": [
  3152. {
  3153. "url": dummyImgURL,
  3154. "width": 64,
  3155. "height": 64
  3156. }
  3157. ]
  3158. },
  3159. "contextMenuEndpoint": {
  3160. "commandMetadata": {
  3161. "webCommandMetadata": {
  3162. "ignoreNavigation": true
  3163. }
  3164. },
  3165. "liveChatItemContextMenuEndpoint": {
  3166. "params": "123=="
  3167. }
  3168. },
  3169. "id": "sk35z",
  3170. "timestampUsec": "1232302352350000",
  3171. "authorBadges": [
  3172. {
  3173. "liveChatAuthorBadgeRenderer": {
  3174. "customThumbnail": {
  3175. "thumbnails": [
  3176. {
  3177. "url": dummyImgURL,
  3178. "width": 16,
  3179. "height": 16
  3180. },
  3181. {
  3182. "url": dummyImgURL,
  3183. "width": 32,
  3184. "height": 32
  3185. }
  3186. ]
  3187. },
  3188. "tooltip": "T",
  3189. "accessibility": {
  3190. "accessibilityData": {
  3191. "label": "E"
  3192. }
  3193. }
  3194. }
  3195. }
  3196. ],
  3197. "authorExternalChannelId": "A",
  3198. "contextMenuAccessibility": {
  3199. "accessibilityData": {
  3200. "label": "E"
  3201. }
  3202. },
  3203. "timestampText": {
  3204. "simpleText": "0:43"
  3205. }
  3206. };
  3207.  
  3208.  
  3209.  
  3210. const { lcRendererElm, visObserver } = (() => {
  3211.  
  3212.  
  3213.  
  3214. let lcRendererWR = null;
  3215.  
  3216. const lcRendererElm = () => {
  3217. let lcRenderer = kRef(lcRendererWR);
  3218. if (!lcRenderer || !lcRenderer.isConnected) {
  3219. lcRenderer = document.querySelector('yt-live-chat-item-list-renderer.yt-live-chat-renderer');
  3220. lcRendererWR = lcRenderer ? mWeakRef(lcRenderer) : null;
  3221. }
  3222. return lcRenderer;
  3223. };
  3224.  
  3225.  
  3226. let hasFirstShowMore = false;
  3227.  
  3228. const visObserverFn = (entry) => {
  3229.  
  3230. const target = entry.target;
  3231. if (!target) return;
  3232. // if(target.classList.contains('dont-render')) return;
  3233. let isVisible = entry.isIntersecting === true && entry.intersectionRatio > 0.5;
  3234. // const h = entry.boundingClientRect.height;
  3235. /*
  3236. if (h < 16) { // wrong: 8 (padding/margin); standard: 32; test: 16 or 20
  3237. // e.g. under fullscreen. the element created but not rendered.
  3238. target.setAttribute('wSr93', '');
  3239. return;
  3240. }
  3241. */
  3242. if (isVisible) {
  3243. // target.style.setProperty('--wsr94', h + 'px');
  3244. target.setAttribute('wSr93', 'visible');
  3245. if (nNextElem(target) === null) {
  3246.  
  3247. // firstVisibleItemDetected = true;
  3248. /*
  3249. if (dateNow() - lastScroll < 80) {
  3250. lastLShow = 0;
  3251. lastScroll = 0;
  3252. Promise.resolve().then(clickShowMore);
  3253. } else {
  3254. lastLShow = dateNow();
  3255. }
  3256. */
  3257. // lastLShow = dateNow();
  3258. } else if (!hasFirstShowMore) { // should more than one item being visible
  3259. // implement inside visObserver to ensure there is sufficient delay
  3260. hasFirstShowMore = true;
  3261. foregroundPromiseFn().then(() => {
  3262. // foreground page
  3263. // page visibly ready -> load the latest comments at initial loading
  3264. const lcRenderer = lcRendererElm();
  3265. if (lcRenderer) {
  3266. if (typeof nextBrowserTick !== 'function') {
  3267. insp(lcRenderer).scrollToBottom_();
  3268. } else {
  3269. nextBrowserTick(() => {
  3270. const cnt = insp(lcRenderer);
  3271. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  3272. cnt.scrollToBottom_();
  3273. });
  3274. }
  3275. }
  3276. });
  3277. }
  3278. }
  3279. else if (target.getAttribute('wSr93') === 'visible') { // ignore target.getAttribute('wSr93') === '' to avoid wrong sizing
  3280.  
  3281. // target.style.setProperty('--wsr94', h + 'px');
  3282. target.setAttribute('wSr93', 'hidden');
  3283. } // note: might consider 0 < entry.intersectionRatio < 0.5 and target.getAttribute('wSr93') === '' <new last item>
  3284.  
  3285. }
  3286.  
  3287.  
  3288.  
  3289. const visObserver = new IntersectionObserver((entries) => {
  3290.  
  3291. for (const entry of entries) {
  3292.  
  3293. Promise.resolve(entry).then(visObserverFn);
  3294.  
  3295. }
  3296.  
  3297. }, {
  3298. // root: HTMLElement.prototype.closest.call(m2, '#item-scroller.yt-live-chat-item-list-renderer'), // nullable
  3299. rootMargin: "0px",
  3300. threshold: [0.05, 0.95],
  3301. });
  3302.  
  3303.  
  3304. return { lcRendererElm, visObserver }
  3305.  
  3306.  
  3307. })();
  3308.  
  3309. const { setupMutObserver } = (() => {
  3310.  
  3311. async function asyncTickerBackgroundOverridedChecker() {
  3312.  
  3313. try {
  3314. await promiseForCustomYtElementsReady.then();
  3315. await customElements.whenDefined('yt-live-chat-text-message-renderer');
  3316. await new Promise(r => setTimeout(r, 800));
  3317.  
  3318. if (!hasTimerModified) return;
  3319. const tickerRenderer = document.querySelector('#ticker yt-live-chat-ticker-renderer.style-scope.yt-live-chat-renderer');
  3320. if (!tickerRenderer) return;
  3321.  
  3322. const tickerRendererDollar = indr(tickerRenderer);
  3323. const items = (tickerRendererDollar || 0).items || 0;
  3324. if (!items) return;
  3325. const template = document.createElement('template');
  3326. template.innerHTML = `<yt-live-chat-ticker-dummy777-item-renderer class="style-scope yt-live-chat-ticker-renderer" whole-message-clickable=""
  3327. modern="" aria-label="¥1,000" role="button" tabindex="0" id="Chw777" style="width: 94px; overflow: hidden;"
  3328. dimmed="" [dummy777]>
  3329. <div id="container" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"
  3330. 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));">
  3331. <div id="content" class="style-scope yt-live-chat-ticker-dummy777-item-renderer" style="color: rgb(255, 255, 255);">
  3332. <yt-img-shadow777 id="author-photo" height="24" width="24"
  3333. class="style-scope yt-live-chat-ticker-dummy777-item-renderer no-transition"
  3334. style="background-color: transparent;" loaded=""><img id="img"
  3335. draggable="false" class="style-scope yt-img-shadow" alt="I" height="24" width="24"
  3336. src="${dummyImgURL}"></yt-img-shadow777>
  3337.  
  3338. <span id="text" dir="ltr" class="style-scope yt-live-chat-ticker-dummy777-item-renderer"1,000</span>
  3339. </div>
  3340. </div>
  3341. </yt-live-chat-ticker-dummy777-item-renderer>`;
  3342. const dummy777 = template.content.firstElementChild;
  3343. await Promise.resolve().then();
  3344. let res = 0;
  3345. if (items instanceof HTMLElement && items.isConnected === true) {
  3346. try {
  3347. items.appendChild(dummy777);
  3348. let container = HTMLElement.prototype.querySelector.call(dummy777, '#container') || 0;
  3349. if (container.isConnected === true) {
  3350. const evaluated = `${getComputedStyleCached(container).background}`;
  3351. container = null;
  3352. res = evaluated.indexOf('0.') < 4 ? 1 : 2;
  3353. }
  3354. } catch (e) { console.warn(e) }
  3355. HTMLElement.prototype.remove.call(dummy777);
  3356. }
  3357. await Promise.resolve().then();
  3358. dummy777.textContent = '';
  3359. if (res === 1) {
  3360. // not fulfilling
  3361. // rgba(0, 0, 0, 0.004) none repeat scroll 0% 0% / auto padding-box border-box
  3362. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  3363. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  3364. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  3365. );
  3366. 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');
  3367. console.groupEnd();
  3368. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND (Overriding other scripting)', 'background-color: #7eb32b; color: #102624; padding: 2px 4px');
  3369. } else if (res === 2) {
  3370. console.log('%cALLOW_ADVANCED_ANIMATED_TICKER_BACKGROUND', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  3371. }
  3372. } catch (e) {
  3373. console.warn(e);
  3374. }
  3375. }
  3376.  
  3377. async function asyncDelayChatOccurrence(m2) {
  3378. try {
  3379. await promiseForCustomYtElementsReady.then();
  3380. await customElements.whenDefined('yt-live-chat-text-message-renderer');
  3381. await new Promise(r => setTimeout(r, 1));
  3382. const dummy888 = document.createElement('yt-live-chat-text-message-renderer');
  3383. // const template = document.createElement('template');
  3384. // template.innerHTML = "<yt-live-chat-text-message-renderer></yt-live-chat-text-message-renderer>"
  3385. // const dummy888 = template.content.firstElementChild;
  3386. const skzCnt = insp(dummy888);
  3387. if (!(skzCnt && 'data' in skzCnt && 'attached' in skzCnt)) {
  3388. return;
  3389. }
  3390. if (!skzCnt.hostElement) skzCnt.hostElement = dummy888;
  3391. /** @type {HTMLTemplateElement} */
  3392. const skzElem = dummy888;
  3393. let cz1 = null;
  3394. const deferredZy1 = new Promise(resolve => {
  3395. skzCnt.attached = function () {
  3396. cz1 = HTMLElement.prototype.querySelector.call(skzElem, '#message img') !== null;
  3397. resolve(skzElem.textContent);
  3398. }
  3399. skzCnt.detached = function () {
  3400. }
  3401. });
  3402. skzElem.id = 'sk35z';
  3403. skzData(skzCnt);
  3404. sk35zResolveFn = null;
  3405. const deferredMutation = new Promise(resolve => {
  3406. sk35zResolveFn = resolve;
  3407. HTMLElement.prototype.appendChild.call(m2, skzElem);
  3408. });
  3409. const [zy1, _] = await Promise.all([deferredZy1, deferredMutation]);
  3410. skzCnt.attached = function () { };
  3411. function fn() {
  3412. const zy2 = skzElem.textContent;
  3413. const cz2 = HTMLElement.prototype.querySelector.call(skzElem, '#message img') !== null;
  3414. if (typeof zy1 === 'string' && typeof zy2 === 'string') {
  3415. allowDontRender = zy1 === zy2 && cz1 === cz2; // '0:43N​em2oji'
  3416. }
  3417. if (allowDontRender === true) return true;
  3418. if (allowDontRender === false) {
  3419. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | Incompatibility Found"}`,
  3420. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  3421. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  3422. );
  3423. 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');
  3424. console.groupEnd();
  3425. }
  3426. }
  3427. await new Promise(r => setTimeout(r, 1));
  3428. if (!fn()) return;
  3429. await foregroundPromiseFn().then();
  3430. if (!fn()) return;
  3431. skzElem.remove();
  3432. await Promise.resolve().then();
  3433. skzElem.textContent = '';
  3434. console.log('%cALLOW_DELAYED_CHAT_OCCURRENCE', 'background-color: #16c450; color: #102624; padding: 2px 4px');
  3435. } catch (e) {
  3436. console.warn(e);
  3437. }
  3438. }
  3439.  
  3440. const mutFn = (items) => {
  3441. let seqIndex = -1;
  3442. const elementSet = new Set();
  3443. for (let node = nLastElem(items); node !== null; node = nPrevElem(node)) {
  3444. if (node.hasAttribute('wSr93')) {
  3445. seqIndex = parseInt(node.getAttribute('yt-chat-item-seq'), 10);
  3446. break;
  3447. }
  3448. node.setAttribute('wSr93', '');
  3449. visObserver.observe(node);
  3450. elementSet.add(node);
  3451. }
  3452. let iter = elementSet.values();
  3453. let i = seqIndex + elementSet.size;
  3454. for (let curr; curr = iter.next().value;) {
  3455. curr.setAttribute('yt-chat-item-seq', i % 60);
  3456. curr.classList.add('yt-chat-item-' + ((i % 2) ? 'odd' : 'even'));
  3457. i--;
  3458. }
  3459. iter = null;
  3460. elementSet.clear();
  3461. }
  3462.  
  3463. const mutObserver = new MutationObserver((mutations) => {
  3464. const items = (mutations[0] || 0).target;
  3465. if (!items) return;
  3466. if (sk35zResolveFn) {
  3467. sk35zResolveFn();
  3468. sk35zResolveFn = null;
  3469. }
  3470. mutFn(items);
  3471. });
  3472.  
  3473. const setupMutObserver = (m2) => {
  3474. scrollChatFn = null;
  3475. mutObserver.disconnect();
  3476. mutObserver.takeRecords();
  3477. if (m2) {
  3478. if (typeof m2.__appendChild932__ === 'function') {
  3479. if (typeof m2.appendChild === 'function') m2.appendChild = m2.__appendChild932__;
  3480. if (typeof m2.__shady_native_appendChild === 'function') m2.__shady_native_appendChild = m2.__appendChild932__;
  3481. }
  3482. mutObserver.observe(m2, {
  3483. childList: true,
  3484. subtree: false
  3485. });
  3486. mutFn(m2);
  3487.  
  3488. const isFirstList = firstList;
  3489. firstList = false;
  3490.  
  3491. if (ENABLE_OVERFLOW_ANCHOR) {
  3492.  
  3493. let items = m2;
  3494. let addedAnchor = false;
  3495. if (items) {
  3496. if (items.nextElementSibling === null) {
  3497. items.classList.add('no-anchor');
  3498. addedAnchor = true;
  3499. items.parentNode.appendChild(dr(document.createElement('item-anchor')));
  3500. }
  3501. }
  3502.  
  3503.  
  3504.  
  3505. if (addedAnchor) {
  3506. nodeParent(m2).classList.add('no-anchor'); // required
  3507. }
  3508.  
  3509. }
  3510.  
  3511.  
  3512.  
  3513. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  3514.  
  3515. (() => {
  3516.  
  3517. const tag = 'yt-iframed-player-events-relay'
  3518. const dummy = document.createElement(tag);
  3519.  
  3520. const cProto = getProto(dummy);
  3521. if (!cProto || !cProto.handlePostMessage_) {
  3522. console.warn(`proto.handlePostMessage_ for ${tag} is unavailable.`);
  3523. return;
  3524. }
  3525.  
  3526. if (typeof cProto.handlePostMessage_ === 'function' && !cProto.handlePostMessage66_) {
  3527.  
  3528. cProto.handlePostMessage66_ = cProto.handlePostMessage_;
  3529.  
  3530. cProto.handlePostMessage67_ = function (a) {
  3531.  
  3532. const da = a.data;
  3533.  
  3534.  
  3535.  
  3536. playEventsStack = playEventsStack.then(() => {
  3537.  
  3538.  
  3539.  
  3540. if ('yt-player-state-change' in da) {
  3541.  
  3542. const qc = da['yt-player-state-change'];
  3543.  
  3544.  
  3545. let isQcChanged = false;
  3546.  
  3547. if (qc === 2) { isQcChanged = qc !== _playerState; _playerState = 2; relayCount = 0; } // paused
  3548. else if (qc === 3) { isQcChanged = qc !== _playerState; _playerState = 3; } // playing
  3549. else if (qc === 1) { isQcChanged = qc !== _playerState; _playerState = 1; } // playing
  3550.  
  3551.  
  3552. if ((isQcChanged) && playerState !== _playerState) {
  3553. playerEventsByIframeRelay = true;
  3554. onPlayStateChangePromise = new Promise((resolve) => {
  3555. let k = _playerState;
  3556. foregroundPromiseFn().then(() => {
  3557. if (k === _playerState && playerState !== _playerState) playerState = _playerState;
  3558. onPlayStateChangePromise = null;
  3559. resolve();
  3560. })
  3561. }).catch(console.warn);
  3562.  
  3563. }
  3564.  
  3565. } else if ('yt-player-video-progress' in da) {
  3566. const vp = da['yt-player-video-progress'];
  3567.  
  3568.  
  3569. relayCount++;
  3570. lastPlayerProgress = vp > 0 ? vp : 0;
  3571.  
  3572.  
  3573. if (relayPromise && vp > 0 && relayCount >= 2) {
  3574. if (onPlayStateChangePromise) {
  3575. onPlayStateChangePromise.then(() => {
  3576. relayPromise && relayPromise.resolve();
  3577. relayPromise = null;
  3578. })
  3579. } else {
  3580. relayPromise.resolve();
  3581. relayPromise = null;
  3582. }
  3583. }
  3584.  
  3585. }
  3586.  
  3587. return this.handlePostMessage66_(a);
  3588.  
  3589. }).catch(console.warn);
  3590.  
  3591. }
  3592.  
  3593. cProto.handlePostMessage_ = function (a) {
  3594.  
  3595. const da = (a || 0).data || 0;
  3596.  
  3597. if (typeof da !== 'object') return;
  3598.  
  3599. if (waitForInitialDataCompletion === 1) return;
  3600.  
  3601. if (!isPlayProgressTriggered) {
  3602. isPlayProgressTriggered = true;
  3603.  
  3604. if ('yt-player-video-progress' in da) {
  3605. waitForInitialDataCompletion = 1;
  3606.  
  3607. const wrapWith = (data) => {
  3608. const { origin } = a;
  3609. return {
  3610. origin,
  3611. data
  3612. };
  3613. }
  3614.  
  3615. this.handlePostMessage67_(wrapWith({
  3616. "yt-iframed-parent-ready": true
  3617. }));
  3618.  
  3619. playEventsStack = playEventsStack.then(() => {
  3620.  
  3621. const lcr = document.querySelector('yt-live-chat-renderer');
  3622. const psc = document.querySelector("yt-player-seek-continuation");
  3623. if (lcr && psc && lcr.replayBuffer_) {
  3624.  
  3625. const rbProgress = lcr.replayBuffer_.lastVideoOffsetTimeMsec;
  3626. const daProgress = da['yt-player-video-progress'] * 1000
  3627. // document.querySelector('yt-live-chat-renderer').playerProgressChanged_(1e-5);
  3628.  
  3629. const front_ = (lcr.replayBuffer_.replayQueue || 0).front_;
  3630. const back_ = (lcr.replayBuffer_.replayQueue || 0).back_;
  3631.  
  3632. // console.log(deepCopy( front_))
  3633. // console.log(deepCopy( back_))
  3634. // console.log(rbProgress, daProgress, )
  3635. if (front_ && back_ && rbProgress > daProgress && back_.length > 2 && back_.some(e => e && +e.videoOffsetTimeMsec > daProgress) && back_.some(e => e && +e.videoOffsetTimeMsec < daProgress)) {
  3636. // no action
  3637. // console.log('ss1')
  3638. } else if (rbProgress < daProgress + 3400 && rbProgress > daProgress - 1200) {
  3639. // daProgress - 1200 < rbProgress < daProgress + 3400
  3640. // console.log('ss2')
  3641. } else {
  3642.  
  3643. lcr.previousProgressSec = 1E-5;
  3644. // lcr._setIsSeeking(!0),
  3645. lcr.replayBuffer_.clear()
  3646. psc.fireSeekContinuation_(da['yt-player-video-progress']);
  3647. }
  3648.  
  3649. }
  3650.  
  3651. waitForInitialDataCompletion = 2;
  3652.  
  3653. this.handlePostMessage_(a);
  3654.  
  3655. }).catch(console.warn);
  3656.  
  3657. return;
  3658.  
  3659. }
  3660.  
  3661. }
  3662.  
  3663.  
  3664.  
  3665. this.handlePostMessage67_(a);
  3666.  
  3667.  
  3668.  
  3669. }
  3670.  
  3671. }
  3672.  
  3673.  
  3674. })();
  3675.  
  3676. }
  3677.  
  3678. if (isFirstList && DO_CHECK_TICKER_BACKGROUND_OVERRIDED) {
  3679. asyncTickerBackgroundOverridedChecker();
  3680. }
  3681.  
  3682. }
  3683. }
  3684.  
  3685. return { setupMutObserver };
  3686.  
  3687.  
  3688.  
  3689. })();
  3690.  
  3691. const setupEvents = () => {
  3692.  
  3693.  
  3694. let scrollCount = 0;
  3695.  
  3696. const passiveCapture = typeof IntersectionObserver === 'function' ? { capture: true, passive: true } : true;
  3697.  
  3698.  
  3699. const delayFlushActiveItemsAfterUserActionK_ = () => {
  3700.  
  3701. const lcRenderer = lcRendererElm();
  3702. if (lcRenderer) {
  3703. const cnt = insp(lcRenderer);
  3704. if (!cnt.hasUserJustInteracted11_) return;
  3705. if (cnt.atBottom && cnt.allowScroll && cnt.activeItems_.length >= 1 && cnt.hasUserJustInteracted11_()) {
  3706. cnt.delayFlushActiveItemsAfterUserAction11_ && cnt.delayFlushActiveItemsAfterUserAction11_();
  3707. }
  3708. }
  3709.  
  3710. }
  3711.  
  3712. document.addEventListener('scroll', (evt) => {
  3713. if (!evt || !evt.isTrusted) return;
  3714. // lastScroll = dateNow();
  3715. if (++scrollCount > 1e9) scrollCount = 9;
  3716. }, passiveCapture); // support contain => support passive
  3717.  
  3718. let lastScrollCount = -1;
  3719. document.addEventListener('wheel', (evt) => {
  3720. if (!evt || !evt.isTrusted) return;
  3721. if (lastScrollCount === scrollCount) return;
  3722. lastScrollCount = scrollCount;
  3723. lastWheel = dateNow();
  3724. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3725. }, passiveCapture); // support contain => support passive
  3726.  
  3727. document.addEventListener('mousedown', (evt) => {
  3728. if (!evt || !evt.isTrusted) return;
  3729. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  3730. lastMouseDown = dateNow();
  3731. currentMouseDown = true;
  3732. lastUserInteraction = lastMouseDown;
  3733. }, passiveCapture);
  3734.  
  3735. document.addEventListener('pointerdown', (evt) => {
  3736. if (!evt || !evt.isTrusted) return;
  3737. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  3738. lastMouseDown = dateNow();
  3739. currentMouseDown = true;
  3740. lastUserInteraction = lastMouseDown;
  3741. }, passiveCapture);
  3742.  
  3743. document.addEventListener('click', (evt) => {
  3744. if (!evt || !evt.isTrusted) return;
  3745. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  3746. lastMouseDown = lastMouseUp = dateNow();
  3747. currentMouseDown = false;
  3748. lastUserInteraction = lastMouseDown;
  3749. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3750. }, passiveCapture);
  3751.  
  3752. document.addEventListener('tap', (evt) => {
  3753. if (!evt || !evt.isTrusted) return;
  3754. if (((evt || 0).target || 0).id !== 'item-scroller') return;
  3755. lastMouseDown = lastMouseUp = dateNow();
  3756. currentMouseDown = false;
  3757. lastUserInteraction = lastMouseDown;
  3758. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3759. }, passiveCapture);
  3760.  
  3761.  
  3762. document.addEventListener('mouseup', (evt) => {
  3763. if (!evt || !evt.isTrusted) return;
  3764. if (currentMouseDown) {
  3765. lastMouseUp = dateNow();
  3766. currentMouseDown = false;
  3767. lastUserInteraction = lastMouseUp;
  3768. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3769. }
  3770. }, passiveCapture);
  3771.  
  3772.  
  3773. document.addEventListener('pointerup', (evt) => {
  3774. if (!evt || !evt.isTrusted) return;
  3775. if (currentMouseDown) {
  3776. lastMouseUp = dateNow();
  3777. currentMouseDown = false;
  3778. lastUserInteraction = lastMouseUp;
  3779. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3780. }
  3781. }, passiveCapture);
  3782.  
  3783. document.addEventListener('touchstart', (evt) => {
  3784. if (!evt || !evt.isTrusted) return;
  3785. lastTouchDown = dateNow();
  3786. currentTouchDown = true;
  3787. lastUserInteraction = lastTouchDown;
  3788. }, passiveCapture);
  3789.  
  3790. document.addEventListener('touchmove', (evt) => {
  3791. if (!evt || !evt.isTrusted) return;
  3792. lastTouchDown = dateNow();
  3793. currentTouchDown = true;
  3794. lastUserInteraction = lastTouchDown;
  3795. }, passiveCapture);
  3796.  
  3797. document.addEventListener('touchend', (evt) => {
  3798. if (!evt || !evt.isTrusted) return;
  3799. if (currentTouchDown) {
  3800. lastTouchUp = dateNow();
  3801. currentTouchDown = false;
  3802. lastUserInteraction = lastTouchUp;
  3803. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3804. }
  3805. }, passiveCapture);
  3806.  
  3807. document.addEventListener('touchcancel', (evt) => {
  3808. if (!evt || !evt.isTrusted) return;
  3809. if (currentTouchDown) {
  3810. lastTouchUp = dateNow();
  3811. currentTouchDown = false;
  3812. lastUserInteraction = lastTouchUp;
  3813. delayFlushActiveItemsAfterUserActionK_ && delayFlushActiveItemsAfterUserActionK_();
  3814. }
  3815. }, passiveCapture);
  3816.  
  3817.  
  3818. }
  3819.  
  3820. const getTimestampUsec = (itemRenderer) => {
  3821. if (itemRenderer && 'timestampUsec' in itemRenderer) {
  3822. return itemRenderer.timestampUsec
  3823. } else if (itemRenderer && itemRenderer.showItemEndpoint) {
  3824. const messageRenderer = ((itemRenderer.showItemEndpoint.showLiveChatItemEndpoint || 0).renderer || 0);
  3825. if (messageRenderer) {
  3826.  
  3827. const messageRendererKey = firstObjectKey(messageRenderer);
  3828. if (messageRendererKey && messageRenderer[messageRendererKey]) {
  3829. const messageRendererData = messageRenderer[messageRendererKey];
  3830. if (messageRendererData && 'timestampUsec' in messageRendererData) {
  3831. return messageRendererData.timestampUsec
  3832. }
  3833. }
  3834. }
  3835. }
  3836. return null;
  3837. }
  3838.  
  3839. const onRegistryReadyForDOMOperations = () => {
  3840.  
  3841. let firstCheckedOnYtInit = false;
  3842.  
  3843. const assertorURL = () => assertor(() => location.pathname.startsWith('/live_chat') && (location.search.indexOf('continuation=') > 0 || location.search.indexOf('v=') > 0));
  3844.  
  3845. const mightFirstCheckOnYtInit = () => {
  3846. if (firstCheckedOnYtInit) return;
  3847. firstCheckedOnYtInit = true;
  3848.  
  3849. if (!document.body || !document.head) return;
  3850. if (!assertorURL()) return;
  3851.  
  3852. addCssManaged();
  3853.  
  3854. let efsContainer = document.getElementById('elzm-fonts-yk75g');
  3855. if (efsContainer && efsContainer.parentNode !== document.body) {
  3856. document.body.appendChild(efsContainer);
  3857. }
  3858.  
  3859. };
  3860.  
  3861. if (!assertorURL()) return;
  3862. // if (!assertor(() => document.getElementById('yt-masthead') === null)) return;
  3863.  
  3864. if (document.documentElement && document.head) {
  3865. addCssManaged();
  3866. }
  3867. // console.log(document.body===null)
  3868.  
  3869. if (ATTEMPT_TICKER_ANIMATION_START_TIME_DETECTION) {
  3870. getLCRDummy().then(async (lcrDummy) => {
  3871.  
  3872. const tag = "yt-live-chat-renderer"
  3873. const dummy = lcrDummy;
  3874.  
  3875. const cProto = getProto(dummy);
  3876. if (!cProto || !cProto.attached) {
  3877. console.warn(`proto.attached for ${tag} is unavailable.`);
  3878. return;
  3879. }
  3880.  
  3881. mightFirstCheckOnYtInit();
  3882. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-renderer hacks");
  3883. console.log("[Begin]");
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890. if (typeof cProto.playerProgressChanged_ === 'function' && !cProto.playerProgressChanged32_) {
  3891.  
  3892. cProto.playerProgressChanged32_ = cProto.playerProgressChanged_;
  3893.  
  3894. const pop078 = function () {
  3895. const r = this.pop78();
  3896.  
  3897. if (r && (r.actions || 0).length >= 1 && r.videoOffsetTimeMsec) {
  3898. for (const action of r.actions) {
  3899.  
  3900. const itemActionKey = !action ? null : 'addChatItemAction' in action ? 'addChatItemAction' : 'addLiveChatTickerItemAction' in action ? 'addLiveChatTickerItemAction' : null;
  3901. if (itemActionKey) {
  3902.  
  3903. const itemAction = action[itemActionKey];
  3904. const item = (itemAction || 0).item;
  3905. if (typeof item === 'object') {
  3906.  
  3907. const rendererKey = firstObjectKey(item);
  3908. if (rendererKey) {
  3909. const renderer = item[rendererKey];
  3910. if (renderer && typeof renderer === 'object') {
  3911. renderer.__videoOffsetTimeMsec__ = r.videoOffsetTimeMsec;
  3912. renderer.__progressAt__ = playerProgressChangedArg1;
  3913. }
  3914.  
  3915. }
  3916.  
  3917. }
  3918. }
  3919. }
  3920. }
  3921. return r;
  3922. }
  3923.  
  3924. cProto.playerProgressChanged_ = function (a, b, c) {
  3925. playerProgressChangedArg1 = a;
  3926. playerProgressChangedArg2 = b;
  3927. playerProgressChangedArg3 = c;
  3928. const replayBuffer_ = this.replayBuffer_;
  3929. if (replayBuffer_) {
  3930. const replayQueue = replayBuffer_.replayQueue
  3931. if (replayQueue && typeof replayQueue === 'object' && !replayQueue.qe3) {
  3932.  
  3933. replayBuffer_.replayQueue = new Proxy(replayBuffer_.replayQueue, {
  3934. get(target, prop, receiver) {
  3935. if (prop === 'qe3') return 1;
  3936. const v = target[prop];
  3937. if (prop === 'front_') {
  3938. if (v && typeof v.length === 'number') {
  3939. if (!v.pop78) {
  3940. v.pop78 = v.pop;
  3941. v.pop = pop078;
  3942. }
  3943. }
  3944. }
  3945. return v;
  3946. }
  3947. });
  3948.  
  3949. }
  3950. }
  3951. return this.playerProgressChanged32_.apply(this, arguments);
  3952. };
  3953.  
  3954. }
  3955.  
  3956. console.log("[End]");
  3957. console.groupEnd();
  3958.  
  3959.  
  3960. });
  3961.  
  3962. }
  3963.  
  3964. customElements.whenDefined('yt-live-chat-item-list-renderer').then(() => {
  3965.  
  3966. const tag = "yt-live-chat-item-list-renderer"
  3967. const dummy = document.createElement(tag);
  3968.  
  3969. const cProto = getProto(dummy);
  3970. if (!cProto || !cProto.attached) {
  3971. console.warn(`proto.attached for ${tag} is unavailable.`);
  3972. return;
  3973. }
  3974.  
  3975. mightFirstCheckOnYtInit();
  3976. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-item-list-renderer hacks");
  3977. console.log("[Begin]");
  3978.  
  3979. const mclp = cProto;
  3980. try {
  3981. assertor(() => typeof mclp.scrollToBottom_ === 'function');
  3982. assertor(() => typeof mclp.flushActiveItems_ === 'function');
  3983. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  3984. assertor(() => typeof mclp.setAtBottom === 'function');
  3985. assertor(() => typeof mclp.scrollToBottom66_ === 'undefined');
  3986. assertor(() => typeof mclp.flushActiveItems66_ === 'undefined');
  3987. } catch (e) { }
  3988.  
  3989.  
  3990. try {
  3991. assertor(() => typeof mclp.attached === 'function');
  3992. assertor(() => typeof mclp.detached === 'function');
  3993. assertor(() => typeof mclp.canScrollToBottom_ === 'function');
  3994. assertor(() => typeof mclp.isSmoothScrollEnabled_ === 'function');
  3995. assertor(() => typeof mclp.maybeResizeScrollContainer_ === 'function');
  3996. assertor(() => typeof mclp.refreshOffsetContainerHeight_ === 'function');
  3997. assertor(() => typeof mclp.smoothScroll_ === 'function');
  3998. assertor(() => typeof mclp.resetSmoothScroll_ === 'function');
  3999. } catch (e) { }
  4000.  
  4001. mclp.__intermediate_delay__ = null;
  4002.  
  4003. let myk = 0;
  4004. let mlf = 0;
  4005. let myw = 0;
  4006. let mzt = 0;
  4007. let zarr = null;
  4008. let mlg = 0;
  4009.  
  4010. if ((mclp._flag0281_ & 0x2000) == 0) {
  4011.  
  4012. if ((mclp.clearList || 0).length === 0) {
  4013. (mclp._flag0281_ & 0x2) == 0 && assertor(() => fnIntegrity(mclp.clearList, '0.106.50'));
  4014. mclp.clearList66 = mclp.clearList;
  4015. mclp.clearList = function () {
  4016. myk++;
  4017. mlf++;
  4018. myw++;
  4019. mzt++;
  4020. mlg++;
  4021. zarr = null;
  4022. this.__intermediate_delay__ = null;
  4023. this.clearList66();
  4024. };
  4025. console.log("clearList", "OK");
  4026. } else {
  4027. console.log("clearList", "NG");
  4028. }
  4029.  
  4030. }
  4031.  
  4032.  
  4033.  
  4034. let onListRendererAttachedDone = false;
  4035.  
  4036. function setList(itemOffset, items) {
  4037.  
  4038. const isFirstTime = onListRendererAttachedDone === false;
  4039.  
  4040. if (isFirstTime) {
  4041. onListRendererAttachedDone = true;
  4042. Promise.resolve().then(watchUserCSS);
  4043. addCssManaged();
  4044. setupEvents();
  4045. }
  4046.  
  4047. setupStyle(itemOffset, items);
  4048.  
  4049. setupMutObserver(items);
  4050. }
  4051.  
  4052. mclp.attached419 = async function () {
  4053.  
  4054. if (!this.isAttached) return;
  4055.  
  4056. let maxTrial = 16;
  4057. while (!this.$ || !this.$['item-scroller'] || !this.$['item-offset'] || !this.$['items']) {
  4058. if (--maxTrial < 0 || !this.isAttached) return;
  4059. await iAFP(this.hostElement).then();
  4060. // await new Promise(requestAnimationFrame);
  4061. }
  4062.  
  4063. if (this.isAttached !== true) return;
  4064.  
  4065. if (!this.$) {
  4066. console.warn("!this.$");
  4067. return;
  4068. }
  4069. if (!this.$) return;
  4070. /** @type {HTMLElement | null} */
  4071. const itemScroller = this.$['item-scroller'];
  4072. /** @type {HTMLElement | null} */
  4073. const itemOffset = this.$['item-offset'];
  4074. /** @type {HTMLElement | null} */
  4075. const items = this.$['items'];
  4076.  
  4077. if (!itemScroller || !itemOffset || !items) {
  4078. console.warn("items.parentNode !== itemOffset");
  4079. return;
  4080. }
  4081.  
  4082. if (nodeParent(items) !== itemOffset) {
  4083.  
  4084. console.warn("items.parentNode !== itemOffset");
  4085. return;
  4086. }
  4087.  
  4088.  
  4089. if (items.id !== 'items' || itemOffset.id !== "item-offset") {
  4090.  
  4091. console.warn("id incorrect");
  4092. return;
  4093. }
  4094.  
  4095. 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')
  4096.  
  4097. if (!isTargetItems) {
  4098. console.warn("!isTargetItems");
  4099. return;
  4100. }
  4101.  
  4102. setList(itemOffset, items);
  4103.  
  4104. }
  4105.  
  4106. mclp.attached331 = mclp.attached;
  4107. mclp.attached = function () {
  4108. this.attached419 && this.attached419();
  4109. return this.attached331();
  4110. }
  4111.  
  4112. mclp.detached331 = mclp.detached;
  4113.  
  4114. mclp.detached = function () {
  4115. setupMutObserver();
  4116. return this.detached331();
  4117. }
  4118.  
  4119. const t29s = document.querySelectorAll("yt-live-chat-item-list-renderer");
  4120. for (const t29 of t29s) {
  4121. if (insp(t29).isAttached === true) {
  4122. t29.attached419();
  4123. }
  4124. }
  4125.  
  4126. if ((mclp.async || 0).length === 2 && (mclp.cancelAsync || 0).length === 1) {
  4127.  
  4128. assertor(() => fnIntegrity(mclp.async, '2.24.15'));
  4129. assertor(() => fnIntegrity(mclp.cancelAsync, '1.15.8'));
  4130.  
  4131. /** @type {Map<number, any>} */
  4132. const aMap = new Map();
  4133. let count = 6150;
  4134. mclp.async66 = mclp.async;
  4135. mclp.async = function (e, f) {
  4136. // ensure the previous operation is done
  4137. // .async is usually after the time consuming functions like flushActiveItems_ and scrollToBottom_
  4138. const hasF = arguments.length === 2;
  4139. const stack = new Error().stack;
  4140. const isFlushAsync = stack.indexOf('flushActiveItems_') >= 0;
  4141. if (count > 1e9) count = 6159;
  4142. const resId = ++count;
  4143. aMap.set(resId, e);
  4144. (this.__intermediate_delay__ || Promise.resolve()).then(rk => {
  4145. const rp = aMap.get(resId);
  4146. if (typeof rp !== 'function') {
  4147. return;
  4148. }
  4149. let cancelCall = false;
  4150. if (isFlushAsync) {
  4151. if (rk < 0) {
  4152. cancelCall = true;
  4153. } else if (rk === 2 && arguments[0] === this.maybeScrollToBottom_) {
  4154. cancelCall = true;
  4155. }
  4156. }
  4157. if (cancelCall) {
  4158. aMap.delete(resId);
  4159. } else {
  4160. const asyncEn = function () {
  4161. aMap.delete(resId);
  4162. return rp.apply(this, arguments);
  4163. };
  4164. aMap.set(resId, hasF ? this.async66(asyncEn, f) : this.async66(asyncEn));
  4165. }
  4166. });
  4167.  
  4168. return resId;
  4169. }
  4170.  
  4171. mclp.cancelAsync66 = mclp.cancelAsync;
  4172. mclp.cancelAsync = function (resId) {
  4173. if (resId <= 6150) {
  4174. this.cancelAsync66(resId);
  4175. } else if (aMap.has(resId)) {
  4176. const rp = aMap.get(resId);
  4177. aMap.delete(resId);
  4178. if (typeof rp !== 'function') {
  4179. this.cancelAsync66(rp);
  4180. }
  4181. }
  4182. }
  4183.  
  4184. console.log("async", "OK");
  4185. } else {
  4186. console.log("async", "NG");
  4187. }
  4188.  
  4189.  
  4190. if ((mclp._flag0281_ & 0x2) == 0) {
  4191. if ((mclp.showNewItems_ || 0).length === 0 && ENABLE_NO_SMOOTH_TRANSFORM) {
  4192.  
  4193. assertor(() => fnIntegrity(mclp.showNewItems_, '0.170.79'));
  4194. mclp.showNewItems66_ = mclp.showNewItems_;
  4195.  
  4196. mclp.showNewItems77_ = async function () {
  4197. if (myk > 1e9) myk = 9;
  4198. let tid = ++myk;
  4199.  
  4200. await iAFP(this.hostElement).then();
  4201. // await new Promise(requestAnimationFrame);
  4202.  
  4203. if (tid !== myk) {
  4204. return;
  4205. }
  4206.  
  4207. const cnt = this;
  4208.  
  4209. await Promise.resolve();
  4210. cnt.showNewItems66_();
  4211.  
  4212. await Promise.resolve();
  4213.  
  4214. }
  4215.  
  4216. mclp.showNewItems_ = function () {
  4217.  
  4218. const cnt = this;
  4219. cnt.__intermediate_delay__ = new Promise(resolve => {
  4220. cnt.showNewItems77_().then(() => {
  4221. resolve();
  4222. });
  4223. });
  4224. }
  4225.  
  4226. console.log("showNewItems_", "OK");
  4227. } else {
  4228. console.log("showNewItems_", "NG");
  4229. }
  4230.  
  4231. }
  4232.  
  4233. if ((mclp._flag0281_ & 0x2000) == 0) {
  4234. if ((mclp.flushActiveItems_ || 0).length === 0) {
  4235.  
  4236. if ((mclp._flag0281_ & 0x2) == 0) {
  4237.  
  4238. const sfi = fnIntegrity(mclp.flushActiveItems_);
  4239. if (sfi === '0.156.86') {
  4240. // https://www.youtube.com/s/desktop/f61c8d85/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4241.  
  4242. // added "refreshOffsetContainerHeight_"
  4243.  
  4244. // f.flushActiveItems_ = function() {
  4245. // var a = this;
  4246. // if (0 < this.activeItems_.length)
  4247. // if (this.canScrollToBottom_()) {
  4248. // var b = Math.max(this.visibleItems.length + this.activeItems_.length - this.data.maxItemsToDisplay, 0);
  4249. // b && this.splice("visibleItems", 0, b);
  4250. // if (this.isSmoothScrollEnabled_() || this.dockableMessages.length)
  4251. // this.preinsertHeight_ = this.items.clientHeight;
  4252. // this.activeItems_.unshift("visibleItems");
  4253. // try {
  4254. // this.push.apply(this, this.activeItems_)
  4255. // } catch (c) {
  4256. // fm(c)
  4257. // }
  4258. // this.activeItems_ = [];
  4259. // this.isSmoothScrollEnabled_() ? this.canScrollToBottom_() && Mw(function() {
  4260. // a.showNewItems_()
  4261. // }) : Mw(function() {
  4262. // a.refreshOffsetContainerHeight_();
  4263. // a.maybeScrollToBottom_()
  4264. // })
  4265. // } else
  4266. // this.activeItems_.length > this.data.maxItemsToDisplay && this.activeItems_.splice(0, this.activeItems_.length - this.data.maxItemsToDisplay)
  4267. // }
  4268. // ;
  4269.  
  4270. } else if (sfi === '0.150.84') {
  4271. // https://www.youtube.com/s/desktop/e4d15d2c/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4272. // var b = Math.max(this.visibleItems.length + this.activeItems_.length - this.data.maxItemsToDisplay, 0);
  4273. // b && this.splice("visibleItems", 0, b);
  4274. // if (this.isSmoothScrollEnabled_() || this.dockableMessages.length)
  4275. // this.preinsertHeight_ = this.items.clientHeight;
  4276. // this.activeItems_.unshift("visibleItems");
  4277. // try {
  4278. // this.push.apply(this, this.activeItems_)
  4279. // } catch (c) {
  4280. // nm(c)
  4281. // }
  4282. // this.activeItems_ = [];
  4283. // this.isSmoothScrollEnabled_() ? this.canScrollToBottom_() && zQ(function() {
  4284. // a.showNewItems_()
  4285. // }) : zQ(function() {
  4286. // a.maybeScrollToBottom_()
  4287. // })
  4288. } else if (sfi === '0.137.81' || sfi === '0.138.81') {
  4289. // e.g. https://www.youtube.com/yts/jsbin/live_chat_polymer-vflCyWEBP/live_chat_polymer.js
  4290. } else {
  4291. assertor(() => fnIntegrity(mclp.flushActiveItems_, '0.150.84'));
  4292. }
  4293. }
  4294.  
  4295. let hasMoreMessageState = !ENABLE_SHOW_MORE_BLINKER ? -1 : 0;
  4296.  
  4297. mclp.flushActiveItems66_ = mclp.flushActiveItems_;
  4298.  
  4299.  
  4300. const preloadFn = (acItems) => {
  4301. let waitFor = [];
  4302. /** @type {Set<string>} */
  4303. const imageLinks = new Set();
  4304.  
  4305. if (ENABLE_PRELOAD_THUMBNAIL || EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL) {
  4306. for (const item of acItems) {
  4307. fixLiveChatItem(item, imageLinks);
  4308. }
  4309. }
  4310. if (ENABLE_PRELOAD_THUMBNAIL && kptPF !== null && (kptPF & (8 | 4)) && imageLinks.size > 0) {
  4311.  
  4312. // reference: https://github.com/Yuanfang-fe/Blog-X/issues/34
  4313. const rel = kptPF & 8 ? 'subresource' : kptPF & 16 ? 'preload' : kptPF & 4 ? 'prefetch' : '';
  4314. // preload performs the high priority fetching.
  4315. // prefetch delays the chat display if the video resoruce is demanding.
  4316.  
  4317. if (rel) {
  4318.  
  4319. imageLinks.forEach(imageLink => {
  4320. let d = false;
  4321. if (SKIP_PRELOAD_EMOJI && imageLink.includes('.ggpht.com/')) return;
  4322. const isEmoji = imageLink.includes('/emoji/');
  4323. const pretechedSet = isEmoji ? emojiPrefetched : authorPhotoPrefetched;
  4324. if (!pretechedSet.has(imageLink)) {
  4325. pretechedSet.add(imageLink);
  4326. d = true;
  4327. }
  4328. if (d) {
  4329. waitFor.push(linker(null, rel, imageLink, 'image'));
  4330.  
  4331. }
  4332. })
  4333.  
  4334. }
  4335.  
  4336. }
  4337.  
  4338. return async () => {
  4339. if (waitFor.length > 0) {
  4340. await Promise.race([new Promise(r => setTimeout(r, 250)), Promise.all(waitFor)]);
  4341. }
  4342. waitFor.length = 0;
  4343. waitFor = null;
  4344. };
  4345.  
  4346. };
  4347.  
  4348. mclp.flushActiveItems78_ = async function (tid) {
  4349. try {
  4350.  
  4351. if (tid !== mlf) return;
  4352. if ((this._flag0281_ & 0x4) == 0x4) {
  4353. const cnt = this;
  4354.  
  4355. if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4356. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return;
  4357.  
  4358. mlf++;
  4359. if (mlg > 1e9) mlg = 9;
  4360. ++mlg;
  4361. const acItems = cnt.activeItems_;
  4362. if (acItems.length < MAX_ITEMS_FOR_FULL_FLUSH) {
  4363. const pn = preloadFn(acItems);
  4364. await pn();
  4365. }
  4366. cnt.flushActiveItems66_();
  4367.  
  4368. return 1;
  4369.  
  4370. }
  4371. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  4372. let logger = false;
  4373. const cnt = this;
  4374. let immd = cnt.__intermediate_delay__;
  4375. await iAFP(this.hostElement).then();
  4376. // await new Promise(requestAnimationFrame);
  4377.  
  4378. if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4379. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return;
  4380.  
  4381. mlf++;
  4382. if (mlg > 1e9) mlg = 9;
  4383. ++mlg;
  4384.  
  4385. const tmpMaxItemsCount = this.data.maxItemsToDisplay;
  4386. const reducedMaxItemsToDisplay = MAX_ITEMS_FOR_FULL_FLUSH;
  4387. let changeMaxItemsToDisplay = false;
  4388. const activeItemsLen = this.activeItems_.length;
  4389. if (activeItemsLen > tmpMaxItemsCount && tmpMaxItemsCount > 0) {
  4390. logger = true;
  4391.  
  4392. groupCollapsed("YouTube Super Fast Chat", " | flushActiveItems78_");
  4393.  
  4394. logger && console.log('[Begin]')
  4395.  
  4396. console.log('this.activeItems_.length > N', activeItemsLen, tmpMaxItemsCount);
  4397. if (ENABLE_REDUCED_MAXITEMS_FOR_FLUSH && lockedMaxItemsToDisplay === tmpMaxItemsCount && lockedMaxItemsToDisplay !== reducedMaxItemsToDisplay) {
  4398. console.log('reduce maxitems');
  4399. if (tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  4400. // as all the rendered chats are already "outdated"
  4401. // all old chats shall remove and reduced number of few chats will be rendered
  4402. // then restore to the original number
  4403. changeMaxItemsToDisplay = true;
  4404. this.data.maxItemsToDisplay = reducedMaxItemsToDisplay;
  4405. console.log(`'maxItemsToDisplay' is reduced from ${tmpMaxItemsCount} to ${reducedMaxItemsToDisplay}.`)
  4406. }
  4407. this.activeItems_.splice(0, activeItemsLen - this.data.maxItemsToDisplay);
  4408. // console.log('changeMaxItemsToDisplay 01', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  4409.  
  4410. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  4411. } else {
  4412. this.activeItems_.splice(0, activeItemsLen - (tmpMaxItemsCount < 900 ? tmpMaxItemsCount : 900));
  4413.  
  4414. console.log('new this.activeItems_.length > N', this.activeItems_.length);
  4415. }
  4416. }
  4417. // it is found that it will render all stacked chats after switching back from background
  4418. // to avoid lagging in popular livestream with massive chats, trim first before rendering.
  4419. // this.activeItems_.length > this.data.maxItemsToDisplay && this.activeItems_.splice(0, this.activeItems_.length - this.data.maxItemsToDisplay);
  4420.  
  4421. cnt.__intermediate_delay__ = Promise.all([cnt.__intermediate_delay__ || null, immd || null]);
  4422. await Promise.resolve();
  4423. const acItems = cnt.activeItems_;
  4424. const len1 = acItems.length;
  4425. if (!len1) console.warn('cnt.activeItems_.length = 0');
  4426.  
  4427. const pn = preloadFn(acItems);
  4428. const noVisibleItem1 = ((cnt.visibleItems || 0).length || 0) === 0;
  4429. skipDontRender = noVisibleItem1;
  4430. await pn();
  4431. // console.log('ss2', Date.now())
  4432. cnt.flushActiveItems66_();
  4433. const noVisibleItem2 = ((cnt.visibleItems || 0).length || 0) === 0;
  4434. skipDontRender = noVisibleItem2;
  4435. await Promise.resolve();
  4436. if (changeMaxItemsToDisplay && this.data.maxItemsToDisplay === reducedMaxItemsToDisplay && tmpMaxItemsCount > reducedMaxItemsToDisplay) {
  4437. this.data.maxItemsToDisplay = tmpMaxItemsCount;
  4438.  
  4439. logger && console.log(`'maxItemsToDisplay' is restored from ${reducedMaxItemsToDisplay} to ${tmpMaxItemsCount}.`);
  4440. // console.log('changeMaxItemsToDisplay 02', this.data.maxItemsToDisplay, oMaxItemsToDisplay, reducedMaxItemsToDisplay)
  4441. } else if (changeMaxItemsToDisplay) {
  4442.  
  4443. logger && console.log(`'maxItemsToDisplay' cannot be restored`, {
  4444. maxItemsToDisplay: this.data.maxItemsToDisplay,
  4445. reducedMaxItemsToDisplay,
  4446. originalMaxItemsToDisplay: tmpMaxItemsCount
  4447. });
  4448. }
  4449. logger && console.log('[End]');
  4450.  
  4451. logger && console.groupEnd();
  4452.  
  4453. if (noVisibleItem1 && !noVisibleItem2) {
  4454. // fix possible no auto scroll issue.
  4455. !((cnt.__notRequired__ || 0) & 256) && setTimeout(() => cnt.setAtBottom(), 1);
  4456. }
  4457.  
  4458. if (!ENABLE_NO_SMOOTH_TRANSFORM) {
  4459.  
  4460.  
  4461. const ff = () => {
  4462.  
  4463. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4464. // if (tid !== mlf || cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4465. if (!cnt.atBottom && cnt.allowScroll && cnt.hasUserJustInteracted11_ && !cnt.hasUserJustInteracted11_()) {
  4466.  
  4467. if (typeof nextBrowserTick !== 'function') {
  4468. cnt.scrollToBottom_();
  4469. Promise.resolve().then(() => {
  4470. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4471. if (!cnt.canScrollToBottom_()) cnt.scrollToBottom_();
  4472. });
  4473. } else {
  4474. nextBrowserTick(() => {
  4475. if (cnt.isAttached === false || (cnt.hostElement || cnt).isConnected === false) return;
  4476. cnt.scrollToBottom_();
  4477. });
  4478. }
  4479.  
  4480. }
  4481. }
  4482.  
  4483. ff();
  4484.  
  4485.  
  4486. Promise.resolve().then(ff);
  4487.  
  4488. // requestAnimationFrame(ff);
  4489. } else if (true) { // it might not be sticky to bottom when there is a full refresh.
  4490.  
  4491. const knt = cnt;
  4492. if (!scrollChatFn) {
  4493. const cnt = knt;
  4494. const f = () => {
  4495. const itemScroller = cnt.itemScroller;
  4496. if (!itemScroller || itemScroller.isConnected === false || cnt.isAttached === false) return;
  4497. if (!cnt.atBottom) {
  4498. cnt.scrollToBottom_();
  4499. } else if (itemScroller.scrollTop === 0) { // not yet interacted by user; cannot stick to bottom
  4500. itemScroller.scrollTop = itemScroller.scrollHeight;
  4501. }
  4502. };
  4503. if (typeof nextBrowserTick !== 'function') {
  4504. scrollChatFn = () => Promise.resolve().then(f).then(f);
  4505. } else {
  4506. scrollChatFn = () => nextBrowserTick(f);
  4507. }
  4508. }
  4509.  
  4510. scrollChatFn();
  4511. }
  4512.  
  4513. return 1;
  4514.  
  4515.  
  4516. } catch (e) {
  4517. console.warn(e);
  4518. }
  4519. }
  4520.  
  4521. mclp.flushActiveItems77_ = function () {
  4522.  
  4523. return new Promise(resResolve => {
  4524. try {
  4525. const cnt = this;
  4526. if (mlf > 1e9) mlf = 9;
  4527. let tid = ++mlf;
  4528. const hostElement = cnt.hostElement || cnt;
  4529. if (tid !== mlf || cnt.isAttached === false || hostElement.isConnected === false) return resResolve();
  4530. if (!cnt.activeItems_ || cnt.activeItems_.length === 0) return resResolve();
  4531.  
  4532. // 4 times to maxItems to avoid frequent trimming.
  4533. // 1 ... 10 ... 20 ... 30 ... 40 ... 50 ... 60 => 16 ... 20 ... 30 ..... 60 ... => 16
  4534.  
  4535. const lockedMaxItemsToDisplay = this.data.maxItemsToDisplay944;
  4536. this.activeItems_.length > lockedMaxItemsToDisplay * 4 && lockedMaxItemsToDisplay > 4 && this.activeItems_.splice(0, this.activeItems_.length - lockedMaxItemsToDisplay - 1);
  4537. if (cnt.canScrollToBottom_()) {
  4538. cnt.mutexPromiseFA78 = (cnt.mutexPromiseFA78 || Promise.resolve())
  4539. .then(() => cnt.flushActiveItems78_(tid)) // async function
  4540. .then((asyncResult) => {
  4541. resResolve(asyncResult); // either undefined or 1
  4542. resResolve = null;
  4543. }).catch((e) => {
  4544. console.warn(e);
  4545. if (resResolve) resResolve();
  4546. });
  4547. } else {
  4548. resResolve(2);
  4549. resResolve = null;
  4550. }
  4551. } catch (e) {
  4552. console.warn(e);
  4553. if (resResolve) resResolve();
  4554. }
  4555.  
  4556.  
  4557. });
  4558.  
  4559. }
  4560.  
  4561. mclp.flushActiveItems_ = function () {
  4562. const cnt = this;
  4563.  
  4564. if (arguments.length !== 0 || !cnt.activeItems_ || !cnt.canScrollToBottom_) return cnt.flushActiveItems66_.apply(this, arguments);
  4565.  
  4566. if (cnt.activeItems_.length === 0) {
  4567. cnt.__intermediate_delay__ = null;
  4568. return;
  4569. }
  4570.  
  4571. const cntData = ((cnt || 0).data || 0);
  4572. if (cntData.maxItemsToDisplay944 === undefined) {
  4573. cntData.maxItemsToDisplay944 = null;
  4574. if (cntData.maxItemsToDisplay > MAX_ITEMS_FOR_TOTAL_DISPLAY) cntData.maxItemsToDisplay = MAX_ITEMS_FOR_TOTAL_DISPLAY;
  4575. cntData.maxItemsToDisplay944 = cntData.maxItemsToDisplay || null;
  4576. }
  4577.  
  4578. // ignore previous __intermediate_delay__ and create a new one
  4579. cnt.__intermediate_delay__ = new Promise(resolve => {
  4580. cnt.flushActiveItems77_().then(rt => { // either undefined or 1 or 2
  4581. if (rt === 1) {
  4582. resolve(1); // success, scroll to bottom
  4583. if (hasMoreMessageState === 1) {
  4584. hasMoreMessageState = 0;
  4585. const showMore = (cnt.$ || 0)['show-more'];
  4586. if (showMore) {
  4587. showMore.classList.remove('has-new-messages-miuzp');
  4588. }
  4589. }
  4590. }
  4591. else if (rt === 2) {
  4592. resolve(2); // success, trim
  4593. if (hasMoreMessageState === 0) {
  4594. hasMoreMessageState = 1;
  4595. const showMore = cnt.$['show-more'];
  4596. if (showMore) {
  4597. showMore.classList.add('has-new-messages-miuzp');
  4598. }
  4599. }
  4600. }
  4601. else resolve(-1); // skip
  4602. }).catch(e => {
  4603. console.warn(e);
  4604. });
  4605. });
  4606.  
  4607. }
  4608. console.log("flushActiveItems_", "OK");
  4609. } else {
  4610. console.log("flushActiveItems_", "NG");
  4611. }
  4612. }
  4613.  
  4614. if ((mclp._flag0281_ & 0x40) == 0) {
  4615.  
  4616. if (SUPPRESS_refreshOffsetContainerHeight_ && typeof mclp.refreshOffsetContainerHeight_ === 'function' && !mclp.refreshOffsetContainerHeight26_ && mclp.refreshOffsetContainerHeight_.length === 0) {
  4617. assertor(() => fnIntegrity(mclp.refreshOffsetContainerHeight_, '0.31.21'));
  4618. mclp.refreshOffsetContainerHeight26_ = mclp.refreshOffsetContainerHeight_;
  4619. mclp.refreshOffsetContainerHeight_ = function () {
  4620. // var a = this.itemScroller.clientHeight;
  4621. // this.itemOffset.style.height = this.items.clientHeight + "px";
  4622. // this.bottomAlignMessages && (this.itemOffset.style.minHeight = a + "px")
  4623. }
  4624. console.log("refreshOffsetContainerHeight_", "OK");
  4625. } else {
  4626. console.log("refreshOffsetContainerHeight_", "NG");
  4627. }
  4628.  
  4629. }
  4630.  
  4631. if ((mclp._flag0281_ & 0x80) == 0) {
  4632. mclp.delayFlushActiveItemsAfterUserAction11_ = async function () {
  4633. try {
  4634. if (mlg > 1e9) mlg = 9;
  4635. const tid = ++mlg;
  4636. const keepTrialCond = () => this.atBottom && this.allowScroll && (tid === mlg) && this.isAttached === true && this.activeItems_.length >= 1 && (this.hostElement || 0).isConnected === true;
  4637. const runCond = () => this.canScrollToBottom_();
  4638. if (!keepTrialCond()) return;
  4639. if (runCond()) return this.flushActiveItems_() | 1; // avoid return promise
  4640. await new Promise(r => setTimeout(r, 80));
  4641. if (!keepTrialCond()) return;
  4642. if (runCond()) return this.flushActiveItems_() | 1;
  4643. await iAFP(this.hostElement).then();
  4644. // await new Promise(requestAnimationFrame);
  4645. if (runCond()) return this.flushActiveItems_() | 1;
  4646. } catch (e) {
  4647. console.warn(e);
  4648. }
  4649. }
  4650. }
  4651.  
  4652. if ((mclp._flag0281_ & 0x40) == 0) {
  4653.  
  4654. if ((mclp.atBottomChanged_ || 0).length === 1) {
  4655. // note: if the scrolling is too frequent, the show more visibility might get wrong.
  4656.  
  4657. const sfi = fnIntegrity(mclp.atBottomChanged_);
  4658. if (sfi === '1.73.37') {
  4659. // https://www.youtube.com/s/desktop/e4d15d2c/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4660. } else if (sfi === '1.75.39') {
  4661. // e.g. https://www.youtube.com/yts/jsbin/live_chat_polymer-vflCyWEBP/live_chat_polymer.js
  4662. } else {
  4663. assertor(() => fnIntegrity(mclp.atBottomChanged_, '1.73.37'));
  4664. }
  4665.  
  4666. const querySelector = HTMLElement.prototype.querySelector;
  4667. const U = (element) => ({
  4668. querySelector: (selector) => querySelector.call(element, selector)
  4669. });
  4670.  
  4671. let qid = 0;
  4672. mclp.__updateButtonVisibility371__ = function (button) {
  4673. Promise.resolve().then(() => {
  4674. button.style.visibility = this.__buttonVisibility371__;
  4675. });
  4676. }
  4677. const fixButtonOnClick = function (cnt, button) {
  4678. button.addEventListener('click', (evt) => {
  4679. evt.stopImmediatePropagation();
  4680. evt.stopPropagation();
  4681. evt.preventDefault();
  4682. Promise.resolve().then(() => {
  4683. cnt.scrollToBottom_();
  4684. });
  4685. }, true);
  4686. // button.addEventListener('pointerup', (evt)=>{
  4687. // evt.stopImmediatePropagation();
  4688. // evt.stopPropagation();
  4689. // }, true);
  4690. // button.addEventListener('mouseup', (evt)=>{
  4691. // evt.stopImmediatePropagation();
  4692. // evt.stopPropagation();
  4693. // }, true);
  4694. }
  4695. mclp.atBottomChanged_ = function (a) {
  4696. const button = (this.$ || 0)['show-more'];
  4697. if (button) {
  4698. // primary execution
  4699. if (a) {
  4700. if (this.__buttonVisibility371__ !== "hidden") {
  4701. this.__buttonVisibility371__ = "hidden";
  4702. if (!this.hideShowMoreAsync_) {
  4703. const tid = ++qid;
  4704. this.hideShowMoreAsync_ = foregroundPromiseFn().then(() => {
  4705. if (tid !== qid) {
  4706. return;
  4707. }
  4708. this.__updateButtonVisibility371__(button);
  4709. });
  4710. }
  4711. }
  4712. } else {
  4713. if (this.__buttonVisibility371__ !== "visible") {
  4714. this.__buttonVisibility371__ = "visible";
  4715. if (this.hideShowMoreAsync_) {
  4716. qid++;
  4717. }
  4718. this.hideShowMoreAsync_ = null;
  4719. if (!button.__fix_onclick__) {
  4720. button.__fix_onclick__ = true;
  4721. fixButtonOnClick(this, button);
  4722. }
  4723. this.__updateButtonVisibility371__(button);
  4724. }
  4725. }
  4726. } else {
  4727. // fallback
  4728. let tid = ++qid;
  4729. let b = this;
  4730. a ? this.hideShowMoreAsync_ || (this.hideShowMoreAsync_ = this.async(function () {
  4731. if (tid !== qid) return;
  4732. U(b.hostElement).querySelector("#show-more").style.visibility = "hidden"
  4733. }, 200)) : (this.hideShowMoreAsync_ && this.cancelAsync(this.hideShowMoreAsync_),
  4734. this.hideShowMoreAsync_ = null,
  4735. U(this.hostElement).querySelector("#show-more").style.visibility = "visible")
  4736. }
  4737. }
  4738.  
  4739. console.log("atBottomChanged_", "OK");
  4740. } else {
  4741. console.log("atBottomChanged_", "NG");
  4742. }
  4743. }
  4744.  
  4745.  
  4746. if ((mclp._flag0281_ & 0x2) == 0) {
  4747. if ((mclp.onScrollItems_ || 0).length === 1) {
  4748.  
  4749. assertor(() => fnIntegrity(mclp.onScrollItems_, '1.17.9'));
  4750. mclp.onScrollItems66_ = mclp.onScrollItems_;
  4751. mclp.onScrollItems77_ = async function (evt) {
  4752. if (myw > 1e9) myw = 9;
  4753. let tid = ++myw;
  4754.  
  4755. await iAFP(this.hostElement).then();
  4756. // await new Promise(requestAnimationFrame);
  4757.  
  4758. if (tid !== myw) {
  4759. return;
  4760. }
  4761.  
  4762. const cnt = this;
  4763.  
  4764. await Promise.resolve();
  4765. if (USE_OPTIMIZED_ON_SCROLL_ITEMS) {
  4766. const onScrollItemsBasicOnly_ = !!((cnt.__notRequired__ || 0) & 512);
  4767. await Promise.resolve().then(() => {
  4768. this.ytRendererBehavior.onScroll(evt);
  4769. }).then(() => {
  4770. if (onScrollItemsBasicOnly_) return;
  4771. if (this.canScrollToBottom_()) {
  4772. const hasUserJustInteracted = this.hasUserJustInteracted11_ ? this.hasUserJustInteracted11_() : true;
  4773. if (hasUserJustInteracted) {
  4774. // only when there is an user action
  4775. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  4776. return 1;
  4777. }
  4778. } else {
  4779. // no message inserting
  4780. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  4781. return 1;
  4782. }
  4783. }).then((r) => {
  4784.  
  4785. if (onScrollItemsBasicOnly_) return;
  4786. if (this.activeItems_.length) {
  4787.  
  4788. if (this.canScrollToBottom_()) {
  4789. this.flushActiveItems_();
  4790. return 1 && r;
  4791. } else if (this.atBottom && this.allowScroll && (this.hasUserJustInteracted11_ && this.hasUserJustInteracted11_())) {
  4792. // delayed due to user action
  4793. this.delayFlushActiveItemsAfterUserAction11_ && this.delayFlushActiveItemsAfterUserAction11_();
  4794. return 0;
  4795. }
  4796. }
  4797. }).then((r) => {
  4798. if (onScrollItemsBasicOnly_) return;
  4799. if (r) {
  4800. // ensure setAtBottom is correctly set
  4801. !((cnt.__notRequired__ || 0) & 256) && this.setAtBottom();
  4802. }
  4803. });
  4804. } else {
  4805. cnt.onScrollItems66_(evt);
  4806. }
  4807.  
  4808. await Promise.resolve();
  4809.  
  4810. }
  4811.  
  4812. mclp.onScrollItems_ = function (evt) {
  4813.  
  4814. const cnt = this;
  4815. cnt.__intermediate_delay__ = new Promise(resolve => {
  4816. cnt.onScrollItems77_(evt).then(() => {
  4817. resolve();
  4818. });
  4819. });
  4820. }
  4821. console.log("onScrollItems_", "OK");
  4822. } else {
  4823. console.log("onScrollItems_", "NG");
  4824. }
  4825. }
  4826.  
  4827. if ((mclp._flag0281_ & 0x2) == 0) {
  4828. if ((mclp.handleLiveChatActions_ || 0).length === 1) {
  4829.  
  4830. const sfi = fnIntegrity(mclp.handleLiveChatActions_);
  4831. if (sfi === '1.39.20') {
  4832. // TBC
  4833. } else if (sfi === '1.31.17') {
  4834. // original
  4835. } else {
  4836. assertor(() => fnIntegrity(mclp.handleLiveChatActions_, '1.31.17'));
  4837. }
  4838.  
  4839. mclp.handleLiveChatActions66_ = mclp.handleLiveChatActions_;
  4840.  
  4841. mclp.handleLiveChatActions77_ = async function (arr) {
  4842. if (typeof (arr || 0).length !== 'number') {
  4843. this.handleLiveChatActions66_(arr);
  4844. return;
  4845. }
  4846. if (mzt > 1e9) mzt = 9;
  4847. let tid = ++mzt;
  4848.  
  4849. if (zarr === null) zarr = arr;
  4850. else Array.prototype.push.apply(zarr, arr);
  4851. arr = null;
  4852.  
  4853. await iAFP(this.hostElement).then();
  4854. // await new Promise(requestAnimationFrame);
  4855.  
  4856. if (tid !== mzt || zarr === null) {
  4857. return;
  4858. }
  4859.  
  4860. const carr = zarr;
  4861. zarr = null;
  4862.  
  4863. await Promise.resolve();
  4864. this.handleLiveChatActions66_(carr);
  4865. await Promise.resolve();
  4866.  
  4867. }
  4868.  
  4869. mclp.handleLiveChatActions_ = function (arr) {
  4870.  
  4871. const cnt = this;
  4872. cnt.__intermediate_delay__ = new Promise(resolve => {
  4873. cnt.handleLiveChatActions77_(arr).then(() => {
  4874. resolve();
  4875. });
  4876. });
  4877. }
  4878. console.log("handleLiveChatActions_", "OK");
  4879. } else {
  4880. console.log("handleLiveChatActions_", "NG");
  4881. }
  4882. }
  4883.  
  4884. mclp.hasUserJustInteracted11_ = () => {
  4885. const t = dateNow();
  4886. return (t - lastWheel < 80) || currentMouseDown || currentTouchDown || (t - lastUserInteraction < 80);
  4887. }
  4888.  
  4889. if ((mclp.canScrollToBottom_ || 0).length === 0) {
  4890.  
  4891. assertor(() => fnIntegrity(mclp.canScrollToBottom_, '0.9.5'));
  4892.  
  4893. mclp.canScrollToBottom_ = function () {
  4894. return this.atBottom && this.allowScroll && !this.hasUserJustInteracted11_();
  4895. }
  4896.  
  4897. console.log("canScrollToBottom_", "OK");
  4898. } else {
  4899. console.log("canScrollToBottom_", "NG");
  4900. }
  4901.  
  4902. if (ENABLE_NO_SMOOTH_TRANSFORM) {
  4903.  
  4904. mclp.isSmoothScrollEnabled_ = function () {
  4905. return false;
  4906. }
  4907.  
  4908. mclp.maybeResizeScrollContainer_ = function () {
  4909. //
  4910. }
  4911.  
  4912. mclp.refreshOffsetContainerHeight_ = function () {
  4913. //
  4914. }
  4915.  
  4916. mclp.smoothScroll_ = function () {
  4917. //
  4918. }
  4919.  
  4920. mclp.resetSmoothScroll_ = function () {
  4921. //
  4922. }
  4923. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "OK");
  4924. } else {
  4925. console.log("ENABLE_NO_SMOOTH_TRANSFORM", "NG");
  4926. }
  4927.  
  4928. if ((this._flag0281_ & 0x8) == 0) {
  4929.  
  4930.  
  4931. if (typeof mclp.forEachItem_ === 'function' && !mclp.forEachItem66_ && skipErrorForhandleAddChatItemAction_ && mclp.forEachItem_.length === 1) {
  4932.  
  4933. mclp.forEachItem66_ = mclp.forEachItem_;
  4934. mclp.forEachItem_ = function (a) {
  4935.  
  4936. if ((this._flag0281_ & 0x8) == 0x8) return this.forEachItem66_(a);
  4937.  
  4938. // ƒ (a){this.visibleItems.forEach(a.bind(this,"visibleItems"));this.activeItems_.forEach(a.bind(this,"activeItems_"))}
  4939.  
  4940. try {
  4941.  
  4942. let items801 = false;
  4943. if (typeof a === 'function') {
  4944. const items = this.items;
  4945. if (items instanceof HTMLDivElement) {
  4946. const ev = this.visibleItems;
  4947. const ea = this.activeItems_;
  4948. if (ev && ea && ev.length >= 0 && ea.length >= 0) {
  4949. items801 = items;
  4950. }
  4951. }
  4952. }
  4953.  
  4954. if (items801) {
  4955. items801.__children801__ = 1;
  4956. const res = this.forEachItem66_(a);
  4957. items801.__children801__ = 0;
  4958. return res;
  4959. }
  4960.  
  4961. } catch (e) { }
  4962. return this.forEachItem66_(a);
  4963.  
  4964.  
  4965. // this.visibleItems.forEach((val, idx, arr)=>{
  4966. // a.call(this, 'visibleItems', val, idx, arr);
  4967. // });
  4968.  
  4969. // this.activeItems_.forEach((val, idx, arr)=>{
  4970. // a.call(this, 'activeItems_', val, idx, arr);
  4971. // });
  4972.  
  4973.  
  4974.  
  4975. }
  4976.  
  4977.  
  4978. }
  4979.  
  4980. }
  4981.  
  4982. if (typeof mclp.handleAddChatItemAction_ === 'function' && !mclp.handleAddChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  4983.  
  4984. mclp.handleAddChatItemAction66_ = mclp.handleAddChatItemAction_;
  4985. mclp.handleAddChatItemAction_ = function (a) {
  4986. try {
  4987. if (a && typeof a === 'object' && !('length' in a)) {
  4988. fixLiveChatItem(a.item, null);
  4989. console.assert(arguments[0] === a);
  4990. }
  4991. } catch (e) { console.warn(e) }
  4992. let res;
  4993. if (skipErrorForhandleAddChatItemAction_) { // YouTube Native Engine Issue
  4994. try {
  4995. res = this.handleAddChatItemAction66_.apply(this, arguments);
  4996. } catch (e) {
  4997. if (e && (e.message || '').includes('.querySelector(')) {
  4998. console.log("skipErrorForhandleAddChatItemAction_", e.message);
  4999. } else {
  5000. throw e;
  5001. }
  5002. }
  5003. } else {
  5004. res = this.handleAddChatItemAction66_.apply(this, arguments);
  5005. }
  5006. return res;
  5007. }
  5008.  
  5009. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  5010. } else {
  5011.  
  5012. if (FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION) console.log("handleAddChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_ADDITION ]", "OK");
  5013. }
  5014.  
  5015.  
  5016. if (typeof mclp.handleReplaceChatItemAction_ === 'function' && !mclp.handleReplaceChatItemAction66_ && FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT && (EMOJI_IMAGE_SINGLE_THUMBNAIL || AUTHOR_PHOTO_SINGLE_THUMBNAIL)) {
  5017.  
  5018. mclp.handleReplaceChatItemAction66_ = mclp.handleReplaceChatItemAction_;
  5019. mclp.handleReplaceChatItemAction_ = function (a) {
  5020. try {
  5021. if (a && typeof a === 'object' && !('length' in a)) {
  5022. fixLiveChatItem(a.replacementItem, null);
  5023. console.assert(arguments[0] === a);
  5024. }
  5025. } catch (e) { console.warn(e) }
  5026. return this.handleReplaceChatItemAction66_.apply(this, arguments);
  5027. }
  5028.  
  5029. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  5030. } else {
  5031.  
  5032. if (FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT) console.log("handleReplaceChatItemAction_ [ FIX_THUMBNAIL_SIZE_ON_ITEM_REPLACEMENT ]", "OK");
  5033. }
  5034.  
  5035. console.log("[End]");
  5036. console.groupEnd();
  5037.  
  5038. }).catch(console.warn);
  5039.  
  5040.  
  5041. const tickerContainerSetAttribute = function (attrName, attrValue) { // ensure '14.30000001%'.toFixed(1)
  5042.  
  5043. let yd = (this.__dataHost || insp(this).__dataHost || 0).__data;
  5044.  
  5045. if (arguments.length === 2 && attrName === 'style' && yd && attrValue) {
  5046.  
  5047. // let v = yd.containerStyle.privateDoNotAccessOrElseSafeStyleWrappedValue_;
  5048. let v = `${attrValue}`;
  5049. // conside a ticker is 101px width
  5050. // 1% = 1.01px
  5051. // 0.2% = 0.202px
  5052.  
  5053.  
  5054. const ratio1 = (yd.ratio * 100);
  5055. if (ratio1 > -1) { // avoid NaN
  5056.  
  5057. // countdownDurationMs
  5058. // 600000 - 0.2% <1% = 6s> <0.2% = 1.2s>
  5059. // 300000 - 0.5% <1% = 3s> <0.5% = 1.5s>
  5060. // 150000 - 1% <1% = 1.5s>
  5061. // 75000 - 2% <1% =0.75s > <2% = 1.5s>
  5062. // 30000 - 5% <1% =0.3s > <5% = 1.5s>
  5063.  
  5064. // 99px * 5% = 4.95px
  5065.  
  5066. // 15000 - 10% <1% =0.15s > <10% = 1.5s>
  5067.  
  5068.  
  5069. // 1% Duration
  5070.  
  5071. let ratio2 = ratio1;
  5072.  
  5073. const ydd = yd.data;
  5074. if (ydd) {
  5075.  
  5076. const d1 = ydd.durationSec;
  5077. const d2 = ydd.fullDurationSec;
  5078.  
  5079. // @ step timing [min. 0.2%]
  5080. let numOfSteps = 500;
  5081. if ((d1 === d2 || (d1 + 1 === d2)) && d1 > 1) {
  5082. if (d2 > 400) numOfSteps = 500; // 0.2%
  5083. else if (d2 > 200) numOfSteps = 200; // 0.5%
  5084. else if (d2 > 100) numOfSteps = 100; // 1%
  5085. else if (d2 > 50) numOfSteps = 50; // 2%
  5086. else if (d2 > 25) numOfSteps = 20; // 5% (max => 99px * 5% = 4.95px)
  5087. else numOfSteps = 20;
  5088. }
  5089. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  5090. if (numOfSteps < 5) numOfSteps = 5;
  5091.  
  5092. const rd = numOfSteps / 100.0;
  5093.  
  5094. ratio2 = Math.round(ratio2 * rd) / rd;
  5095.  
  5096. // ratio2 = Math.round(ratio2 * 5) / 5;
  5097. ratio2 = ratio2.toFixed(1);
  5098. v = v.replace(`${ratio1}%`, `${ratio2}%`).replace(`${ratio1}%`, `${ratio2}%`);
  5099.  
  5100. if (yd.__style_last__ === v) return;
  5101. yd.__style_last__ = v;
  5102. // do not consider any delay here.
  5103. // it shall be inside the looping for all properties changes. all the css background ops are in the same microtask.
  5104.  
  5105. }
  5106. }
  5107.  
  5108. HTMLElement.prototype.setAttribute.call(dr(this), attrName, v);
  5109.  
  5110.  
  5111. } else {
  5112. HTMLElement.prototype.setAttribute.apply(dr(this), arguments);
  5113. }
  5114.  
  5115. };
  5116.  
  5117.  
  5118. const fpTicker = (renderer) => {
  5119. const cnt = insp(renderer);
  5120. assertor(() => typeof (cnt || 0).is === 'string');
  5121. assertor(() => ((cnt || 0).hostElement || 0).nodeType === 1);
  5122. const container = (cnt.$ || 0).container;
  5123. if (container) {
  5124. assertor(() => (container || 0).nodeType === 1);
  5125. assertor(() => typeof container.setAttribute === 'function');
  5126. container.setAttribute = tickerContainerSetAttribute;
  5127. } else {
  5128. console.warn(`"container" does not exist in ${cnt.is}`);
  5129. }
  5130. };
  5131.  
  5132.  
  5133. const tags = [
  5134. "yt-live-chat-ticker-paid-message-item-renderer",
  5135. "yt-live-chat-ticker-paid-sticker-item-renderer",
  5136. "yt-live-chat-ticker-renderer",
  5137. "yt-live-chat-ticker-sponsor-item-renderer"
  5138. ];
  5139.  
  5140. const tagsItemRenderer = [
  5141. "yt-live-chat-ticker-paid-message-item-renderer",
  5142. "yt-live-chat-ticker-paid-sticker-item-renderer",
  5143. "yt-live-chat-ticker-renderer",
  5144. "yt-live-chat-ticker-sponsor-item-renderer"
  5145. ];
  5146.  
  5147.  
  5148. Promise.all(tags.map(tag => customElements.whenDefined(tag))).then(() => {
  5149.  
  5150. mightFirstCheckOnYtInit();
  5151. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-... hacks");
  5152. console.log("[Begin]");
  5153.  
  5154. let dummyValueForStyleReturn = null;
  5155.  
  5156. const genDummyValueForStyleReturn = () => {
  5157. let s = `--nx:82;`
  5158. let ro = {
  5159. "privateDoNotAccessOrElseSafeStyleWrappedValue_": s,
  5160. "implementsGoogStringTypedString": true
  5161. };
  5162. ro.getTypedStringValue = ro.toString = function () { return this.privateDoNotAccessOrElseSafeStyleWrappedValue_ };
  5163. return ro;
  5164. }
  5165.  
  5166. let isCSSPropertySupported_ = null;
  5167. const isCSSPropertySupported = () => {
  5168.  
  5169. // @property --ticker-rtime
  5170.  
  5171. if (typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_;
  5172. isCSSPropertySupported_ = false;
  5173.  
  5174. if (typeof CSS !== 'object' || typeof (CSS || 0).registerProperty !== 'function') return false;
  5175. const documentElement = document.documentElement;
  5176. if (!documentElement) {
  5177. console.warn('document.documentElement is not found');
  5178. return false;
  5179. }
  5180. if (`${getComputedStyleCached(documentElement).getPropertyValue('--ticker-rtime')}`.length === 0) {
  5181. return false;
  5182. }
  5183.  
  5184. const ae = animate.call(documentElement,
  5185. [
  5186. { '--ticker-rtime': '70%' },
  5187. { '--ticker-rtime': '30%' }
  5188. ],
  5189. {
  5190. fill: "forwards",
  5191. duration: 1000 * 40,
  5192. easing: 'linear'
  5193. }
  5194. );
  5195.  
  5196. let animatedValue = getComputedStyleCached(document.documentElement).getPropertyValue('--ticker-rtime');
  5197. ae.finish();
  5198. if (`${animatedValue}`.length !== 3) return false;
  5199.  
  5200. isCSSPropertySupported_ = true;
  5201. return true;
  5202.  
  5203. };
  5204.  
  5205.  
  5206. let windowShownAt = -1;
  5207. const setupEventForWindowShownAt = () => {
  5208. window.addEventListener('visibilitychange', () => {
  5209. if (document.visibilityState === 'visible') windowShownAt = Date.now();
  5210. else windowShownAt = 0;
  5211. }, false);
  5212. }
  5213.  
  5214. const dProto = {
  5215.  
  5216. detachedForTickerInit: function () {
  5217.  
  5218. try {
  5219.  
  5220. this.actionHandlerBehavior.unregisterActionMap(this.behaviorActionMap)
  5221.  
  5222. // this.behaviorActionMap = 0;
  5223. // this.isVisibilityRoot = 0;
  5224.  
  5225.  
  5226. } catch (e) { }
  5227.  
  5228.  
  5229. return this.detached582MemoryLeak();
  5230. },
  5231.  
  5232. attachedForTickerInit: function () {
  5233.  
  5234. fpTicker(this.hostElement || this);
  5235. return this.attached77();
  5236.  
  5237. },
  5238.  
  5239.  
  5240. // doAnimator
  5241.  
  5242. _makeAnimator: function () {
  5243. if (this._r782) return;
  5244. // if (!this.isAttached) return;
  5245. if (!this._runnerAE) {
  5246. /** @type {HTMLElement | null} */
  5247. const aElement = (this.$ || 0).container;
  5248. if (!aElement) return console.warn("this.$.container is undefined");
  5249. const da = this.data;
  5250. if (!da || !da.startBackgroundColor || !da.endBackgroundColor) return console.warn("this.data is undefined or incorrect");
  5251. const c1 = this.colorFromDecimal(da.startBackgroundColor);
  5252. const c2 = this.colorFromDecimal(da.endBackgroundColor);
  5253. if (typeof c1 !== 'string' || typeof c2 !== 'string') return console.warn('c1, c2 is not a string');
  5254.  
  5255. // if (!this.__tickerBackgroundInitialChecked__) {
  5256. // this.constructor.prototype.__tickerBackgroundInitialChecked__ = true;
  5257. // console.log('__tickerBackgroundInitialChecked__')
  5258. // this._checkTickerBackgroundChanged();
  5259. // }
  5260.  
  5261. aElement.style.setProperty('--ticker-c1', c1);
  5262. aElement.style.setProperty('--ticker-c2', c2);
  5263. aElement.classList.add(runTickerClassName);
  5264. const p = (this.countdownMs / this.countdownDurationMs) * 100;
  5265. // this._aeStartV = this.countdownMs;
  5266. // this._aeStartT = this.countdownDurationMs;
  5267. if (!(p >= 0 && p <= 100)) {
  5268. console.warn('incorrect time ratio', p);
  5269. } else {
  5270. /*
  5271. const u0 = p.toFixed(4) + '%';
  5272. this._runnerAE = animate.call(aElement,
  5273. [
  5274. { '--ticker-rtime': u0 },
  5275. { '--ticker-rtime': '0%' }
  5276. ]
  5277. ,
  5278. {
  5279. fill: "forwards",
  5280. duration: this.countdownMs,
  5281. easing: "linear"
  5282. }
  5283. );
  5284. */
  5285.  
  5286. let timingFn = 'linear';
  5287.  
  5288. const totalDuration = this.countdownDurationMs;
  5289.  
  5290. if (ATTEMPT_ANIMATED_TICKER_BACKGROUND === 'steps') {
  5291.  
  5292. // @ step timing [min. 0.2%]
  5293. let stepInterval = 0.2; // unit: %
  5294. if (totalDuration > 400000) stepInterval = 0.2;
  5295. else if (totalDuration > 200000) stepInterval = 0.5;
  5296. else if (totalDuration > 100000) stepInterval = 1;
  5297. else if (totalDuration > 50000) stepInterval = 2;
  5298. else if (totalDuration > 25000) stepInterval = 5;
  5299. else stepInterval = 5;
  5300.  
  5301. let numOfSteps = Math.round(100 / stepInterval);
  5302.  
  5303. if (numOfSteps > TICKER_MAX_STEPS_LIMIT) numOfSteps = TICKER_MAX_STEPS_LIMIT;
  5304. if (numOfSteps < 5) numOfSteps = 5;
  5305.  
  5306. timingFn = `steps(${numOfSteps}, end)`;
  5307.  
  5308. }
  5309.  
  5310.  
  5311. /** @type {Animation} */
  5312. const ae = animate.call(aElement,
  5313. [
  5314. { '--ticker-rtime': '100%' },
  5315. { '--ticker-rtime': '0%' }
  5316. ]
  5317. ,
  5318. {
  5319. fill: "forwards",
  5320. duration: totalDuration,
  5321. easing: timingFn
  5322. }
  5323. );
  5324.  
  5325. this._runnerAE = ae;
  5326.  
  5327. ae.onfinish = (event) => {
  5328. this.onfinish = null;
  5329. if (this._runnerAE !== ae) return;
  5330. if (this.isAttached === true && !this._r782 && ((this.$ || 0).container || 0).isConnected === true) {
  5331. this._aeFinished(event);
  5332. }
  5333. }
  5334.  
  5335. let bq = (1.0 - (this.countdownMs / totalDuration)) * totalDuration;
  5336.  
  5337. if (bq >= 0 && bq <= totalDuration) {
  5338.  
  5339. if (bq > totalDuration - 1) {
  5340. ae.currentTime = bq;
  5341. // setTimeout(() => {
  5342. // if (this._runnerAE === ae && ae.onfinish) ae.onfinish();
  5343. // }, 1);
  5344. } else {
  5345. ae.currentTime = bq;
  5346. }
  5347. } else {
  5348. console.warn('Error on setting _runnerAE.currentTime!');
  5349. }
  5350.  
  5351.  
  5352. aeConstructor = ae.constructor; // constructor is from iframe
  5353. return ae;
  5354. }
  5355. } else {
  5356. if (!aeConstructor) return console.warn('aeConstructor is undefined');
  5357. // assume just time update
  5358. const ae = this._runnerAE;
  5359. if (!(ae instanceof aeConstructor)) return console.warn('this._runnerAE is not Animation');
  5360. if (ae.playState !== 'paused') console.warn('ae.playState !== paused');
  5361. let p = (this.countdownMs / this.countdownDurationMs) * 100;
  5362. if (!(p >= 0 && p <= 100)) {
  5363. console.warn('incorrect time ratio', p);
  5364. } else {
  5365. // let u0 = p.toFixed(4) + '%'
  5366. /*
  5367. ae.effect.setKeyframes([
  5368. { '--ticker-rtime': u0 },
  5369. { '--ticker-rtime': '0%' }
  5370. ]);
  5371. ae.effect.updateTiming({ duration: this.countdownMs });
  5372. */
  5373. // ae.currentTime = 0;
  5374.  
  5375.  
  5376.  
  5377. let bq = (1.0 - (this.countdownMs / this.countdownDurationMs)) * this.countdownDurationMs;
  5378. if (bq >= 0 && bq <= this.countdownDurationMs) {
  5379.  
  5380. this._runnerAE.currentTime = bq
  5381. } else {
  5382. console.warn('Error on setting _runnerAE.currentTime!');
  5383. }
  5384.  
  5385.  
  5386. ae.play();
  5387. return ae;
  5388. }
  5389. }
  5390. },
  5391.  
  5392. _aeFinished: function (event) {
  5393.  
  5394. if (this._r782) return;
  5395.  
  5396. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5397. this._throwOut();
  5398. return;
  5399. }
  5400.  
  5401. if (!this._runnerAE) console.warn('Error in .updateTimeout; this._runnerAE is undefined');
  5402.  
  5403. let lc = window.performance.now();
  5404. this.countdownMs = Math.max(0, this.countdownMs - (lc - this.lastCountdownTimeMs));
  5405. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  5406. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = lc;
  5407. if (this.countdownMs > 76) console.warn('Warning: this.countdownMs is not zero when finished!', this.countdownMs, this, event); // just warning.
  5408.  
  5409. this.countdownMs = 0;
  5410. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = null;
  5411.  
  5412. if (this.isAttached) {
  5413. let fastRemoved = false;
  5414. if (Date.now() - windowShownAt < 80 && typeof this.requestRemoval === 'function') {
  5415. // no animation if the video page is switched from background to foreground
  5416. // this.hostElement.style.display = 'none';
  5417. const id = (this.data || 0).id || 0;
  5418. if (!id) this.data = { id: 1 }
  5419. try {
  5420. this.requestRemoval();
  5421. fastRemoved = true;
  5422. } catch (e) {
  5423.  
  5424. }
  5425. }
  5426.  
  5427. if (!fastRemoved) {
  5428. "auto" === this.hostElement.style.width && this.setContainerWidth();
  5429. this.slideDown();
  5430. }
  5431. }
  5432.  
  5433.  
  5434.  
  5435. },
  5436.  
  5437.  
  5438. /** @type {()} */
  5439. _throwOut: function () {
  5440. this._r782 = 1;
  5441. Promise.resolve().then(() => {
  5442. if (typeof this.requestRemoval === 'function') {
  5443. const id = (this.data || 0).id;
  5444. if (!id) this.data = { id: 1 };
  5445. try {
  5446. this.requestRemoval();
  5447. } catch (e) { }
  5448. }
  5449. this.detached();
  5450. if (this.__dataClientsReady === true) this.__dataClientsReady = false;
  5451. if (this.__dataEnabled === true) this.__dataEnabled = false;
  5452. if (this.__dataReady === true) this.__dataReady = false;
  5453. this.data = null;
  5454. this.countdownMs = 0;
  5455. this.lastCountdownTimeMs = null;
  5456. const hm = this.hostElement || this;
  5457. if (hm.parentNode) hm.remove();
  5458. for (let t; t = hm.firstChild;) t.remove();
  5459. }).catch(e => {
  5460. console.warn(e);
  5461. });
  5462. },
  5463.  
  5464.  
  5465. // doTimerFnModification
  5466.  
  5467.  
  5468. /** @type {(a, b)} */
  5469. startCountdownForTimerFnModA: function (a, b) { // .startCountdown(a.durationSec, a.fullDurationSec)
  5470. try {
  5471. // a.durationSec [s] => countdownMs [ms]
  5472. // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  5473. // lastCountdownTimeMs => raf ongoing
  5474. // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  5475.  
  5476. if (this._r782) return;
  5477.  
  5478. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5479. this._throwOut();
  5480. return;
  5481. }
  5482.  
  5483. // TimerFnModA
  5484.  
  5485. b = void 0 === b ? 0 : b;
  5486. if (void 0 !== a) {
  5487.  
  5488. this.countdownMs = 1E3 * a; // decreasing from durationSec[s] to zero
  5489. this.countdownDurationMs = b ? 1E3 * b : this.countdownMs; // constant throughout the animation
  5490. if (!(this.lastCountdownTimeMs || this.isAnimationPaused)) {
  5491. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = performance.now()
  5492. this.rafId = 1
  5493. if (this._runnerAE) console.warn('Error in .startCountdown; this._runnerAE already created.')
  5494. this.detlaSincePausedSecs = 0;
  5495. const ae = this._makeAnimator();
  5496. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  5497.  
  5498. // if (playerProgressChangedArg1 === null) {
  5499. // console.log('startCountdownForTimerFnModA', this.data)
  5500. // }
  5501.  
  5502. if (isPlayProgressTriggered && this.isAnimationPaused !== true && this.__ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED__) {
  5503.  
  5504.  
  5505.  
  5506.  
  5507. this.playerProgressSec = lastPlayerProgress > 0 ? lastPlayerProgress : 0; // save the progress first
  5508. this.isAnimationPaused = true; // trigger isAnimationPausedChanged
  5509. this.detlaSincePausedSecs = 0;
  5510. this._forceNoDetlaSincePausedSecs783 = 1; // reset this.detlaSincePausedSecs = 0 when resumed
  5511.  
  5512. relayPromise = relayPromise || new PromiseExternal();
  5513.  
  5514. relayPromise.then(() => {
  5515. if (this.isAttached === true && this.countdownDurationMs > 0 && this.isAnimationPaused === true && this.isReplayPaused !== true) {
  5516. this.isAnimationPaused = false;
  5517. }
  5518. });
  5519.  
  5520.  
  5521. }
  5522.  
  5523.  
  5524.  
  5525. }
  5526. }
  5527.  
  5528. } catch (e) {
  5529. console.warn(e);
  5530. }
  5531.  
  5532. },
  5533.  
  5534.  
  5535.  
  5536. /** @type {(a, b)} */
  5537. startCountdownForTimerFnModT: function (a, b) { // .startCountdown(a.durationSec, a.fullDurationSec)
  5538. try {
  5539. // a.durationSec [s] => countdownMs [ms]
  5540. // a.fullDurationSec [s] => countdownDurationMs [ms] OR countdownMs [ms]
  5541. // lastCountdownTimeMs => raf ongoing
  5542. // lastCountdownTimeMs = 0 when rafId = 0 OR countdownDurationMs = 0
  5543.  
  5544. if (this._r782) return;
  5545.  
  5546. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5547. this._throwOut();
  5548. return;
  5549. }
  5550.  
  5551. // TimerFnModT
  5552.  
  5553. // console.log('cProto.startCountdown', tag) // yt-live-chat-ticker-sponsor-item-renderer
  5554. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  5555. b = void 0 === b ? 0 : b;
  5556. void 0 !== a && (this.countdownMs = 1E3 * a,
  5557. this.countdownDurationMs = b ? 1E3 * b : this.countdownMs,
  5558. this.ratio = 1,
  5559. this.lastCountdownTimeMs || this.isAnimationPaused || (this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = performance.now(),
  5560. this.rafId = rafHub.request(this.boundUpdateTimeout37_)))
  5561.  
  5562. } catch (e) {
  5563. console.warn(e);
  5564. }
  5565.  
  5566. },
  5567.  
  5568.  
  5569. /** @type {(a,)} */
  5570. updateTimeoutForTimerFnModA: function (a) {
  5571.  
  5572. try {
  5573.  
  5574. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  5575.  
  5576. if (this._r782) return;
  5577.  
  5578. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5579. this._throwOut();
  5580. return;
  5581. }
  5582.  
  5583. // TimerFnModA
  5584.  
  5585. if (!this._runnerAE) console.warn('Error in .updateTimeout; this._runnerAE is undefined');
  5586. if (this.lastCountdownTimeMs !== this._lastCountdownTimeMsX0) {
  5587. this.countdownMs = Math.max(0, this.countdownMs - (a - (this.lastCountdownTimeMs || 0)));
  5588. }
  5589. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  5590. if (this.isAttached && this.countdownMs) {
  5591. this.lastCountdownTimeMs = a
  5592. const ae = this._makeAnimator(); // request raf
  5593. if (!ae) console.warn('Error in startCountdown._makeAnimator()');
  5594. } else {
  5595. (this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = null,
  5596. this.isAttached && ("auto" === this.hostElement.style.width && this.setContainerWidth(),
  5597. this.slideDown()));
  5598. }
  5599.  
  5600. } catch (e) {
  5601. console.warn(e);
  5602. }
  5603.  
  5604.  
  5605. },
  5606.  
  5607. /** @type {(a,)} */
  5608. updateTimeoutForTimerFnModT: function (a) {
  5609.  
  5610. try {
  5611.  
  5612. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  5613.  
  5614. if (this._r782) return;
  5615.  
  5616. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5617. this._throwOut();
  5618. return;
  5619. }
  5620.  
  5621. // TimerFnModT
  5622.  
  5623. // console.log('cProto.updateTimeout', tag) // yt-live-chat-ticker-sponsor-item-renderer
  5624. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  5625. if (this.lastCountdownTimeMs !== this._lastCountdownTimeMsX0) {
  5626. this.countdownMs = Math.max(0, this.countdownMs - (a - (this.lastCountdownTimeMs || 0)));
  5627. }
  5628. // console.log(703, this.countdownMs)
  5629. this.ratio = this.countdownMs / this.countdownDurationMs;
  5630. this.isAttached && this.countdownMs ? (this.lastCountdownTimeMs = a,
  5631. this.rafId = rafHub.request(this.boundUpdateTimeout37_)) : (this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = null,
  5632. this.isAttached && ("auto" === this.hostElement.style.width && this.setContainerWidth(),
  5633. this.slideDown()))
  5634.  
  5635.  
  5636. } catch (e) {
  5637. console.warn(e);
  5638. }
  5639. },
  5640.  
  5641. /** @type {(a,b)} */
  5642. isAnimationPausedChangedForTimerFnModA: function (a, b) {
  5643.  
  5644. if (this._r782) return;
  5645.  
  5646. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5647. this._throwOut();
  5648. return;
  5649. }
  5650. let forceNoDetlaSincePausedSecs783 = this._forceNoDetlaSincePausedSecs783;
  5651. this._forceNoDetlaSincePausedSecs783 = 0;
  5652.  
  5653. Promise.resolve().then(() => {
  5654.  
  5655. if (a) {
  5656.  
  5657. if (this._runnerAE && this._runnerAE.playState === 'running') {
  5658.  
  5659. this._runnerAE.pause()
  5660. let lc = window.performance.now();
  5661. this.countdownMs = Math.max(0, this.countdownMs - (lc - this.lastCountdownTimeMs));
  5662. if (this.countdownMs > this.countdownDurationMs) this.countdownMs = this.countdownDurationMs;
  5663. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = lc;
  5664. }
  5665.  
  5666. } else if (!a && b) {
  5667.  
  5668.  
  5669. if (forceNoDetlaSincePausedSecs783) this.detlaSincePausedSecs = 0;
  5670. a = this.detlaSincePausedSecs ? (this.lastCountdownTimeMs || 0) + 1000 * this.detlaSincePausedSecs : (this.lastCountdownTimeMs || 0);
  5671. this.detlaSincePausedSecs = 0;
  5672. this.updateTimeout(a);
  5673. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = window.performance.now();
  5674.  
  5675. }
  5676.  
  5677.  
  5678. }).catch(e => {
  5679. console.log(e);
  5680. });
  5681.  
  5682.  
  5683.  
  5684. },
  5685.  
  5686.  
  5687. /** @type {(a,b)} */
  5688. isAnimationPausedChangedForTimerFnModT: function (a, b) {
  5689.  
  5690. if (this._r782) return;
  5691.  
  5692. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5693. this._throwOut();
  5694. return;
  5695. }
  5696. let forceNoDetlaSincePausedSecs783 = this._forceNoDetlaSincePausedSecs783;
  5697. this._forceNoDetlaSincePausedSecs783 = 0;
  5698.  
  5699. Promise.resolve().then(() => {
  5700.  
  5701. // TimerFnModT
  5702.  
  5703. // ez++;
  5704. // if(ez> 1e9) ez=9;
  5705. if (!this.boundUpdateTimeout37_) this.boundUpdateTimeout37_ = this.updateTimeout.bind(this);
  5706. a ? rafHub.cancel(this.rafId) : !a && b && (a = this.lastCountdownTimeMs || 0,
  5707. this.detlaSincePausedSecs && (a = (this.lastCountdownTimeMs || 0) + 1E3 * this.detlaSincePausedSecs,
  5708. this.detlaSincePausedSecs = 0),
  5709. this.boundUpdateTimeout37_(a),
  5710. this.lastCountdownTimeMs = this._lastCountdownTimeMsX0 = window.performance.now())
  5711.  
  5712.  
  5713. }).catch(e => {
  5714. console.log(e);
  5715. });
  5716.  
  5717.  
  5718.  
  5719. },
  5720.  
  5721.  
  5722. /** @type {(a,b)} */
  5723. computeContainerStyleForAnimatorEnabled: function (a, b) {
  5724.  
  5725. if (this._r782) return;
  5726.  
  5727. if (this.isAttached === false && ((this.$ || 0).container || 0).isConnected === false) {
  5728. this._throwOut();
  5729. return;
  5730. }
  5731.  
  5732. return (dummyValueForStyleReturn || (dummyValueForStyleReturn = genDummyValueForStyleReturn()));
  5733.  
  5734. },
  5735.  
  5736.  
  5737.  
  5738. /** @type {()} */
  5739. handlePauseReplayForPlaybackProgressState: function () {
  5740. if (!playerEventsByIframeRelay) return this.handlePauseReplay66.apply(this, arguments);
  5741.  
  5742. if (onPlayStateChangePromise) {
  5743.  
  5744. if (this.rtu > 1e9) this.rtu = this.rtu % 1e4;
  5745. const tid = ++this.rtu;
  5746.  
  5747. onPlayStateChangePromise.then(() => {
  5748. if (tid === this.rtu && !onPlayStateChangePromise && typeof this.handlePauseReplay === 'function') this.handlePauseReplay.apply(this, arguments);
  5749. // this.handlePauseReplay can be undefined if it is memory cleaned
  5750. });
  5751.  
  5752. return;
  5753. }
  5754.  
  5755. if (playerState !== 2) return;
  5756. if (this.isAttached) {
  5757. if (this.rtk > 1e9) this.rtk = this.rtk % 1e4;
  5758. const tid = ++this.rtk;
  5759. const tc = relayCount;
  5760. foregroundPromiseFn().then(() => {
  5761. if (tid === this.rtk && tc === relayCount && playerState === 2 && _playerState === playerState) {
  5762. this.handlePauseReplay66();
  5763. }
  5764.  
  5765. })
  5766. }
  5767. },
  5768.  
  5769. /** @type {()} */
  5770. handleResumeReplayForPlaybackProgressState: function () {
  5771. if (!playerEventsByIframeRelay) return this.handleResumeReplay66.apply(this, arguments);
  5772.  
  5773.  
  5774. if (onPlayStateChangePromise) {
  5775.  
  5776. if (this.rtv > 1e9) this.rtv = this.rtv % 1e4;
  5777. const tid = ++this.rtv;
  5778.  
  5779. onPlayStateChangePromise.then(() => {
  5780. if (tid === this.rtv && !onPlayStateChangePromise && typeof this.handleResumeReplay === 'function') this.handleResumeReplay.apply(this, arguments);
  5781. // this.handleResumeReplay can be undefined if it is memory cleaned
  5782. });
  5783.  
  5784. return;
  5785. }
  5786.  
  5787.  
  5788. if (playerState !== 1) return;
  5789. if (this.isAttached) {
  5790. const tc = relayCount;
  5791.  
  5792. relayPromise = relayPromise || new PromiseExternal();
  5793. relayPromise.then(() => {
  5794. if (relayCount > tc && playerState === 1 && _playerState === playerState) {
  5795. this.handleResumeReplay66();
  5796. }
  5797. });
  5798. }
  5799. },
  5800.  
  5801. /** @type {(a,)} */
  5802. handleReplayProgressForPlaybackProgressState: function (a) {
  5803. if (this.isAttached) {
  5804. const tid = ++this.rtk;
  5805. foregroundPromiseFn().then(() => {
  5806. if (tid === this.rtk) {
  5807. this.handleReplayProgress66(a);
  5808. }
  5809. })
  5810. }
  5811. }
  5812.  
  5813.  
  5814. }
  5815.  
  5816.  
  5817. for (const tag of tagsItemRenderer) { // ##tag##
  5818. const dummy = document.createElement(tag);
  5819.  
  5820. const cProto = getProto(dummy);
  5821. if (!cProto || !cProto.attached) {
  5822. console.warn(`proto.attached for ${tag} is unavailable.`);
  5823. continue;
  5824. }
  5825.  
  5826. if (FIX_MEMORY_LEAKAGE_TICKER_ACTIONMAP && typeof cProto.detached582MemoryLeak !== 'function' && typeof cProto.detached === 'function') {
  5827. cProto.detached582MemoryLeak = cProto.detached;
  5828. cProto.detached = cProto.detachedForTickerInit;
  5829. }
  5830.  
  5831. cProto.attached77 = cProto.attached;
  5832.  
  5833. cProto.attached = dProto.attachedForTickerInit;
  5834.  
  5835. let rafHackState = 0;
  5836.  
  5837. let isTimingFunctionHackable = false;
  5838.  
  5839. let urt = 0;
  5840.  
  5841. if (typeof cProto.startCountdown === 'function' && typeof cProto.updateTimeout === 'function' && typeof cProto.isAnimationPausedChanged === 'function') {
  5842.  
  5843. // console.log('startCountdown', typeof cProto.startCountdown)
  5844. // console.log('updateTimeout', typeof cProto.updateTimeout)
  5845. // console.log('isAnimationPausedChanged', typeof cProto.isAnimationPausedChanged)
  5846.  
  5847. isTimingFunctionHackable = fnIntegrity(cProto.startCountdown, '2.66.37') && fnIntegrity(cProto.updateTimeout, '1.76.45') && fnIntegrity(cProto.isAnimationPausedChanged, '2.56.30')
  5848.  
  5849. } else {
  5850. console.log("ATTEMPT_ANIMATED_TICKER_BACKGROUND", ` ${tag}`, "Skip Timing Function Modification");
  5851. continue;
  5852. }
  5853.  
  5854.  
  5855. if (ENABLE_RAF_HACK_TICKERS && rafHub !== null) {
  5856.  
  5857. // cancelable - this.rafId < isAnimationPausedChanged >
  5858. rafHackState = 1;
  5859.  
  5860. if (isTimingFunctionHackable) {
  5861. rafHackState = 2;
  5862.  
  5863. } else {
  5864. rafHackState = 4;
  5865. }
  5866.  
  5867. }
  5868.  
  5869. const doAnimator = !!ATTEMPT_ANIMATED_TICKER_BACKGROUND && isTimingFunctionHackable && typeof KeyframeEffect === 'function' && typeof animate === 'function' && typeof cProto.computeContainerStyle === 'function' && typeof cProto.colorFromDecimal === 'function' && isCSSPropertySupported();
  5870.  
  5871. const doRAFHack = rafHackState === 2;
  5872.  
  5873. cProto._throwOut = dProto._throwOut;
  5874.  
  5875. cProto._makeAnimator = doAnimator ? dProto._makeAnimator : null;
  5876.  
  5877. cProto._aeFinished = doAnimator ? dProto._aeFinished : null;
  5878.  
  5879.  
  5880. if (ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX) {
  5881.  
  5882.  
  5883.  
  5884. if (typeof cProto.handlePauseReplay === 'function' && !cProto.handlePauseReplay66 && cProto.handlePauseReplay.length === 0) {
  5885. urt++;
  5886. assertor(() => fnIntegrity(cProto.handlePauseReplay, '0.12.4'));
  5887. } else {
  5888. console.log('Error for setting cProto.handlePauseReplay', tag)
  5889. }
  5890.  
  5891. if (typeof cProto.handleResumeReplay === 'function' && !cProto.handleResumeReplay66 && cProto.handlePauseReplay.length === 0) {
  5892. urt++;
  5893. assertor(() => fnIntegrity(cProto.handleResumeReplay, '0.8.2'));
  5894. } else {
  5895. console.log('Error for setting cProto.handleResumeReplay', tag)
  5896. }
  5897.  
  5898. if (typeof cProto.handleReplayProgress === 'function' && !cProto.handleReplayProgress66 && cProto.handleReplayProgress.length === 1) {
  5899. urt++;
  5900. assertor(() => fnIntegrity(cProto.handleReplayProgress, '1.16.13'));
  5901. } else {
  5902. console.log('Error for setting cProto.handleReplayProgress', tag)
  5903. }
  5904.  
  5905.  
  5906.  
  5907. }
  5908.  
  5909. const ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED = ENABLE_VIDEO_PLAYBACK_PROGRESS_STATE_FIX && urt === 3;
  5910. cProto.__ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED__ = ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED;
  5911.  
  5912. if (ENABLE_VIDEO_PROGRESS_STATE_FIX_AND_URT_PASSED) {
  5913.  
  5914. cProto.rtk = 0;
  5915. cProto.rtu = 0;
  5916. cProto.rtv = 0;
  5917.  
  5918. cProto.handlePauseReplay66 = cProto.handlePauseReplay;
  5919. cProto.handlePauseReplay = dProto.handlePauseReplayForPlaybackProgressState;
  5920.  
  5921. cProto.handleResumeReplay66 = cProto.handleResumeReplay;
  5922. cProto.handleResumeReplay = dProto.handleResumeReplayForPlaybackProgressState;
  5923.  
  5924. cProto.handleReplayProgress66 = cProto.handleReplayProgress;
  5925. cProto.handleReplayProgress = dProto.handleReplayProgressForPlaybackProgressState;
  5926.  
  5927. }
  5928.  
  5929. const doTimerFnModification = (doRAFHack || doAnimator);
  5930.  
  5931. if (doAnimator && windowShownAt < 0) {
  5932. windowShownAt = 0;
  5933. setupEventForWindowShownAt();
  5934. }
  5935.  
  5936. if (doTimerFnModification) {
  5937.  
  5938. cProto.startCountdown = (
  5939. doAnimator ? dProto.startCountdownForTimerFnModA : dProto.startCountdownForTimerFnModT
  5940. );
  5941.  
  5942. // _lastCountdownTimeMsX0 is required since performance.now() is not fully the same with rAF timestamp
  5943. cProto.updateTimeout = (
  5944. doAnimator ? dProto.updateTimeoutForTimerFnModA : dProto.updateTimeoutForTimerFnModT
  5945. );
  5946.  
  5947.  
  5948. // let ez = 0;
  5949. cProto.isAnimationPausedChanged = (
  5950. doAnimator ? dProto.isAnimationPausedChangedForTimerFnModA : dProto.isAnimationPausedChangedForTimerFnModT
  5951. );
  5952.  
  5953. }
  5954.  
  5955. if (doAnimator) {
  5956.  
  5957. const s = fnIntegrity(cProto.computeContainerStyle);
  5958.  
  5959. if (s === '2.46.29') {
  5960. // f.computeContainerStyle = function(a, b) {
  5961. // if (!a)
  5962. // return $h(kmb);
  5963. // var c = this.colorFromDecimal(a.startBackgroundColor);
  5964. // a = this.colorFromDecimal(a.endBackgroundColor);
  5965. // b = 100 * b + "%";
  5966. // return $h(lmb, c, c, b, a, b, a)
  5967. // }
  5968. } else if (s === '2.44.29' || s === '2.81.31') {
  5969.  
  5970. // var ofb = da([""])
  5971. // pfb = da("background:linear-gradient(90deg, {,{ {,{ {,{);".split("{"))
  5972.  
  5973. // f.computeContainerStyle = function(a, b) {
  5974. // if (!a)
  5975. // return pi(ofb);
  5976. // var c = this.colorFromDecimal(a.startBackgroundColor);
  5977. // a = this.colorFromDecimal(a.endBackgroundColor);
  5978. // b = 100 * b + "%";
  5979. // return pi(pfb, c, c, b, a, b, a)
  5980. // }
  5981.  
  5982. } else {
  5983. assertor(() => fnIntegrity(cProto.computeContainerStyle, '2.46.29'));
  5984. }
  5985.  
  5986. cProto.computeContainerStyle66 = cProto.computeContainerStyle;
  5987.  
  5988. cProto.computeContainerStyle = dProto.computeContainerStyleForAnimatorEnabled;
  5989.  
  5990. }
  5991.  
  5992. if (doTimerFnModification === true) hasTimerModified = true;
  5993.  
  5994. if (!!ATTEMPT_ANIMATED_TICKER_BACKGROUND) {
  5995. console.log('ATTEMPT_ANIMATED_TICKER_BACKGROUND', tag, doAnimator ? 'OK' : 'NG');
  5996. }
  5997.  
  5998. if (!doAnimator && (rafHackState === 2 || rafHackState === 4)) {
  5999. console.log('RAF_HACK_TICKERS', tag, doRAFHack ? "OK" : "NG");
  6000. }
  6001.  
  6002. }
  6003.  
  6004. const selector = tags.join(', ');
  6005. const elements = document.querySelectorAll(selector);
  6006. if (elements.length >= 1) {
  6007. for (const elm of elements) {
  6008. if (insp(elm).isAttached === true) {
  6009. fpTicker(elm);
  6010. }
  6011. }
  6012. }
  6013.  
  6014. console.log("[End]");
  6015. console.groupEnd();
  6016.  
  6017.  
  6018. }).catch(console.warn);
  6019.  
  6020. customElements.whenDefined('yt-live-chat-ticker-renderer').then(() => {
  6021.  
  6022. mightFirstCheckOnYtInit();
  6023. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-ticker-renderer hacks");
  6024. console.log("[Begin]");
  6025. (() => {
  6026.  
  6027. /* pending!!
  6028.  
  6029. handleLiveChatAction
  6030.  
  6031. removeTickerItemById
  6032.  
  6033. _itemsChanged
  6034. itemsChanged
  6035.  
  6036. handleMarkChatItemAsDeletedAction
  6037. handleMarkChatItemsByAuthorAsDeletedAction
  6038. handleRemoveChatItemByAuthorAction
  6039.  
  6040.  
  6041. */
  6042.  
  6043. const tag = "yt-live-chat-ticker-renderer"
  6044. const dummy = document.createElement(tag);
  6045.  
  6046. const cProto = getProto(dummy);
  6047. if (!cProto || !cProto.attached) {
  6048. console.warn(`proto.attached for ${tag} is unavailable.`);
  6049. return;
  6050. }
  6051.  
  6052. const do_amend_ticker_handleLiveChatAction = AMEND_TICKER_handleLiveChatAction && !AMEND_TICKER_handleLiveChatAction_v3
  6053. && typeof cProto.handleLiveChatAction === 'function' && !cProto.handleLiveChatAction45 && cProto.handleLiveChatAction.length === 1
  6054. && typeof cProto.handleLiveChatActions === 'function' && !cProto.handleLiveChatActions45 && cProto.handleLiveChatActions.length === 1
  6055. && typeof cProto.unshift === 'function' && cProto.unshift.length === 1
  6056. && typeof cProto.handleMarkChatItemAsDeletedAction === 'function' && cProto.handleMarkChatItemAsDeletedAction.length === 1
  6057. && typeof cProto.removeTickerItemById === 'function' && cProto.removeTickerItemById.length === 1
  6058. && typeof cProto.handleMarkChatItemsByAuthorAsDeletedAction === 'function' && cProto.handleMarkChatItemsByAuthorAsDeletedAction.length === 1
  6059. && typeof cProto.handleRemoveChatItemByAuthorAction === 'function' && cProto.handleRemoveChatItemByAuthorAction.length === 1
  6060. ;
  6061.  
  6062. console.log('do_amend_ticker_handleLiveChatAction', fnIntegrity(cProto.handleLiveChatAction), fnIntegrity(cProto.handleLiveChatActions))
  6063.  
  6064.  
  6065. if (do_amend_ticker_handleLiveChatAction) {
  6066.  
  6067.  
  6068. if (fnIntegrity(cProto.handleLiveChatActions) === '1.23.12') {
  6069.  
  6070. console.log(`handleLiveChatActions`, 'modified');
  6071.  
  6072. cProto.handleLiveChatActions45 = cProto.handleLiveChatActions;
  6073.  
  6074. cProto.handleLiveChatActions = function (a) {
  6075. /**
  6076. *
  6077. f.handleLiveChatActions = function(a) {
  6078. a.length && (a.forEach(this.handleLiveChatAction, this),
  6079. this.updateHighlightedItem(),
  6080. this.shouldAnimateIn = !0)
  6081. }
  6082. *
  6083. */
  6084. const len = a.length;
  6085. if (len) {
  6086. const batchToken = String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 19861 + 19861).toString(36);
  6087.  
  6088. if (FIX_BATCH_TICKER_ORDER && len >= 2) {
  6089.  
  6090. // Primarily for the initial batch, this is due to replayBuffer._back.
  6091. const entries = [];
  6092. const entriesI = [];
  6093. for (let i = 0; i < len; i++) {
  6094. const item = ((a[i] || 0).addLiveChatTickerItemAction || 0).item || 0;
  6095. const timestampUsec = item ? parseInt(getTimestampUsec(item[firstObjectKey(item)]), 10) : 0;
  6096. if (timestampUsec > 0) {
  6097. entriesI.push(i);
  6098. binaryInsert(entries, { e: a[i], timestampUsec }, (a, b) => {
  6099. const diff = a.timestampUsec - b.timestampUsec;
  6100. return diff > 0.1 ? 1 : diff < -0.1 ? -1 : 0;
  6101. });
  6102. }
  6103. }
  6104. const mLen = entries.length;
  6105. if (mLen >= 2) {
  6106. for (let j = 0; j < mLen; j++) {
  6107. a[entriesI[j]] = entries[j].e;
  6108. }
  6109. }
  6110. entries.length = 0;
  6111. entriesI.length = 0;
  6112. }
  6113. for (const action of a) {
  6114. action.__batchId45__ = batchToken;
  6115. this.handleLiveChatAction(action);
  6116. }
  6117. }
  6118. }
  6119.  
  6120.  
  6121. }
  6122.  
  6123.  
  6124. console.log(`handleLiveChatAction`, 'modified');
  6125.  
  6126. const cacheChatActions = new LimitedSizeSet(16);
  6127.  
  6128. cProto.handleLiveChatAction45 = cProto.handleLiveChatAction;
  6129.  
  6130. cProto.handleLiveChatAction = function (a) {
  6131.  
  6132. const key = firstObjectKey(a);
  6133. if (!key) return;
  6134.  
  6135. const val = a[key];
  6136. let itemKey = '';
  6137. let itemId = '';
  6138. const valItem = val ? val.item : null;
  6139. if (valItem) {
  6140. itemKey = firstObjectKey(valItem);
  6141. if (itemKey) {
  6142. const itemVal = valItem[itemKey];
  6143. itemId = itemVal ? itemVal.id : '';
  6144. if (itemId) {
  6145. const cacheKey = `${key}.${itemKey}::${itemId}`;
  6146. if (key === 'addChatItemAction' && itemId) return; // no need
  6147. if (cacheChatActions.has(cacheKey)) {
  6148. console.log('handleLiveChatAction Repeated Item', cacheKey);
  6149. return;
  6150. } else {
  6151. cacheChatActions.add(cacheKey);
  6152. }
  6153. }
  6154. }
  6155. }
  6156. return this.handleLiveChatAction45(a);
  6157. };
  6158.  
  6159. console.log("AMEND_TICKER_handleLiveChatAction - OK (v2)");
  6160.  
  6161. } else if (0 && do_amend_ticker_handleLiveChatAction
  6162. && '|1.63.48|1.64.48|'.includes(`|${fnIntegrity(cProto.handleLiveChatAction)}|`)
  6163. && fnIntegrity(cProto.handleLiveChatActions) === '1.23.12'
  6164. ) {
  6165.  
  6166. cProto.handleLiveChatActions45 = cProto.handleLiveChatActions;
  6167.  
  6168. cProto.handleLiveChatActions = function (a) {
  6169. /**
  6170. *
  6171. f.handleLiveChatActions = function(a) {
  6172. a.length && (a.forEach(this.handleLiveChatAction, this),
  6173. this.updateHighlightedItem(),
  6174. this.shouldAnimateIn = !0)
  6175. }
  6176. *
  6177. */
  6178.  
  6179. if (a.length) {
  6180. const batchToken = String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 19861 + 19861).toString(36);
  6181. const len = a.length;
  6182. if (FIX_BATCH_TICKER_ORDER && len >= 2) {
  6183. // Primarily for the initial batch, this is due to replayBuffer._back.
  6184. const entries = [];
  6185. const entriesI = [];
  6186. for (let i = 0; i < len; i++) {
  6187. const item = ((a[i] || 0).addLiveChatTickerItemAction || 0).item || 0;
  6188. if (item) {
  6189. const itemRendererKey = firstObjectKey(item);
  6190. const itemRenderer = item[itemRendererKey];
  6191. if (itemRenderer) {
  6192. let timestampUsec = getTimestampUsec(itemRenderer);
  6193. if (timestampUsec !== null) {
  6194. timestampUsec = parseInt(timestampUsec, 10);
  6195. if (timestampUsec > 0) {
  6196. entriesI.push(i);
  6197. entries.push({ e: a[i], timestampUsec })
  6198. }
  6199. }
  6200. }
  6201. }
  6202. }
  6203. const mLen = entries.length;
  6204. if (mLen >= 2) {
  6205. entries.sort((a, b) => {
  6206. const diff = a.timestampUsec - b.timestampUsec;
  6207. return diff > 0.1 ? 1 : diff < -0.1 ? -1 : 0;
  6208. });
  6209. for (let j = 0; j < mLen; j++) {
  6210. const i = entriesI[j];
  6211. a[i] = entries[j].e;
  6212. }
  6213. }
  6214. entries.length = 0;
  6215. entriesI.length = 0;
  6216. }
  6217. for (const action of a) {
  6218. action.__batchId45__ = batchToken;
  6219. this.handleLiveChatAction(action);
  6220. }
  6221. }
  6222. }
  6223.  
  6224. cProto.handleLiveChatAction45 = cProto.handleLiveChatAction;
  6225.  
  6226. cProto._nszlv_ = 0;
  6227. cProto._stackedLCAs_ = null;
  6228. cProto._lastAddItem_ = null;
  6229. cProto._lastAddItemInStack_ = false;
  6230. cProto.handleLiveChatAction = function (a) {
  6231.  
  6232. /**
  6233. *
  6234. *
  6235. f.handleLiveChatAction = function(a) {
  6236. var b = C(a, xO)
  6237. , c = C(a, yO)
  6238. , d = C(a, o1a)
  6239. , e = C(a, p1a);
  6240. a = C(a, A1a);
  6241. b ? this.unshift("items", b.item) : c ? this.handleMarkChatItemAsDeletedAction(c) : d ? this.removeTickerItemById(d.targetItemId) : e ? this.handleMarkChatItemsByAuthorAsDeletedAction(e) : a && this.handleRemoveChatItemByAuthorAction(a)
  6242. }
  6243. *
  6244. */
  6245.  
  6246. // return this.handleLiveChatAction45(a)
  6247. const { addChatItemAction, addLiveChatTickerItemAction, markChatItemAsDeletedAction,
  6248. removeChatItemAction, markChatItemsByAuthorAsDeletedAction, removeChatItemByAuthorAction, __batchId45__ } = a
  6249.  
  6250. if (addChatItemAction) return;
  6251. const d = Date.now();
  6252.  
  6253. if (this._stackedLCAs_ === null) this._stackedLCAs_ = [];
  6254. const stackArr = this._stackedLCAs_;
  6255. let newStackEntry = null;
  6256. if (addLiveChatTickerItemAction) {
  6257. let isDuplicated = false;
  6258.  
  6259. const newItem = addLiveChatTickerItemAction.item;
  6260. const tickerType = firstObjectKey(newItem);
  6261. if (!tickerType) return;
  6262. const tickerItem = newItem[tickerType];
  6263. const tickerId = tickerItem.id;
  6264. if (!tickerId) return;
  6265.  
  6266. if (this._lastAddItem_ && this._lastAddItem_.id === tickerId) {
  6267. let prevTickerItem = null;
  6268. if (this._lastAddItemInStack_) {
  6269. const entry = stackArr[stackArr.length - 1]; // only consider the last entry
  6270. if (entry && entry.action === 'addItem') {
  6271. prevTickerItem = entry.data; // only consider the first item;
  6272. }
  6273. } else {
  6274. prevTickerItem = this.items[0]; // only consider the first item;
  6275. }
  6276. if (prevTickerItem && prevTickerItem[tickerType]) {
  6277. if (prevTickerItem[tickerType].id === tickerId) {
  6278. isDuplicated = true;
  6279. }
  6280. }
  6281. }
  6282. if (!isDuplicated) {
  6283. this._lastAddItem_ = tickerItem;
  6284. this._lastAddItemInStack_ = true;
  6285. // console.log('newItem', newItem)
  6286.  
  6287. const item = newItem;
  6288. const key = firstObjectKey(item);
  6289. if (key) {
  6290. const itemRenderer = item[key] || 0;
  6291. if (itemRenderer.fullDurationSec > 0) {
  6292. itemRenderer.__actionAt__ = d;
  6293. }
  6294. }
  6295.  
  6296. newStackEntry = { action: 'addItem', data: newItem };
  6297.  
  6298. } else {
  6299. console.log('handleLiveChatAction Repeated Item', tickerItem.id, tickerItem); // happen in both live and playback. Reason Unknown.
  6300. return;
  6301. }
  6302.  
  6303. } else {
  6304. markChatItemAsDeletedAction && (newStackEntry = { action: 'mcItemD', data: markChatItemAsDeletedAction });
  6305. removeChatItemAction && (newStackEntry = { action: 'removeItemById', data: removeChatItemAction.targetId });
  6306. markChatItemsByAuthorAsDeletedAction && (newStackEntry = { action: 'mcItemAD', data: markChatItemsByAuthorAsDeletedAction });
  6307. removeChatItemByAuthorAction && (newStackEntry = { action: 'removeItemA', data: removeChatItemByAuthorAction })
  6308. }
  6309.  
  6310.  
  6311. if (!newStackEntry) return;
  6312. stackArr.push(newStackEntry);
  6313.  
  6314.  
  6315. this._nszlv_++;
  6316. if (this._nszlv_ > 1e9) this._nszlv_ = 9;
  6317. const tid = this._nszlv_;
  6318.  
  6319. newStackEntry.__batchId45__ = __batchId45__ || '';
  6320. newStackEntry.dateTime = Date.now();
  6321.  
  6322.  
  6323. foregroundPromiseFn().then(() => {
  6324.  
  6325. if (tid !== this._nszlv_) return;
  6326. const dateNow = Date.now(); // time difference to shift animation start time shall be considered. (pending)
  6327. const stackArr = this._stackedLCAs_.slice(0);
  6328. this._stackedLCAs_.length = 0;
  6329. this._lastAddItemInStack_ = false;
  6330. let lastDateTime = 0;
  6331. let prevBatchId = '';
  6332. const addItems = [];
  6333. // const previousShouldAnimateIn = this.shouldAnimateIn;
  6334.  
  6335. const addItemsFx = () => {
  6336.  
  6337. if (addItems.length >= 1) {
  6338. const eArr = addItems.slice(0);
  6339. addItems.length = 0;
  6340. if (ADJUST_TICKER_DURATION_ALIGN_RENDER_TIME) {
  6341.  
  6342. const arr = []; // size of arr <= size of eArr
  6343. const d = Date.now();
  6344. for (const item of eArr) {
  6345. const key = firstObjectKey(item);
  6346. if (key) {
  6347.  
  6348.  
  6349. const itemRenderer = item[key] || 0;
  6350. const { durationSec, fullDurationSec, __actionAt__ } = itemRenderer;
  6351. if (__actionAt__ > 0 && durationSec > 0 && fullDurationSec > 0) {
  6352.  
  6353.  
  6354. const offset = d - __actionAt__;
  6355. if (offset > 0 && typeof durationSec === 'number' && typeof fullDurationSec === 'number' && fullDurationSec >= durationSec) {
  6356. const adjustedDurationSec = durationSec - Math.floor(offset / 1000);
  6357. if (adjustedDurationSec < durationSec) { // prevent NaN
  6358. // console.log('adjustedDurationSec', adjustedDurationSec);
  6359. if (adjustedDurationSec > 0) {
  6360. // console.log('offset Sec', Math.floor(offset / 1000));
  6361. itemRenderer.durationSec = adjustedDurationSec;
  6362. } else {
  6363. // if adjustedDurationSec equal 0 or invalid
  6364. continue; // skip adding
  6365. }
  6366. }
  6367.  
  6368. }
  6369.  
  6370. }
  6371.  
  6372. if (fullDurationSec > 0 && durationSec < 1) continue; // fallback check
  6373.  
  6374.  
  6375.  
  6376. }
  6377. arr.push(item)
  6378. // arr.unshift(item);
  6379. }
  6380.  
  6381.  
  6382. // console.log(arr.slice(0))
  6383. this.unshift("items", ...arr);
  6384. } else {
  6385. this.unshift("items", ...eArr);
  6386. }
  6387. }
  6388. }
  6389.  
  6390. for (const entry of stackArr) {
  6391.  
  6392. const { action, data, dateTime, __batchId45__ } = entry;
  6393.  
  6394. const finishLastAction = (
  6395. (prevBatchId !== __batchId45__ && prevBatchId)
  6396. || (dateNow - lastDateTime >= 1000 && dateNow - dateTime < 1000)
  6397. );
  6398.  
  6399. const addPrevItems = addItems.length >= 1 && (finishLastAction || action !== 'addItem');
  6400. lastDateTime = dateTime;
  6401. prevBatchId = __batchId45__;
  6402.  
  6403. if (addPrevItems) {
  6404. addItemsFx();
  6405. }
  6406.  
  6407. if (action === 'addItem') addItems.unshift(data);
  6408. else if (action === 'mcItemD') this.handleMarkChatItemAsDeletedAction(data);
  6409. else if (action === 'removeItemById') this.removeTickerItemById(data);
  6410. else if (action === 'mcItemAD') this.handleMarkChatItemsByAuthorAsDeletedAction(data);
  6411. else if (action === 'removeItemA') this.handleRemoveChatItemByAuthorAction(data);
  6412.  
  6413. }
  6414.  
  6415. addItemsFx();
  6416. })
  6417.  
  6418. }
  6419.  
  6420. console.log("AMEND_TICKER_handleLiveChatAction - OK (v1)");
  6421. } else {
  6422. console.log("AMEND_TICKER_handleLiveChatAction - NG");
  6423. }
  6424.  
  6425.  
  6426.  
  6427. const do_amend_ticker_handleLiveChatAction_v3 = AMEND_TICKER_handleLiveChatAction_v3 && !AMEND_TICKER_handleLiveChatAction
  6428. && typeof cProto.handleLiveChatAction === 'function' && !cProto.handleLiveChatAction45 && cProto.handleLiveChatAction.length === 1
  6429. && typeof cProto.handleLiveChatActions === 'function' && !cProto.handleLiveChatActions45 && cProto.handleLiveChatActions.length === 1
  6430. && typeof cProto.unshift === 'function' && cProto.unshift.length === 1
  6431. && typeof cProto.handleMarkChatItemAsDeletedAction === 'function' && cProto.handleMarkChatItemAsDeletedAction.length === 1
  6432. && typeof cProto.removeTickerItemById === 'function' && cProto.removeTickerItemById.length === 1
  6433. && typeof cProto.handleMarkChatItemsByAuthorAsDeletedAction === 'function' && cProto.handleMarkChatItemsByAuthorAsDeletedAction.length === 1
  6434. && typeof cProto.handleRemoveChatItemByAuthorAction === 'function' && cProto.handleRemoveChatItemByAuthorAction.length === 1
  6435. ;
  6436.  
  6437. if (do_amend_ticker_handleLiveChatAction_v3) {
  6438.  
  6439. /*
  6440. f.handleLiveChatActions = function(a) {
  6441. a.length && (a.forEach(this.handleLiveChatAction, this),
  6442. this.updateHighlightedItem(),
  6443. this.shouldAnimateIn = !0)
  6444. }
  6445. */
  6446.  
  6447. /*
  6448.  
  6449. f.handleLiveChatAction = function(a) {
  6450. var b = y(a, PM)
  6451. , c = y(a, QM)
  6452. , d = y(a, OM)
  6453. , e = y(a, Yab);
  6454. a = y(a, ibb);
  6455. 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)
  6456. }
  6457. */
  6458.  
  6459. const arr00 = new Array(1);
  6460. arr00.forEach = () => { };
  6461. arr00.push = (...args) => { return 1 + args.length };
  6462. arr00.pop = () => { };
  6463. arr00.shift = () => { };
  6464. arr00.unshift = () => { };
  6465. arr00.splice = () => [];
  6466. cProto.handleLiveChatActionsArr0 = arr00;
  6467.  
  6468. cProto.handleLiveChatActions58 = cProto.handleLiveChatActions;
  6469. cProto.xGqq4mo = null;
  6470. cProto.xGqq4Flg = 0;
  6471. cProto.xGqq4moPreparePromise = null;
  6472. cProto.xGqq4f = function () {
  6473. if (this.xGqq4Flg === 2) {
  6474. this.xGqq4Flg = 0;
  6475. tickerPE(async () => { // avoid confliction with ticker generation
  6476. await this.xGqq4moPreparePromise; // just in case
  6477. const s = this.handleLiveChatActionsArr0;
  6478. try {
  6479. this.handleLiveChatActions58(s);
  6480. } catch (e) {
  6481. console.warn(e);
  6482. }
  6483. // console.log('xGqq4f done')
  6484. });
  6485.  
  6486. }
  6487. }
  6488. const liveActionQM = new WeakSet();
  6489. let liveActionsLastTickerAction = null;
  6490. const lastTickerActionM = new WeakSet();
  6491. cProto.handleLiveChatActions = function (a) {
  6492. // let promise = null;
  6493. if (a && a.length) {
  6494. /** @type {MutationObserver | null} */
  6495. let mo = this.xGqq4mo;
  6496. // console.log('xGqq4f aaaa')
  6497. const hostElement = this.hostElement;
  6498. if (hostElement instanceof HTMLElement) {
  6499. if (mo === null || (mo instanceof MutationObserver && this.xGqq4p !== hostElement.xGqq4q)) {
  6500. if (mo instanceof MutationObserver) {
  6501. mo.disconnect();
  6502. mo.takeRecords();
  6503. }
  6504. this.xGqq4mo = mo = new MutationObserver(() => {
  6505. this.xGqq4f();
  6506. })
  6507. const moid = `dm-${Date.now()}-${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;;
  6508. this.xGqq4p = moid;
  6509. hostElement.xGqq4q = moid;
  6510. mo.observe(hostElement, { subtree: true, childList: true });
  6511. }
  6512. }
  6513. for (const u of a) {
  6514. u && liveActionQM.add(u)
  6515. }
  6516.  
  6517. /** @type {Promise} */
  6518. const pastPromise = this.xGqq4moPreparePromise || null;
  6519. this.xGqq4moPreparePromise = (async () => {
  6520. try {
  6521. await pastPromise; // just in case
  6522. liveActionsLastTickerAction = null;
  6523. a.forEach(this.handleLiveChatAction, this);
  6524. if (liveActionsLastTickerAction) lastTickerActionM.add(liveActionsLastTickerAction)
  6525. } catch (e) { console.warn(e); } // Promise catch can make the promise always resolved
  6526. // now tickerPE can execute
  6527. })();
  6528.  
  6529.  
  6530. // console.log('xGqq4f bbbb')
  6531. // promise = this.handleLiveChatAction_LastPromise;
  6532. // const f = () => {
  6533. // const s = this.handleLiveChatActionsArr0;
  6534. // try {
  6535. // return this.handleLiveChatActions58(s);
  6536. // } catch (e) {
  6537. // console.warn(e);
  6538. // }
  6539. // }
  6540. // if (!promise) {
  6541. // f();
  6542. // } else {
  6543. // promise.then(f);
  6544. // }
  6545. } else {
  6546. return this.handleLiveChatActions58(a);
  6547. }
  6548. }
  6549.  
  6550. // 12:17:05.748 PM
  6551. // 12:17:05.785 v {name: 'addLiveChatTickerItemAction'}
  6552. // 12:17:08.059 QM
  6553. // 12:17:08.068 v {name: 'markChatItemAsDeletedAction'}
  6554. // 12:17:09.123 OM
  6555. // 12:17:09.133 v {name: 'removeChatItemAction'}
  6556. // 12:17:11.566 Yab
  6557. // 12:17:11.574 v {name: 'markChatItemsByAuthorAsDeletedAction'}
  6558. // 12:17:14.272 ibb
  6559. // 12:17:14.282 v {name: 'removeChatItemByAuthorAction'}
  6560.  
  6561. const keyFilter = (a, keySet) => {
  6562. if (typeof (a || 0) === 'object') {
  6563. for (const k of Object.keys(a)) {
  6564. if (keySet.has(k)) {
  6565. return k;
  6566. }
  6567. }
  6568. }
  6569. return null;
  6570. }
  6571.  
  6572. cProto.lcuJB = function () {
  6573. this.ddnB8 = 1;
  6574. let res = new Set();
  6575. const pxy = new Proxy({}, {
  6576. get(target, prop) {
  6577. res.add(prop);
  6578. },
  6579. set(target, prop, value) {
  6580. return true;
  6581. }
  6582. });
  6583. this.handleLiveChatAction(pxy);
  6584. this.ddnB8 = 0;
  6585. return res.size > 0 ? res : null;
  6586. }
  6587.  
  6588. cProto.ddnB8 = 0;
  6589. cProto.handleLiveChatAction58 = cProto.handleLiveChatAction;
  6590. cProto.liveChatActionFilterKeys = null;
  6591. cProto.handleLiveChatAction = function (a) {
  6592. if (this.ddnB8) return this.handleLiveChatAction58(a);
  6593. const inQM = a && liveActionQM.delete(a); // true if added from handleLiveChatActions
  6594. let keySet = this.liveChatActionFilterKeys;
  6595. if (keySet === null) {
  6596. const keys = this.lcuJB();
  6597. this.liveChatActionFilterKeys = keySet = (keys || false);
  6598. }
  6599. if (!keySet) {
  6600. if (!unexpectedErr) {
  6601. console.error(unexpectedErr = "************************ [YouTube Super Fast Chat] TickerRenderer:handleLiveChatAction keySet not found; ERR 0xF3D0 ************************");
  6602. }
  6603. return this.handleLiveChatAction58(a);
  6604. }
  6605. const key = keyFilter(a, keySet);
  6606. if (!key) {
  6607. return this.handleLiveChatAction58(a); // just by default
  6608. }
  6609.  
  6610. if (inQM) {
  6611. liveActionsLastTickerAction = a;
  6612. }
  6613. this.handleLiveChatAction_LastPromise = tickerPE(async () => {
  6614. await this.xGqq4moPreparePromise; // avoid tickerPE is called before actions under looping in handleLiveChatActions
  6615. const inLQM = lastTickerActionM.delete(a); // multiple candidates
  6616. if (inLQM) this.xGqq4Flg = 2; // 2 to 2 in case two batches are added "in the same time"
  6617. this.handleLiveChatAction58(a);
  6618. // if (inLQM) await timelineResolve(); // timing split by marco event to make tickers generation in different 16ms frame
  6619. // else await Promise.resolve();
  6620. // await Promise.resolve();
  6621. await timelineResolve(); // timing split by marco event to make tickers generation in different 16ms frame
  6622. });
  6623. }
  6624.  
  6625. }
  6626.  
  6627. if (RAF_FIX_keepScrollClamped) {
  6628.  
  6629. // to be improved
  6630.  
  6631. if (typeof cProto.keepScrollClamped === 'function' && !cProto.keepScrollClamped72 && fnIntegrity(cProto.keepScrollClamped) === '0.17.10') {
  6632.  
  6633. cProto.keepScrollClamped72 = cProto.keepScrollClamped;
  6634. cProto.keepScrollClamped = function () {
  6635. this._bound_keepScrollClamped = this._bound_keepScrollClamped || this.keepScrollClamped.bind(this);
  6636. this.scrollClampRaf = requestAnimationFrame(this._bound_keepScrollClamped);
  6637. this.maybeClampScroll()
  6638. }
  6639.  
  6640. console.log('RAF_FIX: keepScrollClamped', tag, "OK")
  6641. } else {
  6642.  
  6643. assertor(() => fnIntegrity(cProto.keepScrollClamped, '0.17.10'));
  6644. console.log('RAF_FIX: keepScrollClamped', tag, "NG")
  6645. }
  6646.  
  6647. }
  6648.  
  6649.  
  6650. if (RAF_FIX_scrollIncrementally && typeof cProto.startScrolling === 'function' && typeof cProto.scrollIncrementally === 'function' && fnIntegrity(cProto.startScrolling) === '1.43.31' && '|1.78.45|1.82.43|'.indexOf('|' + fnIntegrity(cProto.scrollIncrementally) + '|') >= 0) {
  6651. // to be replaced by animator
  6652.  
  6653. cProto.startScrolling = function (a) {
  6654. this.scrollStopHandle && this.cancelAsync(this.scrollStopHandle);
  6655. this.asyncHandle && cancelAnimationFrame(this.asyncHandle);
  6656. this.lastFrameTimestamp = this.scrollStartTime = performance.now();
  6657. this.scrollRatePixelsPerSecond = a;
  6658. this._bound_scrollIncrementally = this._bound_scrollIncrementally || this.scrollIncrementally.bind(this);
  6659. this.asyncHandle = requestAnimationFrame(this._bound_scrollIncrementally)
  6660. };
  6661.  
  6662. // related functions: startScrollBack, startScrollingLeft, startScrollingRight, etc.
  6663.  
  6664. // 2024.03.26
  6665. // https://www.youtube.com/s/desktop/436f2749/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  6666. /*
  6667.  
  6668. f.scrollIncrementally = function(a) {
  6669. var b = a - (this.lastFrameTimestamp || 0);
  6670. Q(this.hostElement).querySelector(this.tickerBarQuery).scrollLeft += b / 1E3 * (this.scrollRatePixelsPerSecond || 0);
  6671. this.maybeClampScroll();
  6672. this.updateArrows();
  6673. this.lastFrameTimestamp = a;
  6674. 0 < Q(this.hostElement).querySelector(this.tickerBarQuery).scrollLeft || this.scrollRatePixelsPerSecond && 0 < this.scrollRatePixelsPerSecond ? this.asyncHandle = window.requestAnimationFrame(this.scrollIncrementally.bind(this)) : this.stopScrolling()
  6675. }
  6676. */
  6677.  
  6678. cProto.__getTickerBarQuery__ = function () {
  6679. const tickerBarQuery = this.tickerBarQuery === '#items' ? this.$.items : this.hostElement.querySelector(this.tickerBarQuery);
  6680. return tickerBarQuery;
  6681. }
  6682.  
  6683. cProto.scrollIncrementally = (RAF_FIX_scrollIncrementally === 2) ? function (a) {
  6684. const b = a - (this.lastFrameTimestamp || 0);
  6685. const rate = this.scrollRatePixelsPerSecond
  6686. const q = b / 1E3 * (rate || 0);
  6687.  
  6688. const tickerBarQuery = this.__getTickerBarQuery__();
  6689. const sl = tickerBarQuery.scrollLeft;
  6690. // console.log(rate, sl, q)
  6691. if (this.lastFrameTimestamp == this.scrollStartTime) {
  6692.  
  6693. } else if (q > -1e-5 && q < 1e-5) {
  6694.  
  6695. } else {
  6696. let cond1 = sl > 0 && rate > 0 && q > 0;
  6697. let cond2 = sl > 0 && rate < 0 && q < 0;
  6698. let cond3 = sl < 1e-5 && sl > -1e-5 && rate > 0 && q > 0;
  6699. if (cond1 || cond2 || cond3) {
  6700. tickerBarQuery.scrollLeft += q;
  6701. this.maybeClampScroll();
  6702. this.updateArrows();
  6703. }
  6704. }
  6705.  
  6706. this.lastFrameTimestamp = a;
  6707. this._bound_scrollIncrementally = this._bound_scrollIncrementally || this.scrollIncrementally.bind(this);
  6708. 0 < tickerBarQuery.scrollLeft || rate && 0 < rate ? this.asyncHandle = requestAnimationFrame(this._bound_scrollIncrementally) : this.stopScrolling()
  6709. } : function (a) {
  6710. const b = a - (this.lastFrameTimestamp || 0);
  6711. const tickerBarQuery = this.__getTickerBarQuery__();
  6712. tickerBarQuery.scrollLeft += b / 1E3 * (this.scrollRatePixelsPerSecond || 0);
  6713. this.maybeClampScroll();
  6714. this.updateArrows();
  6715. this.lastFrameTimestamp = a;
  6716. this._bound_scrollIncrementally = this._bound_scrollIncrementally || this.scrollIncrementally.bind(this);
  6717. 0 < tickerBarQuery.scrollLeft || this.scrollRatePixelsPerSecond && 0 < this.scrollRatePixelsPerSecond ? this.asyncHandle = requestAnimationFrame(this._bound_scrollIncrementally) : this.stopScrolling()
  6718. };
  6719.  
  6720. console.log(`RAF_FIX: scrollIncrementally${RAF_FIX_scrollIncrementally}`, tag, "OK")
  6721. } else {
  6722. assertor(() => fnIntegrity(cProto.startScrolling, '1.43.31'));
  6723. assertor(() => fnIntegrity(cProto.scrollIncrementally, '1.82.43'));
  6724. console.log('cProto.startScrolling', cProto.startScrolling);
  6725. console.log('cProto.scrollIncrementally', cProto.scrollIncrementally);
  6726. console.log('RAF_FIX: scrollIncrementally', tag, "NG")
  6727. }
  6728.  
  6729.  
  6730. if (CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED && typeof cProto.attached === 'function' && !cProto.attached37 && typeof cProto.detached === 'function' && !cProto.detached37) {
  6731.  
  6732. cProto.attached37 = cProto.attached;
  6733. cProto.detached37 = cProto.detached;
  6734.  
  6735. let naohzId = 0;
  6736. cProto.__naohzId__ = 0;
  6737. cProto.attached = function () {
  6738. Promise.resolve().then(() => {
  6739.  
  6740. const hostElement = this.hostElement || this;
  6741. if (!(hostElement instanceof HTMLElement)) return;
  6742. if (!HTMLElement.prototype.matches.call(hostElement, '.yt-live-chat-renderer')) return;
  6743. const ironPage = HTMLElement.prototype.closest.call(hostElement, 'iron-pages.yt-live-chat-renderer');
  6744. // or #chat-messages
  6745. if (!ironPage) return;
  6746.  
  6747. if (this.__naohzId__) removeEventListener.call(ironPage, 'click', this.messageBoxClickHandlerForFade, { capture: false, passive: true });
  6748. if (naohzId > 1e9) naohzId = naohzId % 1e4;
  6749. this.__naohzId__ = ++naohzId;
  6750. ironPage.setAttribute('naohz', `${+this.__naohzId__}`);
  6751.  
  6752. addEventListener.call(ironPage, 'click', this.messageBoxClickHandlerForFade, { capture: false, passive: true });
  6753.  
  6754. });
  6755. return this.attached37.apply(this, arguments);
  6756. };
  6757. cProto.detached = function () {
  6758. Promise.resolve().then(() => {
  6759.  
  6760. const ironPage = document.querySelector(`iron-pages[naohz="${+this.__naohzId__}"]`);
  6761. if (!ironPage) return;
  6762.  
  6763. removeEventListener.call(ironPage, 'click', this.messageBoxClickHandlerForFade, { capture: false, passive: true });
  6764.  
  6765. });
  6766. return this.detached37.apply(this, arguments);
  6767. };
  6768.  
  6769. const clickFade = (u) => {
  6770. u.click();
  6771. };
  6772. cProto.messageBoxClickHandlerForFade = async (evt) => {
  6773.  
  6774. const target = (evt || 0).target || 0;
  6775. if (!target) return;
  6776.  
  6777. for (let p = target; p instanceof HTMLElement; p = nodeParent(p)) {
  6778. const is = p.is;
  6779. if (typeof is === 'string' && is) {
  6780.  
  6781. if (is === 'yt-live-chat-pinned-message-renderer') {
  6782. return;
  6783. }
  6784. if (is === 'iron-pages' || is === 'yt-live-chat-renderer' || is === 'yt-live-chat-app') {
  6785. const fade = HTMLElement.prototype.querySelector.call(p, 'yt-live-chat-pinned-message-renderer:not([hidden]) #fade');
  6786. if (fade) {
  6787. Promise.resolve(fade).then(clickFade);
  6788. evt && evt.stopPropagation();
  6789. }
  6790. return;
  6791. }
  6792. if (is !== 'yt-live-chat-ticker-renderer') {
  6793. if (is.startsWith('yt-live-chat-ticker-')) return;
  6794. if (!is.endsWith('-renderer')) return;
  6795. }
  6796.  
  6797. } else {
  6798. if ((p.nodeName || '').includes('BUTTON')) return;
  6799. }
  6800.  
  6801. }
  6802. };
  6803.  
  6804. console.log("CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED - OK")
  6805.  
  6806. } else {
  6807. console.log("CLOSE_TICKER_PINNED_MESSAGE_WHEN_HEADER_CLICKED - NG")
  6808. }
  6809.  
  6810.  
  6811. })();
  6812.  
  6813. console.log("[End]");
  6814.  
  6815. console.groupEnd();
  6816.  
  6817. }).catch(console.warn);
  6818.  
  6819.  
  6820.  
  6821. if (ENABLE_RAF_HACK_INPUT_RENDERER || DELAY_FOCUSEDCHANGED) {
  6822.  
  6823. customElements.whenDefined("yt-live-chat-message-input-renderer").then(() => {
  6824.  
  6825. mightFirstCheckOnYtInit();
  6826. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-message-input-renderer hacks");
  6827. console.log("[Begin]");
  6828. (() => {
  6829.  
  6830.  
  6831.  
  6832. const tag = "yt-live-chat-message-input-renderer"
  6833. const dummy = document.createElement(tag);
  6834.  
  6835. const cProto = getProto(dummy);
  6836. if (!cProto || !cProto.attached) {
  6837. console.warn(`proto.attached for ${tag} is unavailable.`);
  6838. return;
  6839. }
  6840.  
  6841.  
  6842. if (ENABLE_RAF_HACK_INPUT_RENDERER && rafHub !== null) {
  6843.  
  6844. let doHack = false;
  6845. if (typeof cProto.handleTimeout === 'function' && typeof cProto.updateTimeout === 'function') {
  6846.  
  6847. // not cancellable
  6848.  
  6849.  
  6850. doHack = fnIntegrity(cProto.handleTimeout, '1.27.16') && fnIntegrity(cProto.updateTimeout, '1.50.33');
  6851.  
  6852. }
  6853.  
  6854. if (doHack) {
  6855.  
  6856. cProto.handleTimeout = function (a) {
  6857. console.log('cProto.handleTimeout', tag)
  6858. if (!this.boundUpdateTimeout38_) this.boundUpdateTimeout38_ = this.updateTimeout.bind(this);
  6859. this.timeoutDurationMs = this.timeoutMs = a;
  6860. this.countdownRatio = 1;
  6861. 0 === this.lastTimeoutTimeMs && rafHub.request(this.boundUpdateTimeout38_)
  6862. };
  6863. cProto.updateTimeout = function (a) {
  6864. console.log('cProto.updateTimeout', tag)
  6865. if (!this.boundUpdateTimeout38_) this.boundUpdateTimeout38_ = this.updateTimeout.bind(this);
  6866. this.lastTimeoutTimeMs && (this.timeoutMs = Math.max(0, this.timeoutMs - (a - this.lastTimeoutTimeMs)),
  6867. this.countdownRatio = this.timeoutMs / this.timeoutDurationMs);
  6868. this.isAttached && this.timeoutMs ? (this.lastTimeoutTimeMs = a,
  6869. rafHub.request(this.boundUpdateTimeout38_)) : this.lastTimeoutTimeMs = 0
  6870. };
  6871.  
  6872. console.log('RAF_HACK_INPUT_RENDERER', tag, "OK")
  6873. } else {
  6874.  
  6875. console.log('typeof handleTimeout', typeof cProto.handleTimeout)
  6876. console.log('typeof updateTimeout', typeof cProto.updateTimeout)
  6877.  
  6878. console.log('RAF_HACK_INPUT_RENDERER', tag, "NG")
  6879. }
  6880.  
  6881.  
  6882. }
  6883.  
  6884. if (DELAY_FOCUSEDCHANGED && typeof cProto.onFocusedChanged === 'function' && cProto.onFocusedChanged.length === 1 && !cProto.onFocusedChanged372) {
  6885. cProto.onFocusedChanged372 = cProto.onFocusedChanged;
  6886. cProto.onFocusedChanged = function (a) {
  6887. Promise.resolve().then(() => {
  6888. if (this.isAttached === true) this.onFocusedChanged372(a);
  6889. }).catch(console.warn);
  6890. }
  6891. }
  6892.  
  6893. })();
  6894.  
  6895. console.log("[End]");
  6896.  
  6897. console.groupEnd();
  6898.  
  6899.  
  6900. })
  6901.  
  6902. }
  6903.  
  6904.  
  6905. if (ENABLE_RAF_HACK_EMOJI_PICKER && rafHub !== null) {
  6906.  
  6907. customElements.whenDefined("yt-emoji-picker-renderer").then(() => {
  6908.  
  6909. mightFirstCheckOnYtInit();
  6910. groupCollapsed("YouTube Super Fast Chat", " | yt-emoji-picker-renderer hacks");
  6911. console.log("[Begin]");
  6912. (() => {
  6913.  
  6914. const tag = "yt-emoji-picker-renderer"
  6915. const dummy = document.createElement(tag);
  6916.  
  6917. const cProto = getProto(dummy);
  6918. if (!cProto || !cProto.attached) {
  6919. console.warn(`proto.attached for ${tag} is unavailable.`);
  6920. return;
  6921. }
  6922.  
  6923. let doHack = false;
  6924. if (typeof cProto.animateScroll_ === 'function') {
  6925.  
  6926. // not cancellable
  6927. console.log('animateScroll_', typeof cProto.animateScroll_)
  6928.  
  6929. doHack = fnIntegrity(cProto.animateScroll_, '1.102.49')
  6930.  
  6931. }
  6932.  
  6933. if (doHack) {
  6934.  
  6935. const querySelector = HTMLElement.prototype.querySelector;
  6936. const U = (element) => ({
  6937. querySelector: (selector) => querySelector.call(element, selector)
  6938. });
  6939.  
  6940. cProto.animateScroll_ = function (a) {
  6941. // console.log('cProto.animateScroll_', tag) // yt-emoji-picker-renderer
  6942. if (!this.boundAnimateScroll39_) this.boundAnimateScroll39_ = this.animateScroll_.bind(this);
  6943. this.lastAnimationTime_ || (this.lastAnimationTime_ = a);
  6944. a -= this.lastAnimationTime_;
  6945. 200 > a ? (U(this.hostElement).querySelector("#categories").scrollTop = this.animationStart_ + (this.animationEnd_ - this.animationStart_) * a / 200,
  6946. rafHub.request(this.boundAnimateScroll39_)) : (null != this.animationEnd_ && (U(this.hostElement).querySelector("#categories").scrollTop = this.animationEnd_),
  6947. this.animationEnd_ = this.animationStart_ = null,
  6948. this.lastAnimationTime_ = 0);
  6949. this.updateButtons_()
  6950. }
  6951.  
  6952. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "OK")
  6953. } else {
  6954.  
  6955. console.log('ENABLE_RAF_HACK_EMOJI_PICKER', tag, "NG")
  6956. }
  6957.  
  6958. })();
  6959.  
  6960. console.log("[End]");
  6961.  
  6962. console.groupEnd();
  6963. });
  6964. }
  6965.  
  6966. if (ENABLE_RAF_HACK_DOCKED_MESSAGE && rafHub !== null) {
  6967.  
  6968. customElements.whenDefined("yt-live-chat-docked-message").then(() => {
  6969.  
  6970. mightFirstCheckOnYtInit();
  6971. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-docked-message hacks");
  6972. console.log("[Begin]");
  6973. (() => {
  6974.  
  6975. const tag = "yt-live-chat-docked-message"
  6976. const dummy = document.createElement(tag);
  6977.  
  6978. const cProto = getProto(dummy);
  6979. if (!cProto || !cProto.attached) {
  6980. console.warn(`proto.attached for ${tag} is unavailable.`);
  6981. return;
  6982. }
  6983.  
  6984. let doHack = false;
  6985. if (typeof cProto.detached === 'function' && typeof cProto.checkIntersections === 'function' && typeof cProto.onDockableMessagesChanged === 'function' && typeof cProto.boundCheckIntersections === 'undefined') {
  6986.  
  6987. // cancelable - this.intersectRAF <detached>
  6988. // yt-live-chat-docked-message
  6989. // boundCheckIntersections <-> checkIntersections
  6990. // onDockableMessagesChanged
  6991. // this.intersectRAF = window.requestAnimationFrame(this.boundCheckIntersections);
  6992.  
  6993. console.log('detached', typeof cProto.detached)
  6994. console.log('checkIntersections', typeof cProto.checkIntersections)
  6995. console.log('onDockableMessagesChanged', typeof cProto.onDockableMessagesChanged)
  6996.  
  6997. doHack = fnIntegrity(cProto.detached, '0.32.22') && fnIntegrity(cProto.checkIntersections, '0.128.85') && fnIntegrity(cProto.onDockableMessagesChanged, '0.20.11')
  6998.  
  6999. }
  7000.  
  7001. if (doHack) {
  7002.  
  7003. cProto.checkIntersections = function () {
  7004. // console.log('cProto.checkIntersections', tag)
  7005. if (this.dockableMessages.length) {
  7006. this.intersectRAF = rafHub.request(this.boundCheckIntersections);
  7007. let a = this.dockableMessages[0]
  7008. , b = this.hostElement.getBoundingClientRect();
  7009. a = a.getBoundingClientRect();
  7010. let c = a.top - b.top
  7011. , d = 8 >= c;
  7012. c = 8 >= c - this.hostElement.clientHeight;
  7013. if (d) {
  7014. let e;
  7015. for (; d;) {
  7016. e = this.dockableMessages.shift();
  7017. d = this.dockableMessages[0];
  7018. if (!d)
  7019. break;
  7020. d = d.getBoundingClientRect();
  7021. c = d.top - b.top;
  7022. let f = 8 >= c;
  7023. if (8 >= c - a.height)
  7024. if (f)
  7025. a = d;
  7026. else
  7027. return;
  7028. d = f
  7029. }
  7030. this.dock(e)
  7031. } else
  7032. c && this.dockedItem && this.clear()
  7033. } else
  7034. this.intersectRAF = 0
  7035. }
  7036.  
  7037. cProto.onDockableMessagesChanged = function () {
  7038. // console.log('cProto.onDockableMessagesChanged', tag) // yt-live-chat-docked-message
  7039. this.dockableMessages.length && !this.intersectRAF && (this.intersectRAF = rafHub.request(this.boundCheckIntersections))
  7040. }
  7041.  
  7042. cProto.detached = function () {
  7043. this.intersectRAF && rafHub.cancel(this.intersectRAF)
  7044. }
  7045.  
  7046. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "OK")
  7047. } else {
  7048.  
  7049. console.log('ENABLE_RAF_HACK_DOCKED_MESSAGE', tag, "NG")
  7050. }
  7051.  
  7052. })();
  7053.  
  7054. console.log("[End]");
  7055.  
  7056. console.groupEnd();
  7057.  
  7058. }).catch(console.warn);
  7059.  
  7060. }
  7061.  
  7062. if (FIX_SETSRC_AND_THUMBNAILCHANGE_) {
  7063.  
  7064. customElements.whenDefined("yt-img-shadow").then(() => {
  7065.  
  7066. mightFirstCheckOnYtInit();
  7067. groupCollapsed("YouTube Super Fast Chat", " | yt-img-shadow hacks");
  7068. console.log("[Begin]");
  7069. (() => {
  7070.  
  7071. const tag = "yt-img-shadow"
  7072. const dummy = document.createElement(tag);
  7073.  
  7074. const cProto = getProto(dummy);
  7075. if (!cProto || !cProto.attached) {
  7076. console.warn(`proto.attached for ${tag} is unavailable.`);
  7077. return;
  7078. }
  7079.  
  7080. if (typeof cProto.thumbnailChanged_ === 'function' && !cProto.thumbnailChanged66_) {
  7081.  
  7082. cProto.thumbnailChanged66_ = cProto.thumbnailChanged_;
  7083. cProto.thumbnailChanged_ = function (a) {
  7084.  
  7085. if (this.oldThumbnail_ && this.thumbnail && this.oldThumbnail_.thumbnails === this.thumbnail.thumbnails) return;
  7086. if (!this.oldThumbnail_ && !this.thumbnail) return;
  7087.  
  7088. return this.thumbnailChanged66_.apply(this, arguments)
  7089.  
  7090. }
  7091. console.log("cProto.thumbnailChanged_ - OK");
  7092.  
  7093. } else {
  7094. console.log("cProto.thumbnailChanged_ - NG");
  7095.  
  7096. }
  7097. if (typeof cProto.setSrc_ === 'function' && !cProto.setSrc66_) {
  7098.  
  7099. cProto.setSrc66_ = cProto.setSrc_;
  7100. cProto.setSrc_ = function (a) {
  7101. if ((((this || 0).$ || 0).img || 0).src === a) return;
  7102. return this.setSrc66_.apply(this, arguments)
  7103. }
  7104.  
  7105. console.log("cProto.setSrc_ - OK");
  7106. } else {
  7107.  
  7108. console.log("cProto.setSrc_ - NG");
  7109. }
  7110.  
  7111. })();
  7112.  
  7113. console.log("[End]");
  7114.  
  7115. console.groupEnd();
  7116.  
  7117. }).catch(console.warn);
  7118.  
  7119. }
  7120.  
  7121. if (FIX_THUMBNAIL_DATACHANGED) {
  7122.  
  7123. customElements.whenDefined("yt-live-chat-author-badge-renderer").then(() => {
  7124.  
  7125. mightFirstCheckOnYtInit();
  7126. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-author-badge-renderer hacks");
  7127. console.log("[Begin]");
  7128. (() => {
  7129.  
  7130. const tag = "yt-live-chat-author-badge-renderer"
  7131. const dummy = document.createElement(tag);
  7132.  
  7133. const cProto = getProto(dummy);
  7134. if (!cProto || !cProto.attached) {
  7135. console.warn(`proto.attached for ${tag} is unavailable.`);
  7136. return;
  7137. }
  7138.  
  7139.  
  7140. if (typeof cProto.dataChanged === 'function' && !cProto.dataChanged86 && '|1.163.100|1.162.100|1.160.97|1.159.97|'.includes(`|${fnIntegrity(cProto.dataChanged)}|`)) {
  7141.  
  7142.  
  7143.  
  7144. cProto.dataChanged86 = cProto.dataChanged;
  7145. cProto.dataChanged = function (a) {
  7146.  
  7147. /*
  7148.  
  7149. for (var b = xC(Z(this.hostElement).querySelector("#image")); b.firstChild; )
  7150. b.removeChild(b.firstChild);
  7151. if (a)
  7152. if (a.icon) {
  7153. var c = document.createElement("yt-icon");
  7154. "MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge ? (c.icon = "yt-sys-icons:shield-filled",
  7155. c.defaultToFilled = !0) : c.icon = "live-chat-badges:" + a.icon.iconType.toLowerCase();
  7156. b.appendChild(c)
  7157. } else if (a.customThumbnail) {
  7158. c = document.createElement("img");
  7159. var d;
  7160. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  7161. b.appendChild(c),
  7162. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail",a.customThumbnail))
  7163. }
  7164.  
  7165. */
  7166.  
  7167.  
  7168. /* 2024.04.20 */
  7169. /*
  7170. for (var b = Tx(N(this.hostElement).querySelector("#image")); b.firstChild; )
  7171. b.removeChild(b.firstChild);
  7172. if (a)
  7173. if (a.icon) {
  7174. var c = document.createElement("yt-icon");
  7175. "MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge ? (c.polymerController.icon = "yt-sys-icons:shield-filled",
  7176. c.polymerController.defaultToFilled = !0) : c.polymerController.icon = "live-chat-badges:" + a.icon.iconType.toLowerCase();
  7177. b.appendChild(c)
  7178. } else if (a.customThumbnail) {
  7179. c = document.createElement("img");
  7180. var d;
  7181. (d = (d = WD(a.customThumbnail.thumbnails, 16)) ? Sb(ec(d)) : null) ? (c.src = d,
  7182. b.appendChild(c),
  7183. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : nr(new mn("Could not compute URL for thumbnail",a.customThumbnail))
  7184. }
  7185. */
  7186.  
  7187. const image = ((this || 0).$ || 0).image
  7188. if (image && a && image.firstElementChild) {
  7189. const exisiting = image.firstElementChild;
  7190. if (exisiting === image.lastElementChild) {
  7191.  
  7192. if (a.icon && exisiting.nodeName.toUpperCase() === 'YT-ICON') {
  7193.  
  7194. const c = exisiting;
  7195. const t = insp(c);
  7196. const w = ('icon' in t || 'defaultToFilled' in t) ? t : c;
  7197. if ("MODERATOR" === a.icon.iconType && this.enableNewModeratorBadge) {
  7198. if (w.icon !== "yt-sys-icons:shield-filled") w.icon = "yt-sys-icons:shield-filled";
  7199. if (w.defaultToFilled !== true) w.defaultToFilled = true;
  7200. } else {
  7201. const p = "live-chat-badges:" + a.icon.iconType.toLowerCase();;
  7202. if (w.icon !== p) w.icon = p;
  7203. if (w.defaultToFilled !== false) w.defaultToFilled = false;
  7204. }
  7205. return;
  7206.  
  7207.  
  7208. } else if (a.customThumbnail && exisiting.nodeName.toUpperCase() == 'IMG') {
  7209.  
  7210. const c = exisiting;
  7211. if (a.customThumbnail.thumbnails.map(e => e.url).includes(c.src)) {
  7212.  
  7213. c.setAttribute("alt", this.hostElement.ariaLabel || "");
  7214. return;
  7215. }
  7216. /*
  7217.  
  7218. var d;
  7219. (d = (d = KC(a.customThumbnail.thumbnails, 16)) ? lc(oc(d)) : null) ? (c.src = d,
  7220.  
  7221. c.setAttribute("alt", this.hostElement.ariaLabel || "")) : lq(new tm("Could not compute URL for thumbnail", a.customThumbnail))
  7222. */
  7223. }
  7224.  
  7225. }
  7226. }
  7227. return this.dataChanged86.apply(this, arguments)
  7228.  
  7229. }
  7230. console.log("cProto.dataChanged - OK");
  7231.  
  7232. } else {
  7233. assertor(() => fnIntegrity(cProto.dataChanged, '1.162.100'));
  7234. console.log("cProto.dataChanged - NG");
  7235.  
  7236. }
  7237.  
  7238. })();
  7239.  
  7240. console.log("[End]");
  7241.  
  7242. console.groupEnd();
  7243.  
  7244. }).catch(console.warn);
  7245.  
  7246.  
  7247. }
  7248.  
  7249.  
  7250. if (FIX_TOOLTIP_DISPLAY) {
  7251.  
  7252. // ----------------------------------------------------------------------------------------------------
  7253.  
  7254. const checkPDGet = (pd) => {
  7255. return pd && pd.get && !pd.set && pd.enumerable && pd.configurable;
  7256. }
  7257.  
  7258. const tooltipUIWM = new WeakMap();
  7259. const tooltipInitProps = {};
  7260. const createTooltipIfRequired_ = function () {
  7261. let r;
  7262. if (tooltipUIWM.get(this) === void 0) {
  7263. const w = document.createElement;
  7264. let EU = null;
  7265. tooltipUIWM.set(this, null);
  7266. document.createElement = function () {
  7267. let r = w.apply(this, arguments);
  7268. EU = r;
  7269. return r;
  7270. };
  7271. r = this.createTooltipIfRequired14_();
  7272. document.createElement = w;
  7273. if (EU instanceof HTMLElement && EU.is) {
  7274. tooltipUIWM.set(this, EU);
  7275. EU.setAttribute('__nogc__', ''); // avoid gc process script
  7276.  
  7277. if (typeof EU.offset === 'number') tooltipInitProps['offset'] = EU.offset;
  7278. if (typeof EU.fitToVisibleBounds === 'boolean') tooltipInitProps['fitToVisibleBounds'] = EU.fitToVisibleBounds;
  7279. if (typeof EU.position === 'string') tooltipInitProps['position'] = EU.position;
  7280. if (typeof EU.for === 'string') tooltipInitProps['for'] = EU.for;
  7281.  
  7282. // this.__mcT__ = EU.outerHTML;
  7283. // EU.__dataX = JSON.stringify(EU.__data);
  7284. // EU.__dataY = Object.entries(EU);
  7285.  
  7286. // <<< FOR DEBUG >>>
  7287. // let kx;
  7288. // Object.defineProperty(EU, '_target', {
  7289. // get(){
  7290. // return kx;
  7291. // },
  7292. // set(nv){
  7293. // kx= nv;
  7294. // debugger;
  7295. // return true;
  7296. // }
  7297. // });
  7298. // <<< FOR DEBUG >>>
  7299.  
  7300. if (typeof Polymer !== 'undefined' && Polymer.__fixedGetOwnerRoot__ && Polymer.__fixedQuerySelector__) {
  7301.  
  7302. } else {
  7303. let eProto = null;
  7304. const euCnt = insp(EU);
  7305. if (checkPDGet(Object.getOwnPropertyDescriptor(euCnt.constructor.prototype || {}, 'target'))) {
  7306.  
  7307. eProto = euCnt.constructor.prototype;
  7308. } else if (checkPDGet(Object.getOwnPropertyDescriptor(EU.constructor.prototype || {}, 'target'))) {
  7309.  
  7310. eProto = EU.constructor.prototype;
  7311. }
  7312. if (eProto) {
  7313. delete eProto.target;
  7314. /*
  7315. get target() {
  7316. var a = Pv(this).parentNode, b = Pv(this).getOwnerRoot(), c;
  7317. this.for ? c = Pv(b).querySelector("#" + this.for) : c = a.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? b.host : a;
  7318. return c
  7319. },
  7320. */
  7321. Object.defineProperty(eProto, 'target', {
  7322. get() {
  7323. let a = this.parentNode, b = this.getRootNode();
  7324. return (this.for ? b.querySelector("#" + this.for) : a)
  7325. }
  7326. })
  7327. }
  7328. }
  7329. // setInterval(()=>EU.updatePosition(), 100)
  7330.  
  7331. } else {
  7332. tooltipUIWM.set(this, null);
  7333. }
  7334. } else {
  7335. r = this.createTooltipIfRequired14_();
  7336. }
  7337.  
  7338. const EU = tooltipUIWM.get(this);
  7339. if (EU) {
  7340. EU.remove();
  7341. if (typeof tooltipInitProps.offset === 'number') EU['offset'] = tooltipInitProps.offset;
  7342. if (typeof tooltipInitProps.fitToVisibleBounds === 'boolean') EU['fitToVisibleBounds'] = tooltipInitProps.fitToVisibleBounds;
  7343. try {
  7344. if (typeof tooltipInitProps.position === 'string') EU['position'] = tooltipInitProps.position;
  7345. if (typeof tooltipInitProps.for === 'string') EU['for'] = tooltipInitProps.for; else delete EU.for;
  7346. } catch (e) { }
  7347. }
  7348. return r;
  7349. };
  7350.  
  7351.  
  7352. // added in 2024.05.02
  7353. getLCRDummy().then(async (lcrDummy) => {
  7354.  
  7355. // console.log(8171, 99);
  7356. const tag = "yt-live-chat-renderer"
  7357. const dummy = lcrDummy;
  7358.  
  7359. const cProto = getProto(dummy);
  7360. if (!cProto || !cProto.attached) {
  7361. console.warn(`proto.attached for ${tag} is unavailable.`);
  7362. return;
  7363. }
  7364.  
  7365. /*
  7366. <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;
  7367. */
  7368.  
  7369. if (cProto && typeof cProto.createTooltipIfRequired_ === 'function' && cProto.createTooltipIfRequired_.length === 0 && !cProto.createTooltipIfRequired14_) {
  7370. cProto.createTooltipIfRequired14_ = cProto.createTooltipIfRequired_;
  7371. cProto.createTooltipIfRequired_ = createTooltipIfRequired_;
  7372. }
  7373.  
  7374. });
  7375.  
  7376. // ----------------------------------------------------------------------------------------------------
  7377.  
  7378. customElements.whenDefined("tp-yt-paper-tooltip").then(() => {
  7379.  
  7380. mightFirstCheckOnYtInit();
  7381. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-paper-tooltip hacks");
  7382. console.log("[Begin]");
  7383. (() => {
  7384.  
  7385. const tag = "tp-yt-paper-tooltip"
  7386. const dummy = document.createElement(tag);
  7387.  
  7388. const cProto = getProto(dummy);
  7389. if (!cProto || !cProto.attached) {
  7390. console.warn(`proto.attached for ${tag} is unavailable.`);
  7391. return;
  7392. }
  7393.  
  7394. if (typeof cProto.attached === 'function' && typeof cProto.detached === 'function' && cProto._readyClients && cProto._attachDom && cProto.ready && !cProto._readyClients43) {
  7395.  
  7396. cProto._readyClients43 = cProto._readyClients;
  7397. cProto._readyClients = function () {
  7398. // console.log(1238)
  7399.  
  7400. let r = cProto._readyClients43.apply(this, arguments);
  7401. if (this.$ && this.$$ && this.$.tooltip) this.root = null; // fix this.root = null != (b = a.root) ? b : this.host
  7402. return r;
  7403. }
  7404.  
  7405. console.log("_readyClients - OK");
  7406.  
  7407. } else {
  7408. console.log("_readyClients - NG");
  7409.  
  7410. }
  7411.  
  7412. if (typeof cProto.show === 'function' && !cProto.show17) {
  7413. cProto.show17 = cProto.show;
  7414. cProto.show = function () {
  7415.  
  7416. let r = this.show17.apply(this, arguments);
  7417. this._showing === true && Promise.resolve().then(() => {
  7418. const tooltip = (this.$ || 0).tooltip;
  7419.  
  7420. if (tooltip && tooltip.firstElementChild === null) {
  7421. let text = tooltip.textContent;
  7422. if (typeof text === 'string' && text.length >= 2) {
  7423. tooltip.textContent = text.trim();
  7424. }
  7425. }
  7426. }).catch(console.warn)
  7427. return r;
  7428. }
  7429.  
  7430. console.log("trim tooltip content - OK");
  7431.  
  7432. } else {
  7433. console.log("trim tooltip content - NG");
  7434.  
  7435. }
  7436.  
  7437.  
  7438. })();
  7439.  
  7440. console.log("[End]");
  7441.  
  7442. console.groupEnd();
  7443.  
  7444. }).catch(console.warn);
  7445.  
  7446. }
  7447.  
  7448.  
  7449. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK) {
  7450.  
  7451. const hookDocumentMouseDownSetupFn = () => {
  7452.  
  7453. let muzTimestamp = 0;
  7454. let nszDropdown = null;
  7455.  
  7456. const handlerObject = {
  7457.  
  7458. muHandler282: function (evt) {
  7459. // console.log(evt, 7, document.querySelector('tp-yt-iron-dropdown[focused].style-scope.yt-live-chat-app'))
  7460. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  7461. const dropdown = nszDropdown;
  7462. muzTimestamp = 0;
  7463. nszDropdown = null;
  7464.  
  7465. const kurMPCe = kRef(currentMenuPivotWR) || 0;
  7466. const hostElement = kurMPCe.hostElement || kurMPCe; // should be always hostElement === kurMPCe ?
  7467. if (!hostElement.hasAttribute('menu-visible')) return;
  7468.  
  7469. const chatBanner = HTMLElement.prototype.closest.call(hostElement, 'yt-live-chat-banner-renderer') || 0;
  7470. if (chatBanner) return;
  7471.  
  7472. if (dropdown && dropdown.positionTarget && hostElement.contains(dropdown.positionTarget)) {
  7473. muzTimestamp = Date.now();
  7474. evt.stopImmediatePropagation();
  7475. evt.stopPropagation();
  7476. Promise.resolve(dropdown).then((dropdown) => {
  7477. dropdown.cancel();
  7478. });
  7479. }
  7480.  
  7481. },
  7482.  
  7483. mlHandler282: function (evt) {
  7484. muzTimestamp = 0;
  7485. nszDropdown = null;
  7486. },
  7487.  
  7488. ckHandler282: function (evt) {
  7489. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  7490. if (Date.now() - muzTimestamp < 40) {
  7491. muzTimestamp = Date.now();
  7492. evt.stopImmediatePropagation();
  7493. evt.stopPropagation();
  7494. }
  7495. },
  7496.  
  7497. tapHandler282: function (evt) {
  7498. if (!evt || !evt.isTrusted || !muzTimestamp) return;
  7499. if (Date.now() - muzTimestamp < 40) {
  7500. muzTimestamp = Date.now();
  7501. evt.stopImmediatePropagation();
  7502. evt.stopPropagation();
  7503. }
  7504. },
  7505.  
  7506. handleEvent(evt) {
  7507. if (evt) {
  7508. const kurMPCe = kRef(currentMenuPivotWR) || 0;
  7509. const kurMPCc = insp(kurMPCe);
  7510. const hostElement = kurMPCc.hostElement || kurMPCc;
  7511. if (!kurMPCc || kurMPCc.isAttached !== true || hostElement.isConnected !== true) return;
  7512. switch (evt.type) {
  7513. case 'mouseup':
  7514. return this.muHandler282(evt);
  7515. case 'mouseleave':
  7516. return this.mlHandler282(evt);
  7517. case 'tap':
  7518. return this.tapHandler282(evt);
  7519. case 'click':
  7520. return this.ckHandler282(evt);
  7521. }
  7522. }
  7523. }
  7524.  
  7525. }
  7526.  
  7527. document.addEventListener('mousedown', function (evt) {
  7528.  
  7529. if (!evt || !evt.isTrusted || !evt.target) return;
  7530.  
  7531. muzTimestamp = 0;
  7532. nszDropdown = null;
  7533.  
  7534. /** @type {HTMLElement | null} */
  7535. const kurMP = kRef(currentMenuPivotWR);
  7536. if (!kurMP) return;
  7537. const kurMPCe = HTMLElement.prototype.closest.call(kurMP, '[menu-visible]') || 0; // element
  7538.  
  7539. if (!kurMPCe || !kurMPCe.hasAttribute('whole-message-clickable')) return;
  7540.  
  7541. const kurMPCc = insp(kurMPCe); // controller
  7542.  
  7543. if (!kurMPCc.isClickableChatRow111 || !kurMPCc.isClickableChatRow111() || !HTMLElement.prototype.contains.call(kurMPCe, evt.target)) return;
  7544.  
  7545. const chatBanner = HTMLElement.prototype.closest.call(kurMPCe, 'yt-live-chat-banner-renderer') || 0;
  7546. if (chatBanner) return;
  7547.  
  7548. let targetDropDown = null;
  7549. for (const dropdown of document.querySelectorAll('tp-yt-iron-dropdown.style-scope.yt-live-chat-app')) {
  7550. if (dropdown && dropdown.positionTarget === kurMP) {
  7551. targetDropDown = dropdown;
  7552. }
  7553. }
  7554.  
  7555. if (!targetDropDown) return;
  7556.  
  7557. if ((nszDropdown = targetDropDown)) {
  7558. muzTimestamp = Date.now();
  7559. evt.stopImmediatePropagation();
  7560. evt.stopPropagation();
  7561. currentMenuPivotWR = mWeakRef(kurMPCe);
  7562.  
  7563. const listenOpts = { capture: true, passive: false, once: true };
  7564.  
  7565. // remove unexcecuted eventHandler
  7566. document.removeEventListener('mouseup', handlerObject, listenOpts);
  7567. document.removeEventListener('mouseleave', handlerObject, listenOpts);
  7568. document.removeEventListener('tap', handlerObject, listenOpts);
  7569. document.removeEventListener('click', handlerObject, listenOpts);
  7570.  
  7571. // inject one time eventHandler to by pass events
  7572. document.addEventListener('mouseup', handlerObject, listenOpts);
  7573. document.addEventListener('mouseleave', handlerObject, listenOpts);
  7574. document.addEventListener('tap', handlerObject, listenOpts);
  7575. document.addEventListener('click', handlerObject, listenOpts);
  7576.  
  7577. }
  7578.  
  7579. }, true);
  7580.  
  7581. }
  7582.  
  7583.  
  7584. // yt-live-chat-paid-message-renderer ??
  7585.  
  7586. /*
  7587.  
  7588. [...(new Set([...document.querySelectorAll('*')].filter(e=>e.is&&('shouldSupportWholeItemClick' in e)).map(e=>e.is))).keys()]
  7589.  
  7590.  
  7591. "yt-live-chat-ticker-paid-message-item-renderer"
  7592. "yt-live-chat-ticker-paid-sticker-item-renderer"
  7593. "yt-live-chat-paid-message-renderer"
  7594. "yt-live-chat-text-message-renderer"
  7595. "yt-live-chat-paid-sticker-renderer"
  7596.  
  7597. */
  7598.  
  7599.  
  7600. whenDefinedMultiple([
  7601.  
  7602. "yt-live-chat-paid-message-renderer",
  7603. "yt-live-chat-membership-item-renderer",
  7604. "yt-live-chat-paid-sticker-renderer",
  7605. "yt-live-chat-text-message-renderer",
  7606. "yt-live-chat-auto-mod-message-renderer",
  7607.  
  7608. /*
  7609. "yt-live-chat-ticker-paid-message-item-renderer",
  7610. "yt-live-chat-ticker-paid-sticker-item-renderer",
  7611. "yt-live-chat-paid-message-renderer",
  7612. "yt-live-chat-text-message-renderer",
  7613. "yt-live-chat-paid-sticker-renderer",
  7614.  
  7615. "yt-live-chat-ticker-sponsor-item-renderer",
  7616. "yt-live-chat-banner-header-renderer",
  7617. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  7618. "ytd-sponsorships-live-chat-header-renderer",
  7619. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  7620.  
  7621.  
  7622.  
  7623.  
  7624. "yt-live-chat-auto-mod-message-renderer",
  7625. "yt-live-chat-text-message-renderer",
  7626. "yt-live-chat-paid-message-renderer",
  7627.  
  7628. "yt-live-chat-legacy-paid-message-renderer",
  7629. "yt-live-chat-membership-item-renderer",
  7630. "yt-live-chat-paid-sticker-renderer",
  7631. "yt-live-chat-donation-announcement-renderer",
  7632. "yt-live-chat-moderation-message-renderer",
  7633. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  7634. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  7635. "yt-live-chat-viewer-engagement-message-renderer",
  7636.  
  7637. */
  7638.  
  7639.  
  7640. ]).then(sTags => {
  7641.  
  7642.  
  7643. mightFirstCheckOnYtInit();
  7644. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-message-renderer(s)... hacks");
  7645. console.log("[Begin]");
  7646. let doMouseHook = false;
  7647.  
  7648. const dProto = {
  7649. isClickableChatRow111: function () {
  7650. return (
  7651. this.data && typeof this.shouldSupportWholeItemClick === 'function' && typeof this.hasModerationOverlayVisible === 'function' &&
  7652. this.data.contextMenuEndpoint && this.wholeMessageClickable && this.shouldSupportWholeItemClick() && !this.hasModerationOverlayVisible()
  7653. ); // follow .onItemTap(a)
  7654. }
  7655. };
  7656.  
  7657. for (const sTag of sTags) { // ##tag##
  7658.  
  7659.  
  7660. (() => {
  7661.  
  7662. const tag = sTag;
  7663. const dummy = document.createElement(tag);
  7664.  
  7665. const cProto = getProto(dummy);
  7666. if (!cProto || !cProto.attached) {
  7667. console.warn(`proto.attached for ${tag} is unavailable.`);
  7668. return;
  7669. }
  7670.  
  7671. const dCnt = insp(dummy);
  7672. if ('wholeMessageClickable' in dCnt && typeof dCnt.hasModerationOverlayVisible === 'function' && typeof dCnt.shouldSupportWholeItemClick === 'function') {
  7673.  
  7674. cProto.isClickableChatRow111 = dProto.isClickableChatRow111;
  7675.  
  7676. const toHookDocumentMouseDown = typeof cProto.shouldSupportWholeItemClick === 'function' && typeof cProto.hasModerationOverlayVisible === 'function';
  7677.  
  7678. if (toHookDocumentMouseDown) {
  7679. doMouseHook = true;
  7680. }
  7681.  
  7682. console.log("shouldSupportWholeItemClick Y", tag);
  7683.  
  7684. } else {
  7685.  
  7686. console.log("shouldSupportWholeItemClick N", tag);
  7687. }
  7688.  
  7689.  
  7690. })();
  7691.  
  7692. }
  7693.  
  7694.  
  7695. if (doMouseHook) {
  7696.  
  7697. hookDocumentMouseDownSetupFn();
  7698.  
  7699. console.log("FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK - Doc MouseEvent OK");
  7700. }
  7701.  
  7702. console.log("[End]");
  7703.  
  7704. console.groupEnd();
  7705.  
  7706.  
  7707. }).catch(console.warn);
  7708.  
  7709.  
  7710. // https://www.youtube.com/watch?v=oQzFi1NO7io
  7711.  
  7712.  
  7713. }
  7714.  
  7715. if (NO_ITEM_TAP_FOR_NON_STATIONARY_TAP) {
  7716. let targetElementCntWR = null;
  7717. let _e0 = null;
  7718. document.addEventListener('mousedown', (e) => {
  7719. if (!e || !e.isTrusted) return;
  7720. let element = e.target;
  7721. for (; element instanceof HTMLElement; element = element.parentNode) {
  7722. if (element.is) break;
  7723. }
  7724. if (!element || !element.is) return;
  7725. const cnt = insp(element);
  7726. if (typeof cnt.onItemTap === 'function') {
  7727. cnt._onItemTap_isNonStationary = 0;
  7728. const cProto = getProto(element);
  7729. if (!cProto.onItemTap366 && typeof cProto.onItemTap === 'function' && cProto.onItemTap.length === 1) {
  7730. cProto.onItemTap366 = cProto.onItemTap;
  7731. cProto.onItemTap = function (a) {
  7732. const t = this._onItemTap_isNonStationary;
  7733. this._onItemTap_isNonStationary = 0;
  7734. if (t > Date.now()) return;
  7735. return this.onItemTap366.apply(this, arguments)
  7736. }
  7737. }
  7738. _e0 = e;
  7739. targetElementCntWR = mWeakRef(cnt);
  7740. } else {
  7741. _e0 = null;
  7742. targetElementCntWR = null;
  7743. }
  7744. }, { capture: true, passive: true });
  7745.  
  7746. document.addEventListener('mouseup', (e) => {
  7747. if (!e || !e.isTrusted) return;
  7748. const e0 = _e0;
  7749. _e0 = null;
  7750. if (!e0) return;
  7751. const cnt = kRef(targetElementCntWR);
  7752. targetElementCntWR = null;
  7753. if (!cnt) return;
  7754. if (e.timeStamp - e0.timeStamp > TAP_ACTION_DURATION) {
  7755. cnt._onItemTap_isNonStationary = Date.now() + 40;
  7756. } else if ((window.getSelection() + "").trim().replace(/[\u2000-\u200a\u202f\u2800\u200B\u200C\u200D\uFEFF]+/g, '').length >= 1) {
  7757. cnt._onItemTap_isNonStationary = Date.now() + 40;
  7758. } else {
  7759. const dx = e.clientX - e0.clientX;
  7760. const dy = e.clientY - e0.clientY;
  7761. const dd = Math.sqrt(dx * dx + dy * dy);
  7762. const ddmm = px2mm(dd);
  7763. if (ddmm > 1.0) {
  7764. cnt._onItemTap_isNonStationary = Date.now() + 40;
  7765. } else {
  7766. cnt._onItemTap_isNonStationary = 0;
  7767. }
  7768. }
  7769. }, { capture: true, passive: true });
  7770.  
  7771. }
  7772.  
  7773.  
  7774. const __showContextMenu_assign_lock_with_external_unlock_ = function (targetCnt) {
  7775.  
  7776. let rr = null;
  7777. const p1 = new Promise(resolve => {
  7778. rr = resolve;
  7779. });
  7780.  
  7781. const p1unlock = () => {
  7782. const f = rr;
  7783. if (f) {
  7784. rr = null;
  7785. f();
  7786. }
  7787. }
  7788.  
  7789. return {
  7790. p1,
  7791. p1unlock,
  7792. assignLock: (targetCnt, timeout) => {
  7793. targetCnt.__showContextMenu_assign_lock__(p1);
  7794. if (timeout) setTimeout(p1unlock, timeout);
  7795. }
  7796. }
  7797.  
  7798. }
  7799.  
  7800. if (PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN) {
  7801.  
  7802. document.addEventListener('mousedown', function (evt) {
  7803.  
  7804. const maxloopDOMTreeElements = 4;
  7805. const maxloopYtCompontents = 4;
  7806. let j1 = 0;
  7807. let j2 = 0;
  7808. let target = (evt || 0).target || 0;
  7809. if (!target) return;
  7810.  
  7811.  
  7812. while (target instanceof HTMLElement) {
  7813. if (++j1 > maxloopDOMTreeElements) break;
  7814. if (typeof (target.is || insp(target).is || null) === 'string') break;
  7815. target = nodeParent(target);
  7816. }
  7817. const components = [];
  7818. while (target instanceof HTMLElement) {
  7819. if (++j2 > maxloopYtCompontents) break;
  7820. const cnt = insp(target);
  7821. if (typeof (target.is || cnt.is || null) === 'string') {
  7822. components.push(target);
  7823. }
  7824. if (typeof cnt.showContextMenu === 'function') break;
  7825. target = target.parentComponent || cnt.parentComponent || null;
  7826. }
  7827. if (!(target instanceof HTMLElement)) return;
  7828. const targetCnt = insp(target);
  7829. if (typeof targetCnt.handleGetContextMenuResponse_ !== 'function' || typeof targetCnt.handleGetContextMenuError !== 'function') {
  7830. console.log('Error Found: handleGetContextMenuResponse_ OR handleGetContextMenuError is not defined on a component with showContextMenu')
  7831. return;
  7832. }
  7833.  
  7834. const endpoint = (targetCnt.data || 0).contextMenuEndpoint
  7835. if (!endpoint) return;
  7836. if (targetCnt.opened || !targetCnt.isAttached) return;
  7837.  
  7838. if (typeof targetCnt.__cacheResolvedEndpointData__ !== 'function') {
  7839. console.log(`preRequest for showContextMenu in ${targetCnt.is} is not yet supported.`)
  7840. }
  7841.  
  7842. const targetDollar = indr(target);
  7843.  
  7844. let doPreRequest = false;
  7845. if (components.length >= 2 && components[0].id === 'menu-button' && (targetDollar || 0)['menu-button'] === components[0]) {
  7846. doPreRequest = true;
  7847. } else if (components.length === 1 && components[0] === target) {
  7848. doPreRequest = true;
  7849. } else if (components.length >= 2 && components[0].id === 'author-photo' && (targetDollar || 0)['author-photo'] === components[0]) {
  7850. doPreRequest = true;
  7851. }
  7852. if (doPreRequest === false) {
  7853. console.log('doPreRequest = fasle on showContextMenu', components);
  7854. return;
  7855. }
  7856.  
  7857. if (typeof targetCnt.__getCachedEndpointData__ !== 'function' || targetCnt.__getCachedEndpointData__(endpoint)) return;
  7858.  
  7859. if ((typeof targetCnt.__showContextMenu_mutex_unlock_isEmpty__ === 'function') && !targetCnt.__showContextMenu_mutex_unlock_isEmpty__()) {
  7860. console.log('preRequest on showContextMenu aborted due to stacked network request');
  7861. return;
  7862. }
  7863.  
  7864.  
  7865. const onSuccess = (a) => {
  7866. /*
  7867.  
  7868. dQ() && (a = a.response);
  7869. a.liveChatItemContextMenuSupportedRenderers && a.liveChatItemContextMenuSupportedRenderers.menuRenderer && this.showContextMenu_(a.liveChatItemContextMenuSupportedRenderers.menuRenderer);
  7870. a.actions && Eu(this.hostElement, "yt-live-chat-actions", [a.actions])
  7871.  
  7872. */
  7873.  
  7874. a = a.response || a;
  7875.  
  7876. if (!a) {
  7877. console.log('unexpected error in prerequest for showContextMenu.onSuccess');
  7878. return;
  7879. }
  7880.  
  7881. let z = null;
  7882. a.liveChatItemContextMenuSupportedRenderers && a.liveChatItemContextMenuSupportedRenderers.menuRenderer && (z = a.liveChatItemContextMenuSupportedRenderers.menuRenderer);
  7883.  
  7884. if (z) {
  7885. a = z;
  7886. targetCnt.__cacheResolvedEndpointData__(endpoint, a, true);
  7887. }
  7888.  
  7889. };
  7890. const onFailure = (a) => {
  7891.  
  7892. /*
  7893.  
  7894. if (a instanceof Error || a instanceof Object || a instanceof String)
  7895. var b = a;
  7896. hq(new xm("Error encountered calling GetLiveChatItemContextMenu",b))
  7897.  
  7898. */
  7899.  
  7900. targetCnt.__cacheResolvedEndpointData__(endpoint, null);
  7901. // console.log('onFailure', a)
  7902.  
  7903. };
  7904.  
  7905. if (doPreRequest) {
  7906.  
  7907. let propertyCounter = 0;
  7908. const pm1 = __showContextMenu_assign_lock_with_external_unlock_(targetCnt);
  7909. const p1Timeout = 800;
  7910. const proxyKey = '__$$__proxy_to_this__$$__' + Date.now();
  7911.  
  7912. try {
  7913.  
  7914. const onSuccessHelperFn = function () {
  7915. pm1.p1unlock();
  7916. if (propertyCounter !== 5) {
  7917. console.log('Error in prerequest for showContextMenu.onSuccessHelperFn')
  7918. return;
  7919. }
  7920. if (this[proxyKey] !== targetCnt) {
  7921. console.log('Error in prerequest for showContextMenu.this');
  7922. return;
  7923. }
  7924. onSuccess(...arguments);
  7925. };
  7926. const onFailureHelperFn = function () {
  7927. pm1.p1unlock();
  7928. if (propertyCounter !== 5) {
  7929. console.log('Error in prerequest for showContextMenu.onFailureHelperFn')
  7930. return;
  7931. }
  7932. if (this[proxyKey] !== targetCnt) {
  7933. console.log('Error in prerequest for showContextMenu.this');
  7934. return;
  7935. }
  7936. onFailure(...arguments);
  7937.  
  7938. }
  7939. const fakeTargetCnt = new Proxy({
  7940. __showContextMenu_forceNativeRequest__: 1,
  7941. __showContextMenu_sync_mode_request__: 1,
  7942. get handleGetContextMenuResponse_() {
  7943. propertyCounter += 2;
  7944. return onSuccessHelperFn;
  7945. },
  7946. get handleGetContextMenuError() {
  7947. propertyCounter += 3;
  7948. return onFailureHelperFn;
  7949. }
  7950. }, {
  7951. get(_, key, receiver) {
  7952. if (key in _) return _[key];
  7953. if (key === proxyKey) return targetCnt;
  7954.  
  7955. let giveNative = false;
  7956. if (key in targetCnt) {
  7957. if (key === 'data') giveNative = true;
  7958. else if (typeof targetCnt[key] === 'function') giveNative = true;
  7959. }
  7960. if (giveNative) return targetCnt[key];
  7961. }
  7962. });
  7963.  
  7964. const fakeEvent = (() => {
  7965. const { target, bubbles, cancelable, cancelBubble, srcElement, timeStamp, defaultPrevented, currentTarget, composed } = evt;
  7966. const nf = function () { }
  7967. const [stopPropagation, stopImmediatePropagation, preventDefault] = [nf, nf, nf];
  7968.  
  7969. return {
  7970. type: 'tap',
  7971. eventPhase: 0,
  7972. isTrusted: false,
  7973. __composed: true,
  7974. bubbles, cancelable, cancelBubble, timeStamp,
  7975. target, srcElement, defaultPrevented, currentTarget, composed,
  7976. stopPropagation, stopImmediatePropagation, preventDefault
  7977. };
  7978. })(evt);
  7979. targetCnt.showContextMenu.call(fakeTargetCnt, fakeEvent);
  7980.  
  7981.  
  7982. } catch (e) {
  7983. console.warn(e);
  7984. propertyCounter = 7;
  7985.  
  7986. }
  7987. if (propertyCounter !== 5) {
  7988. console.log('Error in prerequest for showContextMenu', propertyCounter);
  7989. return;
  7990. }
  7991.  
  7992. pm1.assignLock(targetCnt, p1Timeout);
  7993.  
  7994. }
  7995.  
  7996.  
  7997.  
  7998.  
  7999.  
  8000.  
  8001. }, true);
  8002.  
  8003.  
  8004. }
  8005.  
  8006.  
  8007.  
  8008. /*
  8009.  
  8010. const w=new Set(); for(const a of document.getElementsByTagName('*')) if(a.showContextMenu && a.showContextMenu_) w.add(a.is||''); console.log([...w.keys()])
  8011.  
  8012. */
  8013.  
  8014. whenDefinedMultiple([
  8015. "yt-live-chat-ticker-sponsor-item-renderer",
  8016. "yt-live-chat-banner-header-renderer",
  8017. "yt-live-chat-text-message-renderer",
  8018. "ytd-sponsorships-live-chat-gift-purchase-announcement-renderer",
  8019. "ytd-sponsorships-live-chat-header-renderer",
  8020. "ytd-sponsorships-live-chat-gift-redemption-announcement-renderer",
  8021.  
  8022. "yt-live-chat-paid-sticker-renderer",
  8023. "yt-live-chat-viewer-engagement-message-renderer",
  8024. "yt-live-chat-paid-message-renderer"
  8025.  
  8026.  
  8027.  
  8028.  
  8029. ]).then(sTags => {
  8030.  
  8031. mightFirstCheckOnYtInit();
  8032. groupCollapsed("YouTube Super Fast Chat", " | fixShowContextMenu");
  8033. console.log("[Begin]");
  8034.  
  8035.  
  8036. const __showContextMenu_mutex__ = new Mutex();
  8037. let __showContextMenu_mutex_unlock__ = null;
  8038. let lastShowMenuTarget = null;
  8039.  
  8040.  
  8041.  
  8042.  
  8043. const wm37 = new WeakMap();
  8044.  
  8045. const dProto = {
  8046.  
  8047.  
  8048. // CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN
  8049.  
  8050. __cacheResolvedEndpointData__: (endpoint, a, doDeepCopy) => {
  8051. if (a) {
  8052. if (doDeepCopy) a = deepCopy(a);
  8053. wm37.set(endpoint, a);
  8054. } else {
  8055. wm37.remove(endpoint);
  8056. }
  8057. },
  8058. __getCachedEndpointData__: function (endpoint) {
  8059. endpoint = endpoint || (this.data || 0).contextMenuEndpoint || 0;
  8060. if (endpoint) return wm37.get(endpoint);
  8061. return null;
  8062. },
  8063. /** @type {(resolvedEndpoint: any) => void 0} */
  8064. __showCachedContextMenu__: function (resolvedEndpoint) { // non-null
  8065.  
  8066. resolvedEndpoint = deepCopy(resolvedEndpoint);
  8067. // let b = deepCopy(resolvedEndpoint, ['trackingParams', 'clickTrackingParams'])
  8068. Promise.resolve(resolvedEndpoint).then(() => {
  8069. this.__showContextMenu_skip_cacheResolvedEndpointData__ = 1;
  8070. this.showContextMenu_(resolvedEndpoint);
  8071. this.__showContextMenu_skip_cacheResolvedEndpointData__ = 0;
  8072. });
  8073.  
  8074.  
  8075. },
  8076.  
  8077.  
  8078.  
  8079. showContextMenuForCacheReopen: function (a) {
  8080. if (!this.__showContextMenu_forceNativeRequest__) {
  8081. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  8082. if (endpoint) {
  8083. const resolvedEndpoint = this.__getCachedEndpointData__(endpoint);
  8084. if (resolvedEndpoint) {
  8085. this.__showCachedContextMenu__(resolvedEndpoint);
  8086. a && a.stopPropagation()
  8087. return;
  8088. }
  8089. }
  8090. }
  8091. return this.showContextMenu37(a);
  8092. },
  8093.  
  8094. showContextMenuForCacheReopen_: function (a) {
  8095. if (!this.__showContextMenu_skip_cacheResolvedEndpointData__) {
  8096. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  8097. if (endpoint) {
  8098. const f = this.__cacheResolvedEndpointData__;
  8099. if (typeof f === 'function') f(endpoint, a, true);
  8100. }
  8101. }
  8102. return this.showContextMenu37_(a);
  8103. },
  8104.  
  8105. // ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU
  8106.  
  8107. showContextMenuWithDisableScroll: function (a) {
  8108.  
  8109. const endpoint = (this.data || 0).contextMenuEndpoint || 0;
  8110. if (endpoint && typeof this.is === 'string' && this.menuVisible === false && this.menuOpen === false) {
  8111.  
  8112. const parentComponent = this.parentComponent;
  8113. if (parentComponent && parentComponent.is === 'yt-live-chat-item-list-renderer' && parentComponent.contextMenuOpen === false && parentComponent.allowScroll === true) {
  8114. parentComponent.contextMenuOpen = true; // computeAllowScroll_(contextMenuOpen, moderationModeEnabled): allowScroll = !(contextMenuOpen || moderationModeEnabled)
  8115. }
  8116. }
  8117.  
  8118. return this.showContextMenu48.apply(this, arguments);
  8119.  
  8120. },
  8121.  
  8122. // ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU
  8123.  
  8124. __showContextMenu_mutex_unlock_isEmpty__: () => {
  8125. return __showContextMenu_mutex_unlock__ === null;
  8126. },
  8127.  
  8128. __showContextMenu_assign_lock__: function (p) {
  8129.  
  8130. const mutex = __showContextMenu_mutex__;
  8131.  
  8132. mutex.lockWith(unlock => {
  8133. p.then(unlock);
  8134. });
  8135.  
  8136. },
  8137.  
  8138. showContextMenuWithMutex: function (a) {
  8139. lastShowMenuTarget = this;
  8140.  
  8141. if (this.__showContextMenu_sync_mode_request__) {
  8142.  
  8143. return this.showContextMenu47(a);
  8144. } else {
  8145.  
  8146. const mutex = __showContextMenu_mutex__;
  8147.  
  8148. mutex.lockWith(unlock => {
  8149. if (lastShowMenuTarget !== this) {
  8150. unlock();
  8151. return;
  8152. }
  8153.  
  8154. setTimeout(unlock, 800); // in case network failure
  8155. __showContextMenu_mutex_unlock__ = unlock;
  8156. try {
  8157. this.showContextMenu47(a);
  8158. } catch (e) {
  8159. console.warn(e);
  8160. unlock(); // in case function script error
  8161. }
  8162.  
  8163. });
  8164.  
  8165. }
  8166.  
  8167.  
  8168. },
  8169.  
  8170. showContextMenuWithMutex_: function (a) {
  8171.  
  8172. if (__showContextMenu_mutex_unlock__ && this === lastShowMenuTarget) {
  8173. __showContextMenu_mutex_unlock__();
  8174. __showContextMenu_mutex_unlock__ = null;
  8175. }
  8176. return this.showContextMenu47_(a);
  8177.  
  8178. }
  8179.  
  8180. }
  8181.  
  8182. for (const tag of sTags) { // ##tag##
  8183.  
  8184. (() => {
  8185.  
  8186. const dummy = document.createElement(tag);
  8187.  
  8188. const cProto = getProto(dummy);
  8189. if (!cProto || !cProto.attached) {
  8190. console.warn(`proto.attached for ${tag} is unavailable.`);
  8191. return;
  8192. }
  8193.  
  8194. 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) {
  8195. cProto.showContextMenu37_ = cProto.showContextMenu_;
  8196. cProto.showContextMenu37 = cProto.showContextMenu;
  8197. cProto.__showContextMenu_forceNativeRequest__ = 0;
  8198. cProto.__cacheResolvedEndpointData__ = dProto.__cacheResolvedEndpointData__
  8199. cProto.__getCachedEndpointData__ = dProto.__getCachedEndpointData__
  8200. cProto.__showCachedContextMenu__ = dProto.__showCachedContextMenu__
  8201. cProto.showContextMenu = dProto.showContextMenuForCacheReopen;
  8202. cProto.showContextMenu_ = dProto.showContextMenuForCacheReopen_;
  8203. console.log("CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN - OK", tag);
  8204. } else {
  8205. console.log("CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN - NG", tag);
  8206. }
  8207.  
  8208. 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) {
  8209. cProto.showContextMenu48 = cProto.showContextMenu;
  8210. cProto.showContextMenu = dProto.showContextMenuWithDisableScroll;
  8211. console.log("ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU - OK", tag);
  8212. } else {
  8213. console.log("ADVANCED_NOT_ALLOW_SCROLL_FOR_SHOW_CONTEXT_MENU - NG", tag);
  8214. }
  8215.  
  8216. 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) {
  8217. cProto.showContextMenu47_ = cProto.showContextMenu_;
  8218. cProto.showContextMenu47 = cProto.showContextMenu;
  8219. cProto.__showContextMenu_mutex_unlock_isEmpty__ = dProto.__showContextMenu_mutex_unlock_isEmpty__;
  8220. cProto.__showContextMenu_assign_lock__ = dProto.__showContextMenu_assign_lock__;
  8221. cProto.showContextMenu = dProto.showContextMenuWithMutex;
  8222. cProto.showContextMenu_ = dProto.showContextMenuWithMutex_;
  8223. console.log("ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU - OK", tag);
  8224. } else {
  8225. console.log("ENABLE_MUTEX_FOR_SHOW_CONTEXT_MENU - NG", tag);
  8226. }
  8227.  
  8228. })();
  8229.  
  8230. }
  8231.  
  8232. console.log("[End]");
  8233.  
  8234. console.groupEnd();
  8235.  
  8236. }).catch(console.warn);
  8237.  
  8238.  
  8239.  
  8240. customElements.whenDefined('tp-yt-iron-dropdown').then(() => {
  8241.  
  8242. mightFirstCheckOnYtInit();
  8243. groupCollapsed("YouTube Super Fast Chat", " | tp-yt-iron-dropdown hacks");
  8244. console.log("[Begin]");
  8245. (() => {
  8246.  
  8247. const tag = "tp-yt-iron-dropdown";
  8248. const dummy = document.createElement(tag);
  8249.  
  8250. const cProto = getProto(dummy);
  8251. if (!cProto || !cProto.attached) {
  8252. console.warn(`proto.attached for ${tag} is unavailable.`);
  8253. return;
  8254. }
  8255.  
  8256. if (USE_VANILLA_DEREF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf34 && fnIntegrity(cProto.__deraf) === '2.42.24') {
  8257. cProto.__deraf_hn__ = function (sId, fn) {
  8258. const rhKey = `_rafHandler_${sId}`;
  8259. const m = this[rhKey] || (this[rhKey] = new WeakMap());
  8260. if (m.has(fn)) return m.get(fn);
  8261. const resFn = () => {
  8262. this.__rafs[sId] = null;
  8263. fn.call(this)
  8264. };
  8265. m.set(fn, resFn);
  8266. m.set(resFn, resFn);
  8267. return resFn;
  8268. };
  8269. cProto.__deraf34 = cProto.__deraf;
  8270. cProto.__deraf = function (a, b) { // sId, fn
  8271. let c = this.__rafs;
  8272. null !== c[a] && cancelAnimationFrame(c[a]);
  8273. c[a] = requestAnimationFrame(this.__deraf_hn__(a, b));
  8274. };
  8275. console.log("USE_VANILLA_DEREF - OK");
  8276. } else {
  8277. console.log("USE_VANILLA_DEREF - NG");
  8278. }
  8279.  
  8280. if (FIX_DROPDOWN_DERAF && typeof cProto.__deraf === 'function' && cProto.__deraf.length === 2 && !cProto.__deraf66) {
  8281. cProto.__deraf66 = cProto.__deraf;
  8282. cProto.__deraf = function (sId, fn) {
  8283. if (this.__byPassRAF__) {
  8284. Promise.resolve().then(() => {
  8285. fn.call(this);
  8286. });
  8287. }
  8288. let r = this.__deraf66.apply(this, arguments);
  8289. return r;
  8290. }
  8291. console.log("FIX_DROPDOWN_DERAF - OK");
  8292. } else {
  8293. console.log("FIX_DROPDOWN_DERAF - NG");
  8294. }
  8295.  
  8296.  
  8297. if (BOOST_MENU_OPENCHANGED_RENDERING && typeof cProto.__openedChanged === 'function' && !cProto.__mtChanged__ && fnIntegrity(cProto.__openedChanged) === '0.46.20') {
  8298.  
  8299. let lastClose = null;
  8300. let lastOpen = null;
  8301. let cid = 0;
  8302.  
  8303. cProto.__mtChanged__ = function (b) {
  8304.  
  8305. Promise.resolve().then(() => {
  8306. this._applyFocus();
  8307. }).then(() => {
  8308. b ? this._renderOpened() : this._renderClosed();
  8309. }).catch(console.warn);
  8310.  
  8311. };
  8312.  
  8313. const __moChanged__ = () => {
  8314. if (!cid) return;
  8315. // console.log(553, !!lastOpen, !!lastClose);
  8316. cid = 0;
  8317. if (lastOpen && !lastClose && lastOpen.isAttached) {
  8318. lastOpen.__mtChanged__(1)
  8319. } else if (lastClose && !lastOpen && lastClose.isAttached) {
  8320. lastClose.__mtChanged__(0);
  8321. }
  8322. lastOpen = null;
  8323. lastClose = null;
  8324. };
  8325.  
  8326.  
  8327. if (typeof cProto._openedChanged === 'function' && !cProto._openedChanged66) {
  8328. cProto._openedChanged66 = cProto._openedChanged;
  8329. cProto._openedChanged = function () {
  8330. // this.__byPassRAF__ = !lastOpen ? true : false; // or just true?
  8331. this.__byPassRAF__ = true;
  8332. let r = this._openedChanged66.apply(this, arguments);
  8333. this.__byPassRAF__ = false;
  8334. return r;
  8335. }
  8336. }
  8337.  
  8338. const pSetGet = (key, pdThis, pdBase) => {
  8339. // note: this is not really a standard way for the getOwnPropertyDescriptors; but it is sufficient to make the job done
  8340. return {
  8341. get: (pdThis[key] || 0).get || (pdBase[key] || 0).get,
  8342. set: (pdThis[key] || 0).set || (pdBase[key] || 0).set
  8343. };
  8344. };
  8345.  
  8346. cProto.__modifiedMenuPropsFn__ = function () {
  8347. const pdThis = Object.getOwnPropertyDescriptors(this.constructor.prototype)
  8348. const pdBase = Object.getOwnPropertyDescriptors(this)
  8349.  
  8350. const pdAutoFitOnAttach = pSetGet('autoFitOnAttach', pdThis, pdBase);
  8351. const pdExpandSizingTargetForScrollbars = pSetGet('expandSizingTargetForScrollbars', pdThis, pdBase);
  8352. const pdAllowOutsideScroll = pSetGet('allowOutsideScroll', pdThis, pdBase);
  8353.  
  8354. if (pdAutoFitOnAttach.get || pdAutoFitOnAttach.set) {
  8355. console.warn('there is setter/getter for autoFitOnAttach');
  8356. return;
  8357. }
  8358. if (pdExpandSizingTargetForScrollbars.get || pdExpandSizingTargetForScrollbars.set) {
  8359. console.warn('there is setter/getter for expandSizingTargetForScrollbars');
  8360. return;
  8361. }
  8362. if (!pdAllowOutsideScroll.get || !pdAllowOutsideScroll.set) {
  8363. console.warn('there is NO setter-getter for allowOutsideScroll');
  8364. return;
  8365. }
  8366.  
  8367. let { autoFitOnAttach, expandSizingTargetForScrollbars, allowOutsideScroll } = this;
  8368.  
  8369. this.__AllowOutsideScrollPD__ = pdAllowOutsideScroll;
  8370.  
  8371. const fitEnable = CHAT_MENU_REFIT_ALONG_SCROLLING === 2;
  8372.  
  8373. Object.defineProperties(this, {
  8374. autoFitOnAttach: {
  8375. get() {
  8376. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  8377. return autoFitOnAttach;
  8378. },
  8379. set(nv) {
  8380. autoFitOnAttach = nv;
  8381. return true;
  8382. },
  8383. enumerable: true,
  8384. configurable: true
  8385. }, expandSizingTargetForScrollbars: {
  8386. get() {
  8387. if (fitEnable && this._modifiedMenuPropOn062__) return true;
  8388. return expandSizingTargetForScrollbars;
  8389. },
  8390. set(nv) {
  8391. expandSizingTargetForScrollbars = nv;
  8392. return true;
  8393. },
  8394. enumerable: true,
  8395. configurable: true
  8396. }, allowOutsideScroll: {
  8397. get() {
  8398. if (this._modifiedMenuPropOn062__) return true;
  8399. return allowOutsideScroll;
  8400. },
  8401. set(nv) {
  8402. allowOutsideScroll = nv;
  8403. this.__AllowOutsideScrollPD__.set.call(this, nv);
  8404. return true;
  8405. },
  8406. enumerable: true,
  8407. configurable: true
  8408. }
  8409. })
  8410. };
  8411.  
  8412. /*
  8413. // ***** position() to be changed. *****
  8414. tp-yt-iron-dropdown[class], tp-yt-iron-dropdown[class] #contentWrapper, tp-yt-iron-dropdown[class] ytd-menu-popup-renderer[class] {
  8415.  
  8416. overflow: visible !important;
  8417. min-width: max-content !important;
  8418. max-width: max-content !important;
  8419. max-height: max-content !important;
  8420. min-height: max-content !important;
  8421. white-space: nowrap;
  8422. }
  8423.  
  8424. */
  8425. if (FIX_MENU_POSITION_N_SIZING_ON_SHOWN && typeof cProto.position === 'function' && !cProto.position34 && typeof cProto.refit === 'function') {
  8426.  
  8427. let m34 = 0;
  8428. cProto.__refitByPosition__ = function () {
  8429. m34++;
  8430. if (m34 <= 0) m34 = 0;
  8431. if (m34 !== 1) return;
  8432. const hostElement = this.hostElement || this;
  8433. if (document.visibilityState === 'visible') {
  8434. const sizingTarget = this.sizingTarget;
  8435. if (!sizingTarget) {
  8436. m34 = 0;
  8437. return;
  8438. }
  8439. hostElement.setAttribute('rNgzQ', '');
  8440. sizingTarget.setAttribute('rNgzQ', '');
  8441.  
  8442. const gn = () => {
  8443. hostElement.removeAttribute('rNgzQ');
  8444. sizingTarget.removeAttribute('rNgzQ');
  8445. }
  8446.  
  8447. const an = async () => {
  8448. while (m34 >= 1) {
  8449. await renderReadyPn(sizingTarget);
  8450. if (this.opened && this.isAttached && sizingTarget.isConnected === true && sizingTarget === this.sizingTarget) {
  8451. if (sizingTarget.matches('ytd-menu-popup-renderer[slot="dropdown-content"].yt-live-chat-app')) this.refit();
  8452. }
  8453. m34--;
  8454. }
  8455. m34 = 0;
  8456. Promise.resolve().then(gn);
  8457. }
  8458. setTimeout(an, 4); // wait those resizing function calls
  8459.  
  8460.  
  8461. } else {
  8462. m34 = 0;
  8463. }
  8464. }
  8465. cProto.position34 = cProto.position
  8466. cProto.position = function () {
  8467. if (this._positionInitialize_) {
  8468. this._positionInitialize_ = 0;
  8469. this.__refitByPosition__();
  8470. }
  8471. let r = cProto.position34.apply(this, arguments);
  8472. return r;
  8473. }
  8474. console.log("FIX_MENU_POSITION_ON_SHOWN - OK");
  8475.  
  8476. } else {
  8477.  
  8478. console.log("FIX_MENU_POSITION_ON_SHOWN - NG");
  8479.  
  8480. }
  8481.  
  8482.  
  8483.  
  8484. cProto.__openedChanged = function () {
  8485. this._positionInitialize_ = 1;
  8486. // this.removeAttribute('horizontal-align')
  8487. // this.removeAttribute('vertical-align')
  8488. if (typeof this.__menuTypeCheck__ !== 'boolean') {
  8489. this.__menuTypeCheck__ = true;
  8490. if (CHAT_MENU_SCROLL_UNLOCKING) {
  8491. this._modifiedMenuPropOn062__ = false;
  8492. // console.log(513, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  8493. // this.autoFitOnAttach = true;
  8494. // this.expandSizingTargetForScrollbars = true;
  8495. // this.allowOutsideScroll = true;
  8496. // console.log(519,Object.getOwnPropertyDescriptors(this.constructor.prototype))
  8497. this.__modifiedMenuPropsFn__();
  8498. // this.constrain= function(){}
  8499. // this.position= function(){}
  8500.  
  8501. // this.autoFitOnAttach = true;
  8502. // this.expandSizingTargetForScrollbars = true;
  8503. // this.allowOutsideScroll = true;
  8504. }
  8505. }
  8506. if (CHAT_MENU_SCROLL_UNLOCKING && this.opened) {
  8507. let newValue = null;
  8508. const positionTarget = this.positionTarget;
  8509. if (positionTarget && positionTarget.classList.contains('yt-live-chat-text-message-renderer')) {
  8510. if (this._modifiedMenuPropOn062__ === false) {
  8511. newValue = true;
  8512. }
  8513. } else if (this._modifiedMenuPropOn062__ === true) {
  8514. newValue = false;
  8515. }
  8516. if (newValue !== null) {
  8517. const beforeAllowOutsideScroll = this.allowOutsideScroll;
  8518. this._modifiedMenuPropOn062__ = newValue;
  8519. const afterAllowOutsideScroll = this.allowOutsideScroll;
  8520. if (beforeAllowOutsideScroll !== afterAllowOutsideScroll) this.__AllowOutsideScrollPD__.set.call(this, afterAllowOutsideScroll);
  8521. }
  8522. }
  8523.  
  8524. if (this.opened) {
  8525.  
  8526. Promise.resolve().then(() => {
  8527.  
  8528. this._prepareRenderOpened();
  8529. }).then(() => {
  8530. this._manager.addOverlay(this);
  8531. if (this._manager._overlays.length === 1) {
  8532. lastOpen = this;
  8533. lastClose = null;
  8534. } else {
  8535. return 1;
  8536. }
  8537. // if (cid) {
  8538. // clearTimeout(cid);
  8539. // cid = -1;
  8540. // this.__moChanged__();
  8541. // cid = 0;
  8542. // } else {
  8543. // cid = -1;
  8544. // this.__moChanged__();
  8545. // cid = 0;
  8546. // }
  8547. // cid = cid > 0 ? clearTimeout(cid) : 0;
  8548. // console.log(580, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  8549. // cid = cid || setTimeout(__moChanged__, delay1);
  8550. cid = cid || requestAnimationFrame(__moChanged__);
  8551. }).then((r) => {
  8552.  
  8553. if (r) this.__mtChanged__(1);
  8554. }).catch(console.warn);
  8555.  
  8556. } else {
  8557. Promise.resolve().then(() => {
  8558. this._manager.removeOverlay(this);
  8559. if (this._manager._overlays.length === 0) {
  8560. lastClose = this;
  8561. lastOpen = null;
  8562. } else {
  8563. return 1;
  8564. }
  8565. // cid = cid > 0 ? clearTimeout(cid) : 0;
  8566. // console.log(581, this.positionTarget && this.positionTarget.classList.contains('yt-live-chat-text-message-renderer'))
  8567. // cid = cid || setTimeout(__moChanged__, delay1);
  8568. cid = cid || requestAnimationFrame(__moChanged__);
  8569. }).then((r) => {
  8570. if (r) this.__mtChanged__(0);
  8571. }).catch(console.warn);
  8572.  
  8573. }
  8574.  
  8575. }
  8576. console.log("BOOST_MENU_OPENCHANGED_RENDERING - OK");
  8577.  
  8578. } else {
  8579.  
  8580. assertor(() => fnIntegrity(cProto.__openedChanged, '0.46.20'));
  8581. console.log("FIX_MENU_REOPEN_RENDER_PERFORMANC_1 - NG");
  8582.  
  8583. }
  8584.  
  8585.  
  8586. if (FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK && typeof cProto.__openedChanged === 'function' && !cProto.__openedChanged82) {
  8587.  
  8588. cProto.__openedChanged82 = cProto.__openedChanged;
  8589.  
  8590.  
  8591. cProto.__openedChanged = function () {
  8592. const positionTarget = this.positionTarget;
  8593. currentMenuPivotWR = positionTarget ? mWeakRef(positionTarget) : null;
  8594. return this.__openedChanged82.apply(this, arguments);
  8595. }
  8596. }
  8597.  
  8598.  
  8599. })();
  8600.  
  8601. console.log("[End]");
  8602.  
  8603. console.groupEnd();
  8604.  
  8605. }).catch(console.warn);
  8606.  
  8607.  
  8608.  
  8609. FIX_ToggleRenderPolymerControllerExtractionBug && customElements.whenDefined('yt-live-chat-toggle-renderer').then(() => {
  8610.  
  8611. mightFirstCheckOnYtInit();
  8612. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-toggle-renderer hacks");
  8613. console.log("[Begin]");
  8614. (() => {
  8615.  
  8616. const tag = "yt-live-chat-toggle-renderer";
  8617. const dummy = document.createElement(tag);
  8618.  
  8619. const cProto = getProto(dummy);
  8620. if (!cProto || !cProto.attached) {
  8621. console.warn(`proto.attached for ${tag} is unavailable.`);
  8622. return;
  8623. }
  8624.  
  8625. })();
  8626.  
  8627. console.log("[End]");
  8628. console.groupEnd();
  8629.  
  8630. });
  8631.  
  8632.  
  8633.  
  8634.  
  8635. /*
  8636.  
  8637.  
  8638.  
  8639.  
  8640.  
  8641. var FU = function() {
  8642. var a = this;
  8643. this.nextHandle_ = 1;
  8644. this.clients_ = {};
  8645. this.JSC$10323_callbacks_ = {};
  8646. this.unsubscribeAsyncHandles_ = {};
  8647. this.subscribe = vl(function(b, c, d) {
  8648. var e = Geb(b);
  8649. if (e in a.clients_)
  8650. e in a.unsubscribeAsyncHandles_ && Jq.cancel(a.unsubscribeAsyncHandles_[e]);
  8651. else {
  8652. a: {
  8653. var h = Geb(b), l;
  8654. for (l in a.unsubscribeAsyncHandles_) {
  8655. var m = a.clients_[l];
  8656. if (m instanceof KO) {
  8657. delete a.clients_[l];
  8658. delete a.JSC$10323_callbacks_[l];
  8659. Jq.cancel(a.unsubscribeAsyncHandles_[l]);
  8660. delete a.unsubscribeAsyncHandles_[l];
  8661. i6a(m);
  8662. m.objectId_ = new FQa(h);
  8663. m.register();
  8664. d = m;
  8665. break a
  8666. }
  8667. }
  8668. d.objectSource = b.invalidationId.objectSource;
  8669. d.objectId = h;
  8670. if (b = b.webAuthConfigurationData)
  8671. b.multiUserSessionIndex && (d.sessionIndex = parseInt(b.multiUserSessionIndex, 10)),
  8672. b.pageId && (d.pageId = b.pageId);
  8673. d = new KO(d,a.handleInvalidationData_.bind(a));
  8674. d.register()
  8675. }
  8676. a.clients_[e] = d;
  8677. a.JSC$10323_callbacks_[e] = {}
  8678. }
  8679. d = a.nextHandle_++;
  8680. a.JSC$10323_callbacks_[e][d] = c;
  8681. return d
  8682. })
  8683. };
  8684. FU.prototype.unsubscribe = function(a, b) {
  8685. var c = Geb(a);
  8686. if (c in this.JSC$10323_callbacks_ && (delete this.JSC$10323_callbacks_[c][b],
  8687. !this.JSC$10323_callbacks_[c].length)) {
  8688. var d = this.clients_[c];
  8689. b = Jq.run(function() {
  8690. ei(d);
  8691. delete this.clients_[c];
  8692. delete this.unsubscribeAsyncHandles_[c]
  8693. }
  8694. .bind(this));
  8695. this.unsubscribeAsyncHandles_[c] = b
  8696. }
  8697. }
  8698. ;
  8699.  
  8700.  
  8701. */
  8702.  
  8703.  
  8704. const onManagerFound = (dummyManager) => {
  8705. if (!dummyManager || typeof dummyManager !== 'object') return;
  8706.  
  8707. const mgrProto = dummyManager.constructor.prototype;
  8708.  
  8709. let keyCallbackStore = '';
  8710. for (const [key, v] of Object.entries(dummyManager)) {
  8711. if (key.includes('_callbacks_')) keyCallbackStore = key;
  8712. }
  8713.  
  8714. if (!keyCallbackStore || typeof mgrProto.unsubscribe !== 'function' || mgrProto.unsubscribe.length !== 2) return;
  8715.  
  8716. if (mgrProto.unsubscribe16) return;
  8717.  
  8718. mgrProto.unsubscribe16 = mgrProto.unsubscribe;
  8719.  
  8720. groupCollapsed("YouTube Super Fast Chat", " | *live-chat-manager* hacks");
  8721. console.log("[Begin]");
  8722.  
  8723. const isEmptyObject = ((obj) => (firstKey(obj) === null));
  8724.  
  8725. const idMapper = new Map();
  8726.  
  8727. const convertId = function (objectId) {
  8728. if (!objectId || typeof objectId !== 'string') return null;
  8729.  
  8730. let result = idMapper.get(objectId)
  8731. if (result) return result;
  8732. result = atob(objectId.replace(/-/g, "+").replace(/_/g, "/"));
  8733. idMapper.set(objectId, result)
  8734. return result;
  8735. }
  8736.  
  8737.  
  8738. const rafHandleHolder = [];
  8739.  
  8740. let pzw = 0;
  8741. let lza = 0;
  8742. const rafHandlerFn = () => {
  8743. pzw = 0;
  8744. if (rafHandleHolder.length === 1) {
  8745. const f = rafHandleHolder[0];
  8746. rafHandleHolder.length = 0;
  8747. f();
  8748. } else if (rafHandleHolder.length > 1) {
  8749. const arr = rafHandleHolder.slice(0);
  8750. rafHandleHolder.length = 0;
  8751. for (const fn of arr) fn();
  8752. }
  8753. };
  8754.  
  8755.  
  8756. if (CHANGE_MANAGER_UNSUBSCRIBE) {
  8757.  
  8758. const checkIntegrityForSubscribe = (mgr) => {
  8759. if (mgr
  8760. && typeof mgr.unsubscribe16 === 'function' && mgr.unsubscribe16.length === 2
  8761. && typeof mgr.subscribe18 === 'function' && (mgr.subscribe18.length === 0 || mgr.subscribe18.length === 3)) {
  8762.  
  8763. const ns = new Set(Object.keys(mgr));
  8764. const ms = new Set(Object.keys(mgr.constructor.prototype));
  8765.  
  8766. if (ns.size >= 6 && ms.size >= 4) {
  8767. // including 'subscribe18'
  8768. // 'unsubscribe16', 'subscribe19'
  8769.  
  8770. let r = 0;
  8771. for (const k of ['nextHandle_', 'clients_', keyCallbackStore, 'unsubscribeAsyncHandles_', 'subscribe', 'subscribe18']) {
  8772. r += ns.has(k) ? 1 : 0;
  8773. }
  8774. for (const k of ['unsubscribe', 'handleInvalidationData_', 'unsubscribe16', 'subscribe19']) {
  8775. r += ms.has(k) ? 1 : 0;
  8776. }
  8777. if (r === 10) {
  8778. const isObject = (c) => (c || 0).constructor === Object;
  8779.  
  8780. if (isObject(mgr['clients_']) && isObject(mgr[keyCallbackStore]) && isObject(mgr['unsubscribeAsyncHandles_'])) {
  8781.  
  8782. return true;
  8783. }
  8784.  
  8785.  
  8786. }
  8787.  
  8788. }
  8789.  
  8790.  
  8791. }
  8792. return false;
  8793. }
  8794.  
  8795. mgrProto.subscribe19 = function (o, f, opts) {
  8796.  
  8797. const ct_clients_ = this.clients_ || 0;
  8798. const ct_handles_ = this.unsubscribeAsyncHandles_ || 0;
  8799.  
  8800. if (this.__doCustomSubscribe__ !== true || !ct_clients_ || !ct_handles_) return this.subscribe18.apply(this, arguments);
  8801.  
  8802. let objectId = ((o || 0).invalidationId || 0).objectId;
  8803. if (!objectId) return this.subscribe18.apply(this, arguments);
  8804. objectId = convertId(objectId);
  8805.  
  8806. // console.log('subscribe', objectId, ct_clients_[objectId], arguments);
  8807.  
  8808. if (ct_clients_[objectId]) {
  8809. if (ct_handles_[objectId] < 0) delete ct_handles_[objectId];
  8810. }
  8811.  
  8812. return this.subscribe18.apply(this, arguments);
  8813. }
  8814.  
  8815. mgrProto.unsubscribe = function (o, d) {
  8816. if (!this.subscribe18 && typeof this.subscribe === 'function') {
  8817. this.subscribe18 = this.subscribe;
  8818. this.subscribe = this.subscribe19;
  8819. this.__doCustomSubscribe__ = checkIntegrityForSubscribe(this);
  8820. }
  8821. const ct_clients_ = this.clients_;
  8822. const ct_handles_ = this.unsubscribeAsyncHandles_;
  8823. if (this.__doCustomSubscribe__ !== true || !ct_clients_ || !ct_handles_) return this.unsubscribe16.apply(this, arguments);
  8824.  
  8825. let objectId = ((o || 0).invalidationId || 0).objectId;
  8826. if (!objectId) return this.unsubscribe16.apply(this, arguments);
  8827.  
  8828. objectId = convertId(objectId);
  8829.  
  8830.  
  8831. // console.log('unsubscribe', objectId, ct_clients_[objectId], arguments);
  8832.  
  8833. const callbacks = this[keyCallbackStore] || 0;
  8834. const callbackObj = callbacks[objectId] || 0;
  8835.  
  8836.  
  8837. if (callbackObj && (delete callbackObj[d], isEmptyObject(callbackObj))) {
  8838. const w = ct_clients_[objectId];
  8839. --lza;
  8840. if (lza < -1e9) lza = -1;
  8841. const qta = lza;
  8842. rafHandleHolder.push(() => {
  8843. if (qta === ct_handles_[objectId]) {
  8844. const o = {
  8845. callbacks, callbackObj,
  8846. client: ct_clients_[objectId],
  8847. handle: ct_handles_[objectId]
  8848. };
  8849. let p = 0;
  8850. try {
  8851. if (ct_clients_[objectId] === w) {
  8852. w && "function" === typeof w.dispose && w.dispose();
  8853. delete ct_clients_[objectId];
  8854. delete ct_handles_[objectId];
  8855. p = 1;
  8856. } else {
  8857. // w && "function" === typeof w.dispose && w.dispose();
  8858. // delete ct_clients_[objectId];
  8859. // delete ct_handles_[objectId];
  8860. p = 2;
  8861. }
  8862. } catch (e) {
  8863. console.warn(e);
  8864. }
  8865. console.log(`unsubscribed: ${p}`, this, o);
  8866. }
  8867. });
  8868. ct_handles_[objectId] = qta;
  8869. if (pzw === 0) {
  8870. pzw = requestAnimationFrame(rafHandlerFn);
  8871. }
  8872. }
  8873. }
  8874.  
  8875.  
  8876. console.log("CHANGE_MANAGER_UNSUBSCRIBE - OK")
  8877.  
  8878. } else {
  8879.  
  8880. console.log("CHANGE_MANAGER_UNSUBSCRIBE - NG")
  8881. }
  8882.  
  8883. console.log("[End]");
  8884.  
  8885. console.groupEnd();
  8886.  
  8887. }
  8888.  
  8889.  
  8890.  
  8891. /*
  8892.  
  8893.  
  8894. a.prototype.async = function(e, h) {
  8895. return 0 < h ? Iq.run(e.bind(this), h) : ~Kq.run(e.bind(this))
  8896. }
  8897. ;
  8898. a.prototype.cancelAsync = function(e) {
  8899. 0 > e ? Kq.cancel(~e) : Iq.cancel(e)
  8900. }
  8901.  
  8902. */
  8903.  
  8904.  
  8905. (FASTER_ICON_RENDERING && Promise.all(
  8906. [
  8907. customElements.whenDefined("yt-icon-shape"),
  8908. customElements.whenDefined("yt-icon")
  8909. // document.createElement('icon-shape'),
  8910. ]
  8911. )).then(() => {
  8912. let cq = 0;
  8913. let dummys = [document.createElement('yt-icon-shape'), document.createElement('yt-icon')]
  8914. for (const dummy of dummys) {
  8915. let cProto = getProto(dummy);
  8916. if (cProto && typeof cProto.shouldRenderIconShape === 'function' && !cProto.shouldRenderIconShape571 && cProto.shouldRenderIconShape.length === 1) {
  8917. assertor(() => fnIntegrity(cProto.shouldRenderIconShape, '1.70.38'));
  8918. cq++;
  8919. cProto.shouldRenderIconShape571 = cProto.shouldRenderIconShape;
  8920. cProto.shouldRenderIconShape = function (a) {
  8921. if (this.isAnimatedIcon) return this.shouldRenderIconShape571(a);
  8922. if (!this.iconType || !this.iconShapeData) return this.shouldRenderIconShape571(a);
  8923. if (!this.iconName) return this.shouldRenderIconShape571(a);
  8924. return false;
  8925. // console.log(1051, this.iconType)
  8926. // console.log(1052, this.iconShapeData)
  8927. // console.log(1053, this.isAnimatedIcon)
  8928. }
  8929. }
  8930. // if(cProto && cProto.switchTemplateAtRegistration){
  8931. // cProto.switchTemplateAtRegistration = false;
  8932. // }
  8933. }
  8934. if (cq === 1) {
  8935. console.log("modified shouldRenderIconShape - Y")
  8936. } else {
  8937. console.log("modified shouldRenderIconShape - N", cq)
  8938. }
  8939. });
  8940.  
  8941. customElements.whenDefined("yt-invalidation-continuation").then(() => {
  8942.  
  8943. let __dummyManager__ = null;
  8944.  
  8945. mightFirstCheckOnYtInit();
  8946. groupCollapsed("YouTube Super Fast Chat", " | yt-invalidation-continuation hacks");
  8947. console.log("[Begin]");
  8948. (() => {
  8949.  
  8950. const tag = "yt-invalidation-continuation"
  8951. const dummy = document.createElement(tag);
  8952.  
  8953. const cProto = getProto(dummy);
  8954. if (!cProto || !cProto.attached) {
  8955. console.warn(`proto.attached for ${tag} is unavailable.`);
  8956. return;
  8957. }
  8958.  
  8959. const dummyManager = insp(dummy).manager_ || 0;
  8960. __dummyManager__ = dummyManager;
  8961.  
  8962. 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) {
  8963.  
  8964.  
  8965. const rafHub = new RAFHub();
  8966.  
  8967. rafHub.keepRAF = true;
  8968. cProto.async71 = cProto.async;
  8969. cProto.cancelAsync71 = cProto.cancelAsync;
  8970.  
  8971. // mostly for subscription timeoutMs 10000ms
  8972. let mcw = 1; // 1, 3, 5, ...
  8973. let arr = new Map();
  8974.  
  8975. let __asyncInited__ = 0;
  8976. let __timeoutStartId__ = null;
  8977. const __asyncInit__ = () => {
  8978.  
  8979. if (__asyncInited__) return;
  8980. __asyncInited__ = 1;
  8981.  
  8982. __timeoutStartId__ = setTimeout(() => { });
  8983. mcw = __timeoutStartId__ * 2 + 1;
  8984.  
  8985. setInterval(() => {
  8986.  
  8987. if (!arr.length) return;
  8988.  
  8989. const p = Date.now();
  8990. let deleteKeys = [];
  8991. arr.forEach((entry, key) => {
  8992.  
  8993.  
  8994. if (entry.cid === -1) {
  8995. entry.cid = -2;
  8996. } else if (entry.cid === -2) {
  8997.  
  8998. let offset = p - entry.add
  8999. if (offset < 0) offset = 0;
  9000. let delay2 = entry.delay - offset;
  9001. if (delay2 < 0) delay2 = 0;
  9002. entry.cid = setTimeout(entry.q(), delay2);
  9003. entry.q = null;
  9004.  
  9005. } else if (entry.add + entry.delay < p) {
  9006. deleteKeys.push(key);
  9007.  
  9008. }
  9009.  
  9010. })
  9011.  
  9012. for (const key of deleteKeys) arr.delete(key);
  9013.  
  9014. }, 2000)
  9015.  
  9016. }
  9017.  
  9018.  
  9019. cProto.async = function (e, h) {
  9020.  
  9021. if (!(0 < h)) return this.async71(e, h); // unknown timing Fn
  9022.  
  9023. if (h < 8000) return this.async71(e, h) * 2; // native setTimeout
  9024.  
  9025. if (typeof h !== 'number') return this.async71(e, h); // exceptional case
  9026.  
  9027.  
  9028. if (!this.__asyncInited__) {
  9029. this.__asyncInited__ = 1;
  9030. __asyncInit__();
  9031. }
  9032. mcw += 2; // 2K+3, 2K+4, ...
  9033. if (mcw > 1e9) mcw = mcw % 1e4;
  9034. const cid = mcw;
  9035. const q = () => {
  9036. return () => {
  9037. console.log('async h > 8000');
  9038. e.call(this);
  9039. }
  9040. }
  9041. // setTimeout(q, delay)
  9042. arr.set(cid, {
  9043. cid: -1, // -1 -> -2 -> cid
  9044. add: Date.now(),
  9045. q,
  9046. delay: h
  9047. });
  9048. // console.log('cid-async', cid)
  9049. return cid;
  9050.  
  9051. }
  9052.  
  9053.  
  9054. cProto.cancelAsync = function (e) {
  9055.  
  9056. if (typeof e !== 'number') return this.cancelAsync71(e); // exceptional case
  9057.  
  9058. // console.log('cid-unasync', e)
  9059.  
  9060. if (0 > e) return this.cancelAsync71(e); // unknown timing fn
  9061.  
  9062. if (e > __timeoutStartId__ * 2) { // __timeoutStartId__ is recorded and min is 2K+1
  9063.  
  9064. if ((e % 2) === 0) return this.cancelAsync71(e / 2); // 2(K+1), 2(K+2), ...
  9065.  
  9066. if (!arr.has(e)) return; // duplciated cancel
  9067.  
  9068. const entry = arr.get(e);
  9069. if (entry.cid < 0) {
  9070. entry.cid = 0;
  9071. arr.delete(e);
  9072. } else {
  9073. clearTimeout(entry.cid); // cid >= 1
  9074. entry.cid = 0;
  9075. arr.delete(e);
  9076. }
  9077.  
  9078. } else {
  9079.  
  9080. return this.cancelAsync71(e);
  9081.  
  9082. }
  9083.  
  9084. }
  9085.  
  9086. console.log("CHANGE_DATA_FLUSH_ASYNC - OK");
  9087.  
  9088. } else {
  9089. console.log("CHANGE_DATA_FLUSH_ASYNC - NOT REQUIRED");
  9090.  
  9091. }
  9092.  
  9093. })();
  9094.  
  9095. console.log("[End]");
  9096.  
  9097. console.groupEnd();
  9098.  
  9099.  
  9100.  
  9101. onManagerFound(__dummyManager__);
  9102.  
  9103. }).catch(console.warn);
  9104.  
  9105.  
  9106. if (INTERACTIVITY_BACKGROUND_ANIMATION >= 1) {
  9107.  
  9108. customElements.whenDefined("yt-live-interactivity-component-background").then(() => {
  9109.  
  9110. mightFirstCheckOnYtInit();
  9111. groupCollapsed("YouTube Super Fast Chat", " | yt-live-interactivity-component-background hacks");
  9112. console.log("[Begin]");
  9113. (() => {
  9114.  
  9115. const tag = "yt-live-interactivity-component-background"
  9116. const dummy = document.createElement(tag);
  9117.  
  9118. const cProto = getProto(dummy);
  9119. if (!cProto || !cProto.attached) {
  9120. console.warn(`proto.attached for ${tag} is unavailable.`);
  9121. return;
  9122. }
  9123.  
  9124. cProto.__toStopAfterRun__ = function (hostElement) {
  9125. let mo = new MutationObserver(() => {
  9126. mo.disconnect();
  9127. mo.takeRecords();
  9128. mo = null;
  9129. this.lottieAnimation && this.lottieAnimation.stop(); // primary
  9130. foregroundPromiseFn().then(() => { // if the lottieAnimation is started with rAf triggering
  9131. this.lottieAnimation && this.lottieAnimation.stop(); // fallback
  9132. });
  9133. });
  9134. mo.observe(hostElement, { subtree: true, childList: true });
  9135. }
  9136.  
  9137. if (INTERACTIVITY_BACKGROUND_ANIMATION >= 1 && typeof cProto.maybeLoadAnimationBackground === 'function' && !cProto.maybeLoadAnimationBackground77 && cProto.maybeLoadAnimationBackground.length === 0) {
  9138.  
  9139. cProto.maybeLoadAnimationBackground77 = cProto.maybeLoadAnimationBackground;
  9140. cProto.maybeLoadAnimationBackground = function () {
  9141. let toRun = true;
  9142. let stopAfterRun = false;
  9143. if (!this.__bypassDisableAnimationBackground__) {
  9144. let doFix = false;
  9145. if (INTERACTIVITY_BACKGROUND_ANIMATION === 1) {
  9146. if (!this.lottieAnimation) {
  9147. doFix = true;
  9148. }
  9149. } else if (INTERACTIVITY_BACKGROUND_ANIMATION === 2) {
  9150. doFix = true;
  9151. }
  9152. if (doFix) {
  9153. if (this.useAnimationBackground === true) {
  9154. console.log('DISABLE_INTERACTIVITY_BACKGROUND_ANIMATION', this.lottieAnimation);
  9155. }
  9156. toRun = true;
  9157. stopAfterRun = true;
  9158. }
  9159. }
  9160. if (toRun) {
  9161. if (stopAfterRun && (this.hostElement instanceof HTMLElement)) {
  9162. this.__toStopAfterRun__(this.hostElement); // primary
  9163. }
  9164. const r = this.maybeLoadAnimationBackground77.apply(this, arguments);
  9165. if (stopAfterRun && this.lottieAnimation) {
  9166. this.lottieAnimation.stop(); // fallback if no mutation
  9167. }
  9168. return r;
  9169. }
  9170. }
  9171.  
  9172. console.log(`INTERACTIVITY_BACKGROUND_ANIMATION${INTERACTIVITY_BACKGROUND_ANIMATION} - OK`);
  9173.  
  9174. } else {
  9175. console.log(`INTERACTIVITY_BACKGROUND_ANIMATION${INTERACTIVITY_BACKGROUND_ANIMATION} - NG`);
  9176.  
  9177. }
  9178.  
  9179. })();
  9180.  
  9181. console.log("[End]");
  9182.  
  9183. console.groupEnd();
  9184.  
  9185.  
  9186. }).catch(console.warn);
  9187.  
  9188. }
  9189.  
  9190.  
  9191. if (DELAY_FOCUSEDCHANGED) {
  9192.  
  9193. customElements.whenDefined("yt-live-chat-text-input-field-renderer").then(() => {
  9194.  
  9195.  
  9196. mightFirstCheckOnYtInit();
  9197. groupCollapsed("YouTube Super Fast Chat", " | yt-live-chat-text-input-field-renderer hacks");
  9198. console.log("[Begin]");
  9199. (() => {
  9200.  
  9201. const tag = "yt-live-chat-text-input-field-renderer"
  9202. const dummy = document.createElement(tag);
  9203.  
  9204. const cProto = getProto(dummy);
  9205. if (!cProto || !cProto.attached) {
  9206. console.warn(`proto.attached for ${tag} is unavailable.`);
  9207. return;
  9208. }
  9209.  
  9210. if (DELAY_FOCUSEDCHANGED && typeof cProto.focusedChanged === 'function' && cProto.focusedChanged.length === 0 && !cProto.focusedChanged372) {
  9211. cProto.focusedChanged372 = cProto.focusedChanged;
  9212. cProto.focusedChanged = function () {
  9213. Promise.resolve().then(() => {
  9214. if (this.isAttached === true) this.focusedChanged372();
  9215. });
  9216. }
  9217. }
  9218.  
  9219. })();
  9220.  
  9221. console.log("[End]");
  9222.  
  9223. console.groupEnd();
  9224.  
  9225. });
  9226.  
  9227. }
  9228.  
  9229.  
  9230. }
  9231.  
  9232.  
  9233.  
  9234.  
  9235. promiseForCustomYtElementsReady.then(onRegistryReadyForDOMOperations);
  9236.  
  9237. const fixJsonParse = () => {
  9238.  
  9239. let p1 = window.onerror;
  9240.  
  9241. try {
  9242. JSON.parse("{}");
  9243. } catch (e) {
  9244. console.warn(e);
  9245. }
  9246.  
  9247. let p2 = window.onerror;
  9248.  
  9249. if (p1 !== p2) {
  9250.  
  9251.  
  9252. console.groupCollapsed(`%c${"YouTube Super Fast Chat"}%c${" | JS Engine Issue Found"}`,
  9253. "background-color: #010502; color: #fe806a; font-weight: 700; padding: 2px;",
  9254. "background-color: #010502; color: #fe806a; font-weight: 300; padding: 2px;"
  9255. );
  9256.  
  9257. 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");
  9258.  
  9259. console.groupEnd();
  9260.  
  9261. }
  9262.  
  9263. }
  9264.  
  9265. if (CHECK_JSONPRUNE) {
  9266. promiseForCustomYtElementsReady.then(fixJsonParse);
  9267. }
  9268.  
  9269. });
  9270.  
  9271.  
  9272.  
  9273. })({ IntersectionObserver });