YouTube 超快聊天

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

当前为 2024-03-09 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址