YouTube JS Engine Tamer

修改 YouTube 的 JS 引擎以提升性能

当前为 2025-05-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube JS Engine Tamer
  3. // @name:ja YouTube JS Engine Tamer
  4. // @name:zh-TW YouTube JS Engine Tamer
  5. // @name:zh-CN YouTube JS Engine Tamer
  6. // @namespace UserScripts
  7. // @version 0.40.2
  8. // @match https://www.youtube.com/*
  9. // @match https://www.youtube-nocookie.com/embed/*
  10. // @match https://studio.youtube.com/live_chat*
  11. // @license MIT
  12. // @author CY Fung
  13. // @icon https://raw.githubusercontent.com/cyfung1031/userscript-supports/main/icons/yt-engine.png
  14. // @grant none
  15. // @require https://cdn.jsdelivr.net/gh/cyfung1031/userscript-supports@c2b707e4977f77792042d4a5015fb188aae4772e/library/nextBrowserTick.min.js
  16. // @run-at document-start
  17. // @unwrap
  18. // @inject-into page
  19. // @allFrames true
  20. // @exclude /^https?://\S+\.(txt|png|jpg|jpeg|gif|xml|svg|manifest|log|ini)[^\/]*$/
  21. //
  22. // @description To enhance YouTube performance by modifying YouTube JS Engine
  23. // @description:ja YouTubeのJSエンジンを変更してパフォーマンスを向上させる
  24. // @description:zh-TW 修改 YouTube 的 JS 引擎以提升效能
  25. // @description:zh-CN 修改 YouTube 的 JS 引擎以提升性能
  26. //
  27. // ==/UserScript==
  28.  
  29. (() => {
  30.  
  31. /** @type {WeakMapConstructor} */
  32. const WeakMap = window.WeakMapOriginal || window.WeakMap;
  33.  
  34. const HOOK_ACTIVE_MODULES = true; // added in 0.37.0
  35. const HOOK_ACTIVE_MODULES_fetchUpdatedMetadata = true; // added in 0.37.0 (make likeCount update)
  36. const NATIVE_CANVAS_ANIMATION = false; // for #cinematics
  37. const FIX_schedulerInstanceInstance = 2 | 4;
  38. const FIX_yt_player = true; // DONT CHANGE
  39. const FIX_Animation_n_timeline = true;
  40. const FIX_Animation_n_timeline_cinematic = true;
  41. const FIX_ytScheduler = true;
  42. const NO_PRELOAD_GENERATE_204 = false;
  43. const ENABLE_COMPUTEDSTYLE_CACHE = true;
  44. const NO_SCHEDULING_DUE_TO_COMPUTEDSTYLE = true;
  45. const CHANGE_appendChild = true; // discussions#236759
  46. const FIX_bind_self_this = false; // EXPERIMENTAL !!!!! this affect page switch after live ends
  47. const FIX_weakMap_weakRef = false; // EXPERIMENTAL !!!!! Might Incompatible to some userscripts (as the strong relationship is removed)
  48.  
  49. const FIX_error_many_stack = true; // should be a bug caused by uBlock Origin
  50. // const FIX_error_many_stack_keepAliveDuration = 200; // ms
  51. // const FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than = 8;
  52.  
  53. const FIX_Iframe_NULL_SRC = false;
  54.  
  55. const IGNORE_bindAnimationForCustomEffect = true; // prevent `v.bindAnimationForCustomEffect(this);` being executed
  56.  
  57. const FIX_ytdExpander_childrenChanged = true;
  58. const FIX_paper_ripple_animate = true;
  59. const FIX_avoid_incorrect_video_meta = false; // omit the incorrect yt-animated-rolling-number // 2025.05.10 - obsoleted -> y.fetchUpdatedMetadata(t, e.continuation)
  60. const FIX_avoid_incorrect_video_meta_emitterBehavior = false; // 2025.05.10 - obsoleted -> y.fetchUpdatedMetadata(t, e.continuation)
  61.  
  62. const FIX_doIdomRender = true;
  63.  
  64. const FIX_Shady = true;
  65.  
  66. // [[ 2024.04.24 ]]
  67. const MODIFY_ShadyDOM_OBJ = true;
  68. // << if MODIFY_ShadyDOM_OBJ >>
  69. const WEAKREF_ShadyDOM = true;
  70. const OMIT_ShadyDOM_EXPERIMENTAL = 1 | 0; // 1 => enable; 2 => composedPath
  71. const OMIT_ShadyDOM_settings = 0 | 0 | 0; // 1: inUse; 2: handlesDynamicScoping; 4: force // {{ PRELIM TESTING PURPOSE }}
  72. // << end >>
  73.  
  74. const WEAK_REF_BINDING_CONTROL = 1 | 2; // 2 - conflict control with ShadyDOM weakref
  75.  
  76. const FIX_ytAction_ = true; // ytd-app
  77. const FIX_onVideoDataChange = false;
  78. // const FIX_onClick = true;
  79. const FIX_onStateChange = true;
  80. const FIX_onLoopRangeChange = true;
  81. // const FIX_maybeUpdateFlexibleMenu = true; // ytd-menu-renderer
  82. const FIX_VideoEVENTS_v2 = true; // true might cause bug in switching page
  83.  
  84. const ENABLE_discreteTasking = false; // removed since 0.20.0
  85. const FIX_stampDomArray_ = true; // v0.30.0
  86. const FIX_stampDomArray = FIX_stampDomArray_ && typeof WeakRef === "function" && typeof FinalizationRegistry === "function";
  87. // const stampDomArray_MemoryFix_Flag001 = false;
  88. const XFlag = true; // root issue tbc
  89. const MemoryFix_Flag002 = 1 | 2 | 4 | 8 | 0 | 32 | 64 | 0 | 256;
  90. // 32 required for new stampDomArray
  91. // 128 to be tested
  92.  
  93. const FIX_perfNow = true; // history state issue; see https://bugzilla.mozilla.org/show_bug.cgi?id=1756970
  94. const ENABLE_ASYNC_DISPATCHEVENT = false; // problematic
  95.  
  96. const FIX_Polymer_dom = true;
  97. const FIX_Polymer_AF = true;
  98.  
  99. const SCRIPTLET_REMOVE_PRUNE_propNeedles = true; // brave scriptlet related
  100. const DEBUG_removePrune = false; // true for DEBUG
  101.  
  102. const FIX_XHR_REQUESTING = true;
  103.  
  104. const LOG_FETCHMETA_UPDATE = false; // for DEBUG
  105.  
  106. const IGNORE_bufferhealth_CHECK = false; // experimental; true will make "Stats for nerds" no info.
  107.  
  108. const DENY_requestStorageAccess = true; // remove document.requestStorageAccess
  109. const DISABLE_IFRAME_requestStorageAccess = true; // no effect if DENY_requestStorageAccess is true
  110.  
  111. const DISABLE_COOLDOWN_SCROLLING = true; // YT cause scroll hang in MacOS
  112.  
  113. const FIX_removeChild = true;
  114. const FIX_fix_requestIdleCallback_timing = true;
  115.  
  116. const HOOK_CSSPD_LEFT = true; // global css hack for style.left
  117. const FORCE_NO_REUSEABLE_ELEMENT_POOL = true;
  118.  
  119. const FIX_TRANSCRIPT_SEGMENTS = true; // Based on Tabview Youtube's implementation
  120.  
  121. const FIX_POPUP_UNIQUE_ID = true; // currently only for channel about popup;
  122.  
  123. // ----------------------------- POPUP UNIQUE ID ISSUE -----------------------------
  124. // example. https://www.youtube.com/channel/UCgPev1KKSCMbnNRsvN83Hag/about
  125. // first tp-yt-paper-dialog: show once the page is loaded.
  126. // second tp-yt-paper-dialog: click "...more"
  127. // third tp-yt-paper-dialog: click "... and 3 more links"
  128. // check with document.querySelectorAll('ytd-popup-container tp-yt-paper-dialog').length
  129. // currently, uniqueId is preassigned by the network resolveCommand.
  130. // so don't modify the source side, just modify the display side (popup display) via handleOpenPopupAction
  131. // other related functions e.g. handleClosePopupCommand_, getAndMaybeCreatePopup_, handleClosePopupAction_, getAndMaybeCreatePopup_
  132.  
  133. // handleOpenPopupAction -> createCacheKey
  134. // handleClosePopupAction_ -> createCacheKey
  135. // handleGetPopupOpenedAction_ -> createCacheKey
  136. // getAndMaybeCreatePopup_ -> createCacheKey
  137. // closePopup -> createCacheKey
  138.  
  139. // yt-close-popup-command -> handleClosePopupCommand_
  140.  
  141. // ensurePopup_ -> getAndMaybeCreatePopup_
  142.  
  143. // yt-close-popup-action -> handleClosePopupAction_
  144. // closePopup -> handleClosePopupAction_
  145. // handleOpenPopupAction -> handleClosePopupAction_
  146. // handleClosePopupCommand_ -> handleClosePopupAction_
  147. // closeSheet -> handleClosePopupAction_("yt-sheet-view-model")
  148.  
  149. // yt-open-popup-action -> handleOpenPopupAction
  150.  
  151.  
  152. // yt-close-popup-action -> handleClosePopupAction_ -> createCacheKey
  153. // yt-close-popup-command -> handleClosePopupCommand_ -> handleClosePopupAction_ -> createCacheKey
  154.  
  155. // Experimental flag "ytpopup_disable_default_html_caching" is disabled by default.
  156. // Not sure enabling it can make GC or not (Yt Components are usually not GC-able)
  157. // ----------------------------- POPUP UNIQUE ID ISSUE -----------------------------
  158.  
  159. const MEMORY_RELEASE_NF00 = true;
  160. const MEMORY_RELEASE_NF00_SHOW_MESSAGE = false;
  161. const MEMORY_RELEASE_MAP_SET_REMOVE_NODE = true;
  162. const FULLY_REMOVE_ALL_EVENT_LISTENERS = true; // require MEMORY_RELEASE_NF00
  163. // const FIX_MEMORY_RELEASE_RUNEFFECT_TEMPLATE = true; // require MEMORY_RELEASE_NF00
  164. const FIX_TEMPLATE_BINDING = true;
  165. const FIX_TEMPLATE_BINDING_SHOW_MESSAGE = false;
  166.  
  167. const USE_fastDomIf = 2; // fastDomIf is seem to be experimental 0 = no change, 1 = enable, 2 = disable
  168. const ENHANCE_DOMIF_createAndInsertInstance = true; // root does not need to store in the instance
  169. const ENHANCE_DOMIF_TEARDOWN = true; // require MEMORY_RELEASE_NF00
  170.  
  171. const FIX_DOM_IF_DETACH = true;
  172. const FIX_DOM_IF_REPEAT = true; // semi-experimental (added in 0.17.0)
  173. const FIX_DOM_IF_TEMPLATE = true;
  174. // const FIX_DOM_REPEAT_TEMPLATE = true; // to be implemented
  175. const FIX_DOM_IFREPEAT_RenderDebouncerChange = false; // semi-experimental (added in 0.17.0) // found buggy for chat ticker sizing
  176. const DEBUG_DBR847 = false;
  177. const DEBUG_xx847 = false;
  178. const FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME = true; // default true. false might be required for future change
  179. const DEBUG_renderDebounceTs = false;
  180.  
  181. const FIX_ICON_RENDER = true;
  182. const FIX_GUIDE_ICON = true;
  183. const FIX_ACTIONS_TOOLTIPS = true;
  184.  
  185. const FIX_VIDEO_PLAYER_MOUSEHOVER_EVENTS = true; // avoid unnecessary reflows due to cursor moves on the web player.
  186.  
  187. const DISABLE_isLowLatencyLiveStream = false; // TBC
  188.  
  189. const FIX_FlexibleItemSizing = true;
  190. const FIX_ROLLING_NUMBER_UPDATE = true;
  191.  
  192. /*
  193.  
  194. FIX_DOM_IFREPEAT_RenderDebouncerChange
  195.  
  196. avoid Polymer.flush
  197. // https://www.youtube.com/s/desktop/26a583e4/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  198.  
  199. var Is = function() {
  200. do {
  201. var a = window.ShadyDOM && ShadyDOM.flush();
  202. window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush();
  203. var b = NNa()
  204. } while (a || b)
  205. };
  206.  
  207. , NNa = function() {
  208. var a = !!ts.size;
  209. ts.forEach(function(b) {
  210. try {
  211. b.flush()
  212. } catch (c) {
  213. setTimeout(function() {
  214. throw c
  215. })
  216. }
  217. });
  218. return a
  219. };
  220.  
  221. // why flush twice after all ts are completed? (!!ts.size => true => loop again)
  222. // this coding logic should be incorrect (mistake).
  223.  
  224. */
  225.  
  226.  
  227.  
  228. // ----------------------------- Shortkey Keyboard Control -----------------------------
  229. // dependency: FIX_yt_player
  230.  
  231. const FIX_SHORTCUTKEYS = 2; // 0 - no fix; 1 - basic fix; 2 - advanced fix
  232. // [0] no fix - not recommended
  233. // [1] basic fix - just fix the global focus detection variable
  234. // [2] advanced fix - call the shortcut actions directly, auto foucs change, direct control of spacebar behavior, etc
  235. // (note) 0 or 1 if you find conflict with other userscripts/plugin
  236.  
  237. const CHANGE_SPEEDMASTER_SPACEBAR_CONTROL = 0; // 0 - disable; 1 - force true; 2 - force false
  238. const USE_IMPROVED_PAUSERESUME_UNDER_NO_SPEEDMASTER = true; // only for SPEEDMASTER = false & FIX_SHORTCUTKEYS = 2
  239.  
  240. const PROP_OverReInclusion_AVOID = true;
  241. const PROP_OverReInclusion_DEBUGLOG = false;
  242. const PROP_OverReInclusion_LIST = new Set([
  243. 'hostElement72',
  244. 'parentComponent72',
  245. 'localVisibilityObserver_72',
  246. 'cachedProviderNode_72',
  247. '__template72',
  248. '__templatizeOwner72',
  249. '__templateInfo72',
  250. '__dataHost72',
  251. '__CE_shadowRoot72',
  252. 'elements_72',
  253.  
  254. 'ky36',
  255. 'kz62',
  256. 'm822',
  257.  
  258.  
  259.  
  260. // To be reviewed.
  261.  
  262. // chat messages
  263. 'disabled', 'allowedProps',
  264. 'filledButtonOverrides', 'openPopupConfig', 'supportsInlineActionButtons', 'allowedProps',
  265.  
  266. 'dimension', 'loadTime', 'pendingPaint',
  267.  
  268. 'countdownDurationMs', 'countdownMs', 'lastCountdownTimeMs', 'rafId', 'playerProgressSec', 'detlaSincePausedSecs', 'behaviorActionMap', 'selected', 'maxLikeCount', 'maxReplyCount', 'isMouseOver',
  269.  
  270. 'respectLangDir', 'noEndpoints',
  271.  
  272.  
  273. 'objectURL',
  274. 'buttonOverrides', 'queuedMessages',
  275. 'STEP', 'BLOCK_ON', 'MIN_PROGESS', 'MAX_PROGESS',
  276. 'DISMISSED_CONTENT_KEYSPACE', 'followUpDialogPromise', 'followUpDialogPromiseResolve', 'followUpDialogPromiseReject',
  277. 'hoverJobId', 'JSC$14573_touched',
  278.  
  279.  
  280. // tbc
  281. 'toggleable', 'isConnected',
  282. 'scrollDistance', 'dragging', 'dragMouseStart', 'dragOffsetStart', 'containerWidthDiff',
  283. 'disableDeselectEvent',
  284. 'emojiSize',
  285.  
  286. 'buttonOverride',
  287. 'shouldUseStickyPreferences', 'longPressTimeoutId',
  288.  
  289. // others
  290. 'observeVisibleOption', 'observeHiddenOption', 'observePrescanOption', 'visibilityMonitorKeys',
  291. // 'filledButtonOverrides', 'openPopupConfig', 'supportsInlineActionButtons',
  292. 'observeVisibleOption', 'observeHiddenOption', 'observePrescanOption', 'visibilityMonitorKeys',
  293. // 'dimension', 'loadTime', 'pendingPaint',
  294. // 'disabled', 'allowedProps',
  295.  
  296.  
  297. // 'enableMssLazyLoad', 'popupContainerConfig', 'actionRouterNode', 'actionRouterIsRoot', 'actionMap', 'dynamicActionMap',
  298. // 'actionMap',
  299.  
  300. // 'sharedTooltipPosition', 'sharedTooltipAnimationDelay', 'disableEmojiPickerIncrementalLoading', 'useResolveCommand', 'activeRequest', 'popoutWindowCheckIntervalId', 'supportedTooltipTargets', 'closeActionPanelTimerId', 'delayCloseActionPanelTimerId', 'tooltipTimerIds', 'queuedTooltips', 'isPopupConfigReady', 'popoutWindow', 'actionMap',
  301.  
  302. 'clearTimeout',
  303. 'switchTemplateAtRegistration', 'hasUnmounted',
  304. 'switchTemplateAtRegistration', 'stopKeyboardEventPropagation',
  305. 'tangoConfiguration',
  306. 'itemIdToDockDurationMap',
  307. 'actionMap',
  308.  
  309. 'emojiManager', 'inputMethodEditorActive', 'suggestionIndex', 'JSC$10745_lastSuggestionRange',
  310. 'actionMap', 'asyncHandle', 'shouldAnimateIn', 'lastFrameTimestamp', 'scrollClampRaf',
  311. 'scrollRatePixelsPerSecond', 'scrollStartTime', 'scrollStopHandle'
  312.  
  313. // 'buttonOverrides', 'queuedMessages', 'clearTimeout', 'actionMap',
  314. // 'stopKeyboardEventPropagation', 'emojiSize',
  315. // 'switchTemplateAtRegistration', 'hasUnmounted',
  316. // 'buttonOverrides', 'queuedMessages', 'clearTimeout', 'actionMap',
  317. // 'isReusable', 'tangoConfiguration',
  318. // 'itemIdToDockDurationMap', 'bottomAlignMessages', 'actionMap',
  319. // */
  320.  
  321. ]);
  322.  
  323.  
  324. // const CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE = false; // NO USE; TO BE REVIEWED
  325.  
  326. // ----------------------------- Shortkey Keyboard Control -----------------------------
  327.  
  328. /*
  329. window.addEventListener('edm',()=>{
  330. let p = [...this.onerror.errorTokens][0].token; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  331. });
  332.  
  333. window.addEventListener('edn',()=>{
  334. let p = [...this.onerror.errorTokens][0].token+"X"; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  335. });
  336. window.addEventListener('edr',()=>{
  337. let p = '123'; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  338. });
  339. */
  340.  
  341. // only for macOS with Chrome/Firefox 100+
  342. const advanceLogging = typeof AbortSignal !== 'undefined' && typeof (AbortSignal || 0).timeout === 'function' && typeof navigator !== 'undefined' && /\b(Macintosh|Mac\s*OS)\b/i.test((navigator || 0).userAgent || '');
  343.  
  344. const win = this instanceof Window ? this : window;
  345.  
  346. // Create a unique key for the script and check if it is already running
  347. const hkey_script = 'jswylcojvzts';
  348. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  349. win[hkey_script] = true;
  350.  
  351.  
  352.  
  353. const wk = Symbol();
  354.  
  355. // const [setTimeoutX0, clearTimeoutX0] = [setTimeout, clearTimeout];
  356.  
  357. let BY_PASS_KEYBOARD_CONTROL = false;
  358.  
  359.  
  360. // const setImmediate = ((self || 0).jmt || 0).setImmediate;
  361. /** @type {(f: ()=>{})=>{}} */
  362. const nextBrowserTick_ = nextBrowserTick;
  363. if (typeof nextBrowserTick_ !== "function" || (nextBrowserTick_.version || 0) < 2) {
  364. console.log('nextBrowserTick is not found.');
  365. return;
  366. }
  367.  
  368. let p59 = 0;
  369.  
  370. const Promise = (async () => { })().constructor;
  371.  
  372. const PromiseExternal = ((resolve_, reject_) => {
  373. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  374. return class PromiseExternal extends Promise {
  375. constructor(cb = h) {
  376. super(cb);
  377. if (cb === h) {
  378. /** @type {(value: any) => void} */
  379. this.resolve = resolve_;
  380. /** @type {(reason?: any) => void} */
  381. this.reject = reject_;
  382. }
  383. }
  384. };
  385. })();
  386.  
  387. const FinalizationRegistry_ = typeof FinalizationRegistry !== "undefined" ? FinalizationRegistry : class FinalizationRegistry__ {
  388. constructor(callback = undefined) {
  389.  
  390. }
  391. register(target, heldValue, unregisterToken = undefined) {
  392.  
  393. }
  394. unregister(unregisterToken) {
  395.  
  396. }
  397. }
  398.  
  399. let ttpHTML = (s) => {
  400. ttpHTML = s => s;
  401. if (typeof trustedTypes !== 'undefined' && trustedTypes.defaultPolicy === null) {
  402. let s = s => s;
  403. trustedTypes.createPolicy('default', { createHTML: s, createScriptURL: s, createScript: s });
  404. }
  405. return s;
  406. }
  407.  
  408.  
  409. /** @type { typeof HTMLElement } */
  410. const HTMLElement_ = Reflect.getPrototypeOf(HTMLTitleElement);
  411. const nativeAppendE = HTMLElement_.prototype.append;
  412. const nativeRemoveE = HTMLElement_.prototype.remove;
  413. const DocumentFragment_ = DocumentFragment;
  414. const nativeAppendD = DocumentFragment_.prototype.append;
  415. const Node_ = Node;
  416.  
  417. /**
  418. @param {number} x
  419. @param {number} d */
  420. const toFixed2 = (x, d) => {
  421. let t = x.toFixed(d);
  422. let y = `${+t}`;
  423. return y.length > t.length ? t : y;
  424. }
  425.  
  426.  
  427. const isChatRoomURL = location.pathname.startsWith('/live_chat');
  428.  
  429.  
  430. const TRANSLATE_DEBUG = false;
  431.  
  432.  
  433. let xdeadc00 = null; // a deteched node with __domApi
  434. let xlivec00 = null; // a deteched node with __domApi
  435.  
  436. let removeTNodeRM = null;
  437. let removeTNodeBP = false;
  438.  
  439.  
  440. if (Node.isConnectedOverrided === undefined) {
  441. const pdConnected = Object.getOwnPropertyDescriptor(Node.prototype, 'isConnected');
  442. if (pdConnected && pdConnected.get && pdConnected.configurable) {
  443. Node.isConnectedOverrided = null;
  444. const get_ = pdConnected.get;
  445. const get = function () {
  446. const overrided = Node.isConnectedOverrided;
  447. if (typeof overrided === 'boolean') return overrided;
  448. return get_.call(this);
  449. }
  450. Object.defineProperty(Node.prototype, 'isConnected', {
  451. ...pdConnected,
  452. get
  453. });
  454. }
  455. }
  456.  
  457. const _nmSet = new Set();
  458. _nmSet.add = _nmSet.addOriginal || _nmSet.add;
  459. const _nmMap = new Set();
  460. _nmMap.add = _nmMap.addOriginal || _nmMap.add;
  461. const _nmMapV = new Set();
  462. _nmMapV.add = _nmMapV.addOriginal || _nmMapV.add;
  463. if (MEMORY_RELEASE_MAP_SET_REMOVE_NODE && !Set.prototype.addOriginal && !Map.prototype.setOriginal) {
  464. const Node_ = Node;
  465. Set.prototype.addOriginal = Set.prototype.add;
  466. Set.prototype.add = function (n) {
  467. if (n instanceof Node_) {
  468. if (!this[wk]) this[wk] = mWeakRef(this);
  469. _nmSet.add(this[wk]);
  470. }
  471. return this.addOriginal(n);
  472. };
  473. Map.prototype.setOriginal = Map.prototype.set;
  474. Map.prototype.set = function (n, v) {
  475. if (n instanceof Node_) {
  476. if (!this[wk]) this[wk] = mWeakRef(this);
  477. _nmMap.add(this[wk]);
  478. }
  479. if (v instanceof Node_) {
  480. if (!this[wk]) this[wk] = mWeakRef(this);
  481. _nmMapV.add(this[wk]);
  482. }
  483. return this.setOriginal(n, v);
  484. };
  485. }
  486.  
  487. window.showNM00 = () => {
  488. const nmSet = [..._nmSet].map(e => kRef(e)).filter(e => !!e);
  489. const nmMap = [..._nmMap].map(e => kRef(e)).filter(e => !!e);
  490. const nmMapV = [..._nmMapV].map(e => kRef(e)).filter(e => !!e);
  491. return { nmSet, nmMap, nmMapV };
  492. };
  493.  
  494. window.testNM00 = (x) => {
  495. const nmSet = [..._nmSet].map(e => kRef(e)).filter(e => !!e);
  496. const nmMap = [..._nmMap].map(e => kRef(e)).filter(e => !!e);
  497. const nmMapV = [..._nmMapV].map(e => kRef(e)).filter(e => !!e);
  498. for (const s of nmSet) if (s.has(x)) return 1;
  499. for (const m of nmMap) if (m.has(x)) return 2;
  500. for (const m of nmMapV) {
  501. for (const [u, v] of m.entries()) {
  502. if (v === x) return 4;
  503. }
  504. }
  505. return 0;
  506. };
  507.  
  508. let FORCE_NO_REUSEABLE_ELEMENT_POOL_fired = false;
  509.  
  510. const FORCE_NO_REUSEABLE_ELEMENT_POOL_fn = (mainCnt) => {
  511.  
  512. if (FORCE_NO_REUSEABLE_ELEMENT_POOL_fired) return;
  513.  
  514. FORCE_NO_REUSEABLE_ELEMENT_POOL_fired = true;
  515.  
  516. if (typeof mainCnt.createComponent_ !== 'function' || mainCnt.createComponent_.length != 3) {
  517. console.warn('FORCE_NO_REUSEABLE_ELEMENT_POOL_fn failed.')
  518. return;
  519. }
  520.  
  521. const mapGet = Map.prototype.get;
  522. const setHas = Set.prototype.has;
  523.  
  524. /** @type {Map | null} */
  525. let qcMap = null;
  526.  
  527. Set.prototype.has = function (a) {
  528. if (a === 'dummy-4718') return false; // false to allow re-use?
  529. return setHas.call(this, a);
  530. }
  531.  
  532. Map.prototype.get = function (a) {
  533. if (a === 'dummy-4718') qcMap = this;
  534. return mapGet.call(this, a);
  535. };
  536. let r;
  537. try {
  538. r = mainCnt.createComponent_('dummy-4718', {}, true);
  539. } catch (e) {
  540.  
  541. }
  542.  
  543. Map.prototype.get = mapGet;
  544. Set.prototype.has = setHas;
  545.  
  546. if (r && (r.nodeName || '').toLowerCase() === 'dummy-4718') {
  547.  
  548.  
  549. // clearInterval(ckId);
  550. // ckId = 0;
  551.  
  552. if (qcMap !== null && qcMap instanceof Map) {
  553.  
  554. console.log('[yt-js-engine-tamer] qcMap', qcMap);
  555. qcMap.__qcMap8781__ = true;
  556.  
  557. const setArrayC = (c) => {
  558. if (c instanceof Array) {
  559. c.length = 0;
  560. c.push = function () { };
  561. c.pop = function () { };
  562. c.shift = function () { };
  563. c.unshift = function () { };
  564. c.splice = function () { };
  565. c.sort = function () { };
  566. c.reverse = function () { };
  567. }
  568. }
  569.  
  570. const cleaning = function (m) {
  571. m.forEach(setArrayC);
  572. m.clear();
  573. }
  574.  
  575. qcMap.set = function (b, c) {
  576. if (!this.__qcMap8781__) return Map.prototype.set.call(this, b, c);
  577.  
  578. setArrayC(c);
  579.  
  580. // console.log('qcMap.set', b, c);
  581.  
  582. if (this.size > 0) {
  583. // play safe
  584.  
  585. console.log('[yt-js-engine-tamer] qcMap', 'clear 01')
  586. cleaning(this);
  587. }
  588.  
  589. }
  590. qcMap.get = function (b) {
  591. if (!this.__qcMap8781__) return Map.prototype.get.call(this, b);
  592.  
  593. // console.log('qcMap.get', b);
  594.  
  595. if (this.size > 0) {
  596. // play safe
  597.  
  598. console.log('[yt-js-engine-tamer] qcMap', 'clear 02')
  599. cleaning(this);
  600. }
  601.  
  602. }
  603.  
  604.  
  605. if (qcMap.size > 0) {
  606.  
  607. console.log('[yt-js-engine-tamer] qcMap', 'clear 03')
  608. cleaning(qcMap);
  609. }
  610.  
  611. }
  612.  
  613. }
  614.  
  615. r = null;
  616. qcMap = null;
  617.  
  618. }
  619.  
  620.  
  621. const dispatchYtEvent = function (a, b, c, d) {
  622. d || (d = {
  623. bubbles: !0,
  624. cancelable: !1,
  625. composed: !0
  626. });
  627. c !== null && c !== void 0 && (d.detail = c);
  628. b = new CustomEvent(b, d);
  629. a.dispatchEvent(b);
  630. return b
  631. };
  632.  
  633. if (DISABLE_isLowLatencyLiveStream) {
  634. const sm = Symbol();
  635. const f = () => {
  636. try {
  637. const videoDetails = ytInitialPlayerResponse.videoDetails;
  638. if (videoDetails && videoDetails.isLowLatencyLiveStream) {
  639. videoDetails.isLowLatencyLiveStream = false;
  640. }
  641. if (videoDetails && videoDetails.latencyClass === 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_LOW') {
  642. videoDetails.latencyClass = 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_NORMAL';
  643. }
  644. if (videoDetails && videoDetails.latencyClass === 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_ULTRA_LOW') {
  645. videoDetails.latencyClass = 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_NORMAL';
  646. }
  647. } catch (e) { }
  648. }
  649. Object.defineProperty(Object.prototype, 'isLowLatencyLiveStream', {
  650. get() {
  651. const v = this[sm];
  652. if (typeof v === 'undefined') return v;
  653. f();
  654. return v;
  655. },
  656. set(nv) {
  657. f();
  658. if (nv === true) nv = false;
  659. this[sm] = nv;
  660. },
  661. enumerable: false,
  662. configurable: true
  663. });
  664.  
  665. const sm3 = Symbol();
  666. Object.defineProperty(Object.prototype, 'latencyClass', {
  667. get() {
  668. const v = this[sm3];
  669. if (typeof v === 'undefined') return v;
  670. f();
  671. return v;
  672. },
  673. set(nv) {
  674. f();
  675. if (nv === 'ULTRALOW' || nv === 'LOW') {
  676. nv = 'NORMAL';
  677. } else if (nv === 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_LOW' || nv === 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_ULTRA_LOW') {
  678. nv = 'MDE_STREAM_OPTIMIZATIONS_RENDERER_LATENCY_NORMAL';
  679. }
  680. this[sm3] = nv;
  681. },
  682. enumerable: false,
  683. configurable: true
  684. });
  685.  
  686. }
  687.  
  688. class PlainHTMLElement extends HTMLTitleElement {
  689.  
  690. }
  691.  
  692. const removeShady = function (shady) {
  693. if (!shady || typeof shady !== 'object') return;
  694. const props = [...Object.getOwnPropertyNames(shady), ...Object.getOwnPropertySymbols(shady)];
  695. for (const prop of props) {
  696. const node = shady[prop];
  697. if (typeof (node || 0) !== 'object') continue;
  698. if (node.nodeType >= 1 && node.isConnected === false) _removedElements.addNode(node);
  699. }
  700. }
  701.  
  702. const _removedElements = new Set();
  703. _removedElements.add = _removedElements.addOriginal || _removedElements.add;
  704. _removedElements.addNode = MEMORY_RELEASE_NF00 ? function (node) {
  705. if (!node || node === _emptyElement || node.__keepInstance038__ || node.t792 || node instanceof HTMLTitleElement) return;
  706. const rootNode = node.getRootNode();
  707. if (rootNode && rootNode.nodeType >= 1 && rootNode !== node) {
  708. if (rootNode.isConnected !== node.isConnected) return;
  709. this.addNode(rootNode);
  710. }
  711. if (!node[wk]) node[wk] = mWeakRef(node);
  712. return this.add(node[wk]);
  713. } : () => { };
  714.  
  715. const _emptyElement = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  716. const _emptyTipsElement = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  717. const _emptyVisibilityElement = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  718.  
  719. const nf00 = new FinalizationRegistry_((x) => {
  720. if (MEMORY_RELEASE_NF00_SHOW_MESSAGE) console.log(`NF00: node[${x}] fully removed`);
  721. });
  722. let ud00 = 0;
  723. const ng00 = new Set();
  724. nf00.registerNode = function (node) {
  725. if (node && node.nodeType >= 1) {
  726. if (!node.t792) {
  727. node.t792 = (ud00 = (ud00 & 1073741823) + 1);
  728. const x = `${node.nodeName.toLowerCase()}#${node.t792}`;
  729. this.register(node, x);
  730. if (MEMORY_RELEASE_NF00_SHOW_MESSAGE) console.log(`NF00: try remove node[${x}]`);
  731. ng00.add(mWeakRef(node));
  732. }
  733. }
  734. }
  735. window.showNg00 = () => {
  736. const ng01 = new Set();
  737. ng01.add = ng01.addOriginal || ng01.add;
  738. for (const e of ng00) {
  739. const f = kRef(e);
  740. if (!f) continue;
  741. ng01.add(f);
  742. }
  743. const ng02 = [...ng01];
  744. ng01.clear();
  745. console.log(ng02);
  746. window.showNg01 = [...ng02];
  747. }
  748. window.showTemplates00 = () => {
  749. const result = {};
  750. const elements = document.querySelectorAll('*');
  751. for (const element of elements) {
  752. const tag = element.nodeName.toLocaleLowerCase();
  753. const r = result[tag] || [];
  754. const cnt = insp(element);
  755. if (cnt !== element) {
  756. if (cnt.templateInfo) {
  757. r.push(['cnt0', cnt.templateInfo, element]);
  758. }
  759. if (element._templateInfo) {
  760. r.push(['cnt1', cnt._templateInfo, element]);
  761. }
  762. if (element.__templateInfo) {
  763. r.push(['cnt2', cnt.__templateInfo, element]);
  764. }
  765. }
  766. if (element.templateInfo) {
  767. r.push(['elm0', element.templateInfo, element]);
  768. }
  769. if (element._templateInfo) {
  770. r.push(['elm1', element._templateInfo, element]);
  771. }
  772. if (element.__templateInfo) {
  773. r.push(['elm2', element.__templateInfo, element]);
  774. }
  775. if (r.length >= 1) result[tag] = r;
  776. }
  777. const strCmp = (a, b) => {
  778. if (a === b) return 0;
  779. let u = [a, b].sort();
  780. return u[0] === a ? -1 : 1;
  781. }
  782. const counting1 = Object.entries(result).map(e => [e[0], [...new Set(e[1].map(t => t[0]))].join('|')]).sort((a, b) => {
  783. return strCmp(`${a[1]}.${a[0]}`, `${b[1]}.${b[0]}`);
  784. });
  785.  
  786. const counting2 = Object.entries(result).map(e => [e[0], [...new Set(e[1].map(t => t[1]))]]);
  787.  
  788. const counting3 = Object.entries(result).map(e => {
  789. const a = [...new Set(e[1].map(t => t[1]))];
  790. const b = [...new Set(a.map(e => e.nodeList || e))];
  791.  
  792. const r = [e[0], b];
  793. return r;
  794. });
  795.  
  796. return {result, counting1, counting2, counting3};
  797. };
  798.  
  799. window.showFrag00 = function(){
  800.  
  801. const result = {};
  802. const elements = document.querySelectorAll('*');
  803. for (const element of elements) {
  804. const tag = element.nodeName.toLocaleLowerCase();
  805. const r = result[tag] || [];
  806. const cnt = insp(element);
  807. if (cnt !== element) {
  808. if (cnt.templateInfo) {
  809. r.push(['cnt0', cnt.templateInfo, element]);
  810. }
  811. if (element._templateInfo) {
  812. r.push(['cnt1', cnt._templateInfo, element]);
  813. }
  814. if (element.__templateInfo) {
  815. r.push(['cnt2', cnt.__templateInfo, element]);
  816. }
  817. }
  818. if (element.templateInfo) {
  819. r.push(['elm0', element.templateInfo, element]);
  820. }
  821. if (element._templateInfo) {
  822. r.push(['elm1', element._templateInfo, element]);
  823. }
  824. if (element.__templateInfo) {
  825. r.push(['elm2', element.__templateInfo, element]);
  826. }
  827. if (r.length >= 1) result[tag] = r;
  828. }
  829. return result;
  830.  
  831. }
  832.  
  833. if (MEMORY_RELEASE_NF00) {
  834.  
  835. const __removedElements = new Set();
  836. __removedElements.add = __removedElements.addOriginal || __removedElements.add;
  837.  
  838. setInterval(() => {
  839. const nodesSet = new Set();
  840. nodesSet.add = nodesSet.addOriginal || nodesSet.add;
  841.  
  842. for (const nodeWr of __removedElements) {
  843. __removedElements.delete(nodeWr);
  844. const node = kRef(nodeWr);
  845. if (node && node.nodeType >= 1 && node.isConnected === false) {
  846. nodesSet.add(node);
  847. if (node.querySelectorAll) {
  848. for (const p of node.querySelectorAll('*')) {
  849. nodesSet.add(p);
  850. }
  851. }
  852. }
  853. }
  854. for (const nodeWr of _removedElements) {
  855. _removedElements.delete(nodeWr);
  856. const node = kRef(nodeWr);
  857. if (node && node.isConnected === false) {
  858. __removedElements.add(nodeWr);
  859. }
  860. }
  861.  
  862. if(nodesSet.size === 0) return;
  863.  
  864. const nmSet = [..._nmSet].map(e => kRef(e)).filter(e => !!e);
  865. const nmMap = [..._nmMap].map(e => kRef(e)).filter(e => !!e);
  866. const nmMapV = [..._nmMapV].map(e => kRef(e)).filter(e => !!e);
  867.  
  868. for (const node of nodesSet) {
  869. if (node === _emptyElement || node.__keepInstance038__ || node.t792) continue;
  870. const hasToolTips = !!((insp(node).$ || 0).tooltip);
  871.  
  872. if (node && node.__shady_getRootNode) {
  873. const k = node.__shady_getRootNode();
  874. if (k && k.__keepInstance038__) k.__keepInstance038__ = false;
  875. if (k && k.nodeType >= 1 && k.isConnected === false) _removedElements.addNode(k);
  876. }
  877. if (node && node.getRootNode) {
  878. const k = node.getRootNode();
  879. if (k && k.__keepInstance038__) k.__keepInstance038__ = false;
  880. if (k && k.nodeType >= 1 && k.isConnected === false) _removedElements.addNode(k);
  881. }
  882.  
  883. if (node.__instances) {
  884. for (const k of node.__instances) {
  885. if (k && k.__keepInstance038__) k.__keepInstance038__ = false;
  886. if (k && k.nodeType >= 1 && k.isConnected === false) _removedElements.addNode(k);
  887. }
  888. // node.__instances.length = 0;
  889. }
  890. if (node && node.nodeType === 1) {
  891. if (typeof insp(node).__teardownInstance === 'function') {
  892. try {
  893. insp(node).__teardownInstance();
  894. } catch (e) { }
  895. } else if (typeof node.__teardownInstance === 'function') {
  896. try {
  897. node.__teardownInstance();
  898. } catch (e) { }
  899. }
  900. }
  901. if (node && node.nodeType === 1 && node.__detachAndRemoveInstance && (node.__instances || 0).length >= 1) {
  902. for (let i = node.__instances.length - 1; i >= 0; i--) {
  903. node.__detachAndRemoveInstance(i)
  904. }
  905. }
  906.  
  907. if (node && node.nodeType === 1 && node.is === void 0) {
  908. if (typeof insp(node).dispose === 'function') {
  909. insp(node).dispose();
  910. } else if (typeof node.dispose === 'function') {
  911. node.dispose();
  912. }
  913. }
  914.  
  915. if (node && node.nodeType === 1) {
  916. if (typeof insp(node).unobserve_ === 'function') {
  917. insp(node).unobserve_();
  918. } else if (typeof node.unobserve_ === 'function') {
  919. node.unobserve_();
  920. }
  921. }
  922.  
  923. if (node) {
  924. if (typeof insp(node).unobserveNodes === 'function') {
  925. insp(node).unobserveNodes();
  926. } else if (typeof node.unobserveNodes === 'function') {
  927. node.unobserveNodes();
  928. }
  929. }
  930.  
  931. // if (node && node.nodeType === 1) {
  932. // const cnt = insp(node);
  933. // const paths = cnt.__dataLinkedPaths;
  934. // if (paths && paths.length >= 1 && typeof cnt.unlinkPaths === 'function') {
  935. // for (let k in paths) {
  936. // cnt.unlinkPaths(k);
  937. // }
  938. // }
  939. // }
  940.  
  941. const visibilityMonitorKeys = insp(node).visibilityMonitorKeys || node.visibilityMonitorKeys;
  942. if (visibilityMonitorKeys) {
  943. for (const entry of visibilityMonitorKeys) {
  944. if (entry.element) { entry.element = null }
  945. }
  946. visibilityMonitorKeys.length = 0;
  947. }
  948. const __instances = node.__instances;
  949. if (__instances) {
  950. for (const k of __instances) {
  951. if (k && k.__keepInstance038__) k.__keepInstance038__ = false;
  952. if (k && k.nodeType >= 1 && k.isConnected === false) _removedElements.addNode(k);
  953. }
  954. __instances.length = 0;
  955. }
  956. const sp = node.__shady_parentNode;
  957. if (sp && sp.nodeType >= 1 && sp.isConnected === false) _removedElements.addNode(sp);
  958. FULLY_REMOVE_ALL_EVENT_LISTENERS && node.removeAllEventListener001();
  959. if (node && node.remove) node.remove();
  960.  
  961. /*
  962. if (node._templateInfo && node._templateInfo.content) {
  963. const templateInfoContent = node._templateInfo.content;
  964. if (templateInfoContent.nodeType >= 1 && templateInfoContent.isConnected === false) {
  965. _removedElements.addNode(templateInfoContent);
  966. }
  967. try{
  968. node._templateInfo.content = null;
  969. }catch(e){}
  970. }
  971. */
  972. if (node.__domApi) {
  973. node.__domApi = null;
  974. }
  975. const __shady = node.__shady;
  976. if (__shady) {
  977. node.__shady = null;
  978. removeShady(__shady);
  979. }
  980.  
  981.  
  982. const ceRoot = node.__CE_shadowRoot;
  983. if (ceRoot) {
  984. node.__CE_shadowRoot = null;
  985. if (ceRoot.nodeType >= 1 && ceRoot.isConnected === false) {
  986. _removedElements.addNode(ceRoot);
  987. }
  988.  
  989. }
  990.  
  991. // xTeardownTemplateInfo
  992. const snChildNodes = node.__shady_native_childNodes;
  993. if (snChildNodes.length > 0) {
  994. for (const node of snChildNodes) {
  995. if (node && node.nodeType >= 1 && node.isConnected === false) {
  996. _removedElements.addNode(node);
  997. }
  998. }
  999. snChildNodes.length = 0;
  1000. }
  1001. node.__shady_native_childNodes = null;
  1002.  
  1003.  
  1004. const __templateInfo = node.__templateInfo;
  1005. if (__templateInfo) {
  1006. node.__templateInfo = null;
  1007. // xTeardownTemplateInfo(__templateInfo);
  1008. }
  1009.  
  1010. if (hasToolTips && insp(node).$) {
  1011. insp(node).$.tooltip = _emptyTipsElement;
  1012. }
  1013.  
  1014. if (node && node.nodeType >= 1) {
  1015. const pd = Object.getOwnPropertyDescriptor(node, 'visibilityMonitorKeys');
  1016. if (pd && pd.value && pd.value.length >= 1) {
  1017. const arr = pd.value;
  1018. for (let i = 0; i < arr.length; i++) {
  1019. arr[i].element = _emptyVisibilityElement;
  1020. arr[i] = null;
  1021. }
  1022. }
  1023. }
  1024.  
  1025. if (node.__dataHost) {
  1026. try {
  1027. delete node.__dataHost
  1028. } catch (e) { }
  1029. try {
  1030. node.__dataHost = null;
  1031. } catch (e) { }
  1032. }
  1033.  
  1034. if (node.root) {
  1035. try {
  1036. delete node.root
  1037. } catch (e) { }
  1038. try {
  1039. node.root = null;
  1040. } catch (e) { }
  1041. }
  1042.  
  1043. if (node.children && node.children.splice) {
  1044. try {
  1045. delete node.children
  1046. } catch (e) { }
  1047. try {
  1048. node.children = null;
  1049. } catch (e) { }
  1050. }
  1051.  
  1052. if (node.__shady && typeof node.__shady === 'object') {
  1053. try {
  1054. node.__shady = null;
  1055. } catch (e) { }
  1056. }
  1057.  
  1058. if (node.nodeType === 1) Reflect.setPrototypeOf(node, PlainHTMLElement.prototype);
  1059.  
  1060. for (const prop of Object.getOwnPropertyNames(node)) {
  1061. if (prop === 'host' && typeof (node.host || 0) === 'object') {
  1062. if (node.nodeType === 11) {
  1063. const nodeHost = node.host;
  1064. if (nodeHost && nodeHost.nodeType >= 1) {
  1065. node.host = _emptyElement;
  1066. if (nodeHost.isConnected === false && nodeHost !== _emptyElement) {
  1067. _removedElements.addNode(nodeHost);
  1068. }
  1069. } else {
  1070. node.host = null;
  1071. }
  1072. } else {
  1073. node.host = null;
  1074. }
  1075. continue;
  1076. }
  1077. const pd = Object.getOwnPropertyDescriptor(node, prop);
  1078. if (pd.value) {
  1079. const v = pd.value;
  1080. if (typeof (v || 0) === 'object') node[prop] = null;
  1081. else if (typeof (v || 0) === 'function') delete node[prop];
  1082. }
  1083. }
  1084.  
  1085. for (const prop of Object.getOwnPropertySymbols(node)) {
  1086. const v = node[prop];
  1087. if (typeof (v || 0) === 'object' && !v.deref) node[prop] = null;
  1088. }
  1089.  
  1090. if (node.__shady_native_childNodes) {
  1091. node.__shady_native_childNodes = _emptyElement.childNodes;
  1092. }
  1093. if (node.__shady_children) {
  1094. node.__shady_children = _emptyElement.children;
  1095. }
  1096.  
  1097. for (const s of nmSet) s.delete(node);
  1098. for (const m of nmMap) m.delete(node);
  1099.  
  1100. mightTeardownShadyDomWrap(node);
  1101.  
  1102. nf00.registerNode(node);
  1103.  
  1104.  
  1105.  
  1106. // console.log(1883001, node)
  1107. // console.log(3772001, node, node.countEvent767())
  1108. }
  1109.  
  1110. nodesSet.clear();
  1111.  
  1112. }, 400);
  1113.  
  1114. }
  1115.  
  1116.  
  1117. if (FULLY_REMOVE_ALL_EVENT_LISTENERS && !EventTarget.prototype.addEventListener828 && !EventTarget.prototype.removeAllEventListener001) {
  1118. const handlerMap = new WeakMap();
  1119. EventTarget.prototype.addEventListener828 = EventTarget.prototype.addEventListener;
  1120. EventTarget.prototype.addEventListener = function (type, handler, option = void 0) {
  1121. let hds = handlerMap.get(this);
  1122. if (!hds) handlerMap.set(this, (hds = new Set()));
  1123. hds.add([type, handler, option]);
  1124. return this.addEventListener828(type, handler, option);
  1125. }
  1126. EventTarget.prototype.removeEventListener828 = EventTarget.prototype.removeEventListener;
  1127. EventTarget.prototype.removeEventListener = function (type, handler, option = void 0) {
  1128. let hds = handlerMap.get(this);
  1129. if (hds) {
  1130. for (const entry of hds) {
  1131. if (entry[0] === type && entry[1] === handler && entry[2] === option) {
  1132. hds.delete(entry);
  1133. break;
  1134. }
  1135. }
  1136. }
  1137. return this.removeEventListener828(type, handler, option);
  1138. }
  1139. EventTarget.prototype.countEvent767 = function(){
  1140. return handlerMap.get(this);
  1141. }
  1142. EventTarget.prototype.removeAllEventListener001 = function(){
  1143. let hds = handlerMap.get(this);
  1144. if (hds) {
  1145. handlerMap.delete(this);
  1146. for (const [type, handler, option] of hds) {
  1147. this.removeEventListener828(type, handler, option);
  1148. }
  1149. hds.clear();
  1150. }
  1151. }
  1152. }
  1153.  
  1154. const globalSetup = (key, setup)=>{
  1155. let symb = Symbol();
  1156. Object.defineProperty(Object.prototype, key, {
  1157. get() {
  1158. return this[symb];
  1159. },
  1160. set(nv) {
  1161. if (typeof nv !== 'function') {
  1162. this[symb] = nv;
  1163. return true;
  1164. }
  1165. if (!(symb in this)) {
  1166. setup(this);
  1167. }
  1168. this[symb] = nv;
  1169. return true;
  1170. },
  1171. configurable: true,
  1172. enumerable: false
  1173. });
  1174. }
  1175.  
  1176. const toActualNode = (e) => {
  1177. return e && e.getNode592177 ? e.getNode592177() : e;
  1178. }
  1179.  
  1180. const removeAllChildNodes = (o)=>{
  1181. if ((o instanceof Node) && o.nodeType >= 1) {
  1182. let t, q = null;
  1183. while ((t = o.firstChild) && t !== q) {
  1184. try {
  1185. _removedElements.addNode(t);
  1186. t.__keepInstance038__ = false;
  1187. t.remove();
  1188. q = t;
  1189. } catch (e) { }
  1190. }
  1191. try {
  1192. _removedElements.addNode(o);
  1193. o.__keepInstance038__ = false;
  1194. o.remove();
  1195. } catch (e) { }
  1196. }
  1197. }
  1198.  
  1199. const stampedNodes = new Map(); /* !!!!!! CAUTION FOR MEMORY LEAKAGE !!!!!!! */
  1200. stampedNodes.set = stampedNodes.setOriginal || stampedNodes.set;
  1201. const stampedFragment = new Map(); /* !!!!!! CAUTION FOR MEMORY LEAKAGE !!!!!!! */
  1202. stampedFragment.set = stampedFragment.setOriginal || stampedFragment.set;
  1203.  
  1204. if (FIX_TEMPLATE_BINDING) {
  1205. const templateMap = new Map(); /* !!!!!! CAUTION FOR MEMORY LEAKAGE !!!!!!! */
  1206. templateMap.set = templateMap.setOriginal || templateMap.set;
  1207. // const parsedTemplate = new Map();
  1208.  
  1209.  
  1210. const it0 = Date.now() - 80000000000;
  1211. const genId = () => `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${(Date.now() - it0).toString(36)}`;
  1212.  
  1213.  
  1214. /*
  1215.  
  1216. M.prototype._bindTemplate = function(N, R) {
  1217. var X = this.constructor._parseTemplate(N)
  1218. , A = this.__preBoundTemplateInfo == X;
  1219. if (!A)
  1220. for (var l in X.propertyEffects)
  1221. this._createPropertyAccessor(l);
  1222. R ? (X = Object.create(X),
  1223. X.wasPreBound = A,
  1224. this.__templateInfo ? (N = N._parentTemplateInfo || this.__templateInfo,
  1225. R = N.lastChild,
  1226. X.parent = N,
  1227. N.lastChild = X,
  1228. (X.previousSibling = R) ? R.nextSibling = X : N.firstChild = X) : this.__templateInfo = X) : this.__preBoundTemplateInfo = X;
  1229. return X
  1230. }
  1231. ;
  1232. */
  1233.  
  1234. /*
  1235. ** this.constructor._parseTemplate **
  1236. d._parseTemplate = function(N, R) {
  1237. if (!N._templateInfo) {
  1238. var X = N._templateInfo = {};
  1239. X.nodeInfoList = [];
  1240. X.nestedTemplate = !!R;
  1241. X.stripWhiteSpace = R && R.stripWhiteSpace || N.hasAttribute && N.hasAttribute("strip-whitespace");
  1242. this._parseTemplateContent(N, X, {
  1243. parent: null
  1244. })
  1245. }
  1246. return N._templateInfo
  1247. }
  1248.  
  1249. */
  1250.  
  1251. // let initied1 = false;
  1252. // let _parseTemplateByPass = false;
  1253. const setup1 = (qxx) => {
  1254. // if(initied1) return;
  1255. // initied1 = true;
  1256. const proto = qxx;
  1257. const constructor = proto.constructor;
  1258. const _bindTemplate = proto._bindTemplate;
  1259. // console.log(12883, proto, constructor)
  1260.  
  1261.  
  1262. const _parseTemplate = constructor._parseTemplate;
  1263. if (typeof _parseTemplate === 'function' && _parseTemplate.length === 2 && !constructor._parseTemplate322) {
  1264.  
  1265. FIX_TEMPLATE_BINDING_SHOW_MESSAGE && console.log('Hack00: _parseTemplate', _parseTemplate);
  1266. constructor._parseTemplate322 = _parseTemplate;
  1267. const parsedResults = new WeakMap();
  1268.  
  1269. const _templateInfoPd = {
  1270. get() {
  1271. if (!this || !this[wk]) return undefined;
  1272. const r = parsedResults.get(this[wk]);
  1273. return r;
  1274. },
  1275. set(nv) {
  1276. delete this._templateInfo;
  1277. this._templateInfo = nv;
  1278. console.warn('_templateInfoPd set');
  1279. return true;
  1280. },
  1281. enumerable: true,
  1282. configurable: true
  1283. };
  1284. constructor._parseTemplate = function (N, R) {
  1285. if (!N) return _parseTemplate.call(this, N, R);
  1286. if (!N[wk]) N[wk] = mWeakRef(N);
  1287. let r = parsedResults.get(N[wk]);
  1288. if (r) return r;
  1289. r = _parseTemplate.call(this, N, R);
  1290. if (r && !parsedResults.has(N[wk])) {
  1291. parsedResults.set(N[wk], r);
  1292. r.iAm68 = '_templateInfo';
  1293. N.iHave68 = '_templateInfo';
  1294. if (N._templateInfo && N._templateInfo === r) {
  1295. delete N._templateInfo;
  1296. if (!N._templateInfo) {
  1297. Object.defineProperty(N, '_templateInfo', _templateInfoPd);
  1298. }
  1299. }
  1300. }
  1301. return r;
  1302. }
  1303. }
  1304. if (typeof _bindTemplate === 'function' && _bindTemplate.length === 2 && !proto._bindTemplate322) {
  1305.  
  1306. FIX_TEMPLATE_BINDING_SHOW_MESSAGE && console.log('Hack00: _bindTemplate', _bindTemplate);
  1307. proto._bindTemplate322 = _bindTemplate;
  1308. proto._bindTemplate = function (N, R) {
  1309. // R = boolean true or undefined
  1310. // N = template elemenet
  1311. let M = N;
  1312. if (typeof (N || 0) === 'object' && N instanceof HTMLTemplateElement && (N.content || 0).nodeType === 11) {
  1313. let componentIs = '';
  1314. try {
  1315. componentIs = this ? this.is : '';
  1316. } catch (e) { }
  1317. if (typeof (componentIs || 0) === 'string') {
  1318. if (!templateMap.has(componentIs)) {
  1319. templateMap.set(componentIs, N);
  1320. // const parser = this.constructor;
  1321. // console.log(3882, parser._parseTemplate)
  1322. /*
  1323. if (parser._parseTemplate && !parser._parseTemplate477 && parser._parseTemplate.length === 2) {
  1324. parser._parseTemplate477 = parser._parseTemplate;
  1325. const _parseTemplate477 = parser._parseTemplate477;
  1326. parser._parseTemplate = function (N, R) {
  1327. if (!_parseTemplateByPass && N && N[wk]) {
  1328. const u = parsedTemplate.get(N[wk]);
  1329. if (u) {
  1330. console.log(1838, u)
  1331. return u;
  1332. }
  1333. }
  1334. return _parseTemplate477.call(this, N, R);
  1335. };
  1336. }
  1337. if (parser._parseTemplate && parser._parseTemplate477) {
  1338. if (N && !N[wk]) N[wk] = mWeakRef(N);
  1339. if (!parsedTemplate.has(N[wk])) {
  1340. _parseTemplateByPass = true;
  1341. parsedTemplate.set(N[wk], parser._parseTemplate477(N));
  1342. _parseTemplateByPass = false;
  1343. }
  1344. }
  1345. */
  1346. } else {
  1347. M = templateMap.get(componentIs);
  1348. }
  1349. }
  1350. }
  1351. let r_ = null;
  1352. // Promise.resolve(N).then((N) => {
  1353. // console.log(3488,N.templateInfo, N.templateInfo === r_);
  1354. // })
  1355. const r = _bindTemplate.call(this, M, R);
  1356. r_ = r;
  1357. return r;
  1358. }
  1359. }
  1360.  
  1361. const _runEffectsForTemplate = proto._runEffectsForTemplate;
  1362. const gxx = (window.gxxC572 || (window.gxxC572 = new Set()));
  1363. if (typeof _runEffectsForTemplate === 'function' && _runEffectsForTemplate.length === 4 && !proto._runEffectsForTemplate322) {
  1364. proto._runEffectsForTemplate322 = _runEffectsForTemplate;
  1365.  
  1366. // note: fastDomIf does not work well with runEffects ...
  1367. // so no runEffects actaully?
  1368. const runner = (Tw, Nw, Rw, Xw, Aw) => {
  1369.  
  1370. try {
  1371.  
  1372.  
  1373. // console.log(988003)
  1374. const T = kRef(Tw); // this
  1375. const N = kRef(Nw); // __templateInfo
  1376. if (!T || !N) return;
  1377.  
  1378. // console.log(988004)
  1379. const R = kRef(Rw); // __data
  1380. const X = kRef(Xw); // temp Data ?
  1381. const A = kRef(Aw); // boolean ?
  1382. if (typeof (X || 0) === 'object') gxx.delete(X);
  1383. if (typeof (A || 0) === 'object') gxx.delete(A);
  1384.  
  1385. // console.log(988005)
  1386. const nodeList_ = N.nodeList;
  1387.  
  1388. // console.log(988006, nodeList_)
  1389. const nodeList = nodeList_ ? nodeList_.map(e => toActualNode(e)) : nodeList_;
  1390.  
  1391. // console.log(988007, nodeList)
  1392.  
  1393. const Nx = {
  1394. propertyEffects: N.propertyEffects,
  1395. nodeList: nodeList,
  1396. firstChild: kRef(N.firstChild)
  1397. };
  1398.  
  1399. // if (kRef(N.firstChild)) {
  1400. // console.log(977001, Nx)
  1401. // }
  1402.  
  1403. // console.log(988009, Nx, R, X, A)
  1404.  
  1405.  
  1406. {
  1407.  
  1408.  
  1409. const o = Nx;
  1410. const { propertyEffects, nodeList, firstChild } = o;
  1411. if (propertyEffects && nodeList && nodeList.length >= 0) {
  1412. for (const [effectKey, propertyEffectArr] of Object.entries(propertyEffects)) {
  1413. for (let i = propertyEffectArr.length - 1; i >= 0; i--) {
  1414. const propertyEffect = propertyEffectArr[i];
  1415. const info = (propertyEffect || 0).info;
  1416. if (info && typeof info.index === 'number' && !nodeList[info.index]) {
  1417. propertyEffectArr.splice(i, 1);
  1418. }
  1419. }
  1420. }
  1421. }
  1422.  
  1423. }
  1424.  
  1425.  
  1426. // console.log({T, Nx, R, X , A })
  1427.  
  1428. // console.log(1737001, T)
  1429. // console.log(1737002, Nx)
  1430.  
  1431. // console.log(1737003, R)
  1432. // console.log(1737004, X)
  1433. // console.log(1737005, A)
  1434.  
  1435. const hostElement = T.hostElement;
  1436. const pChildren = (hostElement instanceof Node) ? [...hostElement.childNodes] : null;
  1437.  
  1438. _runEffectsForTemplate.call(T, Nx, R, X, A);
  1439.  
  1440. (pChildren || 0).length >= 1 && Promise.resolve(pChildren).then((pChildren) => {
  1441. for (const node of pChildren) {
  1442. if (node.isConnected === false) {
  1443. let tNode = node;
  1444. let pNode;
  1445. while ((pNode = tNode.parentNode) && pNode.nodeType >= 1) {
  1446. tNode = pNode;
  1447. }
  1448. _removedElements.addNode(tNode);
  1449. }
  1450. }
  1451. pChildren.length = 0;
  1452. pChildren = null;
  1453. });
  1454.  
  1455.  
  1456. } catch (err) {
  1457. debugger;
  1458. console.warn(err);
  1459. }
  1460.  
  1461. };
  1462.  
  1463.  
  1464. proto._runEffectsForTemplate = function (N, R, X, A) {
  1465.  
  1466. // console.log(988001)
  1467. /*
  1468. N {wasPreBound: true, nodeList: Array(23)}
  1469.  
  1470. R {showInput: false, narrow: false, menuStrings: {…}, pageDarkTheme: true, theater: false, …}
  1471. X {showInput: undefined, narrow: undefined, menuStrings: undefined, pageDarkTheme: undefined, theater: undefined, …}
  1472. A false
  1473. */
  1474.  
  1475. const Nw = (!N || typeof N !== 'object') ? N : (N[wk] || (N[wk] = mWeakRef(N))); // __templateInfo
  1476. const Xw = (!X || typeof X !== 'object') ? X : (X[wk] || (X[wk] = mWeakRef(X)));
  1477.  
  1478. const Rw = (!R || typeof R !== 'object') ? R : (R[wk] || (R[wk] = mWeakRef(R))); // __data
  1479. const Aw = (!A || typeof A !== 'object') ? A : (A[wk] || (A[wk] = mWeakRef(A)));
  1480.  
  1481. if (typeof (X || 0) === 'object') gxx.add(X);
  1482. if (typeof (A || 0) === 'object') gxx.add(A);
  1483.  
  1484. const Tw = (!this || typeof this !== 'object') ? this : (this[wk] || (this[wk] = mWeakRef(this)));
  1485.  
  1486.  
  1487. if (N.runEffects) {
  1488. N.runEffects(() => {
  1489. runner(Tw, Nw, Rw, Xw, Aw);
  1490. }, R, A);
  1491. } else {
  1492. runner(Tw, Nw, Rw, Xw, Aw);
  1493. }
  1494.  
  1495. // console.log(988002)
  1496.  
  1497. // const N_ =
  1498.  
  1499. // var l = this
  1500. // , k = function (T, W) {
  1501. // XK(l, N.propertyEffects, T, X, W, N.nodeList);
  1502. // for (var w = N.firstChild; w; w = w.nextSibling)
  1503. // l._runEffectsForTemplate(w, T, X, W)
  1504. // };
  1505. // N.runEffects ? N.runEffects(k, R, A) : k(R, A)
  1506. }
  1507.  
  1508. }
  1509.  
  1510. // const __dataHostSym = Symbol();
  1511. // const __dataHostPd = {
  1512. // get() {
  1513. // return kRef(this[__dataHostSym]);
  1514. // },
  1515. // set(nv) {
  1516. // const w = kRef(nv);
  1517. // if (!w) this[__dataHostSym] = w;
  1518. // else {
  1519. // let byPass = !!('parentModel' in this)
  1520. // if (!byPass && (w instanceof Node && w.isConnected === true)) {
  1521. // if (!w[wk]) w[wk] = mWeakRef(w);
  1522. // this[__dataHostSym] = w[wk];
  1523. // } else {
  1524. // this[__dataHostSym] = w;
  1525. // }
  1526. // }
  1527. // return true;
  1528. // },
  1529. // enumerable: true,
  1530. // configurable: true
  1531. // };
  1532.  
  1533. // const _registerHost = proto._registerHost;
  1534. // if (_registerHost && !proto._registerHost322 && _registerHost.length === 0) {
  1535. // proto._registerHost322 = _registerHost;
  1536. // proto._registerHost = function () {
  1537. // if (!this.__regHost322x__) {
  1538. // const tProto = Reflect.getPrototypeOf(this);
  1539. // if (tProto) {
  1540. // tProto.__regHost322x__ = true;
  1541. // }
  1542. // if (this.__regHost322x__ === true) {
  1543. // const q = this.__dataHost;
  1544. // delete this.__dataHost;
  1545. // delete this[__dataHostSym];
  1546. // if (q !== undefined) this[__dataHostSym] = q;
  1547. // Object.defineProperty(tProto, '__dataHost', __dataHostPd);
  1548. // }
  1549. // }
  1550. // return _registerHost.call(this);
  1551. // }
  1552. // }
  1553.  
  1554.  
  1555.  
  1556. const _registerHost = proto._registerHost;
  1557. if (_registerHost && !proto._registerHost322 && _registerHost.length === 0) {
  1558. proto._registerHost322 = _registerHost;
  1559. const map = new WeakMap();
  1560. map.set = map.setOriginal || map.set;
  1561. proto._registerHost = function () {
  1562. if (!map.has(this)) {
  1563. map.set(this, (this.__dataHost || null));
  1564. Object.defineProperty(this, '__dataHost', {
  1565. get() {
  1566. return kRef(map.get(this)) || null
  1567. },
  1568. set(nv) {
  1569. const w = kRef(nv);
  1570. if (!w) {
  1571. map.set(this, null);
  1572. } else {
  1573. if (!w[wk]) w[wk] = mWeakRef(w);
  1574. let byPass = false;
  1575. if (this.is === 'ytd-masthead') byPass = true;
  1576. if (byPass) {
  1577. map.set(this, w);
  1578. } else {
  1579. map.set(this, w[wk]);
  1580. }
  1581. }
  1582. return true;
  1583. },
  1584. enumerable: true,
  1585. configurable: true
  1586. });
  1587. }
  1588. let previousDataHost = this.__dataHost;
  1589. let r = _registerHost.call(this);
  1590. let currentDataHost = this.__dataHost;
  1591. if (currentDataHost !== previousDataHost) { // future use only
  1592. if (previousDataHost && previousDataHost.nodeType >= 1 && previousDataHost.isConnected === false) {
  1593. _removedElements.addNode(previousDataHost);
  1594. }
  1595. }
  1596. return r;
  1597. }
  1598. }
  1599.  
  1600. }
  1601. globalSetup('_removeBoundDom', setup1);
  1602.  
  1603.  
  1604. /*
  1605.  
  1606. M.prototype._stampTemplate = function(N, R) {
  1607. R = R || this._bindTemplate(N, !0);
  1608. aU.push(this);
  1609. N = d.prototype._stampTemplate.call(this, N, R);
  1610. aU.pop();
  1611. R.nodeList = N.nodeList;
  1612. if (!R.wasPreBound)
  1613. for (var X = R.childNodes = [], A = N.firstChild; A; A = A.nextSibling)
  1614. X.push(A);
  1615. N.templateInfo = R;
  1616. X = R.nodeList;
  1617. A = R.nodeInfoList;
  1618. if (A.length)
  1619. for (var l = 0; l < A.length; l++) {
  1620. var k = X[l]
  1621. , T = A[l].bindings;
  1622. if (T)
  1623. for (var W = 0; W < T.length; W++) {
  1624. var w = T[W]
  1625. , p = k
  1626. , h = w;
  1627. if (h.isCompound) {
  1628. for (var I = p.__dataCompoundStorage || (p.__dataCompoundStorage = {}), O = h.parts, y = Array(O.length), c = 0; c < O.length; c++)
  1629. y[c] = O[c].literal;
  1630. O = h.target;
  1631. I[O] = y;
  1632. h.literal && h.kind == "property" && (O === "className" && (p = (0,
  1633. _.FK)(p)),
  1634. p[O] = h.literal)
  1635. }
  1636. gM2(k, this, w)
  1637. }
  1638. k.__dataHost = this
  1639. }
  1640. this.__dataClientsReady && (this._runEffectsForTemplate(R, this.__data, null, !1),
  1641. this._flushClients());
  1642. return N
  1643. }
  1644. ;
  1645.  
  1646. */
  1647.  
  1648.  
  1649.  
  1650. class WeakNodeC {
  1651. constructor(eid) {
  1652. this.eid = eid;
  1653. }
  1654. addEventListener(type, listener, option = void 0) {
  1655. const nodeWr = stampedNodes.get(this.eid);
  1656. const node = kRef(nodeWr);
  1657. if (!node) return;
  1658. return node.addEventListener(type, listener, option);
  1659. }
  1660. removeEventListener(type, listener, option = void 0) {
  1661. const nodeWr = stampedNodes.get(this.eid);
  1662. const node = kRef(nodeWr);
  1663. if (!node) return;
  1664. return node.removeEventListener(type, listener, option);
  1665. }
  1666. getNode592177() {
  1667. const nodeWr = stampedNodes.get(this.eid);
  1668. const node = kRef(nodeWr);
  1669. return node;
  1670. }
  1671. set __dataHost(nv) {
  1672. const nodeWr = stampedNodes.get(this.eid);
  1673. const node = kRef(nodeWr);
  1674. if (!node) return;
  1675. node.__dataHost = nv;
  1676. return true;
  1677. }
  1678. get __dataHost() {
  1679. const nodeWr = stampedNodes.get(this.eid);
  1680. const node = kRef(nodeWr);
  1681. if (!node) return;
  1682. return node.__dataHost;
  1683. }
  1684.  
  1685. set __dataCompoundStorage(nv) {
  1686. const nodeWr = stampedNodes.get(this.eid);
  1687. const node = kRef(nodeWr);
  1688. if (!node) return;
  1689. node.__dataCompoundStorage = nv;
  1690. return true;
  1691.  
  1692. }
  1693. get __dataCompoundStorage() {
  1694. const nodeWr = stampedNodes.get(this.eid);
  1695. const node = kRef(nodeWr);
  1696. if (!node) return;
  1697. return node.__dataCompoundStorage;
  1698.  
  1699. }
  1700. }
  1701.  
  1702. // let initied2 = false;
  1703. const setup2 = (qxx) => {
  1704. // if(initied2) return;
  1705. // initied2 = true;
  1706. const proto = qxx;
  1707. const constructor = proto.constructor;
  1708. const _stampTemplate = proto._stampTemplate;
  1709. // console.log(12883, proto, constructor)
  1710. if (typeof _stampTemplate === 'function' && _stampTemplate.length === 2 && !proto._stampTemplate374) {
  1711. proto._stampTemplate374 = _stampTemplate;
  1712. proto._stampTemplate = function (N, R) {
  1713. // R = boolean true or binded template
  1714. // N = template elemenet
  1715. let M = N;
  1716. if (typeof (N || 0) === 'object' && N instanceof HTMLTemplateElement && (N.content || 0).nodeType === 11) {
  1717. let componentIs = '';
  1718. try {
  1719. componentIs = this ? this.is : '';
  1720. } catch (e) { }
  1721. if (typeof (componentIs || 0) === 'string') {
  1722. // if (!templateMap.has(componentIs)) {
  1723. // templateMap.set(componentIs, N);
  1724. // } else {
  1725. // M = templateMap.get(componentIs);
  1726. // }
  1727. }
  1728. }
  1729. let r_ = null;
  1730. // Promise.resolve(N).then((N) => {
  1731. // console.log(3488,N.templateInfo, N.templateInfo === r_);
  1732. // })
  1733. const r = _stampTemplate.call(this, M, R); // return the fragment created with nodeList
  1734. r_ = r;
  1735.  
  1736. if (r && r.nodeType === 11) {
  1737.  
  1738. const fid = genId();
  1739.  
  1740. r.__fragId57__ = fid;
  1741. if (!r[wk]) r[wk] = mWeakRef(r);
  1742. stampedFragment.set(fid, r[wk]);
  1743.  
  1744. if (r.nodeList) {
  1745. const nl = r.nodeList;
  1746. nl.__belongFragId57__ = fid;
  1747. for (let i = 0, l = nl.length; i < l; i++) {
  1748. const t = nl[i];
  1749. if (t && t.nodeType >= 1) {
  1750. if (!t[wk]) t[wk] = mWeakRef(t);
  1751. const eid = `${fid}::${i}`;
  1752. nl[i] = new WeakNodeC(eid);
  1753. stampedNodes.set(eid, t[wk]);
  1754. t.__weakNodeCId57__ = eid;
  1755. }
  1756. }
  1757. }
  1758.  
  1759. }
  1760.  
  1761. return r;
  1762. }
  1763. }
  1764. }
  1765.  
  1766. globalSetup('_addMethodEventListenerToNode', setup2);
  1767.  
  1768. }
  1769.  
  1770. if (XFlag) {
  1771.  
  1772. const cMap = new Set();
  1773. cMap.add = cMap.addOriginal || cMap.add;
  1774. const yMap = new Set();
  1775. yMap.add = yMap.addOriginal || yMap.add;
  1776.  
  1777.  
  1778. const ydMap = new Set();
  1779. ydMap.add = ydMap.addOriginal || ydMap.add;
  1780.  
  1781. window.yMap = yMap;
  1782. window.cMap = cMap;
  1783. window.ydMap = ydMap;
  1784.  
  1785. const constructAts = new Set();
  1786. constructAts.add = constructAts.addOriginal || constructAts.add;
  1787. window.constructAts = constructAts;
  1788.  
  1789. const kMap = new WeakMap();
  1790.  
  1791. const kRefProp = (wr, prop)=>{
  1792. let o = kRef(wr);
  1793. return o ? o[prop] : null;
  1794. }
  1795.  
  1796. const wrObj = (objRef, props) => {
  1797. let wr = mWeakRef(objRef);
  1798. if (wr === objRef || !props || !props.length) return wr;
  1799. let properties = {};
  1800. props.forEach(k => {
  1801. properties[k] = {
  1802. get() {
  1803. return kRefProp(this, k)
  1804. },
  1805. enumerable: false,
  1806. configurable: true
  1807. };
  1808. });
  1809. Object.defineProperties(wr, properties);
  1810. return wr;
  1811. }
  1812.  
  1813. const sProtos = {};
  1814.  
  1815. const setupCProto = function (cProto) {
  1816.  
  1817. if(cProto === Object.prototype) return;
  1818.  
  1819. if (!kMap.get(cProto)) kMap.set(cProto, `protoKey0_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${Date.now()}`);
  1820. cProto[kMap.get(cProto)] = true;
  1821. // debugger;
  1822.  
  1823. const constructAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  1824. constructAts.add(constructAt)
  1825.  
  1826. if (MemoryFix_Flag002 & 32) {
  1827. if (!cProto.dk322 && (cProto.__attachInstance || cProto.__detachInstance)) {
  1828. fixDetachFn(cProto);
  1829. }
  1830. }
  1831.  
  1832. if (MemoryFix_Flag002 & 2) {
  1833. if (cProto._setPendingProperty && !cProto.__setPropDX38__) {
  1834. cProto.__setPropDX38__ = true;
  1835.  
  1836. if (cProto._setPendingProperty.length === 3) {
  1837. cProto._setPendingProperty.bind = sProtos._setPendingProperty$bind || (sProtos._setPendingProperty$bind = function (obj, ...args) {
  1838. let wobj = obj[wk] || (obj[wk] = mWeakRef(obj));
  1839. return () => {
  1840. const obj = kRef(wobj);
  1841. let u = Reflect.apply(this, obj, args);
  1842. args.length = 0;
  1843. wobj = null;
  1844. return u;
  1845. };
  1846. });
  1847. }
  1848.  
  1849. }
  1850. }
  1851.  
  1852. // if (false && (MemoryFix_Flag002 & 4)) {
  1853. // if (cProto._runEffectsForTemplate && !cProto.__runEffectDX38__ && !cProto._runEffectsForTemplate3858 && !cProto._runEffectsForTemplate3857) {
  1854. // cProto.__runEffectDX38__ = true;
  1855.  
  1856. // if (cProto._runEffectsForTemplate.length === 4) {
  1857. // cProto._runEffectsForTemplate3858 = cProto._runEffectsForTemplate;
  1858. // if (FIX_MEMORY_RELEASE_RUNEFFECT_TEMPLATE) {
  1859. // cProto._runEffectsForTemplate3857 = function (o, d, e, g) {
  1860. // const { propertyEffects, nodeList, firstChild } = o;
  1861. // if (propertyEffects && nodeList && nodeList.length >= 0) {
  1862. // for (const [effectKey, propertyEffectArr] of Object.entries(propertyEffects)) {
  1863. // for (let i = propertyEffectArr.length - 1; i >= 0; i--) {
  1864. // const propertyEffect = propertyEffectArr[i];
  1865. // const info = (propertyEffect || 0).info;
  1866. // if (info && typeof info.index === 'number' && !nodeList[info.index]) {
  1867. // propertyEffectArr.splice(i, 1);
  1868. // }
  1869. // }
  1870. // }
  1871. // }
  1872. // return this._runEffectsForTemplate3858(o, d, e, g);
  1873. // }
  1874. // } else {
  1875. // cProto._runEffectsForTemplate3857 = cProto._runEffectsForTemplate3858;
  1876. // }
  1877. // cProto._runEffectsForTemplate = sProtos._runEffectsForTemplate || (sProtos._runEffectsForTemplate = function (c, d, e, g) {
  1878. // if (c && c.runEffects) {
  1879. // // const kNodeList = [...c.nodeList].map(e=>{
  1880. // // if(e && e.nodeType >= 1){
  1881. // // return e[wk] || (e[wk] = mWeakRef(e));
  1882. // // }else{
  1883. // // return e;
  1884. // // }
  1885. // // });
  1886. // let wr = wrObj(c, ['propertyEffects', 'nodeList', 'firstChild']);
  1887. // // console.log(12837)
  1888. // if (!this[wk]) this[wk] = mWeakRef(this);
  1889. // if ((typeof (e || 0) === "object") && !e[wk]) e[wk] = mWeakRef(e);
  1890. // let cntWr = this[wk];
  1891. // let eWr = (typeof (e || 0) === "object") ? e[wk] : e;
  1892. // c.runEffects((n, r) => {
  1893. // // console.log(12838)
  1894. // const cnt = kRef(cntWr);
  1895. // const e = kRef(eWr);
  1896. // if (cnt) {
  1897. // cnt._runEffectsForTemplate3857(wr, n, e, r);
  1898. // }
  1899. // wr = cntWr = d = e = g = null;
  1900. // }, d, g);
  1901. // } else if (typeof (c || 0) === 'object') {
  1902. // let { propertyEffects, nodeList, firstChild } = c;
  1903. // let o = { propertyEffects, nodeList, firstChild }
  1904. // // console.log(37271, propertyEffects, nodeList, firstChild);
  1905. // this._runEffectsForTemplate3857(o, d, e, g);
  1906. // o.propertyEffects = o.nodeList = o.firstChild = null;
  1907. // propertyEffects = nodeList = firstChild = null;
  1908. // o = null;
  1909. // }
  1910.  
  1911. // /*
  1912. // B5A = function(M, d, N, R, X, A, l) {
  1913. // l = l[X.index];
  1914.  
  1915.  
  1916. // !(l[X.index])
  1917.  
  1918.  
  1919. // m.fn(M, T, N, R, m.info, X, A),
  1920.  
  1921. // !(A[m.info.index])
  1922.  
  1923. // */
  1924. // });
  1925.  
  1926. // cProto._runEffectsForTemplate.bind = sProtos._runEffectsForTemplate$bind || (sProtos._runEffectsForTemplate$bind = function (obj, ...args) {
  1927. // // console.log(12993, args)
  1928. // let wobj = obj[wk] || (obj[wk] = mWeakRef(obj));
  1929. // return () => {
  1930. // const obj = kRef(wobj);
  1931. // let u = Reflect.apply(this, obj, args);
  1932. // args.length = 0;
  1933. // wobj = null;
  1934. // return u;
  1935. // };
  1936. // });
  1937. // }
  1938.  
  1939. // }
  1940. // }
  1941.  
  1942.  
  1943.  
  1944. const cProtoConstructor = cProto.constructor;
  1945.  
  1946. if (MemoryFix_Flag002 & 8) {
  1947. if (cProtoConstructor._parseBindings && !cProtoConstructor.__parseBindingsDX38__) {
  1948. cProtoConstructor.__parseBindingsDX38__ = true;
  1949.  
  1950. ydMap.add(cProtoConstructor);
  1951.  
  1952. if (cProtoConstructor._parseBindings.length === 2) {
  1953.  
  1954. cProtoConstructor._parseBindings3858 = cProtoConstructor._parseBindings;
  1955.  
  1956. cProtoConstructor._parseBindings = sProtos._parseBindings || (sProtos._parseBindings = function (c, d) {
  1957. let p = this._parseBindings3858(c, d);
  1958. this.__bindingsArrs__ = this.__bindingsArrs__ || [];
  1959. if (p) this.__bindingsArrs__.push(p);
  1960. return p;
  1961. });
  1962.  
  1963. }
  1964. }
  1965. }
  1966.  
  1967. /*
  1968. a.prototype._initializeProperties = function() {
  1969. if (Em && this.hasAttribute("disable-upgrade"))
  1970. this.__isUpgradeDisabled = !0;
  1971. else {
  1972. var e = Object.getPrototypeOf(this);
  1973. e.hasOwnProperty("__hasRegisterFinished") || (this._registered(),
  1974. e.__hasRegisterFinished = !0);
  1975. b.prototype._initializeProperties.call(this);
  1976. this.root = this;
  1977. this.created();
  1978. fpb && !this._legacyForceObservedAttributes && (this.hasAttributes() ? this._takeAttributes() : this.parentNode || (this.__needsAttributesAtConnected = !0));
  1979. this._applyListeners()
  1980. }
  1981. }
  1982. */
  1983. /*
  1984. bOa = function(a, b, c) {
  1985. var d = bya(a.prototype, $Na, a.prototype.behaviors);
  1986. d.prototype.is = b;
  1987. d.prototype.localName = b;
  1988. c && aOa(d, c);
  1989. return function(e) {
  1990. e && (d.prototype.hostElement = e);
  1991. var g = new d;
  1992. g.root = g;
  1993. g.hostElement = e;
  1994. return g
  1995. }
  1996. }
  1997. */
  1998.  
  1999.  
  2000. }
  2001. const symDH = Symbol();
  2002.  
  2003. const wfStore = new WeakMap();
  2004.  
  2005. const wrapF = function (f, key) {
  2006. if (wfStore.get(f)) return wfStore.get(f);
  2007.  
  2008. let g = function () {
  2009. const o = kRef(this);
  2010. if (!o) return;
  2011. const cnt = insp(o);
  2012. // if (cnt === o) return;
  2013. // if (!('ready' in cnt)) return;
  2014. return f.apply(o, arguments);
  2015. };
  2016. g.key38 = key;
  2017. g.originalFunc38 = f;
  2018. g.__wrapF84__ = true;
  2019. wfStore.set(f, g);
  2020. wfStore.set(g, g);
  2021. return g;
  2022. };
  2023.  
  2024. if (MemoryFix_Flag002 & 16) {
  2025. ['_createPropertyAccessor', '_addPropertyToAttributeMap', '_definePropertyAccessor', 'ready', '_initializeProperties', '_initializeInstanceProperties', '_setProperty', '_getProperty', '_setPendingProperty', '_isPropertyPending', '_invalidateProperties', '_enableProperties', '_flushProperties', '_shouldPropertiesChange', '_propertiesChanged', '_shouldPropertyChange', 'attributeChangedCallback', '_attributeToProperty', '_propertyToAttribute', '_valueToNodeAttribute', '_serializeValue', '_deserializeValue'].forEach(key => {
  2026.  
  2027. Object.defineProperty(Node.prototype, key, {
  2028. get() {
  2029. return this[`__a0939${key}__`];
  2030. },
  2031. set(nv) {
  2032. if (typeof nv !== 'function') return;
  2033. const g = (nv.__wrapF84__) ? nv : wrapF(nv, key);
  2034. this[`__a0939${key}__`] = g;
  2035. return true;
  2036. }
  2037. });
  2038.  
  2039.  
  2040. });
  2041. }
  2042.  
  2043.  
  2044.  
  2045. // const wm = new WeakMap();
  2046.  
  2047. const fixDetachFn = (tpProto) => { // & 32
  2048.  
  2049. if (tpProto.dk322) return;
  2050. tpProto.dk322 = true;
  2051.  
  2052. window.__fixTemplateReuse1058__ = true;
  2053.  
  2054.  
  2055. tpProto.__ensureTemplatized994 = tpProto.__ensureTemplatized;
  2056. if (typeof tpProto.__ensureTemplatized994 === 'function' && tpProto.__ensureTemplatized994.length === 0) {
  2057. tpProto.__ensureTemplatized = function () {
  2058. // console.log(18470001)
  2059. return this.__ensureTemplatized994();
  2060. }
  2061. }
  2062.  
  2063.  
  2064. tpProto.__updateInstances994 = tpProto.__updateInstances;
  2065. if (typeof tpProto.__updateInstances994 === 'function' && tpProto.__updateInstances994.length === 3) {
  2066. let bypass= false;
  2067. // tpProto._stampTemplate994 = tpProto._stampTemplate;
  2068. // tpProto._stampTemplate = function(N,R){
  2069. // console.log(3882, [...N.nodeList])
  2070. // return this._stampTemplate994(N,R);
  2071. // }
  2072. tpProto.__updateInstances = function (a, b, c) {
  2073.  
  2074. // const a_ = [...a];
  2075. if(!bypass && a === this.items && (a||0).length >=1 ){
  2076.  
  2077. bypass = true;
  2078. // console.log(18470002, a, b,c)
  2079. let e;
  2080. for (e = 0; e < b; e++) {
  2081. let g = this.__instances[e]
  2082. , k = c[e]
  2083. , m = a[k];
  2084. if(g && typeof (m||0) === 'object'){
  2085. // const q = g._shouldPropertyChange;
  2086. // g._shouldPropertyChange = ()=>true;
  2087. // g[this.as] = {};
  2088. // a_[k]=a[k] = m;
  2089. // g[this.as] = m;
  2090.  
  2091. // use public interface notifyPath instead of internal interface _setPendingProperty
  2092. const m_ = a[k] = Object.assign({}, a[k]);
  2093. try {
  2094. g.notifyPath(this.as, {});
  2095. } catch (e) { }
  2096. try {
  2097. g.notifyPath(this.as, m_);
  2098. } catch (e) { }
  2099.  
  2100. // g._setPendingProperty(this.as, {});
  2101. // g._setPendingProperty(this.as, m);
  2102. // g._setPendingProperty(this.indexAs, e);
  2103. // g._setPendingProperty(this.itemsIndexAs, k);
  2104. // delete g._shouldPropertyChange;
  2105. // if(g._shouldPropertyChange !== q) g._shouldPropertyChange = q;
  2106. }
  2107. }
  2108. bypass = false;
  2109.  
  2110. }
  2111. const r = this.__updateInstances994(a,b,c);
  2112.  
  2113. // for (e = 0; e < b; e++) {
  2114. // let g = this.__instances[e]
  2115. // , k = c[e]
  2116. // , m = a_[k];
  2117. // if(g){
  2118. // // const q = g._shouldPropertyChange;
  2119. // // g._shouldPropertyChange = ()=>true;
  2120. // // g[this.as] = m;
  2121. // // g._setPendingProperty(this.as, {});
  2122. // // g._setPendingProperty(this.as, m);
  2123. // // g._setPendingProperty(this.indexAs, e);
  2124. // // g._setPendingProperty(this.itemsIndexAs, k);
  2125. // // delete g._shouldPropertyChange;
  2126. // // if(g._shouldPropertyChange !== q) g._shouldPropertyChange = q;
  2127. // }
  2128. // }
  2129.  
  2130. return r;
  2131. }
  2132. }
  2133.  
  2134. /*
  2135.  
  2136. tpProto.__updateInstances = function (a, b, c) {
  2137.  
  2138. let renew = this.__wasInstanceDetached001 === true;
  2139. if(renew){
  2140.  
  2141. this.__wasInstanceDetached001 = false;
  2142. }
  2143.  
  2144. // const a_ = [...a];
  2145. // if(a === this.items && (a||0).length >=1 ){
  2146.  
  2147. // // console.log(18470002, a, b,c)
  2148. // let e;
  2149. // for (e = 0; e < b; e++) {
  2150. // let g = this.__instances[e]
  2151. // , k = c[e]
  2152. // , m = a[k];
  2153. // if(g && typeof (m||0) === 'object'){
  2154. // // const q = g._shouldPropertyChange;
  2155. // // g._shouldPropertyChange = ()=>true;
  2156. // // g[this.as] = {};
  2157. // // a_[k]=a[k] = m;
  2158. // // g[this.as] = m;
  2159.  
  2160. // // use public interface notifyPath instead of internal interface _setPendingProperty
  2161. // try {
  2162. // g.notifyPath(this.as, {});
  2163. // } catch (e) { }
  2164. // try {
  2165. // g.notifyPath(this.as, m);
  2166. // } catch (e) { }
  2167.  
  2168. // // g._setPendingProperty(this.as, {});
  2169. // // g._setPendingProperty(this.as, m);
  2170. // // g._setPendingProperty(this.indexAs, e);
  2171. // // g._setPendingProperty(this.itemsIndexAs, k);
  2172. // // delete g._shouldPropertyChange;
  2173. // // if(g._shouldPropertyChange !== q) g._shouldPropertyChange = q;
  2174. // }
  2175. // }
  2176.  
  2177. // }
  2178. const r = this.__updateInstances994(a,b,c);
  2179.  
  2180. // for (e = 0; e < b; e++) {
  2181. // let g = this.__instances[e]
  2182. // , k = c[e]
  2183. // , m = a_[k];
  2184. // if(g){
  2185. // // const q = g._shouldPropertyChange;
  2186. // // g._shouldPropertyChange = ()=>true;
  2187. // // g[this.as] = m;
  2188. // // g._setPendingProperty(this.as, {});
  2189. // // g._setPendingProperty(this.as, m);
  2190. // // g._setPendingProperty(this.indexAs, e);
  2191. // // g._setPendingProperty(this.itemsIndexAs, k);
  2192. // // delete g._shouldPropertyChange;
  2193. // // if(g._shouldPropertyChange !== q) g._shouldPropertyChange = q;
  2194. // }
  2195. // }
  2196. if (renew) {
  2197.  
  2198. const q = [...this.items];
  2199. this.items = [];
  2200. this.items = q;
  2201. console.log(129992)
  2202. // this.items.splice(0, 1, Object.assign({}, this.items[0]));
  2203. }
  2204. return r;
  2205. }
  2206.  
  2207. */
  2208.  
  2209. tpProto.__detachInstance994 = tpProto.__detachInstance;
  2210. if (typeof tpProto.__detachInstance994 === 'function' && tpProto.__detachInstance994.length === 1) {
  2211. tpProto.__detachInstance = function (a) {
  2212. const u = this.__instances[a];
  2213. if (u && !u.__keepInstance038__) u.__keepInstance038__ = true;
  2214. const children = (u || 0).children;
  2215. if (children && children.length >= 1) {
  2216. const pp = document.createDocumentFragment();
  2217. for (const s of [...children]) {
  2218. pp.appendChild(s);
  2219. }
  2220. }
  2221. try {
  2222. return this.__detachInstance994(a);
  2223. } catch (e) { }
  2224. return u;
  2225. }
  2226. }
  2227.  
  2228. tpProto.__attachInstance994 = tpProto.__attachInstance;
  2229. if (typeof tpProto.__attachInstance994 === 'function' && tpProto.__attachInstance994.length === 2) {
  2230. tpProto.__attachInstance = function (a, b) {
  2231. const u = this.__instances[a];
  2232. if (u && !u.__keepInstance038__) u.__keepInstance038__ = true;
  2233. if (u && u.root && b) {
  2234. const root = u.root;
  2235. const pp = document.createDocumentFragment();
  2236. pp.appendChild(root);
  2237. root.appendChild(pp);
  2238. const r = this.__attachInstance994(a, b);
  2239. if (!this.__chunkingId) this.__chunkingId = 0.25;
  2240. return r;
  2241. }
  2242. }
  2243. }
  2244.  
  2245. }
  2246.  
  2247. const ytTemplateDomEntry = (tpProto) => {
  2248.  
  2249. console.log('ytTemplateDomEntry triggered')
  2250.  
  2251.  
  2252. const convertToWeakArr = (arr) => {
  2253.  
  2254. if (arr.isWeak) return;
  2255.  
  2256. for (let i = 0, l = arr.length; i < l; i++) {
  2257. const o = arr[i]
  2258. if (o) {
  2259. let p = kRef(o)
  2260. if (!p) arr[i] = null;
  2261. else {
  2262. if (!o[wk]) o[wk] = mWeakRef(o);
  2263. arr[i] = o[wk];
  2264. }
  2265. }
  2266. }
  2267. arr.isWeak = true;
  2268.  
  2269. }
  2270.  
  2271. const convertToNormalArr = (arr) => {
  2272.  
  2273. if (!arr.isWeak) return;
  2274.  
  2275. for (let i = 0, l = arr.length; i < l; i++) {
  2276. const o = arr[i]
  2277. if (o) {
  2278. let p = kRef(o)
  2279. arr[i] = p;
  2280. }
  2281. }
  2282. arr.isWeak = false;
  2283.  
  2284. }
  2285.  
  2286. if (MemoryFix_Flag002 & 256) {
  2287. Object.defineProperty(tpProto, '__instances', {
  2288. get() {
  2289. this.dk322 || fixDetachFn(Reflect.getPrototypeOf(this));
  2290. let arr = this.__instances_actual471__;
  2291. if (arr && arr.isWeak) {
  2292. convertToNormalArr(arr);
  2293. for (let i = arr.length - 1; i >= 0; i--) {
  2294. const t = arr[i];
  2295. if (!t) arr.splice(i, 1);
  2296. else if (!t.__keepInstance038__) t.__keepInstance038__ = true;
  2297. }
  2298. Promise.resolve(arr).then(convertToWeakArr);
  2299. }
  2300. return arr;
  2301. },
  2302. set(nv) {
  2303. this.dk322 || fixDetachFn(Reflect.getPrototypeOf(this));
  2304. this.__instances_actual471__ = nv;
  2305. if (nv && !nv.isWeak) {
  2306. Promise.resolve(nv).then(convertToWeakArr);
  2307. }
  2308. return true;
  2309. },
  2310. enumerable: false,
  2311. configurable: true
  2312. });
  2313. }
  2314.  
  2315. // console.log(91901, tpProto.__detachInstance)
  2316. if (MemoryFix_Flag002 & 32) {
  2317. if (tpProto.__detachInstance) {
  2318. fixDetachFn(tpProto);
  2319. } else {
  2320. Promise.resolve(tpProto).then((tpProto) => {
  2321. // console.log(91902, tpProto.__detachInstance)
  2322. fixDetachFn(tpProto);
  2323. })
  2324. }
  2325. }
  2326.  
  2327. }
  2328.  
  2329. if (MemoryFix_Flag002 & 32) {
  2330. Object.defineProperty(Object.prototype, '__ensureTemplatized', {
  2331. set(nv) {
  2332. if (nv === true) return false;
  2333. tpProto = this;
  2334. if ('connectedCallback' in tpProto && tpProto !== Node.prototype && !tpProto.__domDX37__) {
  2335. tpProto.__domDX37__ = true;
  2336. ytTemplateDomEntry(tpProto);
  2337. }
  2338. this.__ensureTemplatized949__ = nv;
  2339. return true;
  2340. },
  2341. get() {
  2342. return this.__ensureTemplatized949__;
  2343. }
  2344. });
  2345. }
  2346.  
  2347.  
  2348. if (MemoryFix_Flag002 & 64) {
  2349. HTMLElement_.prototype.__dataHostBinding374 = true;
  2350. Object.defineProperty(HTMLElement_.prototype, '__dataHost', {
  2351. get() {
  2352. return kRef(this.__dataHostWr413__);
  2353. },
  2354. set(nv) {
  2355. if (nv && typeof nv === 'object' && !nv.deref) {
  2356. if (!nv[wk]) nv[wk] = mWeakRef(nv);
  2357. nv = nv[wk];
  2358. }
  2359. this.__dataHostWr413__ = nv;
  2360. return true;
  2361. }
  2362. });
  2363. }
  2364.  
  2365.  
  2366. const setupYProto = function (yProto) {
  2367.  
  2368. if(yProto === Object.prototype) return;
  2369.  
  2370. if (!kMap.get(yProto)) kMap.set(yProto, `protoKey1_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${Date.now()}`);
  2371. yProto[kMap.get(yProto)] = true;
  2372.  
  2373. if (FIX_DOM_IF_DETACH && !yProto.disconnectedCallback277 && yProto.disconnectedCallback && typeof yProto._readyClients === 'function' && typeof yProto._canApplyPropertyDefault === 'function' && typeof yProto._attachDom === 'function' && !yProto.is && typeof yProto.constructor._finalizeTemplate === 'function') {
  2374. const disconnectedCallback277 = yProto.disconnectedCallback;
  2375. yProto.disconnectedCallback277 = true;
  2376. yProto.disconnectedCallback = function () {
  2377. disconnectedCallback277.call(this);
  2378. if (this.nodeName === 'DOM-IF' && this.__instance && typeof this.__teardownInstance === 'function') {
  2379. const shadyParent = (this.__shady_parentNode || 0);
  2380. const actualParent = (this.parentNode || 0);
  2381. if (shadyParent !== actualParent && shadyParent.nodeType === 11 && actualParent.nodeType === 11) {
  2382. // && (shadyParent.compareDocumentPosition(actualParent) & (1|8|16) === 1)
  2383. // if (!this.restamp && !this.id && this.__ctor && this.isConnected === false) {
  2384. const children = (this.__instance.children || 0).length;
  2385. if (children >= 1) {
  2386. try {
  2387. this.__teardownInstance();
  2388. } catch (e) { }
  2389. }
  2390. // }
  2391. }
  2392. }
  2393. }
  2394. }
  2395.  
  2396.  
  2397. // if(yProto.constructor._contentForTemplate && yProto.constructor._parseTemplateNodeAttribute && yProto.constructor._parseTemplateNestedTemplate && !yProto.constructor.y366){
  2398.  
  2399. // yProto.constructor.y366 = 1;
  2400.  
  2401. // const _stampTemplate366 = yProto._stampTemplate;
  2402. // yProto._stampTemplate = function(N, R){
  2403. // console.log(12773, N, R);
  2404. // return _stampTemplate366.call(this, N, R);
  2405. // }
  2406.  
  2407. // }
  2408. /*
  2409. if(yProto._bindTemplate && !yProto._bindTemplate371) {
  2410. yProto._bindTemplate371 = true;
  2411. const _bindTemplate371 = yProto._bindTemplate;
  2412. yProto._bindTemplate = function(a, b){
  2413. const R = _bindTemplate371.call(this, a, b);
  2414. const X = R.nodeList || 0;
  2415. const A = R.nodeInfoList || 0;
  2416. // if(X && A && X.length === A.length){
  2417. // for(let i =0, l=A.length;i<l; i++){
  2418. // if()
  2419. // }
  2420. // }
  2421. const l = Math.max((X.length || 0), (A.length || 0));
  2422. const e = {};
  2423. for (let i = 0; i < l; i++) {
  2424. if (X && !X[i]) X[i] = e;
  2425. if (A && !A[i]) A[i] = e;
  2426. }
  2427.  
  2428.  
  2429. return R;
  2430. }
  2431. }
  2432.  
  2433. if(yProto._stampTemplate && !yProto._stampTemplate371) {
  2434. yProto._stampTemplate371 = true;
  2435. const _stampTemplate371 = yProto._stampTemplate;
  2436. yProto._stampTemplate = function(a, b){
  2437. const R = _stampTemplate371.call(this, a, b);
  2438. const X = R.nodeList || 0;
  2439. const A = R.nodeInfoList || 0;
  2440. // if(X && A && X.length === A.length){
  2441. // for(let i =0, l=A.length;i<l; i++){
  2442. // if()
  2443. // }
  2444. // }
  2445. const l = Math.max((X.length || 0), (A.length || 0));
  2446. const e = {};
  2447. for (let i = 0; i < l; i++) {
  2448. if (X && !X[i]) X[i] = e;
  2449. if (A && !A[i]) A[i] = e;
  2450. }
  2451. return R;
  2452. }
  2453. }
  2454. */
  2455.  
  2456.  
  2457. if (MemoryFix_Flag002 & 32) {
  2458. if (!yProto.dk322 && (yProto.__attachInstance || yProto.__detachInstance)) {
  2459. fixDetachFn(yProto);
  2460. }
  2461. }
  2462.  
  2463. if (MemoryFix_Flag002 & 128) {
  2464. if (!yProto.__dataHostBinding374) {
  2465. yProto.__dataHostBinding374 = true;
  2466. Object.defineProperty(yProto, '__dataHost', {
  2467. set(nv) {
  2468. let dh = nv;
  2469. if (dh && typeof dh === 'object' && !dh.deref) {
  2470. const wr = dh[wk] || (dh[wk] = mWeakRef(dh));
  2471. dh = wr;
  2472. }
  2473. this[symDH] = dh;
  2474. return true;
  2475. },
  2476. get() {
  2477. let wr = this[symDH];
  2478. let obj = typeof wr === 'object' ? kRef(wr) : wr;
  2479. return obj;
  2480. },
  2481. enumerable: false,
  2482. configurable: true
  2483. });
  2484. }
  2485.  
  2486.  
  2487.  
  2488. if (yProto._registerHost && yProto._enqueueClient && yProto.__enableOrFlushClients && !yProto._registerHostDX38__) {
  2489. yProto._registerHostDX38__ = true;
  2490.  
  2491. // yProto._registerHost7133 = yProto._registerHost;
  2492.  
  2493. yProto.__enableOrFlushClients = function () {
  2494. const c_ = this.__dataPendingClients;
  2495. if (c_) {
  2496. const c = c_.slice();
  2497. c_.length = 0;
  2498. for (let d = 0, l = c.length; d < l; d++) {
  2499. let e = kRef(c[d]);
  2500. if (e) {
  2501. e.__dataEnabled ? e.__dataPending && e._flushProperties() : e._enableProperties()
  2502. }
  2503. }
  2504. }
  2505. }
  2506.  
  2507. yProto._enqueueClient = function (c) {
  2508. if (c === this || !c || typeof c !== 'object') return;
  2509. if (c.deref) c = kRef(c);
  2510. const m = this.__dataPendingClients || (this.__dataPendingClients = []);
  2511. if (!c[wk]) c[wk] = mWeakRef(c);
  2512. m.push(c[wk]);
  2513. }
  2514.  
  2515. }
  2516. }
  2517.  
  2518.  
  2519.  
  2520. }
  2521. const setupRendering = function () {
  2522.  
  2523. const cnt = this;
  2524. const cProto = Reflect.getPrototypeOf(cnt);
  2525. let yProto = Reflect.getPrototypeOf(cProto);
  2526.  
  2527. const yProtos = new Set();
  2528.  
  2529. if (!yMap.has(yProto)) {
  2530. // capture all ancenstor constructors of a and b (non-specific component type)
  2531.  
  2532. do {
  2533. if (yProto === Object.prototype || yProto === null) break;
  2534. if (yProto === Element.prototype || yProto === Node.prototype || yProto === EventTarget.prototype || yProto === HTMLElement_.prototype) break;
  2535. yProtos.add(yProto);
  2536. yProto = Reflect.getPrototypeOf(yProto);
  2537. } while (!yProtos.has(yProto));
  2538.  
  2539. for (const yProto of yProtos) {
  2540. yMap.add(yProto);
  2541. setupYProto(yProto)
  2542. }
  2543.  
  2544. }
  2545.  
  2546.  
  2547. if (!cMap.has(cProto)) {
  2548. cMap.add(cProto); // cProto constrcutor is either a or b? (specific component type)
  2549. setupCProto(cProto);
  2550. }
  2551.  
  2552. }
  2553.  
  2554. // const selfRef = {}; // no change. just key
  2555.  
  2556. /*
  2557.  
  2558. jF = function(M) {
  2559. var d = YNV.call(this) || this;
  2560. d._configureProperties(M);
  2561. d.root = d._stampTemplate(d.__dataHost);
  2562. var N = [];
  2563. d.children = N;
  2564. for (var R = d.root.firstChild; R; R = R.nextSibling)
  2565. N.push(R),
  2566. R.__templatizeInstance = d;
  2567. d.__templatizeOwner && d.__templatizeOwner.__hideTemplateChildren__ && d._showHideChildren(!0);
  2568. N = d.__templatizeOptions;
  2569. (M && N.instanceProps || !N.instanceProps) && d._enableProperties();
  2570. return d
  2571. };
  2572. */
  2573.  
  2574. const sb1 = Symbol();
  2575. Object.defineProperty(Object.prototype, 'root', {
  2576. get() {
  2577. return this[sb1];
  2578. },
  2579. set(nv){
  2580. const p = this ? kRef(this) : null;
  2581. const mv = nv ? kRef(nv) : null;
  2582.  
  2583. if (mv && (mv instanceof Node) && !p.__setupRendered399__) {
  2584. p.__setupRendered399__ = true;
  2585. setupRendering.call(p);
  2586. }
  2587. if (mv && mv.is && !mv.__setupRendered399__) {
  2588. mv.__setupRendered399__ = true;
  2589. setupRendering.call(mv);
  2590. }
  2591.  
  2592. this[sb1] = nv;
  2593. return true;
  2594. }
  2595. });
  2596.  
  2597.  
  2598. /*
  2599. let wm3 = new WeakMap();
  2600.  
  2601. Object.defineProperty(Object.prototype, 'root', {
  2602. get() {
  2603. const p = this ? kRef(this) : null;
  2604. const r = p ? wm3.get(p) : null;
  2605. const r2 = r ? kRef(r) : null;
  2606. if (r === selfRef) return p;
  2607. return r2;
  2608. },
  2609. set(nv) {
  2610. const p = this ? kRef(this) : null;
  2611. const mv = nv ? kRef(nv) : null;
  2612. if (typeof mv !== 'object') return;
  2613. if (mv && (mv instanceof Node) && !p.__setupRendered399__) {
  2614. p.__setupRendered399__ = true;
  2615. setupRendering.call(p);
  2616. }
  2617. if (mv && mv.is && !mv.__setupRendered399__) {
  2618. mv.__setupRendered399__ = true;
  2619. setupRendering.call(mv);
  2620. }
  2621. if (mv === p) {
  2622. wm3.set(p, selfRef)
  2623. return true;
  2624. }
  2625. let gv = nv;
  2626. if (nv && !nv[wk]) {
  2627. gv = nv[wk] = mWeakRef(nv);
  2628. }
  2629. if (p) {
  2630. wm3.set(p, gv);
  2631. }
  2632. return true;
  2633. },
  2634. enumerable: false,
  2635. configurable: true
  2636. });
  2637. */
  2638.  
  2639.  
  2640. }
  2641.  
  2642. let _cssSheet = null;
  2643. const addNewCSS = typeof CSSStyleSheet !== 'undefined' && document.adoptedStyleSheets ? (css) => {
  2644. if (!_cssSheet) {
  2645. _cssSheet = new CSSStyleSheet();
  2646. document.adoptedStyleSheets.push(_cssSheet);
  2647. }
  2648. _cssSheet.insertRule(`${css}`);
  2649. } : (css) => {
  2650. let nonce = document.querySelector('style[nonce]');
  2651. nonce = nonce ? nonce.getAttribute('nonce') : null;
  2652. const st = document.createElement('style');
  2653. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  2654. st.textContent = `${css}`;
  2655. let parent;
  2656. if (parent = document.head) parent.appendChild(st);
  2657. else if (parent = (document.body || document.documentElement)) parent.insertBefore(st, parent.firstChild);
  2658. }
  2659.  
  2660. function getTranslate() {
  2661.  
  2662. pLoad.then(() => {
  2663. addNewCSS(".yt-formatted-string-block-line{display:block;}");
  2664. });
  2665.  
  2666. const snCache = new Map();
  2667.  
  2668. if (TRANSLATE_DEBUG) {
  2669. console.log(11)
  2670. }
  2671.  
  2672. /** @type {(str: string?) => string} */
  2673. function _snippetText(str) {
  2674. // str can be underfinded
  2675. if (!str || typeof str !== 'string') return '';
  2676. let res = snCache.get(str);
  2677. if (res === undefined) {
  2678. let b = false;
  2679. res = str.replace(/[\s\u3000\u200b]*[\u200b\xA0\x20\n]+[\s\u3000\u200b]*/g, (m) => {
  2680. b = true;
  2681. return m.includes('\n') ? '\n' : m.replace(/\u200b/g, '').replace(/[\xA0\x20]+/g, ' ');
  2682. });
  2683. res = res.replace(/^[\s\u3000]+|[\u3000\s]+$/g, () => {
  2684. b = true;
  2685. return '';
  2686. });
  2687. if (b) {
  2688. snCache.set(str, res);
  2689. snCache.set(res, null);
  2690. } else {
  2691. res = null;
  2692. snCache.set(str, null);
  2693. }
  2694. }
  2695. return res === null ? str : res;
  2696. }
  2697.  
  2698. /** @type {(snippet: Object) => string} */
  2699. function snippetText(snippet) {
  2700. let runs = snippet.runs;
  2701. const n = runs.length;
  2702. if (n === 1) return _snippetText(runs[0].text);
  2703. let res = new Array(n);
  2704. let ci = 0;
  2705. for (const s of runs) {
  2706. res[ci++] = _snippetText(s.text);
  2707. }
  2708. return res.join('\n');
  2709. }
  2710.  
  2711. const _DEBUG_szz = (t) => t.map(x => {
  2712. const tsr = x.transcriptSegmentRenderer;
  2713. return ({
  2714. t: tsr.snippet.runs.map(x => x.text).join('//'),
  2715. a: tsr.startMs,
  2716. b: tsr.endMs
  2717. });
  2718. });
  2719.  
  2720. const fixRuns = (runs) => {
  2721. if (runs.length === 1 && runs[0]?.text?.includes('\n')) {
  2722. // https://www.youtube.com/watch?v=dmHJJ5k_G-A
  2723. const text = runs[0].text;
  2724. const nlc = text.includes('\r\n') ? '\r\n' : text.includes('\n\r') ? '\n\r' : text.includes('\r') ? '\r' : '\n';
  2725. const s = text.split(nlc);
  2726. let bi = 0;
  2727. runs.length = s.length;
  2728. for (const text of s) {
  2729. runs[bi++] = { ...runs[0], text, ...{blockLine: true} };
  2730. }
  2731. }
  2732. for (const s of runs) {
  2733. s.text = _snippetText(s.text);
  2734. }
  2735. }
  2736.  
  2737. function translate(initialSegments) {
  2738. // 2023.07.13 - fix initialSegments with transcriptSectionHeaderRenderer
  2739.  
  2740. if (!initialSegments) return initialSegments;
  2741.  
  2742. if (TRANSLATE_DEBUG) {
  2743. console.log(12);
  2744. Promise.resolve(JSON.stringify(initialSegments)).then((r) => {
  2745. let obj = JSON.parse(r);
  2746. console.log(7558, 1, obj)
  2747. return obj;
  2748. }).then(p => {
  2749. let obj = _DEBUG_szz(p)
  2750. console.log(7558, 2, obj)
  2751. })
  2752. }
  2753.  
  2754.  
  2755. //let mapRej = new WeakSet();
  2756.  
  2757. const n1 = initialSegments.length;
  2758. if (!n1) return fRes;
  2759. let n2 = 0;
  2760.  
  2761.  
  2762. const fRes = new Array(n1);
  2763. // -----------------------------------------------------------------------------------------
  2764.  
  2765. const s8 = Symbol();
  2766.  
  2767. {
  2768.  
  2769. /** @type {Map<String, Object>} */
  2770. let cacheTexts = new Map(); // avoid duplicate with javascript object properties
  2771.  
  2772. // /-* * @type {Map<String, number>} *-/
  2773. // let mh1 = new Map(); // avoid duplicate with javascript object properties
  2774. // 1: ok
  2775. // 2: abandoned effect text
  2776.  
  2777. for (const initialSegment of initialSegments) {
  2778. const transcript = (initialSegment || 0).transcriptSegmentRenderer;
  2779. if (!transcript) {
  2780. // https://www.youtube.com/watch?v=dmHJJ5k_G-A - transcriptSectionHeaderRenderer
  2781. fRes[n2++] = initialSegment;
  2782. continue;
  2783. }
  2784. const runs = transcript.snippet.runs
  2785. if (!runs || runs.length === 0) {
  2786. initialSegment[s8] = true;
  2787. continue;
  2788. }
  2789. let startMs = (+transcript.startMs || 0); //integer
  2790. let endMs = (+transcript.endMs || 0); //integer
  2791. if (startMs === endMs) {
  2792. // effect text
  2793. // https://www.youtube.com/watch?v=Ud73fm4Uoq0
  2794. //mapRej.add(initialSegment)
  2795. continue;
  2796. }
  2797. if (endMs - startMs < 30) {
  2798. continue;
  2799. }
  2800. const text = snippetText(transcript.snippet);
  2801. const hEntry = cacheTexts.get(text);
  2802. const mh1e = hEntry === undefined ? 0 : hEntry === null ? 2 : 1;
  2803. if (mh1e === 2) continue;
  2804. const entry = {
  2805. startMs,
  2806. endMs,
  2807. initialSegment,
  2808. text
  2809. };
  2810. if (mh1e === 0) {
  2811. if (/^[,.\x60\x27\x22\u200b\xA0\x20;-]*$/.test(text)) {
  2812. initialSegment[s8] = true;
  2813. cacheTexts.set(text, null);
  2814. //effect only
  2815. // https://www.youtube.com/watch?v=zLak0dxBKpM
  2816. //mapRej.add(initialSegment)
  2817. continue;
  2818. }
  2819. } else if (hEntry) {
  2820.  
  2821. const timeDiff = entry.startMs - hEntry.endMs;
  2822. let shouldMerge = false;
  2823.  
  2824. if (timeDiff >= 0) {
  2825.  
  2826. if (timeDiff < 25) {
  2827. shouldMerge = true;
  2828. } else if (timeDiff < 450 && entry.endMs - entry.startMs < 900) {
  2829. shouldMerge = true;
  2830. } else if (timeDiff < 150 && entry.endMs - entry.startMs > 800) {
  2831. shouldMerge = true;
  2832. }
  2833.  
  2834. if (shouldMerge && hEntry.endMs <= endMs && startMs <= endMs) {
  2835. // abandon the current entry.
  2836. // absorbed by previous entry
  2837. hEntry.endMs = entry.endMs;
  2838. hEntry.initialSegment.transcriptSegmentRenderer.endMs = entry.initialSegment.transcriptSegmentRenderer.endMs; // update fRes & initialSegments as well using object reference
  2839. //mapRej.add(entry.initialSegment);
  2840. continue;
  2841. }
  2842.  
  2843. } else if (entry.startMs < hEntry.startMs && hEntry.startMs < entry.endMs) {
  2844.  
  2845. // abandon the current entry.
  2846. // absorbed by previous entry
  2847. if (entry.endMs > hEntry.endMs) {
  2848. hEntry.endMs = entry.endMs;
  2849. hEntry.initialSegment.transcriptSegmentRenderer.endMs = entry.initialSegment.transcriptSegmentRenderer.endMs; // update fRes & initialSegments as well using object reference
  2850. }
  2851. //mapRej.add(entry.initialSegment);
  2852. continue;
  2853.  
  2854. }
  2855.  
  2856. }
  2857. //if not abandoned
  2858. cacheTexts.set(text, entry); //replace the previous valid entry object if any
  2859. // for (const s of runs) {
  2860. // s.text = _snippetText(s.text);
  2861. // }
  2862. fixRuns(runs);
  2863. fRes[n2++] = initialSegment;
  2864. }
  2865.  
  2866. // cacheTexts.clear(); // let GC do it.
  2867. cacheTexts = null;
  2868. // mh1.clear(); // let GC do it.
  2869. // mh1 = null;
  2870.  
  2871. }
  2872.  
  2873. const si_length = fRes.length = n2;
  2874. const sj_length = n1;
  2875.  
  2876. if (si_length !== sj_length) { // for equal length, no fix is required & ignore spacing fix
  2877. // collect the abandon text to become second subtitle
  2878.  
  2879. let sj_start = 0;
  2880. let invalid_sj = -1;
  2881. for (let si = 0; si < si_length; si++) {
  2882. const segment = fRes[si];
  2883. let transcript = segment.transcriptSegmentRenderer;
  2884. if (!transcript) continue; // e.g. transcriptSectionHeaderRenderer
  2885. const runs = transcript.snippet.runs;
  2886. // fixRuns(runs);
  2887. if (runs.length > 1 || runs[0].text.includes('\n')) continue; // skip multi lines
  2888. const main_startMs = (+transcript.startMs || 0);
  2889. const main_endMs = (+transcript.endMs || 0);
  2890. transcript = null;
  2891.  
  2892. /** @type {Map<string, number>} */
  2893. let tMap = new Map(); // avoid duplicate with javascript object properties
  2894.  
  2895. // assume that it is asc-ordered array of key startMs;
  2896. for (let sj = sj_start; sj < sj_length; sj++) {
  2897. const initialSegment = initialSegments[sj];
  2898.  
  2899. if (!initialSegment || initialSegment[s8]) continue; // should invalid_sj be set ?
  2900.  
  2901. const tSegment = initialSegment.transcriptSegmentRenderer;
  2902.  
  2903. if (!tSegment) {
  2904. // https://www.youtube.com/watch?v=dmHJJ5k_G-A - transcriptSectionHeaderRenderer
  2905. invalid_sj = sj; // should invalid_sj be set ?
  2906. continue;
  2907. }
  2908.  
  2909. const startMs = (+tSegment.startMs || 0)
  2910. const isStartValid = startMs >= main_startMs;
  2911. if (!isStartValid) {
  2912. invalid_sj = sj;
  2913. continue;
  2914. }
  2915. // isStartValid must be true
  2916. if (startMs > main_endMs) {
  2917. sj_start = invalid_sj + 1;
  2918. break;
  2919. }
  2920.  
  2921. const endMs = (+tSegment.endMs || 0)
  2922. if (endMs <= main_endMs) {
  2923. const mt = snippetText(tSegment.snippet);
  2924. const prev = tMap.get(mt);
  2925. if (endMs >= startMs) {
  2926. tMap.set(mt, (prev || 0) + 1 + (endMs - startMs));
  2927. }
  2928. }
  2929.  
  2930. }
  2931.  
  2932. if (tMap.size <= 1) continue; // no second line
  2933. let rg = [...tMap.entries()]; // N x 2 2D-array [string,number][]
  2934. tMap = null;
  2935.  
  2936. // https://www.youtube.com/watch?v=Ud73fm4Uoq0
  2937.  
  2938. rg.sort((a, b) => b[1] - a[1]); //descending order of number
  2939.  
  2940. let targetZ = rg[1][1];
  2941. if (targetZ > 4) {
  2942. let az = 0;
  2943. let fail = false;
  2944. for (let idx = 2, rgl = rg.length; idx < rgl; idx++) {
  2945. az += rg[idx][1];
  2946. if (az >= targetZ) {
  2947. fail = true;
  2948. break;
  2949. }
  2950. }
  2951. if (!fail) {
  2952. const rgA = rg[0][0];
  2953. const rgB = rg[1][0];
  2954. const isDiff = rgB.replace(/\s/g, '') !== rgA.replace(/\s/g, '');
  2955. if (isDiff && rgA === _snippetText(runs[0].text)) {
  2956. if (runs[0] && runs[0].text) runs[0].blockLine = true;
  2957. runs.push({ text: rgB, blockLine: true });
  2958. }
  2959. }
  2960. }
  2961. rg = null;
  2962. }
  2963.  
  2964. TRANSLATE_DEBUG && Promise.resolve(fRes).then((r) => {
  2965.  
  2966. let obj = r;
  2967. console.log(7559, 1, obj)
  2968. return obj;
  2969. }).then(p => {
  2970. let obj = _DEBUG_szz(p)
  2971. console.log(7559, 2, obj)
  2972.  
  2973. });
  2974. }
  2975.  
  2976. // -----------------------------------------------------------------------------------------
  2977. snCache.clear();
  2978. return fRes;
  2979.  
  2980. }
  2981.  
  2982.  
  2983. return translate
  2984.  
  2985. }
  2986.  
  2987.  
  2988. let translateFn = null;
  2989.  
  2990. FIX_TRANSCRIPT_SEGMENTS && !isChatRoomURL && (() => {
  2991.  
  2992. const wmx = new WeakMap();
  2993.  
  2994. function fixSegments(ytObj) {
  2995. let a, b;
  2996. let seg = ((a = ytObj.data) == null ? void 0 : a[b = 'searchResultSegments']) || ((a = ytObj.data) == null ? void 0 : a[b = 'initialSegments']) || [];
  2997. if (!seg || !a || !b || typeof (seg || 0) !== 'object' || !Number.isFinite(seg.length * 1)) return;
  2998. translateFn = translateFn || getTranslate();
  2999. let cSeg;
  3000. cSeg = wmx.get(seg);
  3001. if (!cSeg) {
  3002. let vSeg = null;
  3003. try {
  3004. vSeg = translateFn(seg);
  3005. } catch (e) {
  3006. }
  3007. if (seg && typeof seg === 'object' && seg.length >= 1 && vSeg && typeof vSeg === 'object' && vSeg.length >= 1) {
  3008. // console.log('translated', vSeg);
  3009. cSeg = vSeg;
  3010. wmx.set(seg, cSeg);
  3011. wmx.set(cSeg, cSeg);
  3012. }
  3013. }
  3014. if (cSeg && cSeg !== seg) {
  3015. a[b] = cSeg;
  3016. }
  3017. }
  3018.  
  3019. const dfn = Symbol();
  3020. const Object_ = Object;
  3021. Object_[dfn] = Object_.defineProperties;
  3022. let activation = true;
  3023. Object_.defineProperties = function (obj, pds) {
  3024. let segments, get_;
  3025. if (activation && pds && (segments = pds.segments) && (get_ = segments.get)) {
  3026. activation = false;
  3027. segments.get = function () {
  3028. fixSegments(this);
  3029. return get_.call(this);
  3030. };
  3031. }
  3032. return Object_[dfn](obj, pds);
  3033. };
  3034.  
  3035. })();
  3036.  
  3037.  
  3038. let pf31 = new PromiseExternal();
  3039.  
  3040. // native RAF
  3041. let __requestAnimationFrame__ = typeof webkitRequestAnimationFrame === 'function' ? window.webkitRequestAnimationFrame.bind(window) : window.requestAnimationFrame.bind(window);
  3042.  
  3043. // 1st wrapped RAF
  3044. const baseRAF = (callback) => {
  3045. return p59 ? __requestAnimationFrame__(callback) : __requestAnimationFrame__((hRes) => {
  3046. pf31.then(() => {
  3047. callback(hRes);
  3048. });
  3049. });
  3050. };
  3051.  
  3052. // 2nd wrapped RAF
  3053. window.requestAnimationFrame = baseRAF;
  3054.  
  3055. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  3056. const indr = o => insp(o).$ || o.$ || 0;
  3057.  
  3058. const prototypeInherit = (d, b) => {
  3059. const m = Object.getOwnPropertyDescriptors(b);
  3060. for (const p in m) {
  3061. if (!Object.getOwnPropertyDescriptor(d, p)) {
  3062. Object.defineProperty(d, p, m[p]);
  3063. }
  3064. }
  3065. };
  3066.  
  3067.  
  3068. const firstObjectKey = (obj) => {
  3069. for (const key in obj) {
  3070. if (obj.hasOwnProperty(key) && typeof obj[key] === 'object') return key;
  3071. }
  3072. return null;
  3073. };
  3074.  
  3075. function searchNestedObject(obj, predicate, maxDepth = 64) {
  3076. // normal case: depth until 36
  3077. const result = [];
  3078. const visited = new WeakSet();
  3079.  
  3080. function search(obj, depth) {
  3081. visited.add(obj);
  3082. for (const [key, value] of Object.entries(obj)) {
  3083. // Recursively search nested objects and arrays
  3084. if (value !== null && typeof value === 'object') {
  3085. // Prevent infinite loops by checking if the object is already visited or depth exceeded
  3086. if (depth + 1 <= maxDepth && !visited.has(value)) {
  3087. search(value, depth + 1);
  3088. }
  3089. } else if (predicate(value)) {
  3090. result.push([obj, key]);
  3091. }
  3092. }
  3093. }
  3094.  
  3095. typeof (obj || 0) === 'object' && search(obj, 0);
  3096. return result;
  3097. }
  3098.  
  3099. /** @type {(o: Object | null) => WeakRef | null} */
  3100. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  3101.  
  3102. /** @type {(wr: Object | null) => Object | null} */
  3103. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  3104.  
  3105. const isIterable = (obj) => (Symbol.iterator in Object_(obj));
  3106.  
  3107. if (typeof Document.prototype.requestStorageAccessFor === 'function') {
  3108. if (DENY_requestStorageAccess) {
  3109. // https://developer.mozilla.org/en-US/docs/Web/API/Document/requestStorageAccessFor
  3110. Document.prototype.requestStorageAccessFor = undefined;
  3111. console.log('[yt-js-engine-tamer]', 'requestStorageAccessFor is removed.');
  3112. } else if (DISABLE_IFRAME_requestStorageAccess && window !== top) {
  3113. Document.prototype.requestStorageAccessFor = function () {
  3114. return new Promise((resolve, reject) => {
  3115. reject();
  3116. });
  3117. };
  3118. }
  3119. }
  3120.  
  3121. const traceStack = (stack) => {
  3122. let result = new Set();
  3123. let p = new Set();
  3124. let u = ''
  3125. for (const s of stack.split('\n')) {
  3126. if (s.split(':').length < 3) continue;
  3127. let m = /(([\w-_\.]+):\d+:\d+)[^:\r\n]*/.exec(s);
  3128. if (!m) continue;
  3129. p.add(m[2]);
  3130. if (p.size >= 3) break;
  3131. if(!u) u = m[2];
  3132. else if(p.size === 2 && u && u=== m[2]) break;
  3133. result.add(s);
  3134. }
  3135. return [...result].join('\n');
  3136. }
  3137.  
  3138. if (FIX_bind_self_this && !Function.prototype.bind488 && !Function.prototype.bind588) {
  3139. // window.m3bb = new Set();
  3140.  
  3141. // const smb = Symbol();
  3142. const vmb = 'dtz02' // Symbol(); // return kThis for thisArg
  3143. const vmc = 'dtz04' // Symbol(); // whether it is proxied fn
  3144. const vmd = 'dtz08' // Symbol(); // self fn proxy (fn--fn)
  3145.  
  3146. const thisConversionFn = (thisArg) => {
  3147. if (!thisArg) return null;
  3148. const kThis = thisArg[vmb];
  3149. if (kThis) {
  3150. const ref = kThis.ref;
  3151. return (ref ? kRef(ref) : null) || null;
  3152. }
  3153. return thisArg;
  3154. }
  3155.  
  3156. const pFnHandler2 = {
  3157. get(target, prop) {
  3158. if (prop === vmc) return target;
  3159. return Reflect.get(target, prop);
  3160. },
  3161. apply(target, thisArg, argumentsList) {
  3162. thisArg = thisConversionFn(thisArg);
  3163. if (thisArg) return Reflect.apply(target, thisArg, argumentsList);
  3164. }
  3165. }
  3166.  
  3167.  
  3168. const proxySelfHandler = {
  3169. get(target, prop) {
  3170. if(prop === vmb) return target;
  3171. const ref = target.ref;
  3172. const cnt = kRef(ref);
  3173. if (!cnt) return;
  3174. if (typeof cnt[prop] === 'function' && !cnt[prop][vmc] && !cnt[prop][vmb]) {
  3175. if (!cnt[prop][vmd]) cnt[prop][vmd] = new Proxy(cnt[prop], pFnHandler2);
  3176. return cnt[prop][vmd];
  3177. }
  3178. return cnt[prop];
  3179. },
  3180. set(target, prop, value) {
  3181. const cnt = kRef(target.ref);
  3182. if (!cnt) return true;
  3183. if(value && (value[vmc] || value[vmb])){
  3184. cnt[prop] = value[vmc] || thisConversionFn(value);
  3185. return true;
  3186. }
  3187. cnt[prop] = value;
  3188. return true;
  3189. }
  3190. };
  3191.  
  3192. const weakWrap = (thisArg) => {
  3193. thisArg = thisConversionFn(thisArg);
  3194. if (!thisArg) {
  3195. console.error('thisArg is not found');
  3196. return null;
  3197. }
  3198. return new Proxy({ ref: mWeakRef(thisArg) }, proxySelfHandler);
  3199. }
  3200.  
  3201. if (!window.getComputedStyle533 && typeof window.getComputedStyle === 'function') {
  3202. window.getComputedStyle533 = window.getComputedStyle;
  3203. window.getComputedStyle = function (a, ...args) {
  3204. a = thisConversionFn(a);
  3205. if (a) {
  3206. return getComputedStyle533(a, ...args);
  3207. }
  3208. return null;
  3209. }
  3210. }
  3211.  
  3212. Function._count_bind_00 = 0;
  3213. // Function._count_bind_01 = 0;
  3214.  
  3215. // let matchNativeCode = (Object+"");
  3216. // let matchNativeCode1 = matchNativeCode.includes("[native code]");
  3217. // let matchNativeLen = matchNativeCode.length - Object.name.length;
  3218.  
  3219. // const matchConstructor = (thisArg) => {
  3220. // const f = `${(thisArg || 0).constructor}`;
  3221. // if (f.length > 45) return true;
  3222. // if (matchNativeCode1 && f.length - thisArg.constructor.name.length === matchNativeLen) {
  3223. // if (f.includes('[native code]')){
  3224. // return false;
  3225. // }
  3226. // return true;
  3227. // }
  3228. // return false;
  3229. // }
  3230.  
  3231. // const acceptThis = (thisArg)=>{
  3232. // // if(!thisArg || typeof thisArg !=='object') return false;
  3233. // // // if((((thisArg||0).constructor||0).name || 'XXXXXXXX').length < 3) return true;
  3234. // // if(typeof thisArg.path === 'string') return true;
  3235. // // if(typeof thisArg.fn === 'function') return true;
  3236. // // if(typeof thisArg.id === 'string') return true;
  3237. // // if(typeof thisArg.isLoaded === 'boolean') return true;
  3238. // return false;
  3239. // }
  3240.  
  3241. const patchFn = (fn) => {
  3242.  
  3243. let s = `${fn}`;
  3244. if (s.length < 11 || s.includes('\n')) return false;
  3245. if(s.includes('bind(this')) return true;
  3246. if(s.includes('=this') && /[,\s][a-zA-Z_][a-zA-Z0-9_]*=this[;,]/.test(s) ) return true;
  3247. // var a=this;
  3248. // f.bind(this)
  3249.  
  3250.  
  3251. return false;
  3252. }
  3253.  
  3254. Function.prototype.bind488 = Function.prototype.bind;
  3255. Function.prototype.bind = function(thisArg, ...args){
  3256.  
  3257. if (thisConversionFn(thisArg) !== thisArg) {
  3258. return this.bind488(thisArg, ...args);
  3259. }
  3260. if( thisArg && patchFn(this) ){
  3261.  
  3262. // console.log(599,`${this}`)
  3263.  
  3264. try {
  3265. // let b1 = thisArg && typeof thisArg === 'object' && typeof thisArg.isAttached === 'boolean' && !thisArg.dtz06; // ready cnt
  3266. // let b2 = !b1 && thisArg && (thisArg instanceof Node) && typeof thisArg.nodeName === 'string' && !thisArg.dtz06; // dom
  3267. // let b3 = !b1 && !b2 && thisArg && typeof thisArg === 'object' && typeof thisArg.is === 'string' && !thisArg.dtz06; // init stage ?
  3268. // // let b4 = !b1 && !b2 && !b3 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && matchConstructor(thisArg);
  3269. // // let b5 = !b1 && !b2 && !b3 && !b4 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && acceptThis(thisArg);
  3270. // // let b5 = !b1 && !b2 && !b3 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && !(thisArg instanceof Window);
  3271. // // let b4 = false;
  3272. // let b4 = !b1 && !b2 && !b3 && thisArg && !thisArg.dtz06;
  3273.  
  3274. // // b3 = false;
  3275. // // b4 = false;
  3276. // // b5 = false;
  3277.  
  3278. // if (b1 || b2 || b3 ||b4 ) {
  3279. const f = this;
  3280. const ps = thisArg.__proxySelf0__ || (thisArg.__proxySelf0__ = weakWrap(thisArg));
  3281. if (ps && ps[vmb]) {
  3282. Function._count_bind_00++;
  3283. return f.bind488(ps, ...args)
  3284. }
  3285. // }
  3286. } catch (e) {
  3287. console.warn(e)
  3288. }
  3289. }
  3290. return this.bind488(thisArg, ...args);
  3291. }
  3292. Function.prototype.bind588 = 1;
  3293. }
  3294.  
  3295. const ytSchedulerMethods = {
  3296. addJob(a, b, c) {
  3297. const instance = typeof yt !== 'undefined' ? ((yt || 0).scheduler || 0).instance : null;
  3298. if (instance) {
  3299. return instance.addJob(a, b, c);
  3300. } else {
  3301. return setTimeout(a, c);
  3302. }
  3303. },
  3304. addImmediateJob(a) {
  3305. const instance = typeof yt !== 'undefined' ? ((yt || 0).scheduler || 0).instance : null;
  3306. if (instance) {
  3307. return instance.addImmediateJob(a);
  3308. } else {
  3309. a();
  3310. }
  3311. },
  3312. cancelJob(id) {
  3313. const instance = typeof yt !== 'undefined' ? ((yt || 0).scheduler || 0).instance : null;
  3314. if (instance) {
  3315. return instance.cancelJob(id);
  3316. } else {
  3317. return clearTimeout(id);
  3318. }
  3319. }
  3320. };
  3321.  
  3322. if (FIX_ytScheduler) {
  3323.  
  3324. let ytSchedulerFixed = 0;
  3325. // let ytActioned = false;
  3326. // let pr = new PromiseExternal();
  3327.  
  3328. // const hn = function () {
  3329.  
  3330. // document.removeEventListener('yt-action', hn, true);
  3331. // nextBrowserTick_(() => {
  3332. // ytActioned = true;
  3333. // pr.resolve();
  3334. // });
  3335.  
  3336. // }
  3337. // document.addEventListener('yt-action', hn, true);
  3338.  
  3339. // let cancelStore = {}; // tbc
  3340.  
  3341. // yt.scheduler.instance.addJob
  3342. const fixAddJob = (nv) => {
  3343.  
  3344. /*
  3345. function Z() {
  3346. var a = w("ytglobal.schedulerInstanceInstance_");
  3347. if (!a || a.s)
  3348. a = new M(I("scheduler") || {}),
  3349. x("ytglobal.schedulerInstanceInstance_", a);
  3350. return a
  3351. }
  3352. */
  3353.  
  3354. /*
  3355. function R(a, b, c, d) {
  3356. ++a.D;
  3357. if (c === 10)
  3358. return P(a, b),
  3359. a.D;
  3360. var e = a.D;
  3361. a.h[e] = b;
  3362. a.l && !d ? a.u.push({
  3363. id: e,
  3364. priority: c
  3365. }) : (a.i[c].push(e),
  3366. a.C || a.l || (a.g !== 0 && S(a) !== a.m && T(a),
  3367. a.start()));
  3368. return e
  3369. }
  3370. */
  3371.  
  3372. /*
  3373. function sa(a, b, c) {
  3374. if (!c)
  3375. return c = c === void 0,
  3376. -R(Z(), a, b, c);
  3377. var d = window.setTimeout(function() {
  3378. var e = R(Z(), a, b);
  3379. W[d] = e
  3380. }, c);
  3381. return d
  3382. }
  3383. */
  3384. window.originalAddJob = nv;
  3385. // const q1 = new PromiseExternal();
  3386. // const q2 = new PromiseExternal();
  3387. // let uu = 0;
  3388. // let q3 = 0;
  3389. // let mof = null;
  3390. // const mo = new MutationObserver((mutation, observer) => {
  3391. // if (mof) {
  3392. // if (mof() === true) {
  3393. // observer.disconnect();
  3394. // mof = null;
  3395. // }
  3396. // }
  3397. // });
  3398.  
  3399. let lenSkip = -1;
  3400. let lastLen = null;
  3401. let fetchCommentJobTimerId = 0;
  3402. let requestFinish = false;
  3403.  
  3404. const fetchCommentJobDone = ()=>{
  3405. clearInterval(fetchCommentJobTimerId);
  3406. fetchCommentJobTimerId = 0;
  3407. console.log('[yt-js-engine-tamer] fetchCommentJob done');
  3408. }
  3409.  
  3410. const fetchCommentJob = (a, cid) => {
  3411.  
  3412. // if (cid && cancelStore[cid]) return; // tbc
  3413.  
  3414. if(fetchCommentJobTimerId > 0){
  3415. fetchCommentJobDone();
  3416. }
  3417.  
  3418. // if (mof) {
  3419. // console.log('[yt-js-engine-tamer] fetchCommentJob done');
  3420. // mof = null;
  3421. // }
  3422.  
  3423. let f = a;
  3424.  
  3425. const selector = 'ytd-comments, ytd-comments > *, ytd-comments [id] > *, ytd-comments ytd-continuation-item-renderer';
  3426.  
  3427. console.log('[yt-js-engine-tamer] fetchCommentJob start');
  3428.  
  3429. lastLen = -1;
  3430. let u = 0;
  3431. let g = () => {
  3432. if (requestFinish) lastLen = -1;
  3433. const lastLen_ = lastLen;
  3434. const len1 = lastLen = document.querySelectorAll(selector).length;
  3435. let mm = true;
  3436. let ff = false;
  3437. if (len1 !== lastLen_) {
  3438. u = 0;
  3439. f();
  3440. const len2 = lastLen = document.querySelectorAll(selector).length;
  3441. if (len2 !== len1) {
  3442. ff = true;
  3443. mm = false;
  3444. }
  3445. }
  3446. if (mm) {
  3447. ++u;
  3448. if (u > 10 || document.querySelector('ytd-comments:not([hidden]) [id]')) {
  3449. ff = true;
  3450. }
  3451. }
  3452.  
  3453. if (requestFinish) {
  3454. requestFinish = false;
  3455. fetchCommentJobDone();
  3456. } else if (ff){
  3457. fetchCommentJobDone();
  3458. }
  3459.  
  3460. }
  3461.  
  3462.  
  3463. fetchCommentJobTimerId = setInterval(g, 80);
  3464. // g(9);
  3465. // if (lastLen === lenSkip) {
  3466. // console.log('[yt-js-engine-tamer] fetchCommentJob done');
  3467. // g = f = null;
  3468. // return;
  3469. // }
  3470. // console.log('[yt-js-engine-tamer] fetchCommentJob done');
  3471. // const q1 = lastLen;
  3472. // mof = () => {
  3473. // const q2 = document.querySelectorAll(selector).length;
  3474. // if (q1 === q2) return;
  3475. // fetchCommentJobTimerId = setTimeout(g, 80);
  3476. // g = null;
  3477. // return true;
  3478. // }
  3479. // mo.observe(document, { childList: true, subtree: true });
  3480.  
  3481. }
  3482.  
  3483. // let pr72 = Promise.resolve();
  3484.  
  3485.  
  3486. let qa = null;
  3487. let qasf = '';
  3488.  
  3489.  
  3490. document.addEventListener("fullscreenchange", (evt) => {
  3491. if (evt.isTrusted !== true) return;
  3492. if (qa) {
  3493. // qa();
  3494. nextBrowserTick_(qa);
  3495. }
  3496. // const pr = new Promise(resolve => { setTimeout(resolve, 94.25) });
  3497. // pr72 = pr72.then(() => {
  3498. // return pr
  3499. // });
  3500. }, true);
  3501.  
  3502. window.addEventListener("resize", (evt) => {
  3503. if (evt.isTrusted !== true) return;
  3504. if (qa) {
  3505. // qa();
  3506. nextBrowserTick_(qa);
  3507. }
  3508. // const pr = new Promise(resolve => { setTimeout(resolve, 94.25) });
  3509. // pr72 = pr72.then(() => {
  3510. // return pr
  3511. // });
  3512. }, true);
  3513.  
  3514.  
  3515. setInterval(() => {
  3516. const f = qa;
  3517. if (typeof f !== 'function') return;
  3518. qa = null;
  3519. // pr72 = pr72.then(() => {
  3520. // f();
  3521. // });
  3522. // nextBrowserTick_(()=>{
  3523. f();
  3524. // });
  3525. }, 475.25);
  3526.  
  3527.  
  3528.  
  3529. return function (a, b, c) {
  3530.  
  3531.  
  3532. const f = a;
  3533. // const g = ()=>{
  3534. // pr72 = pr72.then(()=>{
  3535. // f();
  3536. // });
  3537. // }
  3538.  
  3539. if (!c) return arguments.length < 3 ? nv(f, b) : nv(f, b, c);
  3540.  
  3541. const c_ = c;
  3542.  
  3543. if (c > 0.25 && (c % 1) === 0) c -= 0.125;
  3544.  
  3545. if (b === 1 && c_ === 500) {
  3546. const sf = `${a}`;
  3547. if (qasf ? (sf === qasf) : (sf.includes('.mediaElement') && sf.includes('.getCurrentTime') && sf.includes('.seekTo'))) {
  3548. qasf = sf;
  3549. qa = a;
  3550. // console.log(12883, a)
  3551. return nv(() => {
  3552. if (qa === a) {
  3553. qa = null;
  3554. a();
  3555. }
  3556. }, b, c);
  3557. }
  3558. }
  3559.  
  3560.  
  3561. if (!b && c_ === 5000 && `${a}`.includes('.cleanupJob=0')) {
  3562. // console.log('[yt-js-engine-tamer] cleanupJob 01');
  3563. // const pr = new Promise(resolve => { setTimeout(resolve, 94.25) });
  3564. // pr72 = pr72.then(() => {
  3565. // return pr
  3566. // });
  3567. // try {
  3568. // yt.scheduler.instance.cancelAllJobs();
  3569. // yt.scheduler.instance.dispose();
  3570. // if(ytglobal.schedulerInstanceInstance_) ytglobal.schedulerInstanceInstance_.dispose();
  3571. // console.log('[yt-js-engine-tamer] cleanupJob 02');
  3572. // } catch (e) { }
  3573. return nv(f, b, c);
  3574. }
  3575.  
  3576. // if(!b && c > 50) c = 50;
  3577. // console.log(58372,a,b,c)
  3578. // function(){xxx(xxx)}
  3579. if (!b && c_ === 1000 && `${a}`.length <= 20 && a.name === '' && /function\(\)\{\w{1,3}\(\w{1,3}\)\}/.test(`${a}`)) {
  3580.  
  3581. /*
  3582.  
  3583. V.setCommentsJobId = _.et(_.r0, function() {
  3584. F5V(V)
  3585. }, 1E3)
  3586.  
  3587. */
  3588.  
  3589. requestFinish = false;
  3590. const cid = nv(() => { if(fetchCommentJobTimerId > 0) requestFinish = true;}, b, 1000);
  3591.  
  3592. // lastLen = null;
  3593. fetchCommentJob(a, cid);
  3594.  
  3595. // queueMicrotask_(a);
  3596. // nextBrowserTick_(a);
  3597. // a(); // no need to delay
  3598. return cid
  3599.  
  3600. // return nv(a, b, 1.125);
  3601. // const cid = window.setTimeout(() => {
  3602. // nextBrowserTick_(() => {
  3603. // if (cancelStore[cid]) {
  3604. // console.log('task cancelled');
  3605. // return;
  3606. // }
  3607. // a();
  3608.  
  3609. // });
  3610. // }, 0.125);
  3611. // return cid;
  3612. } else {
  3613.  
  3614.  
  3615.  
  3616. return nv(f,b,c);
  3617.  
  3618.  
  3619. // if (c > 2400) c = 2400;
  3620. // else if (c > 800) c = 800;
  3621. // if (c > 0.2 && (c % 1) === c) c -= 0.125;
  3622. // if (0 && ytActioned && !b) {
  3623. // const cid = window.setTimeout(() => {
  3624. // nextBrowserTick_(() => {
  3625. // if (cancelStore[cid]) {
  3626. // console.log('task cancelled');
  3627. // return;
  3628. // }
  3629. // a();
  3630. // });
  3631. // }, c);
  3632. // return cid;
  3633. // } else {
  3634. // return nv(a, b, c);
  3635. // }
  3636.  
  3637. }
  3638. }
  3639. }
  3640.  
  3641. const fixCancelJob = (nv) => {
  3642.  
  3643.  
  3644. window.originalCancelJob = nv;
  3645. return function (a) {
  3646. if (a < 0) return nv(a);
  3647. // cancelStore[a] = true; // tbc
  3648. nv(a);
  3649. }
  3650. }
  3651.  
  3652. const sk44 = Symbol();
  3653. Object.defineProperty(Object.prototype, 'addJob', {
  3654. get() {
  3655. return this[sk44];
  3656. },
  3657. set(nv) {
  3658. if (typeof nv === 'function' && !(ytSchedulerFixed & 1) && typeof yt !== 'undefined' && this === ((yt || 0).scheduler || 0).instance) {
  3659. ytSchedulerFixed |= 1;
  3660. nv = fixAddJob(nv);
  3661. }
  3662. this[sk44] = nv;
  3663. return true;
  3664. },
  3665. enumerable: false,
  3666. configurable: true
  3667. });
  3668.  
  3669.  
  3670.  
  3671. const sk45 = Symbol();
  3672. Object.defineProperty(Object.prototype, 'cancelJob', {
  3673. get() {
  3674. return this[sk45];
  3675. },
  3676. set(nv) {
  3677. if (typeof nv === 'function' && !(ytSchedulerFixed & 2) && typeof yt !== 'undefined' && this === ((yt || 0).scheduler || 0).instance) {
  3678. ytSchedulerFixed |= 2;
  3679. nv = fixCancelJob(nv);
  3680. }
  3681. this[sk45] = nv;
  3682. return true;
  3683. },
  3684. enumerable: false,
  3685. configurable: true
  3686. });
  3687.  
  3688.  
  3689.  
  3690. if (typeof yt !== 'undefined' && this === ((yt || 0).scheduler || 0).instance) {
  3691. const { addJob, cancelJob } = yt.scheduler.instance;
  3692. if (addJob) {
  3693. yt.scheduler.instance.addJob = null;
  3694. yt.scheduler.instance.addJob = addJob;
  3695. }
  3696. if (cancelJob) {
  3697. yt.scheduler.instance.cancelJob = null;
  3698. yt.scheduler.instance.cancelJob = cancelJob;
  3699. }
  3700. }
  3701.  
  3702.  
  3703. }
  3704.  
  3705.  
  3706. if (FIX_weakMap_weakRef && !window.WeakMapOriginal && typeof window.WeakMap === 'function' && typeof WeakRef === 'function') {
  3707. const WeakMapOriginal = window.WeakMapOriginal = window.WeakMap;
  3708. const wm6 = new WeakMapOriginal();
  3709.  
  3710. const skipW = new WeakSet();
  3711.  
  3712.  
  3713. window.WeakMap = class WeakMap extends WeakMapOriginal {
  3714. constructor(iterable = undefined) {
  3715. super();
  3716. if (iterable && iterable[Symbol.iterator]) {
  3717. for (const entry of iterable) {
  3718. entry && this.set(entry[0], entry[1]);
  3719. }
  3720. }
  3721. }
  3722. delete(a) {
  3723. if (!this.has(a)) return false;
  3724. super.delete(a);
  3725. return true;
  3726. }
  3727. get(a) {
  3728. const p = super.get(a);
  3729. if (p && typeof p === 'object' && p.deref && !skipW.has(p)) {
  3730. let v = kRef(p);
  3731. if (!v) {
  3732. super.delete(a);
  3733. }
  3734. return v || undefined;
  3735. }
  3736. return p;
  3737. }
  3738. has(a) {
  3739. if (!super.has(a)) return false;
  3740. const p = super.get(a);
  3741. if (p && typeof p === 'object' && p.deref && !skipW.has(p)) {
  3742. if (!kRef(p)) {
  3743. super.delete(a);
  3744. return false;
  3745. }
  3746. }
  3747. return true;
  3748. }
  3749. set(a, b) {
  3750. let wq = b;
  3751. if (b && (typeof b === 'function' || typeof b === 'object')) {
  3752. if (b.deref) {
  3753. skipW.add(b);
  3754. wq = b;
  3755. } else {
  3756. wq = wm6.get(b);
  3757. if (!wq) {
  3758. wq = mWeakRef(b);
  3759. wm6.set(b, wq);
  3760. }
  3761. }
  3762. }
  3763. super.set(a, wq);
  3764. return this;
  3765. }
  3766. }
  3767. Object.defineProperty(window.WeakMap, Symbol.toStringTag, {
  3768. configurable: true,
  3769. enumerable: false,
  3770. value: "WeakMap",
  3771. writable: false
  3772. });
  3773. }
  3774.  
  3775. const isWatchPageURL = (url) => {
  3776. url = url || location;
  3777. return location.pathname === '/watch' || location.pathname.startsWith('/live/')
  3778. };
  3779.  
  3780. const isCustomElementsProvided = typeof customElements !== "undefined" && typeof (customElements || 0).whenDefined === "function";
  3781.  
  3782. const promiseForCustomYtElementsReady = isCustomElementsProvided ? Promise.resolve(0) : new Promise((callback) => {
  3783. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  3784. if (typeof customElements === 'undefined') {
  3785. if (!('__CE_registry' in document)) {
  3786. // https://github.com/webcomponents/polyfills/
  3787. Object.defineProperty(document, '__CE_registry', {
  3788. get() {
  3789. // return undefined
  3790. },
  3791. set(nv) {
  3792. if (typeof nv == 'object') {
  3793. delete this.__CE_registry;
  3794. this.__CE_registry = nv;
  3795. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  3796. }
  3797. return true;
  3798. },
  3799. enumerable: false,
  3800. configurable: true
  3801. })
  3802. }
  3803. let eventHandler = (evt) => {
  3804. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  3805. const f = callback;
  3806. callback = null;
  3807. eventHandler = null;
  3808. f();
  3809. };
  3810. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  3811. } else {
  3812. callback();
  3813. }
  3814. });
  3815.  
  3816. const whenCEDefined = isCustomElementsProvided
  3817. ? (nodeName) => customElements.whenDefined(nodeName)
  3818. : (nodeName) => promiseForCustomYtElementsReady.then(() => customElements.whenDefined(nodeName));
  3819.  
  3820. FIX_perfNow && performance.timeOrigin > 9 && (() => {
  3821. if (performance.now23 || performance.now16 || typeof Performance.prototype.now !== 'function') return;
  3822. const f = performance.now23 = Performance.prototype.now;
  3823.  
  3824. let k = 0; // 0 <= k < 9998m
  3825. let u = 0;
  3826. let s = ((performance.timeOrigin % 7) + 1) / 7 - 1e-2 / 7; // s > 0.14
  3827.  
  3828. // By definition, performance.now() is mono increasing.
  3829. // Fixing in YouTube.com is required to ensure performance.now() is strictly increasing.
  3830. performance.now = performance.now16 = function () {
  3831. /**
  3832. * Bug 1842437 - When attempting to go back on youtube.com, the content remains the same
  3833. *
  3834. * If consecutive session history entries had history.state.entryTime set to same value,
  3835. * back button doesn't work as expected. The entryTime value is coming from performance.now()
  3836. * and modifying its return value slightly to make sure two close consecutive calls don't
  3837. * get the same result helped with resolving the issue.
  3838. */
  3839. // see https://bugzilla.mozilla.org/show_bug.cgi?id=1756970
  3840. // see https://bugzilla.mozilla.org/show_bug.cgi?id=1842437
  3841.  
  3842. const v = typeof (this || 0).now23 === 'function' ? this.now23() + s : f.call(performance) + s; // v > 0.14
  3843. if (u + 0.0015 < (u = v)) k = 0; // note: hRes should be accurate to 5 µs in isolated contexts
  3844. else if (k < 0.001428) k += 1e-6 / 7; // M = 10000 * m; m * 9996 = 0.001428
  3845. else { // more than 9998 consecutive calls
  3846. /**
  3847. *
  3848. * max no. of consecutive calls
  3849. *
  3850. * Sample Size: 4800
  3851. * Sample Avg = 1565.375
  3852. * Sample Median = 1469.5
  3853. * Sample Max = 5660 << 7500 << 9999
  3854. *
  3855. *
  3856. * */
  3857. k = 0;
  3858. s += 1 / 7;
  3859. }
  3860. return v + k; // 0 < v - M < v - M + k < v
  3861. }
  3862.  
  3863. let loggerMsg = '';
  3864. if (`${performance.now()}` === `${performance.now()}`) {
  3865. const msg1 = 'performance.now is modified but performance.now() is not strictly increasing.';
  3866. const msg2 = 'performance.now cannot be modified and performance.now() is not strictly increasing.';
  3867. loggerMsg = performance.now !== performance.now16 ? msg1 : msg2; // might not able to set in Firefox
  3868. }
  3869. loggerMsg && console.warn(loggerMsg);
  3870. })();
  3871.  
  3872. // let __forceRemoveMode__ = false;
  3873. FIX_removeChild && (() => {
  3874. if (typeof Node.prototype.removeChild === 'function' && typeof Node.prototype.removeChild062 !== 'function') {
  3875. let internalByPass = false;
  3876. const fragD = document.createDocumentFragment();
  3877. fragD.appendChild4201 = fragD.appendChild;
  3878. fragD.removeChild4201 = fragD.removeChild;
  3879. Node.prototype.removeChild062 = Node.prototype.removeChild;
  3880. Node.prototype.removeChild = function (child) {
  3881. try {
  3882. return this.removeChild062(child);
  3883. } catch (e) { }
  3884. if (internalByPass) return child;
  3885. if (this instanceof Node && child instanceof Node && this.nodeType === 11 && child.parentNode !== this && this.contains(child)) { // eg. child = DOM-IF
  3886. let idx = (this.childNodes || 0).length >= 1 ? this.childNodes.indexOf(child) : -1;
  3887. if (idx >= 0) {
  3888. internalByPass = true;
  3889. child.parentNode !== fragD && fragD.appendChild4201(child);
  3890. this.childNodes[idx] === child && typeof this.childNodes.splice === 'function' && this.childNodes.splice(idx, 1);
  3891. fragD.removeChild4201(child);
  3892. internalByPass = false;
  3893. return child;
  3894. }
  3895. }
  3896. // if (this instanceof Node && child instanceof Node && child.parentNode && child.parentNode.nodeType === 11 && child.parentNode !== this && !this.contains(child)) {
  3897. // // force removal
  3898. // internalByPass = true;
  3899. // child.parentNode !== fragD && fragD.appendChild4201(child);
  3900. // fragD.removeChild4201(child);
  3901. // internalByPass = false;
  3902. // return child;
  3903. // }
  3904. if (this && child) {
  3905. if (this.childNodes && this.childNodes.splice) { // tbc
  3906. let idx = (this.childNodes || 0).length >= 1 ? this.childNodes.indexOf(child) : -1;
  3907. if (idx >= 0) {
  3908. internalByPass = true;
  3909. child.parentNode !== fragD && fragD.appendChild4201(child);
  3910. this.childNodes[idx] === child && typeof this.childNodes.splice === 'function' && this.childNodes.splice(idx, 1);
  3911. fragD.removeChild4201(child);
  3912. internalByPass = false;
  3913. return child;
  3914. }
  3915. }
  3916.  
  3917. if (child.parentNode !== this && child.parentNode && child.parentNode === child.__shady_parentNode && child.parentNode.nodeType === 11) {
  3918. if (child.isConnected === false && (this.compareDocumentPosition(child) & (1 | 8 | 16)) === 1) {
  3919. // just ignore (!e.root && a.localName !== "slot" || f === a.__shady_native_parentNode) && f.__shady_native_removeChild(a));
  3920. return child;
  3921. }
  3922. }
  3923.  
  3924. if (child && child.is === 'tp-yt-paper-tooltip' && !child.parentNode && !child.__shady_parentNode) {
  3925. // skip
  3926. return child;
  3927. }
  3928.  
  3929. console.warn('[yt-js-engine-tamer] Node is not removed from parent', {
  3930. parent: this, child: child,
  3931. isParent: child.parentNode === this,
  3932. isParentParent: (child.parentNode || 0).parentNode === this,
  3933. parentNode: child.parentNode,
  3934. shadyParent: child.__shady_parentNode,
  3935. isShadyParent: child.__shady_parentNode === this,
  3936. isAncestor: this instanceof Node && child instanceof Node && this.contains(child)
  3937. });
  3938.  
  3939. }
  3940. return child;
  3941. }
  3942. }
  3943. })();
  3944.  
  3945.  
  3946. FIX_VIDEO_PLAYER_MOUSEHOVER_EVENTS && !isChatRoomURL && (() => {
  3947.  
  3948. const [setIntervalX0, clearIntervalX0] = [setInterval, clearInterval];
  3949.  
  3950. // let cid = 0;
  3951.  
  3952. let mousemoveFn = null;
  3953. let mousemoveDT = 0;
  3954. let mousemoveCount = 0;
  3955. // let qv = false;
  3956. const cif = () => {
  3957. if (!mousemoveFn) return;
  3958. const ct = Date.now();
  3959. if (mousemoveDT + 1200 > ct) { // avoid setTimeout delay too long without execution
  3960. mousemoveFn && mousemoveFn();
  3961. }
  3962. mousemoveFn = null;
  3963. };
  3964. let mousemoveCId = 0;
  3965. let mouseoverFn = null;
  3966. HTMLElement_.prototype.addEventListener4882 = HTMLElement_.prototype.addEventListener;
  3967. HTMLElement_.prototype.addEventListener = function (a, b, c) {
  3968. if (this.id == 'movie_player' && `${a}`.startsWith('mouse') && c === undefined) {
  3969. const bt = `${b}`;
  3970. if (bt.length >= 61 && bt.length <= 71 && bt.startsWith('function(){try{return ') && bt.includes('.apply(this,arguments)}catch(')) {
  3971. b[`__$$${a}$$1926__`] = true;
  3972. this[`__$$${a}$$1937__`] = (this[`__$$${a}$$1937__`] || 0) + 1;
  3973. if (this[`__$$${a}$$1937__`] > 1073741823) this[`__$$${a}$$1937__`] -= 536870911;
  3974. // console.log(3928, a, this[`__$$${a}$$1937__`])
  3975. if (!this[`__$$${a}$$1938__`]) {
  3976. this[`__$$${a}$$1938__`] = b;
  3977. if (a === 'mousemove') {
  3978. this.addEventListener4882('mouseenter', (evt) => {
  3979. if (mousemoveCId) return;
  3980. mousemoveCId = setIntervalX0(cif, 380);
  3981. });
  3982. this.addEventListener4882('mouseleave', (evt) => {
  3983. clearIntervalX0(mousemoveCId);
  3984. mousemoveCId = 0;
  3985. });
  3986. }
  3987. this.addEventListener4882(a, (evt) => {
  3988. const evt_ = evt;
  3989. if (!this[`__$$${a}$$1937__`]) return;
  3990. if (!this[`__$$${a}$$1938__`]) return;
  3991. if (a === 'mousemove') {
  3992. mouseoverFn && mouseoverFn();
  3993. if (mousemoveDT + 350 > (mousemoveDT = Date.now())) {
  3994. (++mousemoveCount > 1e9) && (mousemoveCount = 9);
  3995. } else {
  3996. mousemoveCount = 0;
  3997. }
  3998. const f = mousemoveFn = () => {
  3999. if (f !== mousemoveFn) return;
  4000. mousemoveFn = null;
  4001. this[`__$$${a}$$1938__`](evt_);
  4002. };
  4003. if (mousemoveCount <= 1) mousemoveFn();
  4004. } else {
  4005. if (a === 'mouseout' || a === 'mouseleave') {
  4006. mousemoveFn = null;
  4007. mousemoveDT = 0;
  4008. mousemoveCount = 0;
  4009. this[`__$$${a}$$1938__`](evt_);
  4010. mouseoverFn && mouseoverFn();
  4011. } else { // mouseover, mouseenter
  4012. mousemoveFn = null;
  4013. mousemoveDT = 0;
  4014. mousemoveCount = 0;
  4015. mouseoverFn && mouseoverFn(); // just in case
  4016. const f = mouseoverFn = () => {
  4017. if (f !== mouseoverFn) return;
  4018. mouseoverFn = null;
  4019. this[`__$$${a}$$1938__`](evt_);
  4020. }
  4021. nextBrowserTick_(mouseoverFn);
  4022. }
  4023. }
  4024. }, c);
  4025.  
  4026.  
  4027. return;
  4028. } else {
  4029.  
  4030. return;
  4031. }
  4032. }
  4033.  
  4034. }
  4035. return this.addEventListener4882(a, b, c)
  4036. }
  4037.  
  4038.  
  4039.  
  4040.  
  4041. HTMLElement_.prototype.removeEventListener4882 = HTMLElement_.prototype.removeEventListener;
  4042. HTMLElement_.prototype.removeEventListener = function (a, b, c) {
  4043. if (this.id == 'movie_player' && `${a}`.startsWith('mouse') && c === undefined) {
  4044.  
  4045. if (b[`__$$${a}$$1926__`]) {
  4046. b[`__$$${a}$$1926__`] = false;
  4047.  
  4048. if (this[`__$$${a}$$1937__`]) this[`__$$${a}$$1937__`] -= 1;
  4049.  
  4050. // console.log(3929, a, this[`__$$${a}$$1937__`], b[`__$$${a}$$1926__`])
  4051.  
  4052. return;
  4053.  
  4054. }
  4055.  
  4056. }
  4057. return this.removeEventListener4882(a, b, c)
  4058. }
  4059.  
  4060.  
  4061. })();
  4062.  
  4063.  
  4064. FIX_DOM_IF_REPEAT && (() => {
  4065. // https://www.youtube.com/s/desktop/26a583e4/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  4066. // DOM-IF is still a core class of Polymer, so no polymerController is available.
  4067. // Be careful of the mixture of polymer functions and native Element functions
  4068. // Be careful of the coding design is different with the modern Yt elements
  4069.  
  4070.  
  4071. /*
  4072.  
  4073.  
  4074. function Ks(a, b, c) {
  4075. if (kj && !BOa(a))
  4076. throw Error("strictTemplatePolicy: template owner not trusted");
  4077. c = c || {};
  4078. if (a.__templatizeOwner)
  4079. throw Error("A <template> can only be templatized once");
  4080. a.__templatizeOwner = b;
  4081. var d = (b ? b.constructor : Js)._parseTemplate(a)
  4082. , e = d.templatizeInstanceClass;
  4083. e || (e = COa(a, d, c),
  4084. d.templatizeInstanceClass = e);
  4085. var g = BOa(a);
  4086. EOa(a, d, c, g);
  4087. c = function() {
  4088. return e.apply(this, arguments) || this
  4089. }
  4090. ;
  4091. h(c, e);
  4092. c.prototype._methodHost = g;
  4093. c.prototype.__dataHost = a;
  4094. c.prototype.__templatizeOwner = b;
  4095. c.prototype.__hostProps = d.hostProps;
  4096. return c
  4097. }
  4098.  
  4099. */
  4100.  
  4101. // Polymer.enqueueDebouncer
  4102.  
  4103. const s81 = Symbol();
  4104. const s83 = Symbol();
  4105. const s84 = Symbol();
  4106. const s85 = Symbol();
  4107. const s85b = Symbol();
  4108. const s85c = Symbol();
  4109.  
  4110. let renderDebounceTs = null;
  4111.  
  4112. let renderDebouncePromise = null;
  4113. let qp;
  4114.  
  4115. let cme = 0;
  4116.  
  4117. const shadyFlushMO = new MutationObserver(() => {
  4118.  
  4119. if (!renderDebounceTs) return;
  4120.  
  4121. if (renderDebounceTs.size > 0) {
  4122. console.warn('renderDebounceTs.size is incorect', renderDebounceTs.size);
  4123. try {
  4124. Polymer.flush();
  4125. return;
  4126. } catch (e) { }
  4127. }
  4128.  
  4129. renderDebouncePromise && Promise.resolve().then(() => {
  4130.  
  4131. if (renderDebouncePromise) {
  4132. renderDebouncePromise && renderDebouncePromise.resolve();
  4133. renderDebouncePromise = null;
  4134. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by MutationObserver')
  4135. }
  4136.  
  4137. });
  4138.  
  4139. // Polymer.flush
  4140.  
  4141. window.ShadyDOM && ShadyDOM.flush();
  4142. window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush();
  4143.  
  4144.  
  4145. });
  4146.  
  4147. if (FIX_DOM_IFREPEAT_RenderDebouncerChange) {
  4148.  
  4149.  
  4150. let p = 0;
  4151. qp = observablePromise(() => {
  4152. if (!(p & 1)) {
  4153.  
  4154. if (window.ShadyDOM && ShadyDOM.flush) {
  4155. p |= 1;
  4156. if (!ShadyDOM.flush847) {
  4157.  
  4158. ShadyDOM.flush847 = ShadyDOM.flush;
  4159. ShadyDOM.flush = function () {
  4160.  
  4161. DEBUG_xx847 && console.log('xx847 ShadyDOM.flush')
  4162. renderDebouncePromise && Promise.resolve().then(() => {
  4163. if (renderDebouncePromise) {
  4164.  
  4165. renderDebouncePromise && renderDebouncePromise.resolve();
  4166. renderDebouncePromise = null;
  4167.  
  4168. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by ShadyDOM.flush')
  4169.  
  4170. }
  4171.  
  4172. });
  4173. let r = this.flush847(...arguments);
  4174. if (r) {
  4175. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  4176. }
  4177. return r
  4178. }
  4179.  
  4180. }
  4181. }
  4182. }
  4183.  
  4184. if (!(p & 2)) {
  4185.  
  4186. if (window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush) {
  4187. p |= 2;
  4188. const ScopingShim = window.ShadyCSS && window.ShadyCSS.ScopingShim;
  4189. if (!ScopingShim.flush848) {
  4190.  
  4191. ScopingShim.flush848 = ScopingShim.flush;
  4192. ScopingShim.flush = function () {
  4193.  
  4194. DEBUG_xx847 && console.log('xx847 ScopingShim.flush')
  4195.  
  4196. renderDebouncePromise && Promise.resolve().then(() => {
  4197.  
  4198. if (renderDebouncePromise) {
  4199.  
  4200. renderDebouncePromise && renderDebouncePromise.resolve();
  4201. renderDebouncePromise = null;
  4202.  
  4203. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by ScopingShim.flush')
  4204.  
  4205.  
  4206.  
  4207. }
  4208.  
  4209. });
  4210. return this.flush848(...arguments);
  4211. }
  4212.  
  4213. }
  4214. }
  4215. }
  4216. if (p === 3) {
  4217. p |= 8;
  4218.  
  4219. let r = (window.ShadyDOM && ShadyDOM.flush && ShadyDOM.flush847
  4220. && window.ShadyCSS && window.ShadyCSS.ScopingShim &&
  4221. window.ShadyCSS.ScopingShim.flush && window.ShadyCSS.ScopingShim.flush848);
  4222.  
  4223. if (r) {
  4224. let w = Set.prototype.add;
  4225. let u = null;
  4226. Set.prototype.add = function () {
  4227. u = this;
  4228. throw new Error();
  4229. }
  4230. try {
  4231. Polymer.enqueueDebouncer()
  4232. } catch (e) { }
  4233. Set.prototype.add = w;
  4234. if (u !== null) {
  4235. renderDebounceTs = u;
  4236. if (DEBUG_renderDebounceTs) {
  4237. renderDebounceTs.add58438 = renderDebounceTs.add;
  4238. renderDebounceTs.add = function () {
  4239. console.log('renderDebounceTs.add')
  4240. console.log(traceStack((new Error()).stack))
  4241. // debugger;
  4242. return this.add58438(...arguments)
  4243. }
  4244.  
  4245. renderDebounceTs.delete58438 = renderDebounceTs.delete;
  4246. renderDebounceTs.delete = function () {
  4247. console.log('renderDebounceTs.delete')
  4248. const stack = `${(new Error()).stack}`
  4249. let isCallbackRemoval = false;
  4250. if (stack) {
  4251. let t = stack.replace(/[^\r\n]+renderDebounceTs\.delete[^\r\n]+/, '').replace('://','');
  4252. const s = t.split(':');
  4253. if (s.length === 3 && +s[1] > 0 && +s[2] > 0) {
  4254. isCallbackRemoval = true;
  4255. }
  4256. }
  4257. if (isCallbackRemoval) {
  4258. return this.delete58438(...arguments)
  4259. }
  4260. console.log(traceStack((new Error()).stack))
  4261. // debugger;
  4262. return this.delete58438(...arguments)
  4263. }
  4264. }
  4265. DEBUG_renderDebounceTs && (window.renderDebounceTs = renderDebounceTs);
  4266. console.log('renderDebounceTs', renderDebounceTs, `debug=${DEBUG_renderDebounceTs}`);
  4267. }
  4268. }
  4269.  
  4270. return true;
  4271. }
  4272. })
  4273.  
  4274. // if(window.ShadyDOM && ShadyDOM.flush){
  4275. // console.log('FIX_DOM_IF_RenderDebouncerChange X1')
  4276.  
  4277. // }
  4278. // if(window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush){
  4279.  
  4280. // console.log('FIX_DOM_IF_RenderDebouncerChange X2')
  4281. // }
  4282.  
  4283. // console.log('FIX_DOM_IF_RenderDebouncerChange X3')
  4284.  
  4285. }
  4286.  
  4287. const setupPolymerAdv = () => {
  4288. // here we can obtain the Polymer faster.
  4289. // reserved for future use.
  4290. }
  4291.  
  4292.  
  4293. if (USE_fastDomIf) {
  4294. // 0 = no effect. 1 = enable. 2 = disable
  4295. // fastDomIf because it delayed the rendering process?
  4296. Object.defineProperty(Object.prototype, 'fastDomIf', {
  4297. get() {
  4298. if (this === window.Polymer) {
  4299. const v = USE_fastDomIf === 1 ? true : false;
  4300. this.fastDomIf = v;
  4301. delete Object.prototype.fastDomIf;
  4302. setupPolymerAdv(this);
  4303. return v;
  4304. }
  4305. },
  4306. set(nv) {
  4307. return false;
  4308. }
  4309. });
  4310. }
  4311.  
  4312. let setupDomIfDone = false;
  4313. const setupDomIf = (DomIf)=>{
  4314. setupDomIfDone = true;
  4315. if(setupDomIfDone) return;
  4316.  
  4317. const fProto = DomIf.prototype;
  4318.  
  4319.  
  4320. // Polymer.DomIf
  4321. // Polymer.DomIf = Polymer.fastDomIf ? ZbL : ESz
  4322. // Assume ESz by default
  4323.  
  4324. // We don't need to store "root" in DOM-IF
  4325. if (ENHANCE_DOMIF_createAndInsertInstance && fProto.__createAndInsertInstance && !fProto.__createAndInsertInstance239 && fProto.__createAndInsertInstance.length === 1) {
  4326. fProto.__createAndInsertInstance239 = fProto.__createAndInsertInstance;
  4327. fProto.__createAndInsertInstance = function (M) {
  4328. const r = this.__createAndInsertInstance239(M);
  4329. const __instance = this.__instance;
  4330. const __ctor = this.__ctor;
  4331. if (__instance && __ctor && __instance instanceof __ctor) {
  4332. for (const sym of Object.getOwnPropertySymbols(__instance)) {
  4333. const o = __instance[sym];
  4334. if (o && o.nodeType === 11) {
  4335. __instance[sym] = null;
  4336. }
  4337. }
  4338. }
  4339. return r;
  4340. }
  4341.  
  4342. /*
  4343.  
  4344.  
  4345. sX = function(M, d, N) {
  4346. if (o_ && !vDv(M))
  4347. throw Error("Jd");
  4348. N = N || {};
  4349. if (M.__templatizeOwner)
  4350. throw Error("Kd");
  4351. M.__templatizeOwner = d;
  4352. var R = (d ? d.constructor : jF)._parseTemplate(M)
  4353. , X = R.templatizeInstanceClass;
  4354. X || (X = sfi(M, R, N),
  4355. R.templatizeInstanceClass = X);
  4356. var A = vDv(M);
  4357. y9Z(M, R, N, A);
  4358. N = function() {
  4359. return X.apply(this, arguments) || this
  4360. }
  4361. ;
  4362. _.v(N, X);
  4363. N.prototype._methodHost = A;
  4364. N.prototype.__dataHost = M;
  4365. N.prototype.__templatizeOwner = d;
  4366. N.prototype.__hostProps = R.hostProps;
  4367. return N
  4368. }
  4369.  
  4370. */
  4371. }
  4372.  
  4373. // Polymer.DomIf
  4374. // We can fully teardown the entire instance (including stampFrag and stampNodes), just keep ctor stamper
  4375. if (ENHANCE_DOMIF_TEARDOWN && fProto.__teardownInstance && !fProto.__teardownInstance239 && fProto.__teardownInstance.length === 0) {
  4376. fProto.__teardownInstance239 = fProto.__teardownInstance;
  4377. fProto.__teardownInstance = function () {
  4378. const { __instance, __invalidProps } = this;
  4379. let r, e_;
  4380. try {
  4381. r = this.__teardownInstance239();
  4382. } catch (e) { e_ = e }
  4383. if (!__instance) return r;
  4384.  
  4385. try {
  4386.  
  4387. //console.log(599901,this.countEvent767());
  4388. //console.log('__teardownInstance F', __instance, __invalidProps, this._removeEventListenerFromNode, __instance._removeEventListenerFromNode);
  4389. __instance.__data = null;
  4390. __instance.__dataClientsReady = __instance.__dataEnabled = __instance.__dataReady = false;
  4391. __instance.__dataInvalid = true;
  4392. __instance.__dataHost = __instance.__dataTemp = null;
  4393. __instance.__isPropertyEffectsClient = false;
  4394. __instance.__keepInstance038__ = false;
  4395.  
  4396.  
  4397. const __templateInfo = __instance.__templateInfo;
  4398.  
  4399. let stampFragId = null;
  4400. if (__templateInfo && __templateInfo.nodeList) {
  4401. stampFragId = __templateInfo.nodeList.__belongFragId57__;
  4402. for (const weakNodeC of __templateInfo.nodeList) {
  4403. const node = toActualNode(weakNodeC);
  4404. if (node && node.nodeType >= 1) {
  4405. _removedElements.addNode(node);
  4406. node.__keepInstance038__ = false;
  4407. node.remove();
  4408. }
  4409. }
  4410. __templateInfo.nodeList.length = 0;
  4411. __templateInfo.nodeList = null;
  4412. }
  4413.  
  4414. const stampFrag = stampFragId ? kRef(stampedFragment.get(stampFragId)) : null;
  4415.  
  4416. if (stampFrag && stampFrag.nodeType === 11) {
  4417. _removedElements.addNode(stampFrag);
  4418. removeAllChildNodes(stampFrag);
  4419. try {
  4420. stampFrag.__keepInstance038__ = false;
  4421. stampFrag.remove();
  4422. } catch (e) { }
  4423. stampFrag.__shady = null;
  4424. stampFrag.$ = null;
  4425. stampFrag.__fragTeardowned57__ = true;
  4426. stampFrag.nodeList = null;
  4427. stampFrag.templateInfo = null;
  4428.  
  4429. }
  4430.  
  4431. for (const sym of Object.getOwnPropertySymbols(__instance)) {
  4432. const o = __instance[sym];
  4433. if (o && o.nodeType === 11) {
  4434. __instance[sym] = null;
  4435. }
  4436. }
  4437.  
  4438. const children = (__instance || 0).children;
  4439. if (children && children.splice) {
  4440. __instance.children = null;
  4441. for (const n of children) {
  4442. if (n && n.nodeType >= 1) {
  4443. n.__keepInstance038__ = false;
  4444. _removedElements.addNode(n);
  4445. }
  4446. }
  4447. children.length = 0;
  4448. }
  4449.  
  4450. if (__instance.__templateInfo) __instance.__templateInfo = null;
  4451.  
  4452. if (__instance.root) __instance.root = null;
  4453.  
  4454. } catch (e) {
  4455. console.error(e);
  4456. }
  4457.  
  4458. // console.log(3882)
  4459. if (e_) throw e_;
  4460. return r;
  4461. }
  4462. }
  4463.  
  4464. }
  4465.  
  4466. if (ENHANCE_DOMIF_createAndInsertInstance || ENHANCE_DOMIF_TEARDOWN) {
  4467.  
  4468. Object.defineProperty(Object.prototype, 'DomIf', {
  4469. get() {
  4470. return undefined;
  4471. },
  4472. set(nv) {
  4473. if (typeof (nv || 0) !== 'function') return false;
  4474. delete Object.prototype.DomIf;
  4475. this.DomIf = nv;
  4476. setupDomIf(nv);
  4477. return true;
  4478. },
  4479. enumerable: false,
  4480. configurable: true
  4481. });
  4482.  
  4483. }
  4484.  
  4485. Object.defineProperty(Object.prototype, '_lastIf', {
  4486. get() {
  4487. return this[s81];
  4488. },
  4489. set(nv) {
  4490. if (nv === false && this.nodeName === "DOM-IF" && this.__renderDebouncer === null && this[s81] === undefined) {
  4491. // DOM-IF initialization
  4492. nv = null; // avoid (this.if == this._lastIf) primitive type conversion (object vs false)
  4493.  
  4494. this.__xiWB8__ = 2;
  4495. // this.restamp = true;
  4496.  
  4497. const cProto = this.__proto__;
  4498. if (cProto && !cProto.__xiWB7__) {
  4499. cProto.__xiWB7__ = 1;
  4500.  
  4501. // dom-if __template
  4502. // dom-repeat template
  4503. if (FIX_DOM_IF_TEMPLATE && !cProto.__template && !cProto.__template847) {
  4504. cProto.__template847 = true;
  4505. try {
  4506. // note: this is not "_template" in Polymer ( see POLYMER_COMPONENT_DEFINITION )
  4507. Object.defineProperty(cProto, '__template', {
  4508. get() {
  4509. const v = this[s84];
  4510. return (typeof (v || 0) === 'object' && v.deref) ? kRef(v) : v;
  4511. },
  4512. set(nv) {
  4513. if (typeof (nv || 0) === 'object' && !nv.deref) nv = mWeakRef(nv);
  4514. this[s84] = nv;
  4515. return true;
  4516. }
  4517. });
  4518. } catch (e) {
  4519. console.warn(e);
  4520. }
  4521.  
  4522. console.log('FIX_DOM_IF - __template')
  4523. }
  4524.  
  4525. // dom-if __ensureTemplate
  4526. // dom-repeat __ensureTemplatized
  4527. if (FIX_DOM_IF_TEMPLATE && !cProto.__ensureTemplate847 && typeof cProto.__ensureTemplate === 'function' && cProto.__ensureTemplate.length === 0 && this instanceof HTMLElement_ && `${cProto.__ensureTemplate}`.length > 20) {
  4528. // note that "_templateInfo" diffs the different version of DOM-IF
  4529.  
  4530. cProto.__ensureTemplate847 = cProto.__ensureTemplate;
  4531. cProto.__ensureTemplate = function () {
  4532. if (!(this instanceof HTMLElement_) || arguments.length > 0) return this.__ensureTemplate847(...arguments);
  4533. if (!this.__template) {
  4534. let b;
  4535. if (this._templateInfo) {
  4536. b = this;
  4537. } else {
  4538. if (!this.__templateCollection011__) this.__templateCollection011__ = this.getElementsByTagName('template');
  4539. b = this.__templateCollection011__[0];
  4540. if (!b) {
  4541. if (!this[wk]) this[wk] = mWeakRef(this);
  4542. let a = this[wk];
  4543. let c = new MutationObserver(function () {
  4544. if (!this.__templateCollection011__[0]) throw Error("dom-if requires a <template> child"); // to be reviewed
  4545. if (c && a) {
  4546. c.disconnect();
  4547. a = kRef(a);
  4548. a && a.__render();
  4549. a && (a.__templateCollection011__ = null);
  4550. }
  4551. c = null;
  4552. a = null;
  4553. });
  4554. c && c.observe(this, {
  4555. childList: !0
  4556. });
  4557. return !1
  4558. } else {
  4559. this.__templateCollection011__ = null;
  4560. }
  4561. }
  4562. this.__template = b
  4563. }
  4564. return !0
  4565. }
  4566.  
  4567. console.log('FIX_DOM_IF - __ensureTemplate')
  4568.  
  4569. }
  4570. /*
  4571.  
  4572. if (FIX_DOM_IF_TEMPLATE && !cProto.disconnectedCallback847 && cProto.disconnectedCallback && cProto.__teardownInstance) {
  4573. cProto.disconnectedCallback847 = cProto.disconnectedCallback;
  4574. cProto.disconnectedCallback = function () {
  4575.  
  4576. console.log(1949001, 'disconnectedCallback')
  4577. this.disconnectedCallback847();
  4578. try {
  4579. this.__teardownInstance();
  4580. console.log(1949002, '__teardownInstance 00D')
  4581. } catch (e) { }
  4582. }
  4583. }
  4584.  
  4585. if (FIX_DOM_IF_TEMPLATE && !cProto.connectedCallback847 && cProto.connectedCallback && cProto.__teardownInstance) {
  4586. cProto.connectedCallback847 = cProto.connectedCallback;
  4587. cProto.connectedCallback = function () {
  4588.  
  4589. console.log(1949003, 'connectedCallback')
  4590. try {
  4591. this.__teardownInstance();
  4592. console.log(1949004, '__teardownInstance 00C')
  4593. } catch (e) { }
  4594. this.connectedCallback847();
  4595. }
  4596. }
  4597. */
  4598.  
  4599.  
  4600. // if(!cProto.__createAndInsertInstance847 && typeof cProto.__createAndInsertInstance === 'function' && cProto.__createAndInsertInstance.length === 1 && `${cProto.__createAndInsertInstance}`.length >20){
  4601.  
  4602. // cProto.__createAndInsertInstance847 = cProto.__createAndInsertInstance;
  4603.  
  4604. // cProto.__createAndInsertInstance = function (a) {
  4605. // Promise.resolve().then(()=>{
  4606. // console.log('__createAndInsertInstance')
  4607. // window.lm5 = window.lm5 || [];
  4608. // window.lm5.push([mWeakRef(this), mWeakRef(this.__instance)])
  4609. // });
  4610. // return this.__createAndInsertInstance847(a);
  4611. // }
  4612.  
  4613. // }
  4614.  
  4615.  
  4616. // if(!cProto._bindTemplate847 && typeof cProto._bindTemplate === 'function' && cProto._bindTemplate.length === 2){
  4617.  
  4618. // cProto._bindTemplate847 = cProto._bindTemplate;
  4619.  
  4620. // cProto._bindTemplate = function (a, b) {
  4621. // return this._bindTemplate847(kRef(a), b); // might throw Error as a -> null inside _bindTemplate847
  4622. // }
  4623.  
  4624. // }
  4625. // if(!cProto._stampTemplate847 && typeof cProto._stampTemplate === 'function' && cProto._stampTemplate.length === 2){
  4626.  
  4627. // cProto._stampTemplate847 = cProto._stampTemplate;
  4628.  
  4629. // cProto._stampTemplate = function (a, b) {
  4630. // return this._stampTemplate847(kRef(a), b); // might throw Error as a -> null inside _stampTemplate847
  4631. // }
  4632.  
  4633. // }
  4634. console.log('FIX_DOM_IF OK', Object.keys(cProto))
  4635. }
  4636.  
  4637.  
  4638. // need to fix __observeEffects
  4639. // this.__observeEffects.if[0].info.method === this.__debounceRender
  4640. const f = () => {
  4641.  
  4642. const __observeEffects = this.__observeEffects;
  4643.  
  4644. if (__observeEffects && __observeEffects.if && isIterable(__observeEffects.if)) {
  4645. for (const effect of __observeEffects.if) {
  4646. const info = effect.info;
  4647. if (info && typeof info.method === 'function') {
  4648.  
  4649. if (info.method === this.__debounceRender847 || info.method === this.__debounceRender) {
  4650. info.method = FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME ? '__debounceRender' : this.__debounceRender;
  4651. }
  4652.  
  4653. }
  4654. }
  4655. }
  4656.  
  4657.  
  4658. if (__observeEffects && __observeEffects.restamp && isIterable(__observeEffects.restamp)) {
  4659. for (const effect of __observeEffects.restamp) {
  4660. const info = effect.info;
  4661. if (info && typeof info.method === 'function') {
  4662.  
  4663. if (info.method === this.__debounceRender847 || info.method === this.__debounceRender) {
  4664. info.method = FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME ? '__debounceRender' : this.__debounceRender;
  4665. }
  4666.  
  4667. }
  4668. }
  4669. }
  4670.  
  4671. // console.log(5881, this.__observeEffects)
  4672. }
  4673. if (FIX_DOM_IFREPEAT_RenderDebouncerChange) {
  4674. f();
  4675. Promise.resolve().then(f);
  4676. // afterward, don't care adding fn directly (the fn is already modified)
  4677. }
  4678.  
  4679. }
  4680. this[s81] = nv;
  4681. return true;
  4682. }
  4683. });
  4684.  
  4685.  
  4686. Object.defineProperty(Object.prototype, '__renderDebouncer', {
  4687. get() {
  4688. return this[s85];
  4689. },
  4690. set(nv) {
  4691. if (nv === null && this[s85] === undefined) {
  4692. // DOM-IF / DOM-REPEAT initialization
  4693.  
  4694.  
  4695. const cProto = this.__proto__;
  4696. if (qp) {
  4697. qp.obtain();
  4698. qp = null;
  4699. shadyFlushMO.observe(document.documentElement, { attributes: ['nw3a24np'] });
  4700. }
  4701. if (FIX_DOM_IFREPEAT_RenderDebouncerChange && !cProto.__debounceRender847 && typeof cProto.__debounceRender === 'function' && !(`${cProto.__debounceRender}`.includes("{}"))) {
  4702.  
  4703. cProto.__debounceRender847 = cProto.__debounceRender;
  4704.  
  4705. if (cProto.__debounceRender.length === 2) {
  4706.  
  4707. cProto.__debounceRender = function (a, b) {
  4708.  
  4709. if (!renderDebounceTs) return this.__debounceRender847(a, b);
  4710.  
  4711. b = b === void 0 ? 0 : b;
  4712.  
  4713. /*
  4714. b = b === void 0 ? 0 : b;
  4715. this.__renderDebouncer = us(this.__renderDebouncer, b > 0 ? Rr.after(b) : Tr, a.bind(this));
  4716. vs(this.__renderDebouncer)
  4717. */
  4718.  
  4719. this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  4720.  
  4721. if (!renderDebouncePromise) {
  4722. renderDebouncePromise = new PromiseExternal();
  4723. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  4724. }
  4725.  
  4726. renderDebouncePromise.then(async () => {
  4727. if (b > 0) await delayPn(b);
  4728.  
  4729. const f = this.__dsIRYqw1__;
  4730. if (f === cme) return;
  4731. this.__dsIRYqw1__ = cme;
  4732. a.call(this);
  4733. DEBUG_DBR847 && console.log(`__DBR847__ done 01 (delay=${b})`, this.__DBR848__)
  4734.  
  4735. });
  4736.  
  4737. DEBUG_DBR847 && console.log(`__DBR847__ add 01 (delay=${b})`, this.__DBR848__)
  4738. }
  4739.  
  4740. } else if (cProto.__debounceRender.length === 0) {
  4741.  
  4742.  
  4743. cProto.__debounceRender = function () {
  4744.  
  4745. if (!renderDebounceTs) return this.__debounceRender847();
  4746.  
  4747. this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  4748. /*
  4749. var a = this;
  4750. this.__renderDebouncer = us(this.__renderDebouncer, Tr, function() {
  4751. return a.__render()
  4752. });
  4753. vs(this.__renderDebouncer)
  4754. */
  4755.  
  4756. if (!renderDebouncePromise) {
  4757. renderDebouncePromise = new PromiseExternal();
  4758. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  4759. }
  4760. renderDebouncePromise.then(() => {
  4761. const f = this.__dsIRYqw1__;
  4762. if (f === cme) return;
  4763. this.__dsIRYqw1__ = cme;
  4764. this.__render()
  4765. DEBUG_DBR847 && console.log('__DBR847__ done 02', this.__DBR848__)
  4766. });
  4767. DEBUG_DBR847 && console.log('__DBR847__ add 02', this.__DBR848__)
  4768.  
  4769.  
  4770. }
  4771. }
  4772. }
  4773.  
  4774.  
  4775.  
  4776. // if(FIX_DOM_IFREPEAT_RenderDebouncerChange && !cProto.render847 && typeof cProto.render === 'function' && cProto.render.length === 0 && !(`${cProto.render}`.includes("{}"))){
  4777. // cProto.render847 = cProto.render;
  4778. // cProto.render = function(){
  4779.  
  4780. // this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  4781. // try{
  4782. // this.render847();
  4783. // }catch(e){}
  4784. // // if(this.__DBR847__){
  4785. // // this.__DBR847__.resolve();
  4786. // // DEBUG_DBR847 && console.log('__DBR847__ resolve', this.__DBR848__)
  4787. // // }
  4788.  
  4789. // // renderDebouncePromise && renderDebouncePromise.resolve()
  4790. // // renderDebouncePromise = null;
  4791. // // DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by render', this.__DBR848__)
  4792.  
  4793. // }
  4794. // console.log('FIX_DOM_IF - render', `${cProto.render847}`, cProto.render847)
  4795. // }
  4796.  
  4797. }
  4798. this[s85] = nv;
  4799. return true;
  4800. }
  4801. });
  4802.  
  4803. // PS-DOM-REPEAT
  4804.  
  4805. Object.defineProperty(Object.prototype, 'JSC$10034_renderDebouncer', {
  4806. get() {
  4807. return this[s85b];
  4808. },
  4809. set(nv) {
  4810.  
  4811. this[s85b] = nv;
  4812. return true;
  4813. }
  4814. })
  4815.  
  4816. Object.defineProperty(Object.prototype, 'JSC$10027_renderDebouncer', {
  4817. get() {
  4818. return this[s85c];
  4819. },
  4820. set(nv) {
  4821.  
  4822. this[s85c] = nv;
  4823. return true;
  4824. }
  4825. })
  4826.  
  4827.  
  4828. })();
  4829.  
  4830. const setupXdeadC = (cnt)=>{
  4831.  
  4832. let xdeadc = xdeadc00;
  4833. if(!xdeadc){
  4834. setupSDomWrapper(); // just in case
  4835. const hostElement = cnt.hostElement;
  4836. const el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  4837. hostElement.insertAdjacentHTML('beforeend', ttpHTML('<!---->'));
  4838. hostElement.lastChild.replaceWith(el);
  4839. el.insertAdjacentHTML('afterbegin', ttpHTML(`<div></div>`));
  4840. const rid = `xdead_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  4841. el.firstElementChild.id = rid;
  4842. cnt.$[rid] = el.firstElementChild;
  4843. cnt.stampDomArray9682_(null, rid, null, false, false, false);
  4844.  
  4845. xdeadc = cnt.getStampContainer_(rid);
  4846. el.remove();
  4847. xdeadc00 = xdeadc;
  4848. // console.log(xdeadc.__domApi)
  4849. // debugger;
  4850. // const xdeadv = xdeadc.__domApi;
  4851. }
  4852.  
  4853. let xlivec = xlivec00;
  4854. if(!xlivec){
  4855. setupSDomWrapper(); // just in case
  4856. const hostElement = cnt.hostElement;
  4857. const el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  4858. hostElement.insertAdjacentHTML('beforeend', ttpHTML('<!---->'));
  4859. hostElement.lastChild.replaceWith(el);
  4860. el.insertAdjacentHTML('afterbegin', ttpHTML(`<div></div>`));
  4861. const rid = `xlive_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  4862. el.firstElementChild.id = rid;
  4863. cnt.$[rid] = el.firstElementChild;
  4864. cnt.stampDomArray9682_(null, rid, null, false, false, false);
  4865.  
  4866. xlivec = cnt.getStampContainer_(rid);
  4867. xlivec00 = xlivec;
  4868. // console.log(xdeadc.__domApi)
  4869. // debugger;
  4870. // const xdeadv = xdeadc.__domApi;
  4871. }
  4872.  
  4873. return xdeadc00;
  4874. }
  4875.  
  4876. let standardWrap_ = null;
  4877.  
  4878. const setupSDomWrapper = () => {
  4879.  
  4880. const sdwProto = ShadyDOM.Wrapper.prototype;
  4881.  
  4882. if (sdwProto.__pseudo__isConnected__ !== null) {
  4883. sdwProto.__pseudo__isConnected__ = null;
  4884. const isConnectedPd = Object.getOwnPropertyDescriptor(sdwProto, 'isConnected');
  4885. if (isConnectedPd && isConnectedPd.get && isConnectedPd.configurable === true) {
  4886. const get = isConnectedPd.get;
  4887. isConnectedPd.get = function () {
  4888. const pseudoVal = this.__pseudo__isConnected__;
  4889. return typeof pseudoVal === 'boolean' ? pseudoVal : get.call(this);
  4890. }
  4891. Object.defineProperty(sdwProto, 'isConnected', { ...isConnectedPd });
  4892. }
  4893.  
  4894. // debugger;
  4895. // new xdeadc.__domApi.constructor(document.createElement('div'));
  4896. }
  4897.  
  4898. }
  4899.  
  4900. let domApiConstructor = null;
  4901. const setupDomApi = (daProto) => {
  4902.  
  4903. daProto.__daHook377__ = true;
  4904.  
  4905. domApiConstructor = daProto.constructor; // TBC
  4906.  
  4907. // TBC
  4908.  
  4909. }
  4910.  
  4911.  
  4912. // WEAKREF_ShadyDOM
  4913.  
  4914. let mightTeardownShadyDomWrap = () => { };
  4915.  
  4916. MODIFY_ShadyDOM_OBJ && ((WeakRef) => {
  4917.  
  4918. const setupPlainShadyDOM = (b) => {
  4919. (OMIT_ShadyDOM_settings & 1) && (b.inUse === true) && (b.inUse = false);
  4920. (OMIT_ShadyDOM_settings & 2) && (b.handlesDynamicScoping === true) && (b.handlesDynamicScoping = false);
  4921. (OMIT_ShadyDOM_settings & 4) && (b.force === true) && (b.force = false);
  4922. b.patchOnDemand = true;
  4923. b.preferPerformance = true;
  4924. b.noPatch = true;
  4925. }
  4926.  
  4927. const isPlainObject = (b, m) => {
  4928. if (!b || typeof b !== 'object') return false;
  4929. const e = Object.getOwnPropertyDescriptors(b);
  4930. if (e.length <= m) return false;
  4931. let pr = 0;
  4932. for (const k in e) {
  4933. const d = e[k];
  4934. if (!d || d.get || d.set || !d.enumerable || !d.configurable) return false;
  4935. if (!('value' in d) || typeof d.value === 'function') return false;
  4936. pr++;
  4937. }
  4938. return pr > m;
  4939. }
  4940.  
  4941. let b;
  4942.  
  4943. let lz = 0;
  4944.  
  4945. const sdp = Object.getOwnPropertyDescriptor(window, 'ShadyDOM');
  4946. if (sdp && sdp.configurable && sdp.value && sdp.enumerable && sdp.writable) {
  4947.  
  4948. // Brave - ShadyDOM exists before userscripting
  4949. b = sdp.value;
  4950.  
  4951. if (b && typeof b === 'object' && isPlainObject(b, 0)) {
  4952. OMIT_ShadyDOM_EXPERIMENTAL && setupPlainShadyDOM(b);
  4953. lz = 1;
  4954. }
  4955.  
  4956. }
  4957.  
  4958.  
  4959. if (sdp && sdp.configurable && sdp.value && sdp.enumerable && sdp.writable && !sdp.get && !sdp.set) {
  4960. } else if (!sdp) {
  4961. } else {
  4962. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM is not applied [ PropertyDescriptor issue ]', sdp);
  4963. return;
  4964. }
  4965.  
  4966. const shadyDOMNodeWRM = new WeakMap();
  4967.  
  4968. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 01 >>', b);
  4969.  
  4970. const weakWrapperNodeHandlerFn = () => ({
  4971. get() {
  4972. const wv = this[wk];
  4973. if (typeof wv === 'undefined') return undefined;
  4974. let node = kRef(wv);
  4975. if (!node) this[wk] = undefined;
  4976. return node || undefined;
  4977. },
  4978. set(nv) {
  4979. const wv = nv ? (nv[wk] || (nv[wk] = mWeakRef(nv))) : nv;
  4980. this[wk] = wv;
  4981. return true;
  4982. },
  4983. enumerable: true,
  4984. configurable: true
  4985. });
  4986.  
  4987.  
  4988. function weakWrapper(_ShadyDOM) {
  4989. const ShadyDOM = _ShadyDOM;
  4990. if (WEAKREF_ShadyDOM && lz < 3 && typeof WeakRef === 'function' && typeof ShadyDOM.Wrapper === 'function' && ShadyDOM.Wrapper.length === 1 && typeof (ShadyDOM.Wrapper.prototype || 0) === 'object') {
  4991. let nullElement = { node: null };
  4992. Object.setPrototypeOf(nullElement, Element.prototype);
  4993. let p = new ShadyDOM.Wrapper(nullElement);
  4994. let d = Object.getOwnPropertyDescriptor(p, 'node');
  4995. if (d.configurable && d.enumerable && !d.get && !d.set && d.writable && d.value === nullElement && !Object.getOwnPropertyDescriptor(ShadyDOM.Wrapper.prototype, 'node')) {
  4996. Object.defineProperty(ShadyDOM.Wrapper.prototype, 'node', weakWrapperNodeHandlerFn());
  4997. console.log('[yt-js-engine-tamer] FIX::ShadyDOM << WEAKREF_ShadyDOM >>')
  4998. }
  4999.  
  5000. }
  5001. if (typeof (((ShadyDOM || 0).Wrapper || 0).prototype || 0) === 'object') {
  5002. try {
  5003. setupSDomWrapper();
  5004. } catch (e) { }
  5005. }
  5006.  
  5007. }
  5008.  
  5009. let previousWrapStore = null;
  5010.  
  5011. mightTeardownShadyDomWrap = (node) => {
  5012. if (previousWrapStore) previousWrapStore.delete(node);
  5013. if (shadyDOMNodeWRM) shadyDOMNodeWRM.delete(node);
  5014. };
  5015.  
  5016. const standardWrap = function (a) {
  5017. // if(a && a.deref) a= a.deref();
  5018. if(!a) return a;
  5019. if (a instanceof ShadowRoot || a instanceof ShadyDOM.Wrapper) return a;
  5020. if (previousWrapStore) {
  5021. const s = kRef(previousWrapStore.get(a)); // kRef for play safe only
  5022. if (s) {
  5023. previousWrapStore.delete(a);
  5024. shadyDOMNodeWRM.set(a, mWeakRef(s));
  5025. }
  5026. }
  5027. let u = kRef(shadyDOMNodeWRM.get(a));
  5028. if (!u) {
  5029. u = new ShadyDOM.Wrapper(a);
  5030. shadyDOMNodeWRM.set(a, mWeakRef(u));
  5031. }
  5032. return u;
  5033. }
  5034.  
  5035. standardWrap_ = standardWrap;
  5036.  
  5037.  
  5038. function setupWrapFunc(_ShadyDOM) {
  5039. const ShadyDOM = _ShadyDOM;
  5040.  
  5041.  
  5042. const wmPD = Object.getOwnPropertyDescriptor(WeakMap.prototype, 'get');
  5043. if (!(wmPD && wmPD.writable && !wmPD.enumerable && wmPD.configurable && wmPD.value && !wmPD.get && !wmPD.set)) {
  5044. return;
  5045. }
  5046. let mm = new Set();
  5047. const pget = wmPD.value;
  5048. WeakMap.prototype.get = function (a) {
  5049. mm.add(this);
  5050. return a;
  5051. }
  5052. try {
  5053. let nullElement = { node: null };
  5054. Object.setPrototypeOf(nullElement, Element.prototype);
  5055. ShadyDOM.wrapIfNeeded(nullElement)
  5056. ShadyDOM.wrap(nullElement)
  5057. } catch (e) { }
  5058. WeakMap.prototype.get = pget;
  5059. if (mm.size !== 1) {
  5060. mm.clear();
  5061. return;
  5062. }
  5063. const p = mm.values().next().value;
  5064. if (!(p instanceof WeakMap)) return;
  5065. // p.clear();
  5066. // p.get = function (a) { return a }
  5067. // p.set = function (a, b) { return this }
  5068. // console.log(188, window.n2n = mm, window.n2p = p)
  5069.  
  5070. // console.log(34929,p.size)
  5071. previousWrapStore = p;
  5072.  
  5073. if (typeof ShadyDOM.wrap === 'function' && ShadyDOM.wrap.length === 1) {
  5074. ShadyDOM.wrap = function (a) { 0 && console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - wrap'); return standardWrap(a) }
  5075. }
  5076. if (typeof ShadyDOM.wrapIfNeeded === 'function' && ShadyDOM.wrapIfNeeded.length === 1) {
  5077. ShadyDOM.wrapIfNeeded = function (a) { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - wrapIfNeeded'); return standardWrap(a) }
  5078. }
  5079.  
  5080. }
  5081.  
  5082. function setupLZ3(nv) {
  5083.  
  5084. const ShadyDOM = nv;
  5085.  
  5086. const ShadyDOMSettings = ShadyDOM.settings;
  5087. if (!(ShadyDOMSettings.inUse === true && ShadyDOM.inUse === true && (ShadyDOMSettings.handlesDynamicScoping || ShadyDOM.handlesDynamicScoping) === true)) {
  5088. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [02]', window.ShadyDOM);
  5089. return false;
  5090. }
  5091.  
  5092. weakWrapper(ShadyDOM);
  5093.  
  5094. if (OMIT_ShadyDOM_EXPERIMENTAL && lz < 3) {
  5095.  
  5096. setupPlainShadyDOM(ShadyDOMSettings);
  5097. setupPlainShadyDOM(ShadyDOM);
  5098.  
  5099. ShadyDOM.isShadyRoot = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - isShadyRoot'); return false; }
  5100.  
  5101. setupWrapFunc(ShadyDOM);
  5102. ShadyDOM.patchElementProto = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - patchElementProto') }
  5103. ShadyDOM.patch = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - patch') }
  5104.  
  5105. // To be confirmed
  5106. if (OMIT_ShadyDOM_EXPERIMENTAL & 2) {
  5107. ShadyDOM.composedPath = function (e) {
  5108. const t = (e || 0).target || null;
  5109. if (!(t instanceof HTMLElement_)) {
  5110. console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM&2) composedPath', t)
  5111. }
  5112. return t instanceof HTMLElement_ ? [t] : [];
  5113. };
  5114. }
  5115.  
  5116. }
  5117.  
  5118. }
  5119.  
  5120.  
  5121. function setupLZ6(nv) {
  5122.  
  5123. const ShadyDOM = nv;
  5124.  
  5125. const ShadyDOMSettings = ShadyDOM.settings;
  5126.  
  5127. if (!(ShadyDOMSettings.inUse === true && ShadyDOM.inUse === true && (ShadyDOMSettings.handlesDynamicScoping || ShadyDOM.handlesDynamicScoping) === true)) {
  5128. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [02]', window.ShadyDOM);
  5129. return false;
  5130. }
  5131.  
  5132. weakWrapper(ShadyDOM);
  5133.  
  5134. if (OMIT_ShadyDOM_EXPERIMENTAL && lz < 3) {
  5135.  
  5136. setupPlainShadyDOM(ShadyDOMSettings);
  5137. setupPlainShadyDOM(ShadyDOM);
  5138.  
  5139. setupWrapFunc(ShadyDOM);
  5140.  
  5141. }
  5142.  
  5143. }
  5144.  
  5145. if (b && typeof b.Wrapper === 'function' && typeof b.settings === 'object' && typeof b.wrap === 'function') {
  5146.  
  5147. const nv = b;
  5148.  
  5149. if (setupLZ6(nv) === false) return;
  5150.  
  5151. lz = 6;
  5152.  
  5153. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 02b >>', nv)
  5154.  
  5155. return;
  5156. }
  5157.  
  5158. delete window.ShadyDOM;
  5159.  
  5160. Object.defineProperty(window, 'ShadyDOM', {
  5161. get() {
  5162. return b;
  5163. },
  5164. set(nv) {
  5165. let ret = 0;
  5166. try {
  5167. do {
  5168. if (!nv || !nv.settings) {
  5169. if (lz < 1 && nv && typeof nv === 'object' && isPlainObject(nv, 0)) {
  5170. OMIT_ShadyDOM_EXPERIMENTAL && setupPlainShadyDOM(nv);
  5171. lz = 1;
  5172. break;
  5173. } else {
  5174. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM is not applied [nv:null]', nv);
  5175. break;
  5176. }
  5177. }
  5178.  
  5179. const sdp = Object.getOwnPropertyDescriptor(this || {}, 'ShadyDOM');
  5180. if (!(sdp && sdp.configurable && sdp.get && sdp.set)) {
  5181. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [ incorrect PropertyDescriptor ]', nv);
  5182. break;
  5183. }
  5184.  
  5185. if (setupLZ3(nv) === false) break;
  5186.  
  5187. lz = 3;
  5188.  
  5189. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 02a >>', nv)
  5190.  
  5191. ret = 1;
  5192.  
  5193. } while (0);
  5194. } catch (e) {
  5195. console.log('[yt-js-engine-tamer] FIX::ShadyDOM << ERROR >>', e)
  5196. }
  5197.  
  5198. if (!ret) b = nv;
  5199. else {
  5200. delete this.ShadyDOM;
  5201. this.ShadyDOM = nv;
  5202. }
  5203. return true;
  5204. },
  5205. enumerable: false,
  5206. configurable: true
  5207. });
  5208.  
  5209. })(typeof WeakRef !== 'undefined' ? WeakRef : function () { });
  5210.  
  5211. if (ENABLE_ASYNC_DISPATCHEVENT) {
  5212. const filter = new Set([
  5213. 'yt-action',
  5214. // 'iframe-src-replaced',
  5215. 'shown-items-changed',
  5216. 'can-show-more-changed', 'collapsed-changed',
  5217.  
  5218. 'yt-navigate', 'yt-navigate-start', 'yt-navigate-cache',
  5219. 'yt-player-updated', 'yt-page-data-fetched', 'yt-page-type-changed', 'yt-page-data-updated',
  5220. 'yt-navigate-finish',
  5221.  
  5222. // 'data-changed','yt-watch-comments-ready'
  5223. ])
  5224. EventTarget.prototype.dispatchEvent938 = EventTarget.prototype.dispatchEvent;
  5225. EventTarget.prototype.dispatchEvent = function (event) {
  5226. const type = (event || 0).type;
  5227. if (typeof type === 'string' && event.isTrusted === false && (event instanceof CustomEvent) && event.cancelable === false) {
  5228. if (!filter.has(type) && !type.endsWith('-changed')) {
  5229. if (this instanceof Node || this instanceof Window) {
  5230. nextBrowserTick_(() => this.dispatchEvent938(event));
  5231. return true;
  5232. }
  5233. }
  5234. }
  5235. return this.dispatchEvent938(event);
  5236. }
  5237. }
  5238.  
  5239. // avoid REGEXP testPattern execution in Brave's scriptlet for performance boost
  5240. SCRIPTLET_REMOVE_PRUNE_propNeedles && (() => {
  5241. // const xhr = new XMLHttpRequest;
  5242. const pdOri = Object.getOwnPropertyDescriptor(Map.prototype, 'size');
  5243. if (!pdOri || pdOri.configurable !== true) return;
  5244. let propNeedles = null;
  5245. const pdNew = {
  5246. configurable: true,
  5247. enumerable: true,
  5248. get: function () {
  5249. propNeedles = this;
  5250. if (DEBUG_removePrune) debugger; // to locate Brave scriptlets
  5251. throw new Error();
  5252. }
  5253. }
  5254. Object.defineProperty(Map.prototype, 'size', pdNew);
  5255. try {
  5256. XMLHttpRequest.prototype.open.call(0);
  5257. // xhr.open.call(null)
  5258. } catch (e) { }
  5259. Object.defineProperty(Map.prototype, 'size', pdOri);
  5260. if (!propNeedles) return;
  5261. const entries = [...propNeedles.entries()];
  5262. propNeedles.clear();
  5263. console.log('[yt-js-engine-tamer] propNeedles is cleared from scriptlet', entries, propNeedles);
  5264. })();
  5265.  
  5266. if (FIX_XHR_REQUESTING) {
  5267.  
  5268. const URL = window.URL || new Function('return URL')();
  5269. const createObjectURL = URL.createObjectURL.bind(URL);
  5270.  
  5271. XMLHttpRequest = (() => {
  5272. const XMLHttpRequest_ = XMLHttpRequest;
  5273. if ('__xmMc8__' in XMLHttpRequest_.prototype) return XMLHttpRequest_;
  5274. const url0 = createObjectURL(new Blob([], { type: 'text/plain' }));
  5275. const c = class XMLHttpRequest extends XMLHttpRequest_ {
  5276. constructor(...args) {
  5277. super(...args);
  5278. }
  5279. open(method, url, ...args) {
  5280. let skip = false;
  5281. if (!url || typeof url !== 'string') skip = true;
  5282. else if (typeof url === 'string') {
  5283. let turl = url[0] === '/' ? `.youtube.com${url}` : `${url}`;
  5284. if (turl.includes('googleads') || turl.includes('doubleclick.net')) {
  5285. skip = true;
  5286. } else if (turl.includes('.youtube.com/pagead/')) {
  5287. skip = true;
  5288. } else if (turl.includes('.youtube.com/ptracking')) {
  5289. skip = true;
  5290. } else if (turl.includes('.youtube.com/youtubei/v1/log_event?')) {
  5291. skip = true;
  5292. } else if (turl.includes('.youtube.com/api/stats/')) { // /api/stats/
  5293. if (turl.includes('.youtube.com/api/stats/qoe?')) {
  5294. skip = true;
  5295. } else if (turl.includes('.youtube.com/api/stats/ads?')) {
  5296. skip = true;
  5297. } else {
  5298. // skip = true; // for user activity logging e.g. watched videos
  5299. }
  5300. } else if (turl.includes('play.google.com/log')) {
  5301. skip = true;
  5302. } else if (turl.includes('.youtube.com//?')) { // //?cpn=
  5303. skip = true;
  5304. }
  5305. }
  5306. if (!skip) {
  5307. this.__xmMc8__ = 1;
  5308. return super.open(method, url, ...args);
  5309. } else {
  5310. this.__xmMc8__ = 2;
  5311. return super.open('GET', url0);
  5312. }
  5313. }
  5314. send(...args) {
  5315. if (this.__xmMc8__ === 1) {
  5316. return super.send(...args);
  5317. } else if (this.__xmMc8__ === 2) {
  5318. return super.send();
  5319. } else {
  5320. console.log('[yt-js-engine-tamer]', 'xhr warning');
  5321. return super.send(...args);
  5322. }
  5323. }
  5324. }
  5325. c.prototype.__xmMc8__ = 0;
  5326. prototypeInherit(c.prototype, XMLHttpRequest_.prototype);
  5327. return c;
  5328. })();
  5329. }
  5330.  
  5331. // Alternative HACK -> Tabview Youtube
  5332. if (DISABLE_COOLDOWN_SCROLLING && typeof EventTarget.prototype.addEventListener52178 !== 'function' && typeof EventTarget.prototype.addEventListener === 'function') {
  5333.  
  5334. // ---- << this.overscrollConfig HACK >> -----
  5335.  
  5336. // 2024.04.19 - Playlist in Single Column Mode cannot be scrolled correctly.
  5337.  
  5338. /*
  5339.  
  5340. ;function gZb(a, b) {
  5341. b = void 0 === b ? !0 : b;
  5342. a.addEventListener("wheel", hZb);
  5343. a.overscrollConfig = {
  5344. cooldown: b
  5345. }
  5346. }
  5347. function iZb(a) {
  5348. a.overscrollConfig = void 0;
  5349. a.removeEventListener("wheel", hZb)
  5350. }
  5351. function hZb(a) {
  5352. var b = a.deltaY
  5353. , c = a.target
  5354. , d = null;
  5355. if (window.Polymer && window.Polymer.Element) {
  5356. if (c = a.path || a.composedPath && a.composedPath()) {
  5357. c = g(c);
  5358. for (var e = c.next(); !e.done && (e = e.value,
  5359. !jZb(e, b)); e = c.next())
  5360. if (e.overscrollConfig) {
  5361. d = e;
  5362. break
  5363. }
  5364. }
  5365. } else
  5366. for (; c && !jZb(c, b); ) {
  5367. if (c.overscrollConfig) {
  5368. d = c;
  5369. break
  5370. }
  5371. c = c.parentElement
  5372. }
  5373. d && (b = d.overscrollConfig,
  5374. b.cooldown ? (d = a.deltaY,
  5375. c = b.lastDeltaY || 0,
  5376. b.lastDeltaY = d,
  5377. e = b.lastStopped || 0,
  5378. c && e && 0 < c == 0 < d ? Math.abs(c) >= Math.abs(d) ? (d = e + 1200,
  5379. c = !1) : (d = e + 600,
  5380. c = !0) : (d = Date.now() + 600,
  5381. c = !0),
  5382. d > Date.now() && (a.preventDefault(),
  5383. c && (b.lastStopped = Date.now()))) : a.preventDefault())
  5384. }
  5385. */
  5386.  
  5387. let wheelHandler = function (a) {
  5388. if (window.Polymer && window.Polymer.Element) {
  5389. let c;
  5390. if (c = a.path || a.composedPath && a.composedPath()) {
  5391. for (const e of c) {
  5392. const cnt = insp(e);
  5393. if (e.overscrollConfig) e.overscrollConfig = void 0;
  5394. if (cnt.overscrollConfig) cnt.overscrollConfig = void 0;
  5395. }
  5396. }
  5397. } else {
  5398. let e = a.target;
  5399. for (; e instanceof Element; e = e.parentElement) {
  5400. const cnt = insp(e);
  5401. if (e.overscrollConfig) e.overscrollConfig = void 0;
  5402. if (cnt.overscrollConfig) cnt.overscrollConfig = void 0;
  5403. }
  5404. }
  5405. };
  5406.  
  5407. let checkWheelListenerObjs = null;
  5408.  
  5409. let getObjsFn = () => {
  5410. let euyVal = 0;
  5411. const eukElm = {};
  5412. Object.setPrototypeOf(eukElm, HTMLElement_.prototype);
  5413. const euzObj = new Proxy(eukElm, {
  5414. get(target, prop) {
  5415. throw `ErrorF31.get(${prop})`
  5416. },
  5417. set(target, prop, value) {
  5418. throw `ErrorF33.set(${prop}, ${value})`
  5419. }
  5420. });
  5421. const euxElm = new Proxy(eukElm, {
  5422. get(target, prop) {
  5423. if (prop === 'scrollTop') {
  5424. euyVal = euyVal | 8;
  5425. return 0;
  5426. }
  5427. if (prop === 'overscrollConfig') {
  5428. euyVal = euyVal | 16;
  5429. return void 0;
  5430. }
  5431. if (prop === 'scrollHeight' || prop === 'clientHeight' || prop === 'offsetHeight') {
  5432. return 640;
  5433. }
  5434. if (prop === 'scrollLeft') {
  5435. euyVal = euyVal | 8;
  5436. return 0;
  5437. }
  5438. if (prop === 'scrollWidth' || prop === 'clientWidth' || prop === 'offsetWidth') {
  5439. return 800;
  5440. }
  5441. throw `ErrorF45.get(${prop})`
  5442. },
  5443. set(target, prop, value) {
  5444. throw `ErrorF47.set(${prop}, ${value})`
  5445. }
  5446. });
  5447. const eukEvt = {};
  5448. Object.setPrototypeOf(eukEvt, WheelEvent.prototype);
  5449. const euyEvt = new Proxy(eukEvt, {
  5450. get(target, prop) {
  5451. if (prop === 'deltaY' || prop === 'deltaX') {
  5452. euyVal = euyVal | 1;
  5453. return -999;
  5454. }
  5455. if (prop === 'target') {
  5456. euyVal = euyVal | 2;
  5457. return euxElm
  5458. }
  5459. if (prop === 'path' || prop === 'composedPath') {
  5460. euyVal = euyVal | 2;
  5461. return [euxElm]
  5462. }
  5463. throw `ErrorF51.get(${prop})`
  5464. },
  5465. set(target, prop, value) {
  5466. throw `ErrorF53.set(${prop}, ${value})`
  5467. }
  5468. });
  5469. const setVal = (v) => {
  5470. euyVal = v;
  5471. }
  5472. const getVal = () => {
  5473. return euyVal;
  5474. }
  5475. return { euzObj, euyEvt, setVal, getVal };
  5476. }
  5477.  
  5478. let checkWheelListener = (callback) => {
  5479.  
  5480. let callbackIdentifier = '';
  5481.  
  5482. let res = null;
  5483. try {
  5484. const { euzObj, euyEvt, getVal, setVal } = checkWheelListenerObjs || (checkWheelListenerObjs = getObjsFn());
  5485. setVal(0);
  5486. if (callback.call(euzObj, euyEvt) !== void 0) throw 'ErrorF99';
  5487. throw `RESULT${getVal()}`;
  5488. } catch (e) {
  5489. res = e;
  5490. }
  5491.  
  5492. res = `${res}` || `${null}`;
  5493. if (res.length > 20) res = `${res.substring(0, 20)}...`;
  5494.  
  5495. callbackIdentifier = res;
  5496. if (callbackIdentifier === 'RESULT27') 0;
  5497. else if (callbackIdentifier === 'RESULT0') {
  5498. // a.isSearch && !a.disableWheelScroll && B("desktop_enable_dmpanel_wheel_scroll")
  5499. } else if (callbackIdentifier.startsWith('RESULT')) {
  5500. console.log('wheel eventListener - RESULT', callbackIdentifier, callback)
  5501. }
  5502. return callbackIdentifier;
  5503.  
  5504. };
  5505.  
  5506. let callbackFound = false;
  5507. EventTarget.prototype.addEventListener52178 = EventTarget.prototype.addEventListener;
  5508. EventTarget.prototype.addEventListener = function (type, callback, option = void 0) {
  5509. // M-youtube-js-engine-tamer.52178
  5510. if (type === 'wheel' && !option && typeof callback === 'function' && callback.length === 1) {
  5511. // (( match with signature `a.addEventListener("wheel", hZb);` )) [subject to further review]
  5512. const callbackIdentifier = callback.yaujmoms || (callbackFound ? 'IGNORE' : (callback.yaujmoms = checkWheelListener(callback)));
  5513. // RESULTXX / ErrorFXX / Other...
  5514. if (callbackIdentifier === 'RESULT27') {
  5515. this.overscrollConfigDisable = true;
  5516. if (!callbackFound) {
  5517. callbackFound = true; // suppose only one function is assigned to overscrollConfig cooldown [no function binding]
  5518. getObjsFn = checkWheelListener = null;
  5519. checkWheelListenerObjs = null;
  5520. wheelHandler = null;
  5521. }
  5522. return void 0;
  5523. } else if (!callbackFound && !this.overscrollConfigDisable) {
  5524. this.overscrollConfigDisable = true;
  5525. this.addEventListener52178('wheel', wheelHandler, { passive: false });
  5526. }
  5527. }
  5528. return this.addEventListener52178(type, callback, option);
  5529. };
  5530.  
  5531. // ---- << this.overscrollConfig HACK >> -----
  5532.  
  5533. }
  5534.  
  5535. const { pageMediaWatcher, shortcutKeysFixer, keyboardController } = (() => {
  5536.  
  5537. let p_a_objWR = null;
  5538. let isSpaceKeyImmediate = false; // for ADVANCED_FIX_SHORTCUTKEYS
  5539. let ytPageReady = 0;
  5540.  
  5541. let isSpeedMastSpacebarControlEnabled = false; // youtube experimental feature // can be forced by CHANGE_SPEEDMASTER_SPACEBAR_CONTROL
  5542. let isGlobalSpaceControl = true;
  5543. let mediaPlayerElementWR = null;
  5544. let focusedElementAtSelection = null;
  5545.  
  5546. // let want_control_video = false;
  5547.  
  5548. let spaceBarControl_keyG = '';
  5549.  
  5550. let lastUserAction = 0;
  5551.  
  5552. const wmKeyControlPhase = new WeakMap();
  5553.  
  5554. let currentSelectionText = null;
  5555.  
  5556. const getCurrentSelectionText = () => {
  5557. if (currentSelectionText !== null) return currentSelectionText
  5558. return (currentSelectionText = `${getSelection()}`)
  5559. }
  5560.  
  5561. const pageMediaWatcher = () => {
  5562.  
  5563. // CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE && document.addEventListener('wheel', () => {
  5564. // want_control_video = false;
  5565. // }, { capture: true, passive: true });
  5566.  
  5567. document.addEventListener('yt-navigate', () => {
  5568. ytPageReady = 0;
  5569. });
  5570. document.addEventListener('yt-navigate-start', () => {
  5571. ytPageReady = 0;
  5572. });
  5573. document.addEventListener('yt-navigate-cache', () => {
  5574. ytPageReady = 0;
  5575. });
  5576.  
  5577. document.addEventListener('yt-navigate-finish', () => {
  5578. ytPageReady = 1;
  5579. });
  5580.  
  5581. document.addEventListener('durationchange', () => {
  5582. for (const elm of document.querySelectorAll('#movie_player video[src], #movie_player audio[src]')) {
  5583. if (elm.duration > 0.01) {
  5584. if (elm.closest('[hidden]')) continue;
  5585. mediaPlayerElementWR = mWeakRef(elm);
  5586. return;
  5587. }
  5588. }
  5589. }, { capture: true, passive: true });
  5590.  
  5591. document.addEventListener('selectionchange', (evt) => {
  5592. if (!evt || !evt.isTrusted || !(evt instanceof Event)) return;
  5593. currentSelectionText = null;
  5594. if (!(evt.target instanceof Node)) return;
  5595. focusedElementAtSelection = evt.target;
  5596. }, { capture: true, passive: true })
  5597.  
  5598. document.addEventListener('pointerdown', (evt) => {
  5599. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  5600. }, { capture: true, passive: true });
  5601.  
  5602.  
  5603. document.addEventListener('pointerup', (evt) => {
  5604. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  5605. }, { capture: true, passive: true });
  5606.  
  5607.  
  5608. document.addEventListener('keydown', (evt) => {
  5609. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  5610. }, { capture: true, passive: true });
  5611.  
  5612. document.addEventListener('keyup', (evt) => {
  5613. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  5614. }, { capture: true, passive: true });
  5615.  
  5616. };
  5617.  
  5618.  
  5619. const checkKeyB = (p_a_obj) => {
  5620.  
  5621. const boolList = new Set();
  5622. const p_a_obj_api = p_a_obj.api;
  5623.  
  5624. const nilFunc0 = function () {
  5625. return void 0
  5626. };
  5627. const mt = new Proxy({}, {
  5628. get(target, prop) {
  5629. if (prop === 'get') return nilFunc0;
  5630. return mt;
  5631. }
  5632. });
  5633. const nilFunc = function () {
  5634. return mt
  5635. };
  5636. const mw = new Proxy({}, {
  5637. get(target, prop) {
  5638. if (prop in p_a_obj_api) {
  5639. if (typeof p_a_obj_api.constructor.prototype[prop] === 'function') return nilFunc;
  5640. let q = Object.getOwnPropertyDescriptor(p_a_obj_api, prop);
  5641. if (q && q.value) {
  5642. if (!q.writable) return q.value;
  5643. if (typeof q.value === 'string') return '';
  5644. if (typeof q.value === 'number') return 0;
  5645. if (typeof q.value === 'boolean') return false;
  5646. if (q.value && typeof q.value === 'object') return {};
  5647. }
  5648. }
  5649. return undefined;
  5650. },
  5651. set(target, prop) {
  5652. throw 'mwSet';
  5653. }
  5654. });
  5655.  
  5656. const mq = new Proxy({}, {
  5657. get(target, prop) {
  5658. if (prop === 'api') return mw;
  5659. if (prop in p_a_obj) {
  5660. if (typeof p_a_obj.constructor.prototype[prop] === 'function') return nilFunc;
  5661. let q = Object.getOwnPropertyDescriptor(p_a_obj, prop);
  5662. if (q && q.value) {
  5663. if (!q.writable) return q.value;
  5664. if (typeof q.value === 'string') return '';
  5665. if (typeof q.value === 'number') return 0;
  5666. if (typeof q.value === 'boolean') return false;
  5667. if (q.value && typeof q.value === 'object') return {};
  5668. }
  5669. }
  5670. return undefined;
  5671. },
  5672. set(target, prop, val) {
  5673. if (typeof val === 'boolean') boolList.add(prop)
  5674. throw `mqSet(${prop},${val})`;
  5675. }
  5676. });
  5677.  
  5678. let res = ''
  5679. try {
  5680. res = `RESULT::${p_a_obj.handleGlobalKeyUp.call(mq, 9, false, false, false, false, "Tab", "Tab")}`;
  5681. } catch (e) {
  5682. res = `ERROR::${e}`;
  5683. }
  5684.  
  5685. if (boolList.size === 1) {
  5686. const value = boolList.values().next().value;
  5687. if (res === `ERROR::mqSet(${value},${true})`) {
  5688. p_a_obj.__uZWaD__ = value;
  5689. }
  5690. }
  5691.  
  5692. console.log('[yt-js-engine-tamer] global shortcut control', { '__uZWaD__': p_a_obj.__uZWaD__ });
  5693.  
  5694. }
  5695.  
  5696.  
  5697. let pm_p_a = null;
  5698.  
  5699. const p_a_init = function () {
  5700. const r = this.init91();
  5701. const keyBw = this.__cPzfo__ || '__NIL__';
  5702. const p_a_obj = this[keyBw];
  5703. if (!p_a_obj) return;
  5704. try {
  5705. checkKeyB(p_a_obj);
  5706. } catch (e) { }
  5707. p_a_objWR = mWeakRef(p_a_obj);
  5708. if (FIX_SHORTCUTKEYS > 0) {
  5709. if (p_a_obj && !p_a_obj.hVhtg) {
  5710. p_a_obj.hVhtg = 1;
  5711.  
  5712. p_a_obj.handleGlobalKeyUp91 = p_a_obj.handleGlobalKeyUp;
  5713. p_a_obj.handleGlobalKeyUp = p_a_xt.handleGlobalKeyUp;
  5714. p_a_obj.handleGlobalKeyDown91 = p_a_obj.handleGlobalKeyDown;
  5715. p_a_obj.handleGlobalKeyDown = p_a_xt.handleGlobalKeyDown;
  5716. p_a_obj.__handleGlobalKeyBefore__ = p_a_xt.__handleGlobalKeyBefore__;
  5717. p_a_obj.__handleGlobalKeyAfter__ = p_a_xt.__handleGlobalKeyAfter__;
  5718.  
  5719. }
  5720. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE && p_a_obj && p_a_obj.api && !p_a_obj.api.hVhtg) {
  5721. // const api = p_a_obj.api
  5722. // api.hVhtg = 1;
  5723. // api.playVideo91 = api.playVideo;
  5724. // api.playVideo = p_a_jt.playVideo;
  5725. // api.pauseVideo91 = api.pauseVideo;
  5726. // api.pauseVideo = p_a_jt.pauseVideo;
  5727. // }
  5728. }
  5729. if (pm_p_a) {
  5730. pm_p_a.resolve();
  5731. pm_p_a = null;
  5732. }
  5733. return r;
  5734. };
  5735.  
  5736. const p_a_xt = {
  5737.  
  5738. __handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) {
  5739.  
  5740. if (FIX_SHORTCUTKEYS === 2) {
  5741.  
  5742. // if (flagSpeedMaster !== false && !getGlobalSpacebarControlFlag()) return false;
  5743.  
  5744. if (activeElement) {
  5745.  
  5746. const controlPhaseCache = wmKeyControlPhase.get(activeElement);
  5747.  
  5748. if (controlPhaseCache === 6 && getCurrentSelectionText() !== "") void 0;
  5749. else if (controlPhaseCache === 1 || controlPhaseCache === 2 || controlPhaseCache === 5) return false;
  5750. else if ((controlPhaseCache !== 6 || focusedElementAtSelection === document.activeElement) && getCurrentSelectionText() !== "") return false;
  5751.  
  5752. }
  5753.  
  5754. const isSpaceBar = a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space';
  5755. const isDelayedSpaceBar = FIX_SHORTCUTKEYS === 2 && isSpaceBar && !isSpaceKeyImmediate && (isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag());
  5756. // console.log(582, isDelayedSpaceBar)
  5757. if (isDelayedSpaceBar) return void 0; // accept delay spacebar under isSpeedMastSpacebarControlEnabled (no rejection)
  5758.  
  5759. if (activeElement && (h === 'Space' || h === 'Enter')) {
  5760. const controlPhase = wmKeyControlPhase.get(activeElement);
  5761. if (controlPhase === 4 || controlPhase === 5) return false;
  5762. }
  5763. if (focusedElementAtSelection === activeElement && getCurrentSelectionText() !== "") return false;
  5764. // if (!isSpeedMastSpacebarControlEnabled && a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space') {
  5765. // if (!isSpaceKeyImmediate) return false;
  5766. // }
  5767. }
  5768.  
  5769. },
  5770.  
  5771. __handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret) {
  5772.  
  5773. if (FIX_SHORTCUTKEYS === 2 && ret && a >= 32 && ytPageReady === 1 && Date.now() - lastUserAction < 40 && activeElement === document.activeElement) {
  5774.  
  5775. const isSpaceBar = a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space';
  5776. const isDelayedSpaceBar = FIX_SHORTCUTKEYS === 2 && isSpaceBar && !isSpaceKeyImmediate && (isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag());
  5777. // console.log(583, isDelayedSpaceBar)
  5778. if (isDelayedSpaceBar) return void 0; // accept delay spacebar under isSpeedMastSpacebarControlEnabled (no rejection)
  5779.  
  5780. const mediaPlayerElement = kRef(mediaPlayerElementWR);
  5781.  
  5782. let mediaWorking = false;
  5783. if (mediaPlayerElement && (mediaPlayerElement.readyState === 4 || mediaPlayerElement.readyState === 1) && mediaPlayerElement.networkState === 2 && mediaPlayerElement.duration > 0.01) {
  5784. mediaWorking = true;
  5785. } else if (mediaPlayerElement && !mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  5786. mediaWorking = true;
  5787. }
  5788. // console.log(182, mediaWorking, mediaPlayerElement.readyState , mediaPlayerElement.networkState)
  5789. mediaWorking && Promise.resolve().then(() => {
  5790. if (activeElement === document.activeElement) {
  5791. return activeElement.blur()
  5792. } else {
  5793. return false
  5794. }
  5795. }).then((r) => {
  5796. r !== false && mediaPlayerElement.focus();
  5797. });
  5798. }
  5799. },
  5800.  
  5801.  
  5802. handleGlobalKeyUp(a, b, c, d, e, f, h) {
  5803.  
  5804. if (BY_PASS_KEYBOARD_CONTROL) return this.handleGlobalKeyUp91(a, b, c, d, e, f, h);
  5805.  
  5806. const activeElement = document.activeElement;
  5807.  
  5808. const allow = typeof this.__handleGlobalKeyBefore__ === 'function' ? this.__handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) : void 0;
  5809. if (allow === false) return false;
  5810.  
  5811. const ret = this.handleGlobalKeyUp91(a, b, c, d, e, f, h);
  5812. // console.log('handleGlobalKeyUp',ret, a, b, c, d, e, f, h);
  5813.  
  5814. typeof this.__handleGlobalKeyAfter__ === 'function' && this.__handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret);
  5815.  
  5816. return ret;
  5817. },
  5818. handleGlobalKeyDown(a, b, c, d, e, f, h, l) {
  5819.  
  5820.  
  5821. if (BY_PASS_KEYBOARD_CONTROL) return this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  5822.  
  5823. const activeElement = document.activeElement;
  5824. // if (a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space' && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  5825. // return this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  5826. // }
  5827. const allow = typeof this.__handleGlobalKeyBefore__ === 'function' ? this.__handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) : void 0;
  5828. if (allow === false) return false;
  5829.  
  5830. const ret = this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  5831. // console.log('handleGlobalKeyDown',ret, a, b, c, d, e, f, h,l)
  5832.  
  5833. typeof this.__handleGlobalKeyAfter__ === 'function' && this.__handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret);
  5834.  
  5835. return ret;
  5836. }
  5837.  
  5838. };
  5839.  
  5840. // const p_a_jt = { // API
  5841.  
  5842. // playVideo(a) { // without spinner effect
  5843.  
  5844. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE) {
  5845.  
  5846. // const mediaPlayerElement = kRef(mediaPlayerElementWR);
  5847. // if (mediaPlayerElement && !mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  5848. // want_control_video = true;
  5849. // // Promise.resolve().then(()=> mediaPlayerElement.focus() );
  5850. // }
  5851.  
  5852. // }
  5853. // return this.playVideo91(a);
  5854.  
  5855. // },
  5856.  
  5857. // pauseVideo(a) { // without spinner effect
  5858.  
  5859. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE) {
  5860.  
  5861. // const mediaPlayerElement = kRef(mediaPlayerElementWR);
  5862. // if (mediaPlayerElement && mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  5863. // want_control_video = true;
  5864. // // Promise.resolve().then(()=> mediaPlayerElement.focus() );
  5865. // }
  5866.  
  5867. // }
  5868. // return this.pauseVideo91(a);
  5869.  
  5870. // }
  5871. // };
  5872.  
  5873. let flagSpeedMaster = null;
  5874. const getSpeedMasterControlFlag = () => {
  5875.  
  5876. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  5877. isSpeedMastSpacebarControlEnabled = false;
  5878. if (config && config.EXPERIMENT_FLAGS && config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control) {
  5879. isSpeedMastSpacebarControlEnabled = true;
  5880. }
  5881. if (config && config.EXPERIMENTS_FORCED_FLAGS && config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control) {
  5882. isSpeedMastSpacebarControlEnabled = true;
  5883. }
  5884.  
  5885. if (flagSpeedMaster === null) {
  5886. const p = (((config || 0).WEB_PLAYER_CONTEXT_CONFIGS || 0).WEB_PLAYER_CONTEXT_CONFIG_ID_KEVLAR_WATCH || 0).serializedExperimentFlags;
  5887. if (!p) {
  5888. flagSpeedMaster = false;
  5889. } else {
  5890.  
  5891. flagSpeedMaster = (p.includes('web_enable_speedmaster=true') && p.includes('web_speedmaster_spacebar_control=true') && p.includes('web_speedmaster_updated_edu=true'));
  5892.  
  5893. }
  5894.  
  5895. }
  5896. if (!flagSpeedMaster) isSpeedMastSpacebarControlEnabled = false;
  5897.  
  5898. return isSpeedMastSpacebarControlEnabled;
  5899. }
  5900.  
  5901.  
  5902. const getGlobalSpacebarControlFlag = () => {
  5903.  
  5904. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  5905. isGlobalSpaceControl = false;
  5906. if (config && config.EXPERIMENT_FLAGS && config.EXPERIMENT_FLAGS.global_spacebar_pause) {
  5907. isGlobalSpaceControl = true;
  5908. }
  5909. if (config && config.EXPERIMENTS_FORCED_FLAGS && config.EXPERIMENTS_FORCED_FLAGS.global_spacebar_pause) {
  5910. isGlobalSpaceControl = true;
  5911. }
  5912.  
  5913. return isGlobalSpaceControl;
  5914. }
  5915.  
  5916. const keyboardController = async (_yt_player) => {
  5917.  
  5918. const keyQT = getQT(_yt_player);
  5919. const keySV = getSV(_yt_player);
  5920. const keyDX = getDX(_yt_player);
  5921. console.log(`[QT,SV,DX]`, [keyQT, keySV, keyDX]);
  5922.  
  5923. if (!keyDX) return;
  5924. if (keyDX === keyQT || keyDX === keySV) return;
  5925.  
  5926. if (typeof keyDX !== 'string') return;
  5927.  
  5928. let lastAccessKey = '';
  5929. let lastAccessKeyConfirmed = '';
  5930. const mb = new Proxy({}, {
  5931. get(target, prop) {
  5932. if (prop === 'handleGlobalKeyUp') lastAccessKeyConfirmed = lastAccessKey;
  5933. throw 'mbGet'
  5934. },
  5935. set(target, prop, val) {
  5936. throw 'mbSet'
  5937. }
  5938. });
  5939. const ma = new Proxy({}, {
  5940. get(target, prop) {
  5941. lastAccessKey = prop;
  5942. return mb
  5943. },
  5944. set(target, prop, val) {
  5945. throw 'maSet'
  5946. }
  5947. });
  5948.  
  5949. let keyBw = '';
  5950. try {
  5951. _yt_player[keyDX].prototype.handleGlobalKeyUp.call(ma);
  5952. } catch (e) {
  5953. if (e === 'mbGet' && typeof lastAccessKeyConfirmed === 'string' && lastAccessKeyConfirmed.length > 0) {
  5954. keyBw = lastAccessKeyConfirmed;
  5955. }
  5956. }
  5957.  
  5958. if (!keyBw) return;
  5959.  
  5960. if (typeof _yt_player[keyDX].prototype.init !== 'function' || _yt_player[keyDX].prototype.init.length !== 0) return;
  5961.  
  5962. pm_p_a = new PromiseExternal();
  5963.  
  5964. _yt_player[keyDX].prototype.__cPzfo__ = keyBw;
  5965.  
  5966. _yt_player[keyDX].prototype.init91 = _yt_player[keyDX].prototype.init;
  5967.  
  5968. _yt_player[keyDX].prototype.init = p_a_init;
  5969.  
  5970. await pm_p_a.then();
  5971. const p_a_obj = kRef(p_a_objWR);
  5972.  
  5973. const isSpeedMastSpacebarControlEnabledA = getSpeedMasterControlFlag();
  5974.  
  5975.  
  5976. if (CHANGE_SPEEDMASTER_SPACEBAR_CONTROL > 0) {
  5977.  
  5978. isSpeedMastSpacebarControlEnabled = CHANGE_SPEEDMASTER_SPACEBAR_CONTROL == 1;
  5979.  
  5980. if (!isSpeedMastSpacebarControlEnabled) {
  5981.  
  5982. if (config && config.EXPERIMENT_FLAGS) {
  5983. config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control = false;
  5984. }
  5985. if (config && config.EXPERIMENTS_FORCED_FLAGS) {
  5986. config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control = false;
  5987. }
  5988.  
  5989. } else {
  5990.  
  5991. if (config && config.EXPERIMENT_FLAGS) {
  5992. config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control = true;
  5993. }
  5994. if (config && config.EXPERIMENTS_FORCED_FLAGS) {
  5995. config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control = true;
  5996. }
  5997.  
  5998. }
  5999.  
  6000. }
  6001.  
  6002. const isSpeedMastSpacebarControlEnabledB = getSpeedMasterControlFlag();
  6003.  
  6004.  
  6005.  
  6006.  
  6007. console.log('[yt-js-engine-tamer] speedmaster by space (yt setting)', isSpeedMastSpacebarControlEnabledA, isSpeedMastSpacebarControlEnabledB);
  6008.  
  6009. // console.log(p_a_obj.handleGlobalKeyUp)
  6010. console.log('[yt-js-engine-tamer] p_a', p_a_obj);
  6011.  
  6012. // console.log(p_a_obj.api)
  6013.  
  6014.  
  6015. // QT -> DX(SV) -> p_a
  6016.  
  6017.  
  6018. /*
  6019. *
  6020. *
  6021. g.k.handleGlobalKeyUp = function(a, b, c, d, e, f, h) {
  6022. b = void 0 === b ? !1 : b;
  6023. c = void 0 === c ? !1 : c;
  6024. d = void 0 === d ? !1 : d;
  6025. e = void 0 === e ? !1 : e;
  6026. var l = g.PT(this);
  6027. l && l.handleGlobalKeyUp(a, b, c, d, e, f, h)
  6028. }
  6029.  
  6030. */
  6031.  
  6032. /*
  6033. *
  6034. *
  6035. *
  6036. g.k.handleGlobalKeyUp = function(a, b, c, d, e, f, h) {
  6037. return this.Bw ? this.Bw.handleGlobalKeyUp(a, b, c, d, e, f, h) : !1
  6038. }
  6039.  
  6040. */
  6041.  
  6042.  
  6043. // if(!keyDX) return;
  6044.  
  6045. // console.log(4999, keyDX)
  6046.  
  6047. };
  6048.  
  6049.  
  6050. const ytResumeFn = function () { // ADVANCED_FIX_SHORTCUTKEYS
  6051.  
  6052. const p_a_obj = kRef(p_a_objWR);
  6053. // const api = p_a_obj.api;
  6054.  
  6055.  
  6056. // console.log(540);
  6057.  
  6058. let boolList = null;
  6059. let ret;
  6060. isSpaceKeyImmediate = true;
  6061. try {
  6062.  
  6063. ret = 0;
  6064. ret = ret | (p_a_obj.handleGlobalKeyDown(32, false, false, false, false, ' ', 'Space', false) ? 1 : 0);
  6065. let p_a_objT;
  6066. if (!spaceBarControl_keyG) { // just in case
  6067. boolList = new Set();
  6068. p_a_objT = new Proxy(p_a_obj, {
  6069. get(target, prop, handler) {
  6070. const val = target[prop];
  6071. if (typeof val !== 'boolean') return val;
  6072. boolList.add(prop);
  6073. // console.log(555, prop, val);
  6074. if (typeof prop === 'string' && prop.length <= 3 && val === true && boolList.length === 1) {
  6075. spaceBarControl_keyG = prop;
  6076. p_a_obj.__uZWaD__ = spaceBarControl_keyG;
  6077. val = false;
  6078. }
  6079. return val;
  6080. }
  6081. });
  6082.  
  6083.  
  6084. } else if (p_a_obj[spaceBarControl_keyG] === true) {
  6085. p_a_obj[spaceBarControl_keyG] = false;
  6086. p_a_objT = p_a_obj;
  6087. // console.log(p_a_obj, spaceBarControl_keyG, p_a_obj[spaceBarControl_keyG] )
  6088. } else {
  6089.  
  6090. p_a_objT = p_a_obj;
  6091. }
  6092.  
  6093. ret = ret | (p_a_objT.handleGlobalKeyUp(32, false, false, false, false, ' ', 'Space') ? 2 : 0);
  6094.  
  6095.  
  6096. } catch (e) {
  6097. console.log(e)
  6098. }
  6099. isSpaceKeyImmediate = false;
  6100.  
  6101. if (boolList && boolList.size === 1) {
  6102. const value = boolList.values().next().value;
  6103. spaceBarControl_keyG = value;
  6104. p_a_obj.__uZWaD__ = spaceBarControl_keyG;
  6105.  
  6106. }
  6107.  
  6108. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  6109.  
  6110. return ret;
  6111. }
  6112.  
  6113. const shortcutKeysFixer = () => {
  6114.  
  6115. let pausePromiseControlJ = 0;
  6116.  
  6117.  
  6118. const obtainCurrentControlPhase = (evt, mediaPlayerElement) => {
  6119.  
  6120. let controlPhase = 0;
  6121. const aElm = document.activeElement;
  6122.  
  6123. if (aElm) {
  6124.  
  6125. const controlPhaseCache = wmKeyControlPhase.get(aElm);
  6126.  
  6127. if (typeof controlPhaseCache === 'number') {
  6128.  
  6129. controlPhase = controlPhaseCache;
  6130. } else {
  6131.  
  6132. if (aElm instanceof HTMLInputElement) controlPhase = 1;
  6133. else if (aElm instanceof HTMLTextAreaElement) controlPhase = 1;
  6134. else if (aElm instanceof HTMLButtonElement) controlPhase = 2;
  6135. else if (aElm instanceof HTMLIFrameElement) controlPhase = 2;
  6136. else if (aElm instanceof HTMLImageElement) controlPhase = 2;
  6137. else if (aElm instanceof HTMLEmbedElement) controlPhase = 2;
  6138. else {
  6139. if (aElm instanceof HTMLElement_ && aElm.closest('[role]')) controlPhase = 5;
  6140. if (aElm instanceof HTMLDivElement) controlPhase = 2;
  6141. else if (aElm instanceof HTMLAnchorElement) controlPhase = 2;
  6142. else if (!(aElm instanceof HTMLElement_) && (aElm instanceof Element)) controlPhase = 2; // svg
  6143. }
  6144.  
  6145. if ((controlPhase === 2 || controlPhase === 5) && (aElm instanceof HTMLElement_) && aElm.contains(mediaPlayerElement)) {
  6146. controlPhase = 0;
  6147. }
  6148.  
  6149. if ((controlPhase === 2 || controlPhase === 5) && evt && evt.target && evt.target === aElm) {
  6150. if (aElm.closest('[contenteditable], input, textarea')) {
  6151. controlPhase = 5;
  6152. } else if (aElm.closest('button')) {
  6153. controlPhase = 4;
  6154. }
  6155. }
  6156.  
  6157. if (aElm.closest('#movie_player')) controlPhase = 6;
  6158.  
  6159. wmKeyControlPhase.set(aElm, controlPhase);
  6160.  
  6161. }
  6162. }
  6163.  
  6164. return controlPhase;
  6165.  
  6166. }
  6167.  
  6168. const isStateControllable = (api) => {
  6169. let appState = null;
  6170. let playerState = null;
  6171. let adState = null;
  6172. try {
  6173. appState = api.getAppState();
  6174. playerState = api.getPlayerState();
  6175. adState = api.getAdState();
  6176. } catch (e) { }
  6177. // ignore playerState -1
  6178. return appState === 5 && adState === -1 && (playerState === 1 || playerState === 2 || playerState === 3);
  6179. };
  6180.  
  6181.  
  6182. const keyEventListener = (evt) => {
  6183. if (BY_PASS_KEYBOARD_CONTROL) return;
  6184.  
  6185. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  6186. if (isSpaceKeyImmediate || !evt.isTrusted || !(evt instanceof KeyboardEvent)) return;
  6187. if (!ytPageReady) return;
  6188.  
  6189. if (evt.defaultPrevented === true) return;
  6190.  
  6191. const p_a_obj = kRef(p_a_objWR);
  6192.  
  6193. if (!p_a_obj) return;
  6194.  
  6195.  
  6196. const mediaPlayerElement = kRef(mediaPlayerElementWR);
  6197. if (!mediaPlayerElement) return;
  6198.  
  6199. // let focusBodyIfSuccess = false;
  6200.  
  6201. const controlPhase = obtainCurrentControlPhase(evt, mediaPlayerElement);
  6202.  
  6203. if (controlPhase === 6 && getCurrentSelectionText() !== "") void 0;
  6204. else if (controlPhase === 1 || controlPhase === 2 || controlPhase === 5) return;
  6205. else if ((controlPhase !== 6 || focusedElementAtSelection === document.activeElement) && getCurrentSelectionText() !== "") return;
  6206.  
  6207.  
  6208. if (evt.code === 'Space' && !getGlobalSpacebarControlFlag()) return;
  6209.  
  6210. // console.log(`${evt.type}::controlPhase`,controlPhase)
  6211.  
  6212. // if (controlPhase == 4) {
  6213. // focusBodyIfSuccess = true;
  6214. // }
  6215.  
  6216. spaceBarControl_keyG = spaceBarControl_keyG || p_a_obj.__uZWaD__ || ''
  6217. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  6218.  
  6219. if (FIX_SHORTCUTKEYS < 2) return;
  6220. if (!(!evt.shiftKey && !evt.ctrlKey && !evt.altKey && !evt.metaKey)) return; // ignore if modifier key is pressed -> let other event listener to handle first
  6221.  
  6222. let rr;
  6223. const isSpaceBar = evt.code === 'Space' && !evt.shiftKey && !evt.ctrlKey && !evt.altKey && !evt.metaKey;
  6224.  
  6225.  
  6226.  
  6227. let useImprovedPauseResume = false;
  6228.  
  6229. if (USE_IMPROVED_PAUSERESUME_UNDER_NO_SPEEDMASTER && isSpaceBar && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  6230.  
  6231. const api = p_a_obj.api;
  6232. const stateControllable = isStateControllable(api);
  6233. // console.log(2122, appState, playerState, adState)
  6234.  
  6235. if (stateControllable && isWatchPageURL() && mediaPlayerElement.duration > 0.01 && (mediaPlayerElement.readyState === 4 || mediaPlayerElement.readyState === 1) && mediaPlayerElement.networkState === 2) {
  6236.  
  6237. useImprovedPauseResume = true;
  6238.  
  6239. }
  6240.  
  6241.  
  6242. }
  6243.  
  6244.  
  6245. // force flag: CHANGE_SPEEDMASTER_SPACEBAR_CONTROL
  6246. if (evt.type === 'keydown') {
  6247.  
  6248. if (useImprovedPauseResume) {
  6249.  
  6250. const isPaused = mediaPlayerElement.paused;
  6251.  
  6252. const cj = ++pausePromiseControlJ;
  6253. Promise.resolve().then(() => {
  6254.  
  6255. if (cj !== pausePromiseControlJ) return;
  6256.  
  6257. if (mediaPlayerElement.paused !== isPaused) return;
  6258.  
  6259. const ret = ytResumeFn();
  6260. if (!ret) { // fallback
  6261. isPaused ? api.playVideo() : api.pauseVideo();
  6262. }
  6263.  
  6264. /*
  6265. let a = void 0;
  6266. console.log('Rb', api.Rb())
  6267. a = !window._yt_player.nL(api.Rb());
  6268. p_a_obj.Wd.kG(a)
  6269. a ? api.playVideo() : api.pauseVideo();
  6270.  
  6271. */
  6272.  
  6273.  
  6274. });
  6275. rr = true;
  6276. } else {
  6277.  
  6278. isSpaceKeyImmediate = true;
  6279. rr = p_a_obj.handleGlobalKeyDown(evt.keyCode, evt.shiftKey, evt.ctrlKey, evt.altKey, evt.metaKey, evt.key, evt.code, evt.repeat);
  6280. isSpaceKeyImmediate = false;
  6281. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  6282.  
  6283. }
  6284.  
  6285.  
  6286. } else if (evt.type === 'keyup') {
  6287.  
  6288. if (isSpaceBar && useImprovedPauseResume && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  6289.  
  6290. rr = true;
  6291. } else {
  6292.  
  6293. isSpaceKeyImmediate = true;
  6294. rr = p_a_obj.handleGlobalKeyUp(evt.keyCode, evt.shiftKey, evt.ctrlKey, evt.altKey, evt.metaKey, evt.key, evt.code);
  6295. isSpaceKeyImmediate = false;
  6296. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  6297.  
  6298. }
  6299.  
  6300.  
  6301. /*
  6302.  
  6303. if (d)
  6304. switch (c) {
  6305. case 32:
  6306. case 13:
  6307. if ("BUTTON" === d.tagName || "A" === d.tagName || "INPUT" === d.tagName)
  6308. b = !0,
  6309. e = !1;
  6310. else if (e) {
  6311. var m = d.getAttribute("role");
  6312. !m || "option" !== m && "button" !== m && 0 !== m.indexOf("menuitem") || (b = !0,
  6313. d.click(),
  6314. f = !0)
  6315. }
  6316. break;
  6317. case 37:
  6318. case 39:
  6319. case 36:
  6320. case 35:
  6321. b = "slider" === d.getAttribute("role");
  6322. break;
  6323. case 38:
  6324. case 40:
  6325. m = d.getAttribute("role"),
  6326. d = 38 === c ? d.previousSibling : d.nextSibling,
  6327. "slider" === m ? b = !0 : e && ("option" === m ? (d && "option" === d.getAttribute("role") && d.focus(),
  6328. f = b = !0) : m && 0 === m.indexOf("menuitem") && (d && d.hasAttribute("role") && 0 === d.getAttribute("role").indexOf("menuitem") && d.focus(),
  6329. f = b = !0))
  6330. }
  6331. if (e && !f)
  6332. switch (c) {
  6333. case 38:
  6334. f = Math.min(this.api.getVolume() + 5, 100);
  6335. XV(this.Wd, f, !1);
  6336. this.api.setVolume(f);
  6337. h = f = !0;
  6338. break;
  6339. case 40:
  6340. f = Math.max(this.api.getVolume() - 5, 0);
  6341. XV(this.Wd, f, !0);
  6342. this.api.setVolume(f);
  6343. h = f = !0;
  6344. break;
  6345. case 36:
  6346. this.api.Yh() && (this.api.startSeekCsiAction(),
  6347. this.api.seekTo(0, void 0, void 0, void 0, 79),
  6348. h = f = !0);
  6349. break;
  6350. case 35:
  6351. this.api.Yh() && (this.api.startSeekCsiAction(),
  6352. this.api.seekTo(Infinity, void 0, void 0, void 0, 80),
  6353. h = f = !0)
  6354. }
  6355. */
  6356.  
  6357. }
  6358.  
  6359.  
  6360. if (rr) {
  6361.  
  6362. // focusBodyIfSuccess && Promise.resolve().then(() => {
  6363. // activeElement === document.activeElement && activeElement.blur();
  6364. // });
  6365.  
  6366. evt.preventDefault();
  6367. evt.stopImmediatePropagation();
  6368. evt.stopPropagation();
  6369.  
  6370. }
  6371.  
  6372. };
  6373.  
  6374. document.addEventListener('keydown', keyEventListener, { capture: true });
  6375.  
  6376.  
  6377. document.addEventListener('keyup', keyEventListener, { capture: true });
  6378.  
  6379. }
  6380.  
  6381. return { pageMediaWatcher, shortcutKeysFixer, keyboardController };
  6382.  
  6383. })();
  6384.  
  6385.  
  6386. pageMediaWatcher();
  6387. FIX_SHORTCUTKEYS > 0 && shortcutKeysFixer();
  6388.  
  6389.  
  6390. const check_for_set_key_order = (() => {
  6391.  
  6392. let mySet = new Set();
  6393.  
  6394. mySet.add("value1");
  6395. mySet.add("value2");
  6396. mySet.add("value3");
  6397.  
  6398. // Function to convert Set values to an array
  6399. function getSetValues(set) {
  6400. return Array.from(set.values());
  6401. }
  6402.  
  6403. // Function to test if the Set maintains insertion order
  6404. function testSetOrder(set, expectedOrder) {
  6405. let values = getSetValues(set);
  6406. return expectedOrder.join(',') === values.join(',');
  6407. }
  6408.  
  6409. // Test 1: Initial order
  6410. if (mySet.values().next().value !== "value1") return false;
  6411. if (!testSetOrder(mySet, ["value1", "value2", "value3"])) return false;
  6412.  
  6413. // Test 2: After deleting an element
  6414. mySet.delete("value2");
  6415. if (mySet.values().next().value !== "value1") return false;
  6416. if (!testSetOrder(mySet, ["value1", "value3"])) return false;
  6417.  
  6418. // Test 3: After re-adding a deleted element
  6419. mySet.add("value2");
  6420. if (mySet.values().next().value !== "value1") return false;
  6421. if (!testSetOrder(mySet, ["value1", "value3", "value2"])) return false;
  6422.  
  6423. // Test 4: After adding a new element
  6424. mySet.add("value4");
  6425. if (mySet.values().next().value !== "value1") return false;
  6426. if (!testSetOrder(mySet, ["value1", "value3", "value2", "value4"])) return false;
  6427.  
  6428. // Test 5: Delete+Add
  6429. mySet.delete("value1");
  6430. mySet.delete("value3");
  6431. mySet.add("value3");
  6432. mySet.add("value1");
  6433. if (mySet.values().next().value !== "value2") return false;
  6434. if (!testSetOrder(mySet, ["value2", "value4", "value3", "value1"])) return false;
  6435.  
  6436. return true;
  6437. })();
  6438.  
  6439.  
  6440. // const qm47 = Symbol();
  6441. const qm57 = Symbol();
  6442. const qm53 = Symbol();
  6443. const qn53 = Symbol();
  6444.  
  6445.  
  6446. const ump3 = new WeakMap();
  6447.  
  6448. const stp = document.createElement('noscript');
  6449. stp.id = 'weakref-placeholder';
  6450.  
  6451. PROP_OverReInclusion_AVOID && (() => {
  6452.  
  6453.  
  6454. if (typeof HTMLElement_.prototype.hasOwnProperty72 === 'function' || typeof HTMLElement_.prototype.hasOwnProperty !== 'function') return;
  6455. const f = HTMLElement_.prototype.hasOwnProperty72 = HTMLElement_.prototype.hasOwnProperty;
  6456. let byPassVal = null;
  6457. let byPassCount = 0;
  6458. let mmw = new Set();
  6459. HTMLElement_.prototype.hasOwnProperty = function (prop) {
  6460. if (arguments.length !== 1) return f.apply(this, arguments);
  6461. if (byPassVal !== null && typeof prop === 'string') {
  6462.  
  6463. if (PROP_OverReInclusion_LIST.has(prop)) {
  6464. byPassCount++;
  6465. return byPassVal;
  6466. }
  6467. PROP_OverReInclusion_DEBUGLOG && mmw.add(prop);
  6468.  
  6469. }
  6470. return this.hasOwnProperty72(prop);
  6471. };
  6472.  
  6473.  
  6474. /*
  6475.  
  6476.  
  6477. z.prototype.forwardDynamicProps = function() {
  6478. var B = m(this.inst);
  6479. B = h(B);
  6480. for (var F = B.next(); !F.done; F = B.next()) {
  6481. var H = h(F.value);
  6482. F = H.next().value;
  6483. H = H.next().value;
  6484. my(this, F, H);
  6485. r(b) && !ly(F) && Wua(this.inst, F)
  6486. }
  6487. }
  6488.  
  6489. */
  6490.  
  6491.  
  6492.  
  6493. let byPassZeroShowed = false;
  6494. const forwardDynamicPropsGeneral = function () {
  6495. byPassVal = true;
  6496. byPassCount = 0;
  6497. PROP_OverReInclusion_DEBUGLOG && mmw.clear();
  6498. const ret = this.forwardDynamicProps72();
  6499. byPassVal = null;
  6500. if (byPassCount === 0 && !byPassZeroShowed) {
  6501. byPassZeroShowed = true;
  6502. console.log('[yt-js-engine-tamer] byPassCount = 0 in forwardDynamicProps')
  6503. }
  6504. byPassCount = 0;
  6505. if (PROP_OverReInclusion_DEBUGLOG && mmw.size > 0) {
  6506. console.log(399, '[yt-js-engine-tamer]', [...mmw]);
  6507. mmw.clear();
  6508. }
  6509. return ret;
  6510. };
  6511.  
  6512. const propCheck = (proto) => {
  6513. if (typeof (proto || 0) == 'object' && typeof proto.forwardDynamicProps === 'function' && typeof proto.forwardDynamicProps72 !== 'function') {
  6514. proto.forwardDynamicProps72 = proto.forwardDynamicProps;
  6515. if (proto.forwardDynamicProps.length === 0) {
  6516. proto.forwardDynamicProps = forwardDynamicPropsGeneral;
  6517. }
  6518. }
  6519. };
  6520.  
  6521. const valMap = new WeakMap();
  6522. Object.defineProperty(HTMLElement_.prototype, 'didForwardDynamicProps', {
  6523. get() {
  6524. propCheck(this.constructor.prototype);
  6525. return valMap.get(this);
  6526. },
  6527. set(nv) {
  6528. propCheck(this.constructor.prototype);
  6529. valMap.set(this, nv);
  6530. return true;
  6531. },
  6532. enumerable: false,
  6533. configurable: true
  6534.  
  6535. });
  6536.  
  6537. promiseForCustomYtElementsReady.then(() => {
  6538. if (typeof customElements !== 'object' || typeof customElements.define72 === 'function' || typeof customElements.define !== 'function') return;
  6539. if (customElements.define.length !== 2) return;
  6540. customElements.define72 = customElements.define;
  6541. customElements.define = function (b, w) {
  6542. propCheck(w.prototype);
  6543. const ret = this.define72(b, w);
  6544. return ret;
  6545. }
  6546. });
  6547.  
  6548. })();
  6549.  
  6550. if (FIX_FlexibleItemSizing) { // for youtube flow chat
  6551.  
  6552. const flexibleItemListMo = new MutationObserver((mutations) => {
  6553. // cnt.onStamperFinished
  6554. // cnt.maybeUpdateFlexibleMenu
  6555. const set = new Set();
  6556. for (const mutation of mutations) {
  6557. if (mutation && ((mutation.addedNodes || 0).length > 0 || (mutation.removedNodes || 0).length > 0)) {
  6558. set.add(mutation.target);
  6559. }
  6560. }
  6561. for (const s of set) {
  6562. const cnt = insp(s);
  6563. if (typeof cnt.maybeUpdateFlexibleMenuImpl === 'function') {
  6564. cnt.maybeUpdateFlexibleMenuImpl();
  6565. } else if (typeof cnt.maybeUpdateFlexibleMenu === 'function') {
  6566. cnt.maybeUpdateFlexibleMenu();
  6567. } else if (typeof cnt.onStamperFinished === 'function') {
  6568. cnt.onStamperFinished();
  6569. }
  6570. }
  6571. set.clear();
  6572. });
  6573.  
  6574. let checkConfig = true;
  6575. const flexibleItemDocMo = new MutationObserver(() => {
  6576. for (const s of document.querySelectorAll('ytd-menu-renderer[has-flexible-items]:not([b289ad])')) {
  6577. s.setAttribute('b289ad', '');
  6578. flexibleItemListMo.observe(s, { subtree: false, childList: true });
  6579. s.appendChild(document.createComment('.')).remove();
  6580. }
  6581. if (checkConfig) {
  6582. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  6583. if (config && config.EXPERIMENT_FLAGS) {
  6584. checkConfig = false;
  6585. config.EXPERIMENT_FLAGS.web_fix_missing_action_buttons = true;
  6586. }
  6587. }
  6588. });
  6589. flexibleItemDocMo.observe(document, { subtree: true, childList: true });
  6590.  
  6591. }
  6592.  
  6593.  
  6594.  
  6595.  
  6596. const observablePromise = (proc, timeoutPromise) => {
  6597. let promise = null;
  6598. return {
  6599. obtain() {
  6600. if (!promise) {
  6601. promise = new Promise(resolve => {
  6602. let mo = null;
  6603. const f = () => {
  6604. let t = proc();
  6605. if (t) {
  6606. mo.disconnect();
  6607. mo.takeRecords();
  6608. mo = null;
  6609. resolve(t);
  6610. }
  6611. }
  6612. mo = new MutationObserver(f);
  6613. mo.observe(document, { subtree: true, childList: true })
  6614. f();
  6615. timeoutPromise && timeoutPromise.then(() => {
  6616. resolve(null)
  6617. });
  6618. });
  6619. }
  6620. return promise
  6621. }
  6622. }
  6623. }
  6624.  
  6625.  
  6626. if (HOOK_ACTIVE_MODULES_fetchUpdatedMetadata) {
  6627. observablePromise(() => {
  6628. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  6629. if (config && config.EXPERIMENT_FLAGS) {
  6630. config.EXPERIMENT_FLAGS.web_watch_get_updated_metadata_manager = true;
  6631. return true;
  6632. }
  6633. }).obtain();
  6634. }
  6635.  
  6636. if (FIX_ROLLING_NUMBER_UPDATE) {
  6637.  
  6638.  
  6639. observablePromise(() => {
  6640. if (typeof customElements === 'undefined') return;
  6641. const ce = customElements.get('yt-animated-rolling-number');
  6642. if (!ce) return;
  6643. return ce.prototype;
  6644. }).obtain().then(async (cProto) => {
  6645.  
  6646. const p = document.createElement('yt-animated-rolling-number');
  6647.  
  6648. const frag = document.createDocumentFragment();
  6649. frag.appendChild(p);
  6650. const pDoc = document.implementation.createHTMLDocument();
  6651. pDoc.body.appendChild(frag);
  6652.  
  6653. let p88 = p;
  6654.  
  6655. const __instance = await observablePromise(() => {
  6656. const __instance = (p88 || 0).__instance;
  6657. if (__instance && __instance.render) return __instance;
  6658. }).obtain();
  6659. p88 = null;
  6660.  
  6661. const itProto = Reflect.getPrototypeOf(__instance);
  6662.  
  6663. try {
  6664. p.remove();
  6665. } catch (e) { }
  6666.  
  6667. if (itProto.render && !itProto.render37 && itProto.render.length === 1) {
  6668.  
  6669. itProto.render37 = itProto.render;
  6670. itProto.render = function (t) {
  6671. // (this.xCounter = (this.xCounter & 1073741823)+1)
  6672. let c33 = '';
  6673. let r33 = null;
  6674. let kc = 0;
  6675.  
  6676. if (this && t && this.hookCounter >= 1 && !this.__unmounted && this.el) {
  6677. const el = this.el;
  6678. const ct = Date.now();
  6679. const lastFireTime = (el.__lastFireTime491__ || 0);
  6680.  
  6681. const fireTimeDiff = lastFireTime > 0 ? ct - lastFireTime : 1e9;
  6682.  
  6683. if (fireTimeDiff < 80 && this.__previousRender61__) {
  6684. return this.__previousRender61__;
  6685. }
  6686.  
  6687. const caseInt =
  6688. (t && typeof t.numberText === 'string' && Number.isFinite(t.numberValue)) ? 1 :
  6689. (t && typeof t.character === 'string') ? (
  6690. (typeof t.previousCharacter === 'string') ? 6 : 2
  6691. ) : 0;
  6692.  
  6693. if (caseInt === 6 && t.previousCharacter && t.character && this.__previousRender61__ && fireTimeDiff < 9400) {
  6694. if (this[`__lastCharRender62__${t.previousCharacter}>${t.character}`] === this.__previousRender61__) {
  6695. return this.__previousRender61__;
  6696. }
  6697. }
  6698. if (caseInt === 1 && t.numberText.length > 0 && this.__previousRender61__ && fireTimeDiff < 9400) {
  6699. if (this[`__lastCharRender65__${t.numberValue}>${t.numberText}`] === this.__previousRender61__) {
  6700. return this.__previousRender61__;
  6701. }
  6702. }
  6703.  
  6704. if (caseInt & 2) {
  6705.  
  6706. if (caseInt & 4) {
  6707.  
  6708. if (el.__lastCharacter353__ && el.__lastCharacter353__.length === 1 && t.character.length === 1 && t.previousCharacter.length === 1) {
  6709. if (t.character !== t.previousCharacter && t.character === el.__lastCharacter353__) {
  6710. t.previousCharacter = t.character;
  6711. kc = 1;
  6712. }
  6713. }
  6714.  
  6715. if (t && t.character && t.previousCharacter && t.shouldAnimate === true && t.character === t.previousCharacter) {
  6716. t.shouldAnimate = false;
  6717. }
  6718. }
  6719.  
  6720.  
  6721. c33 = `__lastCharRender62__${t.previousCharacter}>${t.character}`;
  6722.  
  6723. el.__lastCharacter353__ = t.character;
  6724.  
  6725. } else if (caseInt === 1) {
  6726.  
  6727. if (el.__lastNumberValue353__ === t.numberValue && t.shouldAnimate === true) {
  6728. t.shouldAnimate = false;
  6729. }
  6730. el.__lastNumberValue353__ = t.numberValue;
  6731.  
  6732. if (el.__lastNumberText353__ === t.numberText && t.shouldAnimate === true) {
  6733. t.shouldAnimate = false;
  6734. }
  6735. el.__lastNumberText353__ = t.numberText;
  6736.  
  6737. c33 = `__lastCharRender65__${t.numberValue}>${t.numberText}`;
  6738.  
  6739. }
  6740.  
  6741. // console.log(138002, this, t, caseInt, kc, fireTimeDiff);
  6742.  
  6743. el.__lastFireTime491__ = ct;
  6744. }
  6745.  
  6746. // // console.log(21399, t.character, t.previousCharacter, (t.xCounter = (t.xCounter & 1073741823)+1), t, (this.xCounter = (this.xCounter & 1073741823)+1) )
  6747. // // console.log(12883, this, t);
  6748. const r = r33 || this.render37(t);
  6749. this.__previousRender61__ = r;
  6750. if (c33) this[c33] = r;
  6751. return r
  6752. }
  6753.  
  6754. }
  6755.  
  6756.  
  6757. /*
  6758.  
  6759. let jArr = null;
  6760. Array.prototype.push781 = null;
  6761. Array.prototype.push782 = function(...args){
  6762. if(args.length === 1 && typeof (args[0]||0) ==='object' && 'rollUp' in args[0] && Array.prototype.push781){
  6763.  
  6764. jArr= this;
  6765. // debugger;
  6766. const f = Array.prototype.push = Array.prototype.push781;
  6767. Array.prototype.push781 = null;
  6768. jArr.push381 = jArr.push;
  6769. jArr.push = Array.prototype.push783;
  6770. return Array.prototype.push783.call(this, ...args);
  6771.  
  6772. }
  6773. return Array.prototype.push781.call(this, ...args);
  6774. }
  6775. Array.prototype.push783 = function(...args){
  6776. if(args.length === 1){
  6777. const o = args[0];
  6778. if(o.character === o.previousCharacter){
  6779. o.rollUp = false;
  6780. o.shouldAnimate = false;
  6781. }
  6782. console.log(12399, o)
  6783. }
  6784. return this.push381(...args);
  6785. }
  6786.  
  6787. console.log(123001)
  6788.  
  6789. cProto.update192 = cProto.update;
  6790.  
  6791. cProto.update = function () {
  6792. Object.assign192 = Object.assign;
  6793. let targetObject = null;
  6794. let kThis = this;
  6795. Object.assign = function (...args) {
  6796. let r = Object.assign192(...args);;
  6797. if (args[1] === kThis.props) {
  6798. targetObject = args[0];
  6799. fixObject();
  6800. }
  6801. return r;
  6802. }
  6803. const fixObject = () => {
  6804.  
  6805. console.log(1929, fixObject, this)
  6806.  
  6807. const t = targetObject.forceRollUp;
  6808. targetObject.forceRollUp919 = t;
  6809. Object.defineProperty(targetObject, 'forceRollUp', {
  6810. get() {
  6811.  
  6812.  
  6813. if (Array.prototype.push782 !== Array.prototype.push && !Array.prototype.push781) {
  6814.  
  6815. Array.prototype.push781 = Array.prototype.push;
  6816. Array.prototype.push = Array.prototype.push782;
  6817. Promise.resolve().then(() => {
  6818. if (Array.prototype.push782 === Array.prototype.push && Array.prototype.push781) {
  6819.  
  6820. Array.prototype.push = Array.prototype.push781;
  6821.  
  6822. Array.prototype.push781 = null;;
  6823. }
  6824. })
  6825. }
  6826. console.log(1233001);
  6827. // debugger;
  6828. return this.forceRollUp919
  6829. },
  6830. set(nv) {
  6831. this.forceRollUp919 = nv;
  6832. console.log(1233002, nv);
  6833. return true;
  6834. }
  6835. });
  6836. }
  6837. console.log(1949, this)
  6838. let r, e_;
  6839. try {
  6840. r = this.update192();
  6841. } catch (e) { e_ = e }
  6842. Object.assign = Object.assign192;
  6843. kThis = null;
  6844. if (e_) throw e_;
  6845. return r;
  6846. };
  6847.  
  6848.  
  6849.  
  6850. cProto.enqueueUpdate192 = cProto.enqueueUpdate;
  6851.  
  6852. cProto.enqueueUpdate = function () {
  6853. console.log(1948, this);
  6854. return this.enqueueUpdate192();
  6855. }
  6856.  
  6857.  
  6858. */
  6859.  
  6860.  
  6861.  
  6862. });
  6863.  
  6864.  
  6865. /*
  6866.  
  6867. observablePromise(() => {
  6868. if(typeof customElements==='undefined')return;
  6869. const ce = customElements.get('segmented-like-dislike-button-view-model');
  6870. if(!ce) return;
  6871. return ce.prototype;
  6872. }).obtain().then((cProto) => {
  6873.  
  6874.  
  6875. cProto.update192 = cProto.update;
  6876. cProto.update = function () {
  6877.  
  6878. const rolNumNode = this.querySelector('yt-animated-rolling-number');
  6879. if(rolNumNode && rolNumNode.__instance && rolNumNode.__instance.props){
  6880. rolNumNode.props = rolNumNode.__instance.props;
  6881.  
  6882. if(!rolNumNode.props.forceRollUp848){
  6883. rolNumNode.props.forceRollUp848 = true;
  6884. rolNumNode.props.forceRollUp833= rolNumNode.props.forceRollUp;
  6885. Object.defineProperty(rolNumNode.props, 'forceRollUp', {
  6886. get(){
  6887. debugger;
  6888. return this.forceRollUp833;
  6889. },
  6890. set(nv){
  6891. this.forceRollUp833 = nv;
  6892. return true;
  6893. },
  6894. enumerable: false,
  6895. configurable: true
  6896. });
  6897.  
  6898. Object.defineProperty(rolNumNode.props, 'numberValue', {
  6899. get(){
  6900. debugger;
  6901. return this.numberValue8833;
  6902. },
  6903. set(nv){
  6904. debugger;
  6905. this.numberValue8833 = nv;
  6906. return true;
  6907. },
  6908. enumerable: false,
  6909. configurable: true
  6910. });
  6911.  
  6912. }
  6913. // rolNumNode.update();
  6914. return;
  6915. }
  6916.  
  6917. return this.update192();
  6918. };
  6919.  
  6920.  
  6921.  
  6922.  
  6923. });
  6924. */
  6925. }
  6926.  
  6927. if (HOOK_ACTIVE_MODULES) {
  6928.  
  6929. let watchController;
  6930. const watchControllerObservable = observablePromise(() => {
  6931. const watchFlexy = document.querySelector('ytd-watch-flexy');
  6932. if (!watchFlexy) return;
  6933. return insp(watchFlexy).watchController;
  6934. }).obtain();
  6935. (async () => {
  6936. watchController = await watchControllerObservable;
  6937.  
  6938. const activeModules = watchController.activeModules;
  6939. if (!activeModules) return;
  6940.  
  6941. const checkFn = (activeModule) => {
  6942. if (activeModule && typeof activeModule.fetchUpdatedMetadata === 'function' && activeModule.fetchUpdatedMetadata.length === 2) {
  6943. HOOK_ACTIVE_MODULES_fetchUpdatedMetadata && hookActiveModuleFetchUpdatedMetadata(activeModule);
  6944. }
  6945. }
  6946. if (!activeModules.push8792 && activeModules.push) {
  6947. activeModules.push8792 = activeModules.push;
  6948. activeModules.push = function (a, ...args) {
  6949. checkFn(a);
  6950. let r = args.length >= 1 ? this.push8792(a, ...args) : this.push8792(a);
  6951. return r;
  6952. }
  6953. }
  6954. activeModules.forEach(checkFn);
  6955.  
  6956. })();
  6957.  
  6958. let yieldResultWrappingByPass = false;
  6959. let asyncProto = null;
  6960. const yieldResultWrapping = (f) => {
  6961. if (yieldResultWrappingByPass) return [f(), null];
  6962. yieldResultWrappingByPass = true;
  6963. let D = null;
  6964. let promise, e_;
  6965. if (asyncProto) {
  6966. Object.defineProperty(asyncProto, 'yieldResult', {
  6967. get() {
  6968. return undefined;
  6969. },
  6970. set(nv) {
  6971. delete asyncProto.yieldResult;
  6972. this.yieldResult = nv;
  6973. D = this;
  6974. // console.log(122, this);
  6975. return true;
  6976. },
  6977. enumerable: false,
  6978. configurable: true
  6979. });
  6980. try {
  6981. promise = f();
  6982. } catch (e) { e_ = e }
  6983. delete asyncProto.yieldResult;
  6984. yieldResultWrappingByPass = false;
  6985. } else {
  6986. Object.defineProperty(Object.prototype, 'yieldResult', {
  6987. get() {
  6988. return undefined;
  6989. },
  6990. set(nv) {
  6991. delete Object.prototype.yieldResult;
  6992. this.yieldResult = nv;
  6993. D = this;
  6994. // console.log(122, this);
  6995. return true;
  6996. },
  6997. enumerable: false,
  6998. configurable: true
  6999. });
  7000. try {
  7001. promise = f();
  7002. } catch (e) { e_ = e }
  7003. delete Object.prototype.yieldResult;
  7004. yieldResultWrappingByPass = false;
  7005. if (D) {
  7006. asyncProto = Reflect.getPrototypeOf(D);
  7007. }
  7008. }
  7009. if (e_) throw e_;
  7010. return [promise, D];
  7011. }
  7012.  
  7013. const hookActiveModuleFetchUpdatedMetadata = (activeModule) => {
  7014.  
  7015. const aProto = Reflect.getPrototypeOf(activeModule);
  7016.  
  7017. if (!aProto || !aProto.fetchUpdatedMetadata || aProto.fetchUpdatedMetadata517) return;
  7018.  
  7019. console.log('[yt-js-engine-tamer] hookActiveModuleFetchUpdatedMetadata');
  7020.  
  7021. // console.log(12885)
  7022. aProto.fetchUpdatedMetadata517 = aProto.fetchUpdatedMetadata;
  7023. // let qxt=false;
  7024. aProto.fetchUpdatedMetadata = function (t, P) {
  7025.  
  7026. // if (!qxt) {
  7027. // qxt = true;
  7028. // var y = watchController.subscribe("WATCH_NEXT_RESPONSE_UPDATED", function (...args) {
  7029. // console.log(199001,...args)
  7030. // });
  7031. // this.addOnDisposeCallback(function (...args) {
  7032.  
  7033. // console.log(199002,...args)
  7034. // watchController.unsubscribeByKey(y)
  7035. // qxt = false;
  7036. // });
  7037. // }
  7038. const [promise, D] = yieldResultWrapping(() => this.fetchUpdatedMetadata517(t, P));
  7039. if (D) promise.then(() => {
  7040. const yieldResult = D.yieldResult;
  7041. if (yieldResult) {
  7042. const mutations = (((yieldResult || 0).frameworkUpdates || 0).entityBatchUpdate || 0).mutations;
  7043.  
  7044. if (mutations && mutations.length >= 1) {
  7045. let likeCountEntity = null;
  7046. for (const mutation of mutations) {
  7047. if (typeof (mutation.entityKey || 0) === 'string' && (likeCountEntity = (mutation.payload || 0).likeCountEntity)) {
  7048. break;
  7049. }
  7050. }
  7051. if (likeCountEntity) {
  7052. const model = insp(document.querySelector('segmented-like-dislike-button-view-model'));
  7053. if (model && typeof model.update === 'function' && model.update.length === 0) {
  7054. const data = ((model || 0).props || 0).data;
  7055. if (data) {
  7056. if (typeof data.likeCountEntity !== 'object') data.likeCountEntity = {};
  7057. // console.log(12838, {...data.likeCountEntity}, {...likeCountEntity})
  7058. // const shouldModelUpdate = (data.likeCountEntity.key !== likeCountEntity.key); // to be reviewed
  7059. const shouldModelUpdate = true;
  7060. Object.assign(data.likeCountEntity, likeCountEntity);
  7061. // data.likeCountEntity = likeCountEntity;
  7062. // if (shouldModelupdate) model.update();
  7063. // else {
  7064. // if (typeof model.notifyPath === 'function' && model.notifyPath.length === 0) model.notifyPath();
  7065. // }
  7066.  
  7067. if (shouldModelUpdate) {
  7068. if (typeof model.enqueueUpdate === 'function' && model.enqueueUpdate.length === 0) {
  7069. // console.log('kk1a enqueueUpdate')
  7070. model.enqueueUpdate();
  7071. // console.log('kk1b enqueueUpdate')
  7072. } else if (typeof model.update === 'function' && model.update.length === 0) {
  7073. // console.log('kk2a update')
  7074. model.update();
  7075. // console.log('kk2b update')
  7076. } else {
  7077. console.warn('[yt-js-engine-tamer] cannot do model update.')
  7078. }
  7079. }
  7080.  
  7081. }
  7082. }
  7083. }
  7084. }
  7085. }
  7086. }).catch(console.warn);
  7087. return promise;
  7088. };
  7089.  
  7090. }
  7091.  
  7092. }
  7093.  
  7094. /*
  7095. let cid = 0;
  7096.  
  7097. document.addEventListener('transitionrun', function(evt){
  7098.  
  7099. if(!evt || !evt.isTrusted || evt.propertyName !== 'margin-top' || !evt.target) return;
  7100.  
  7101. if (evt.target.nodeName !== 'ANIMATED-ROLLING-CHARACTER') return;
  7102.  
  7103.  
  7104.  
  7105.  
  7106. const target = evt.target;
  7107. let finish = false;
  7108. if (target.getAttribute('style-old126') === target.getAttribute('style')) finish = true;
  7109. else target.setAttribute('style-old126', target.getAttribute('style'));
  7110.  
  7111. target.setAttribute('should-finish', finish ? 'true' : 'false');
  7112.  
  7113.  
  7114. const animations = (document.timeline || 0)._animations;
  7115. if (!animations || !animations.length) return;
  7116.  
  7117. let aa = [...animations].filter(e => e.effect.target.hasAttribute('a85j2'));
  7118. if (!aa.length) return;
  7119.  
  7120. for (const a of aa) {
  7121.  
  7122. const s = a.effect.target;
  7123. if (s !== evt.target) continue;
  7124. if (a.eut33 && Date.now() - a.eut33 < 600) continue;
  7125. a.eut33 = Date.now();
  7126.  
  7127. if (finish) a.finish();
  7128.  
  7129.  
  7130. }
  7131.  
  7132. // console.log(1848);
  7133. }, true);
  7134. */
  7135.  
  7136.  
  7137. /*
  7138. let rnf33 = 0;
  7139.  
  7140. const rollingNumberFindMo = new MutationObserver(()=>{
  7141. for(const s of document.querySelectorAll('animated-rolling-character[style]:not([a85j2])')){
  7142.  
  7143. if(rnf33===0) {
  7144. rnf33= 1;
  7145.  
  7146.  
  7147. if (!document.getElementById('rnf33_script')) {
  7148. const style = document.createElement('style');
  7149. style.id = 'rnf33_script';
  7150. style.textContent = `
  7151. .rolling-no-move{
  7152. transition-duration: 0.0001s !important;
  7153. animation-duration: 0.0001s !important;
  7154. }
  7155. `;
  7156. (document.head || document.documentElement).appendChild(style);
  7157. }
  7158.  
  7159. }
  7160.  
  7161. s.setAttribute('a85j2','');
  7162. s.classList.add('rolling-no-move');
  7163. s.setAttribute('style-old126', s.getAttribute('style'));
  7164. }
  7165.  
  7166. });
  7167. rollingNumberFindMo.observe(document, {subtree: true, childList: true})
  7168. */
  7169.  
  7170. // ----------------------------
  7171.  
  7172.  
  7173. // const pendingStampFlushs = [];
  7174.  
  7175. const nativeNow = Reflect.getPrototypeOf(performance).now.bind(performance);
  7176.  
  7177. const queueMicrotask_ = typeof queueMicrotask === 'function' ? queueMicrotask : (f) => (Promise.resolve().then(f), void 0);
  7178.  
  7179. FIX_ICON_RENDER && whenCEDefined('yt-icon').then(async () => {
  7180.  
  7181.  
  7182. // const globalPromiseStack = {};
  7183.  
  7184. // let dummy;
  7185. // while(!dummy){
  7186.  
  7187. // dummy = document.querySelector('yt-icon');
  7188. // await new Promise(r=>setTimeout(r,0));
  7189. // }
  7190.  
  7191. dummy = document.createElement('yt-icon');
  7192.  
  7193. let cProto;
  7194. if (!(dummy instanceof Element)) return;
  7195. cProto = insp(dummy).constructor.prototype;
  7196.  
  7197. cProto.handlePropertyChange671 = cProto.handlePropertyChange;
  7198. cProto.determineIconSet671 = cProto.determineIconSet;
  7199. cProto.switchToYtSysIconset671 = cProto.switchToYtSysIconset;
  7200. cProto.useYtSysIconsetForMissingIcons671 = cProto.useYtSysIconsetForMissingIcons;
  7201. cProto.getIconManager671 = cProto.getIconManager;
  7202. cProto.getIconShapeData671 = cProto.getIconShapeData;
  7203. cProto.renderIcon671 = cProto.renderIcon;
  7204.  
  7205. // cProto.attached488 = cProto.attached;
  7206. // cProto.attached = function(){
  7207. // console.log('attached')
  7208. // return this.attached488(...arguments);
  7209. // }
  7210. // cProto.detached488 = cProto.detached;
  7211. // cProto.detached = function(){
  7212. // console.log('detached')
  7213. // return this.detached488(...arguments);
  7214. // }
  7215.  
  7216. if (cProto.__renderIconFix__) return;
  7217. cProto.__renderIconFix__ = true;
  7218.  
  7219. let taskStack = [];
  7220. const cmObs = new MutationObserver(() => {
  7221. const tasks = taskStack.slice();
  7222. taskStack.length = 0;
  7223. for (const task of tasks) {
  7224. task();
  7225. }
  7226. })
  7227. const cm = document.createComment('1');
  7228. const stackTask = (f) => {
  7229. taskStack.push(f);
  7230. cm.data = `${(cm.data & 7) + 1}`;
  7231. }
  7232. cmObs.observe(cm, { characterData: true });
  7233.  
  7234. // let iconManagers = {}; // assume shared
  7235.  
  7236. // window.iconManagers = () => iconManagers;
  7237.  
  7238.  
  7239. const setupYtIcon = (inst) => {
  7240.  
  7241. if (inst.__ytIconSetup588__) return;
  7242. const cProto = Reflect.getPrototypeOf(inst);
  7243. cProto.__ytIconSetup588__ = true;
  7244.  
  7245.  
  7246. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  7247.  
  7248. config.EXPERIMENT_FLAGS.wil_icon_render_when_idle = false; // single rendering
  7249. config.EXPERIMENT_FLAGS.wil_icon_load_immediately = true; // single rendering
  7250. // config.EXPERIMENT_FLAGS.wil_icon_use_mask_rendering = false; // DON'T!
  7251. config.EXPERIMENT_FLAGS.wil_icon_network_first = true; // single rendering
  7252.  
  7253.  
  7254. // this.renderingMode = _.x("wil_icon_use_mask_rendering") ? 1 : 0;
  7255. // this.isNetworkFirstStrategy = _.x("wil_icon_network_first");
  7256. // this.renderWhenIdle = _.x("wil_icon_render_when_idle");
  7257. // this.waitForAnimationFrame = !_.x("wil_icon_load_immediately");
  7258.  
  7259.  
  7260.  
  7261. }
  7262.  
  7263. cProto.handlePropertyChange = function (...a) { // 10+
  7264.  
  7265. const __data = this.__data;
  7266. if (FIX_GUIDE_ICON && this.id === 'guide-icon' && __data && !__data.icon && typeof this.set === 'function') {
  7267. this.set('icon', "yt-icons:menu")
  7268. }
  7269.  
  7270. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7271. this.__resolved__ = {
  7272.  
  7273. };
  7274. const a01 = this.isAttached;
  7275. let a02, a03;
  7276.  
  7277.  
  7278. const t = this.__stackedKey3818__ = (this.__stackedKey3818__ & 1073741823) + 1;
  7279.  
  7280. const stackFn = () => {
  7281. if (t !== this.__stackedKey3818__) {
  7282. return;
  7283. }
  7284. a03 = this.isAttached;
  7285.  
  7286. if (a01 === false && a02 === false && a03 === false) return;
  7287.  
  7288. if (a01 === true && a02 === true && a03 === true) {
  7289.  
  7290. } else {
  7291. if (a01 === undefined && a02 === undefined && a03 === undefined && (this.hostElement || this).isConnected === false) {
  7292. // unknown yt-icon#label-icon
  7293. return;
  7294. } else {
  7295. console.log('[yt-icon] debug', a01, a02, a03, this)
  7296. }
  7297. }
  7298.  
  7299. this.handlePropertyChange671(...arguments);
  7300.  
  7301. };
  7302.  
  7303.  
  7304.  
  7305. Promise.resolve().then(() => {
  7306. a02 = this.isAttached;
  7307. stackTask(stackFn);
  7308. });
  7309.  
  7310.  
  7311. }
  7312.  
  7313. cProto.determineIconSet = function (a, b, c, d) { // 10-
  7314.  
  7315. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7316. // string bool? bool=false int=24
  7317. // NOTIFICATIONS_NONE OR LIKE
  7318. // console.log('yt-icon.determineIconSet', ...arguments);
  7319.  
  7320. const r = this.determineIconSet671(...arguments);
  7321. return r;
  7322. }
  7323.  
  7324. cProto.switchToYtSysIconset = function (a, b, c, d) { // 10-
  7325.  
  7326. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7327. // same as determineIconSet
  7328. // console.log('yt-icon.switchToYtSysIconset', ...arguments);
  7329. return this.switchToYtSysIconset671(...arguments);
  7330. }
  7331.  
  7332. cProto.useYtSysIconsetForMissingIcons = function (a, b, c, d) { // X
  7333.  
  7334. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7335. // console.log('yt-icon.useYtSysIconsetForMissingIcons', ...arguments);
  7336. return this.useYtSysIconsetForMissingIcons671(...arguments);
  7337. }
  7338.  
  7339. cProto.getIconManager = function () { // 10+
  7340.  
  7341. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7342. if (!this.__resolved__) this.__resolved__ = {};
  7343. if (!this.__resolved__.getIconManager) this.__resolved__.getIconManager = this.getIconManager671(...arguments);
  7344. const r = this.__resolved__.getIconManager;
  7345. return r;
  7346. }
  7347.  
  7348. cProto.getIconShapeData = function () { // 10+
  7349.  
  7350. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7351.  
  7352. // no argument
  7353. // console.log('yt-icon.getIconShapeData', ...arguments);
  7354. if (!this.__resolved__) this.__resolved__ = {};
  7355. if (!this.__resolved__.getIconShapeData) this.__resolved__.getIconShapeData = this.getIconShapeData671(...arguments);
  7356. const r = this.__resolved__.getIconShapeData;
  7357. return r
  7358. }
  7359.  
  7360. cProto.renderIcon = function (a, b) { // X
  7361.  
  7362. if (!this.__ytIconSetup588__) setupYtIcon(this);
  7363. // "" yt-icons:xxx
  7364. // console.log('yt-icon.renderIcon', ...arguments);
  7365. return this.renderIcon671(...arguments);
  7366. }
  7367.  
  7368. });
  7369.  
  7370.  
  7371. /**
  7372. * Compute the Longest Common Subsequence between two arrays.
  7373. * Returns an array of the LCS elements (in order).
  7374. */
  7375. function computeLCS(a, b) {
  7376. // Input validation
  7377. if (!Array.isArray(a) || !Array.isArray(b)) {
  7378. throw new Error('Inputs must be arrays');
  7379. }
  7380.  
  7381. const n = a.length, m = b.length;
  7382. // Early termination for trivial cases
  7383. if (n === 0 || m === 0) return [];
  7384. // Check for shallow equality
  7385. if (n === m && a.every((x, i) => x === b[i])) return a.slice();
  7386.  
  7387. // Use smaller dimension for space optimization
  7388. if (n > m) return computeLCS(b, a); // Ensure n <= m
  7389.  
  7390. // dp[i%2][j] = length of LCS of a[i..] and b[j..]
  7391. // Use Uint32Array for robustness with long sequences
  7392. const dp = [
  7393. new Uint32Array(m + 1),
  7394. new Uint32Array(m + 1),
  7395. ];
  7396. // Store predecessor for backtracking: 0=diagonal, 1=down, 2=right
  7397. // Optimize space by storing only necessary entries
  7398. const pred = new Uint8Array(n * m); // Single array for moves
  7399.  
  7400. for (let i = n - 1; i >= 0; i--) {
  7401. const curr = i % 2;
  7402. const next = 1 - curr;
  7403. // Clear current row for reuse
  7404. dp[curr].fill(0);
  7405.  
  7406. for (let j = m - 1; j >= 0; j--) {
  7407. const idx = i * m + j;
  7408. if (a[i] === b[j]) {
  7409. dp[curr][j] = dp[next][j + 1] + 1;
  7410. pred[idx] = 0; // Diagonal
  7411. } else if (dp[next][j] >= dp[curr][j + 1]) {
  7412. dp[curr][j] = dp[next][j];
  7413. pred[idx] = 1; // Down
  7414. } else {
  7415. dp[curr][j] = dp[curr][j + 1];
  7416. pred[idx] = 2; // Right
  7417. }
  7418. }
  7419. }
  7420.  
  7421. // Check for potential overflow
  7422. if (dp[0][0] > 0xFFFFFFFF) {
  7423. throw new Error('LCS length exceeds safe integer limit');
  7424. }
  7425.  
  7426. // Backtrack to build the actual LCS
  7427. const lcs = [];
  7428. let i = 0, j = 0;
  7429. while (i < n && j < m) {
  7430. const idx = i * m + j;
  7431. const p = pred[idx];
  7432. if (p === 0) {
  7433. lcs.push(a[i]);
  7434. i++; j++;
  7435. } else if (p === 1) {
  7436. i++;
  7437. } else {
  7438. j++;
  7439. }
  7440. }
  7441. return lcs;
  7442. }
  7443.  
  7444. /**
  7445. * Given original[] and modified[], produce an array of splice-ops:
  7446. * [ [start0, deleteCount0, addedItems0],
  7447. * [start1, deleteCount1, addedItems1],
  7448. * … ]
  7449. * When you do:
  7450. * let arr = original.slice();
  7451. * for (let [s, d, adds] of ops) arr.splice(s, d, ...adds);
  7452. * arr will equal modified.
  7453. */
  7454. function diffSplices(original, modified) {
  7455. // Input validation
  7456. if (!Array.isArray(original) || !Array.isArray(modified)) {
  7457. throw new Error('Inputs must be arrays');
  7458. }
  7459.  
  7460. const origLen = original.length;
  7461. const modLen = modified.length;
  7462. // Early termination for trivial cases
  7463. if (origLen === 0 && modLen === 0) return [];
  7464. if (origLen === 0) return [[0, 0, modified.slice()]];
  7465. if (modLen === 0) return [[0, origLen, []]];
  7466.  
  7467. // Trim common prefix and suffix
  7468. let prefixLen = 0;
  7469. while (prefixLen < origLen && prefixLen < modLen && original[prefixLen] === modified[prefixLen]) {
  7470. prefixLen++;
  7471. }
  7472. let suffixLen = 0;
  7473. while (
  7474. suffixLen < origLen - prefixLen &&
  7475. suffixLen < modLen - prefixLen &&
  7476. original[origLen - 1 - suffixLen] === modified[modLen - 1 - suffixLen]
  7477. ) {
  7478. suffixLen++;
  7479. }
  7480.  
  7481. // Cache references for speed
  7482. const orig = original.slice(prefixLen, origLen - suffixLen);
  7483. const mod = modified.slice(prefixLen, modLen - suffixLen);
  7484. const lcs = computeLCS(orig, mod);
  7485. // Pre-allocate ops array, accounting for potential moves
  7486. const ops = new Array(Math.ceil((orig.length + mod.length) / 1.5));
  7487. let opCount = 0;
  7488.  
  7489. let i = 0, j = 0, k = 0;
  7490. let curIndex = prefixLen;
  7491. const lcsLen = lcs.length;
  7492.  
  7493. while (k < lcsLen) {
  7494. const match = lcs[k];
  7495. let deleteCount = 0;
  7496. const deleted = [];
  7497. const added = [];
  7498.  
  7499. // 1) Collect deletions up to the next common element
  7500. while (i < orig.length && orig[i] !== match) {
  7501. deleted.push(orig[i]);
  7502. deleteCount++;
  7503. i++;
  7504. }
  7505.  
  7506. // 2) Collect insertions up to that same element
  7507. while (j < mod.length && mod[j] !== match) {
  7508. added.push(mod[j]);
  7509. j++;
  7510. }
  7511.  
  7512. // 3) Check for a move (deleted segment matches inserted segment)
  7513. let isMove = false;
  7514. if (deleteCount > 0 && deleteCount === added.length) {
  7515. isMove = deleted.every((x, idx) => x === added[idx]);
  7516. if (isMove) {
  7517. // If a move, split into delete and insert at different indices
  7518. if (deleteCount > 0) {
  7519. ops[opCount++] = [curIndex, deleteCount, []]; // Delete at current index
  7520. ops[opCount++] = [curIndex, 0, added]; // Insert at same index
  7521. curIndex += added.length; // Advance past inserted items
  7522. }
  7523. }
  7524. }
  7525.  
  7526. // 4) Combine delete and insert into a single operation if not a move
  7527. if (!isMove && (deleteCount > 0 || added.length > 0)) {
  7528. ops[opCount++] = [curIndex, deleteCount, added];
  7529. curIndex += added.length; // Advance past inserted items
  7530. }
  7531.  
  7532. // 5) Skip over the matching element itself
  7533. i++;
  7534. j++;
  7535. k++;
  7536. curIndex++;
  7537. }
  7538.  
  7539. // 6) Handle any trailing deletions and insertions as a single operation
  7540. const trailingDelete = orig.length - i;
  7541. const trailingAdd = mod.slice(j);
  7542. if (trailingDelete > 0 || trailingAdd.length > 0) {
  7543. // Check for trailing move
  7544. const trailingDeleted = orig.slice(i);
  7545. let isMove = false;
  7546. if (trailingDelete > 0 && trailingDelete === trailingAdd.length) {
  7547. isMove = trailingDeleted.every((x, idx) => x === trailingAdd[idx]);
  7548. if (isMove) {
  7549. ops[opCount++] = [curIndex, trailingDelete, []];
  7550. ops[opCount++] = [curIndex, 0, trailingAdd];
  7551. }
  7552. }
  7553. if (!isMove) {
  7554. ops[opCount++] = [curIndex, trailingDelete, trailingAdd];
  7555. }
  7556. }
  7557.  
  7558. // 7) Truncate ops array to actual size
  7559. ops.length = opCount;
  7560.  
  7561. return ops;
  7562. }
  7563. // class listPlaceholder {
  7564. // constructor(len){
  7565. // this.length = len;
  7566. // }
  7567. // }
  7568.  
  7569.  
  7570.  
  7571. // rendererStamperApplyChangeRecord_: function(path, key, changeRecord) {
  7572. // var renderJob = this.renderJobsMap_[key],
  7573. // renderCallback = null;
  7574.  
  7575. // if (path === changeRecord.path) {
  7576. // let value = changeRecord.value;
  7577.  
  7578. // if (!_.v_(value)) {
  7579. // value = (value === void 0 || value === null) ? [] : [value];
  7580. // }
  7581.  
  7582. // let stampDomEntry = this.stampDom[path];
  7583.  
  7584. // if (stampDomEntry.mapping) {
  7585. // renderCallback = this.stampDomArray_.bind(
  7586. // this,
  7587. // value,
  7588. // key,
  7589. // stampDomEntry.mapping,
  7590. // stampDomEntry.reuseComponents,
  7591. // stampDomEntry.events,
  7592. // stampDomEntry.stamperStableList
  7593. // );
  7594. // }
  7595.  
  7596. // if (renderJob) renderJob.cancel();
  7597.  
  7598. // let taskManager = stampDomEntry.usePageScheduler ? this.getTaskManager()() : void 0;
  7599.  
  7600. // if (!renderJob && stampDomEntry.initialRenderPriority == void 0) {
  7601. // if (stampDomEntry.renderPriority != void 0 && !renderJob) {
  7602. // renderJob = new _.X6(stampDomEntry.renderPriority, stampDomEntry.waitForSignal, taskManager);
  7603. // this.renderJobsMap_[key] = renderJob;
  7604. // }
  7605. // } else {
  7606. // renderJob = new _.X6(stampDomEntry.initialRenderPriority, stampDomEntry.waitForSignal, taskManager);
  7607. // this.renderJobsMap_[key] = renderJob;
  7608. // renderCallback = function(callback, job) {
  7609. // callback();
  7610. // q4C(job, 10);
  7611. // }.bind(this, renderCallback, renderJob);
  7612. // }
  7613. // } else {
  7614. // renderCallback = (path + ".splices" === changeRecord.path)
  7615. // ? this.stampDomArraySplices_.bind(this, path, key, changeRecord.value)
  7616. // : this.forwardRendererStamperChanges_.bind(this, path, key, changeRecord);
  7617. // }
  7618.  
  7619. // if (renderJob) {
  7620. // _.vY(renderJob, renderCallback);
  7621. // } else {
  7622. // renderCallback();
  7623. // }
  7624. // }
  7625.  
  7626.  
  7627.  
  7628.  
  7629. const createStampDomFnsC_ = () => {
  7630.  
  7631. const config = ((win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0);
  7632.  
  7633. if (config.DEFERRED_DETACH === true) config.DEFERRED_DETACH = false;
  7634. if (config.REUSE_COMPONENTS === true) config.REUSE_COMPONENTS = false;
  7635.  
  7636.  
  7637. // const rq0 = document.createElement('rp');
  7638. // rq0.setAttribute('yt-element-placholder', '');
  7639.  
  7640. const it0 = Date.now() - 80000000000;
  7641. const genId = () => `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${(Date.now() - it0).toString(36)}`;
  7642.  
  7643.  
  7644. const getStampContainer_ = function (containerId) {
  7645.  
  7646. return this.getStampContainer7409_(containerId);
  7647.  
  7648. }
  7649.  
  7650.  
  7651.  
  7652.  
  7653. const createComponent_ = function (componentConfig, data, canReuse) {
  7654.  
  7655. return this.createComponent7409_(componentConfig, data, canReuse);
  7656.  
  7657. }
  7658.  
  7659.  
  7660. const s52 = Symbol();
  7661.  
  7662. const deferRenderStamperBinding_ = function (component, typeOrConfig, data) {
  7663.  
  7664. // if(component.querySelectorAll('dom-if').length > 0){
  7665.  
  7666. // // console.log(1233, component.isConnected, component.parentNode, component.querySelectorAll('dom-if'))
  7667. // if (component.isConnected === false) {
  7668. // for (const s of component.querySelectorAll('dom-if')) {
  7669. // try {
  7670. // console.log(1299);
  7671. // insp(s).__teardownInstance();
  7672. // } catch (e) { }
  7673. // }
  7674. // }
  7675.  
  7676. // }
  7677.  
  7678. if (typeof (data || 0) === 'object') {
  7679. if (!data[s52]) data[s52] = genId();
  7680. component[s52] = data[s52];
  7681. // console.log(component[s52], data);
  7682. } else {
  7683. component[s52] = null;
  7684. }
  7685.  
  7686. return this.deferRenderStamperBinding7409_(component, typeOrConfig, data);
  7687.  
  7688. }
  7689.  
  7690. // let pr77 = Promise.resolve();
  7691.  
  7692. const flushRenderStamperComponentBindings_ = function () {
  7693. if (!this.__qsd477__ || !this.deferredBindingTasks_) return this.flushRenderStamperComponentBindings7409_();
  7694.  
  7695. if (this.deferredBindingTasks_.length >= 0) {
  7696.  
  7697. // const deferredBindingTasks_ = this.deferredBindingTasks_;
  7698.  
  7699. const gid = this[`__$$stampFlushKey$$__`] = genId();
  7700. const g = (() => {
  7701. if (gid !== this[`__$$stampFlushKey$$__`]) { return; }
  7702. // if (deferredBindingTasks_.length === 0) return;
  7703. // let q = this.deferredBindingTasks_;
  7704. // this.deferredBindingTasks_ = deferredBindingTasks_;
  7705. this.flushRenderStamperComponentBindings7409_();
  7706. // deferredBindingTasks_.length = 0;
  7707. // this.deferredBindingTasks_ = q;
  7708.  
  7709. const s = [...this.__lat457__];
  7710. this.__lat457__.clear();
  7711.  
  7712. for (const containerWr of s) {
  7713.  
  7714. const container = kRef(containerWr);
  7715. if (!container) continue;
  7716.  
  7717. // const s = new Set();
  7718. if (!container.querySelector('[ytx-flushing]')) {
  7719. if (container.hasAttribute('ytx-flushing')) {
  7720. const attrVal = container.getAttribute('ytx-flushing');
  7721. container.removeAttribute('ytx-flushing');
  7722. // s.add([container, attrVal]);
  7723. addTask(container, attrVal);
  7724. // addTaskIm(container, attrVal);
  7725. let ancestor = container.closest('[ytx-flushing]');
  7726. while (ancestor) {
  7727. if (ancestor.querySelector('[ytx-flushing]')) break;
  7728. const attrVal = ancestor.getAttribute('ytx-flushing');
  7729. ancestor.removeAttribute('ytx-flushing');
  7730. // s.add([ancestor, attrVal]);
  7731. addTask(ancestor, attrVal);
  7732. // addTaskIm(ancestor, attrVal);
  7733. ancestor = ancestor.closest('[ytx-flushing]');
  7734. }
  7735. }
  7736. }
  7737. }
  7738. executeTasks();
  7739.  
  7740.  
  7741. });
  7742. g();
  7743. // const useMicroTaskQueue = this.__qsd477__ === 2;
  7744. // useMicroTaskQueue ? addTask2(g) : g();
  7745. // executeTasks();
  7746.  
  7747. // addTask2(g);
  7748. // executeTasks();
  7749.  
  7750. }
  7751.  
  7752. throw new Error('e5bd8d2f');
  7753.  
  7754. }
  7755.  
  7756. let tasks = [];
  7757. let excuted = false;
  7758. const executeTasks = ()=>{
  7759. if(excuted || tasks.length === 0) return;
  7760. excuted = true;
  7761. let t0 = 0;
  7762. const perform = ()=>{
  7763. if(!t0) t0 = nativeNow();
  7764. const task = tasks.shift();
  7765. if(!task){
  7766. excuted = false;
  7767. return;
  7768. }
  7769. task.fn(task);
  7770. const t1 = nativeNow();
  7771. if(t1 - t0 > 10){
  7772. t0 = 0;
  7773. nextBrowserTick_(perform);
  7774. }else{
  7775. queueMicrotask_(perform);
  7776. }
  7777. }
  7778. queueMicrotask_(perform);
  7779. }
  7780.  
  7781. const taskFn = (task) => {
  7782.  
  7783. if(!task) return;
  7784. const { containerWr, attrVal } = task;
  7785. const container = kRef(containerWr);
  7786. if (!container) return;
  7787. if (attrVal === '0') return;
  7788. const bEventCb = attrVal === '2';
  7789. const producerWr = containerMapping.get(container);
  7790. const producer = kRef(producerWr);
  7791. if (!producer) return;
  7792. const hostElement = producer.hostElement;
  7793. if (!hostElement) return;
  7794. if (hostElement.isConnected !== true) return; // tbc
  7795. producer.markDirty && producer.markDirty();
  7796. bEventCb && dispatchYtEvent(hostElement, "yt-rendererstamper-finished", {
  7797. container
  7798. });
  7799.  
  7800. }
  7801.  
  7802. const addTask = (container, attrVal) => {
  7803. if (!container) return;
  7804. const containerWr = container[wk] || (container[wk] = mWeakRef(container));
  7805. tasks.push({
  7806. fn: taskFn,
  7807. containerWr: containerWr,
  7808. attrVal
  7809. });
  7810. // pr77 = pr77.then(()=>{
  7811.  
  7812. // })
  7813. // taskFn({
  7814. // containerWr: containerWr,
  7815. // attrVal
  7816. // })
  7817.  
  7818. }
  7819.  
  7820. const addTaskIm = (container, attrVal) => {
  7821. if (!container) return;
  7822. const containerWr = container[wk] || (container[wk] = mWeakRef(container));
  7823. taskFn({
  7824. fn: taskFn,
  7825. containerWr: containerWr,
  7826. attrVal
  7827. });
  7828.  
  7829. }
  7830.  
  7831.  
  7832. const addTask2 = (f) => {
  7833. // pr77 = pr77.then(f).catch(console.warn);
  7834. tasks.push({
  7835. fn: f
  7836. });
  7837.  
  7838. }
  7839.  
  7840. // const mo = new MutationObserver((mutations)=>{
  7841.  
  7842. // });
  7843. // mo.observe(document, {attributeFilter: ['ytx-flushing'], attributes: true, subtree: true, childList: false});
  7844.  
  7845. const containerMapping = new WeakMap();
  7846.  
  7847. // let pr77 = Promise.resolve();
  7848. // let pr88 = Promise.resolve();
  7849. const uA4 = function (t, P) {
  7850. for (let y in t)
  7851. if (t.hasOwnProperty(y) && P[y])
  7852. return y;
  7853. return null
  7854. }
  7855.  
  7856. const evaluteUseMicroTaskQueue = (ax_, containerId, hostIs_, producer, hostElement)=>{
  7857.  
  7858. const ax = ax_;
  7859. const useMicroTaskQueue = ax ? (ax[2] && ax[2]!==ax[0]) : false;
  7860. let useMicroTaskQueue2 = ax && ax[1] && ax[2];
  7861. // const useMicroTaskQueue = false;
  7862. if (ax && ax[2] && ax[2] === ax[0]) { // short ... execute job
  7863. ax[2].cancel();
  7864. useMicroTaskQueue2 = false;
  7865. }
  7866. // console.log(1992,containerId, this.hostElement.is)
  7867.  
  7868. // if (hostElement.nodeType !== 1 || !hostElement.is || hostElement.isConnected === false || !document.body.contains(hostElement)){
  7869. // console.log(12773, hostElement.nodeType !== 1, !hostElement.is, hostElement.isConnected === false, !document.body.contains(hostElement))
  7870. // return false;
  7871.  
  7872. // }
  7873.  
  7874. if (hostElement.isConnected === false || hostElement.closest('[hidden]')) {
  7875. return false;
  7876. }
  7877.  
  7878. const hostIs = hostIs_;
  7879.  
  7880. if (hostIs === 'ytd-masthead' || hostIs === 'ytd-button-renderer' || hostIs === 'yt-button-shape' || hostIs === 'yt-icon-button' || hostIs === 'ytd-notification-topbar-button-renderer' || containerId === 'buttons' || containerId === 'button' || containerId === 'icon' || hostIs === 'yt-interaction' || containerId === 'interaction') return false;
  7881.  
  7882. if (containerId === 'overlays') useMicroTaskQueue2 = true;
  7883. else if (hostIs === 'ytd-rich-grid-media' || hostIs === 'ytd-rich-grid-renderer') useMicroTaskQueue2 = true;
  7884. // else if (hostIs === 'ytd-rich-grid-media' || hostIs === 'ytd-rich-grid-renderer') useMicroTaskQueue2 = false;
  7885. // else if (containerId === 'menu') useMicroTaskQueue2 = true;
  7886. else if (containerId === 'replies') useMicroTaskQueue2 = true;
  7887. else if (containerId === 'flexible-item-buttons' && hostIs === 'ytd-menu-renderer') useMicroTaskQueue2 = true;
  7888. else if(hostIs === 'ytd-menu-popup-renderer') useMicroTaskQueue2 = false;
  7889. else if ( containerId === 'ghost-comment-section' && hostIs === 'ytd-continuation-item-renderer') useMicroTaskQueue2 = true;
  7890. else if (hostIs === 'ytd-continuation-item-renderer') useMicroTaskQueue2 = false;
  7891. else if (hostIs === 'ytd-feed-filter-chip-bar-renderer' || hostIs === 'yt-chip-cloud-renderer' || containerId==='filter' || containerId ==='chips' || containerId==='left-arrow-button' ||containerId==='right-arrow-button') useMicroTaskQueue2 =false;
  7892. // else if (containerId === 'contents' || containerId === 'content' || containerId === 'header') useMicroTaskQueue2 = true;
  7893. // else if( containerId === 'items') useMicroTaskQueue2 = true;
  7894. else if (containerId === 'menu' && hostIs === 'ytd-playlist-panel-video-renderer') useMicroTaskQueue2 = true;
  7895. else if (containerId === 'top-level-buttons-computed' && hostIs === 'ytd-menu-renderer') useMicroTaskQueue2 = false;
  7896. else if (hostIs === 'ytd-comment-view-model') useMicroTaskQueue2 = true;
  7897. // else if (hostIs === 'ytd-rich-item-renderer') useMicroTaskQueue2 = true;
  7898. // else if (hostIs === 'ytd-rich-grid-media') useMicroTaskQueue2 = true;
  7899. else if (hostIs === 'ytd-video-preview') useMicroTaskQueue2 = true;
  7900. // else if (hostIs === 'ytd-game-card-renderer')useMicroTaskQueue2 = true;
  7901.  
  7902.  
  7903. // console.log(19920030+(useMicroTaskQueue2?1:0), containerId, hostIs)
  7904.  
  7905.  
  7906. // console.log(5992,stackAt)
  7907.  
  7908. // console.log(2883, this[`__quu477#${containerId}__`] )
  7909. // if (useMicroTaskQueue) {
  7910. // console.log(stackAt)
  7911. // }
  7912.  
  7913. // if (useMicroTaskQueue) {
  7914. // console.log(1120301)
  7915. // }
  7916.  
  7917. // if(hostElement.closest('ytd-feed-filter-chip-bar-renderer')) useMicroTaskQueue2 = false;
  7918.  
  7919. return useMicroTaskQueue2;
  7920.  
  7921. }
  7922.  
  7923. const frag385 = document.createDocumentFragment();
  7924. frag385.appendChild4202 = frag385.appendChild;
  7925. frag385.removeChild4202 = frag385.removeChild;
  7926. const cm385 = document.createComment('.');
  7927.  
  7928. const doc385 = document.implementation.createHTMLDocument();
  7929. const html385 = doc385.firstElementChild;
  7930. const node385 = html385.appendChild(document.createElement('div'));
  7931.  
  7932. const fixContainerApi = (container) => {
  7933. if (container instanceof Node) {
  7934. const containerDomApi = container.__domApi;
  7935. if (containerDomApi && !containerDomApi.removeChild588 && containerDomApi.removeChild) {
  7936. // console.log(123882, container)
  7937. containerDomApi.removeChild588 = containerDomApi.removeChild;
  7938. containerDomApi.removeChild = function (elem) {
  7939. let r;
  7940. for (const s of elem.querySelectorAll('[ytx-flushing]')) {
  7941. s.setAttribute('ytx-flushing', '0');
  7942. }
  7943. try {
  7944. r = this.removeChild588(elem);
  7945. } catch (e) { }
  7946. if (!r) {
  7947. frag385.appendChild4202(elem);
  7948. frag385.removeChild4202(elem);
  7949. r = elem;
  7950. }
  7951. for (const s of elem.querySelectorAll('[ytx-flushing]')) {
  7952. s.removeAttribute('ytx-flushing');
  7953. }
  7954. return r;
  7955. }
  7956. }
  7957. }
  7958. }
  7959.  
  7960. const stampDomArray_ = function (dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList) {
  7961.  
  7962. const sqq = this[`__$$stampSqq$$#${containerId}__`];
  7963. if (typeof sqq === 'function') sqq();
  7964.  
  7965. // trigger in rendererStamperApplyChangeRecord_
  7966.  
  7967. // const stackAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  7968. // const useMicroTaskQueue = (stackAt.includes('.rendererStamperApplyChangeRecord_'));
  7969. // const useMicroTaskQueue = stackAt.includes('.<anonymous>') ? true : false;
  7970. // const stackAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  7971.  
  7972. // const isRenderJob = this[`__quu477#${containerId}__`] || !!this.renderJobsMap_[containerId];
  7973. // const useMicroTaskQueue = isRenderJob && !stackAt.includes('scheduler.js') && 0 ? true : false; // avoid immediate job
  7974.  
  7975.  
  7976. const ax = this[`__quu477#${containerId}__`];
  7977. const hostIs = (this.hostElement || 0).is;
  7978. const useMicroTaskQueue2 = evaluteUseMicroTaskQueue(ax, containerId, hostIs, this, this.hostElement);
  7979.  
  7980. const container = this.getStampContainer7409_(containerId);
  7981. const pChildren = [...container.children];
  7982.  
  7983. containerMapping.set(container,
  7984. (this[wk] || (this[wk] = mWeakRef(this)))
  7985. );
  7986.  
  7987. if (bEventCb) container.setAttribute('ytx-flushing', '2');
  7988. else if (!container.hasAttribute('ytx-flushing')) container.setAttribute('ytx-flushing', '1');
  7989.  
  7990. // let dataList_ = dataList;
  7991. let dataList_ = typeof (dataList || 0) === 'object' ? (dataList.length >= 1 ? dataList.slice() : []) : dataList;
  7992.  
  7993. dataList = null;
  7994. const gid = this[`__$$stampSID$$#${containerId}__`] = genId();
  7995. let fq = 0;
  7996. const f = (() => {
  7997. if(fq) return;
  7998. fq = 1;
  7999. if (gid !== this[`__$$stampSID$$#${containerId}__`]) { return; }
  8000. this[`__$$stampSFn$$#${containerId}__`] = null;
  8001. const container = this.getStampContainer7409_(containerId);
  8002.  
  8003. this.__lat457__ = this.__lat457__ || new Set();
  8004. if(!container[wk]) container[wk] = mWeakRef(container);
  8005. this.__lat457__.add(container[wk]);
  8006. fixContainerApi(container);
  8007.  
  8008. // let q = this.deferredBindingTasks_;
  8009. // this.deferredBindingTasks_ = [];
  8010. this.__qsd477__ = useMicroTaskQueue2 ? 2 : 1;
  8011. let e_;
  8012. try {
  8013. this.stampDomArray7409_(dataList_, containerId, typeOrConfig, false, bEventCb, bStableList);
  8014. } catch (e) { e_ = e }
  8015. this.__qsd477__ = false;
  8016. dataList_ = typeOrConfig = null;
  8017. fixContainerApi(container);
  8018. // this.deferredBindingTasks_ = q;
  8019. if(e_ && e_.message !== 'e5bd8d2f') throw e_;
  8020. if (!e_) {
  8021. // container.setAttribute('ytx-flushing', '0');
  8022. }
  8023. // if( container.childElementCount === 0 ){
  8024. // container.setAttribute('ytx-flushing', '0');
  8025. // this.markDirty && this.markDirty();
  8026. // bEventCb && dispatchYtEvent(this.hostElement, "yt-rendererstamper-finished", {
  8027. // container
  8028. // });
  8029. // }
  8030.  
  8031.  
  8032.  
  8033.  
  8034. });
  8035. this[`__$$stampSFn$$#${containerId}__`] = f;
  8036. this[`__$$stampSqq$$#${containerId}__`] = f;
  8037. useMicroTaskQueue2 ? addTask2(f) : f();
  8038. executeTasks();
  8039.  
  8040. for (const node of pChildren) {
  8041. if (node.isConnected === false) {
  8042. _removedElements.addNode(node);
  8043. }
  8044. }
  8045.  
  8046. // console.log(58801, this.hostElement.parentNode instanceof HTMLElement_);
  8047.  
  8048. return undefined;
  8049.  
  8050. }
  8051.  
  8052. const stampDomArraySplices_ = function (stampKey, containerId, indexSplicesObj) {
  8053.  
  8054.  
  8055. const sqq = this[`__$$stampSqq$$#${containerId}__`];
  8056. if (typeof sqq === 'function') sqq();
  8057.  
  8058. // trigger in rendererStamperApplyChangeRecord_
  8059.  
  8060. if (typeof indexSplicesObj === 'object' && indexSplicesObj.indexSplices instanceof Array) {
  8061. } else {
  8062. return this.stampDomArraySplices7409_(stampKey, containerId, indexSplicesObj);
  8063. }
  8064.  
  8065.  
  8066. // trigger in rendererStamperApplyChangeRecord_
  8067.  
  8068. // const stackAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  8069. // const useMicroTaskQueue = (stackAt.includes('.rendererStamperApplyChangeRecord_'));
  8070. // const useMicroTaskQueue = stackAt.includes('.<anonymous>') ? true : false;
  8071.  
  8072. // const stackAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  8073.  
  8074. // const isRenderJob = this[`__quu477#${containerId}__`] || !!this.renderJobsMap_[containerId];
  8075. // const useMicroTaskQueue = isRenderJob && !stackAt.includes('scheduler.js') && 0 ? true : false; // avoid immediate job
  8076. // const useMicroTaskQueue = this[`__quu477#${containerId}__`] ? true : false;
  8077.  
  8078. const ax = this[`__quu477#${containerId}__`];
  8079. const hostIs = (this.hostElement || 0).is;
  8080. const useMicroTaskQueue2 = evaluteUseMicroTaskQueue(ax, containerId, hostIs, this, this.hostElement);
  8081.  
  8082.  
  8083. // const stackAt = `\n\n${new Error().stack}\n\n`.replace(/[\r\n]([^\r\n]*?\.user\.js[^\r\n]*?[\r\n]+)+/g, '\n').replace(/[\r\n]([^\r\n.]+[\r\n]+)+/g, '\n').trim().split(/[\r\n]+/)[0];
  8084. // const useMicroTaskQueue = true;
  8085. const container = this.getStampContainer7409_(containerId);
  8086.  
  8087. containerMapping.set(container,
  8088. (this[wk] || (this[wk] = mWeakRef(this)))
  8089. );
  8090. const bEventCb = this.stampDom[stampKey].events;
  8091. if (bEventCb) container.setAttribute('ytx-flushing', '2');
  8092. else if (!container.hasAttribute('ytx-flushing')) container.setAttribute('ytx-flushing', '1');
  8093.  
  8094. // let indexSplicesObj_ = indexSplicesObj;
  8095. // if (typeof indexSplicesObj === 'object' && indexSplicesObj.indexSplices instanceof Array) {
  8096. // indexSplicesObj_ = {
  8097. // indexSplices: indexSplicesObj.indexSplices.map(slice => {
  8098. // const { index, addedCount, removed, object, type } = slice;
  8099. // this[`__$$stampSpliceObj$$#${containerId}__`] = (object[wk] || (object[wk] = mWeakRef(object)));
  8100. // return { index, addedCount, removed, object, type };
  8101. // })
  8102. // };
  8103. // }
  8104.  
  8105.  
  8106. indexSplicesObj.indexSplices.forEach(slice => {
  8107. const object = slice.object;
  8108. if (!object || typeof object !== 'object') return;
  8109. // const { index, addedCount, removed, object, type } = slice;
  8110. this[`__$$stampSpliceObj$$#${containerId}__`] = (object[wk] || (object[wk] = mWeakRef(object)));
  8111. // return { index, addedCount, removed, object, type };
  8112. });
  8113.  
  8114. // let indexSplicesObj_ = indexSplicesObj;
  8115.  
  8116. // console.log(128783, indexSplicesObj)
  8117.  
  8118. // let indexSplicesObj_ = indexSplicesObj.map(slice => {
  8119. // const { index, addedCount, removed, object, type } = slice;
  8120. // return { index, addedCount, removed, object, type };
  8121. // });
  8122.  
  8123. indexSplicesObj = null;
  8124.  
  8125. if (!this[`__$$stampSID$$#${containerId}__`]) this[`__$$stampSID$$#${containerId}__`] = genId();
  8126. const gid = this[`__$$stampSID$$#${containerId}__`];
  8127. let fq = 0;
  8128. const f = (() => {
  8129. if(fq) return;
  8130. fq = 1;
  8131. if (gid !== this[`__$$stampSID$$#${containerId}__`]) { return; }
  8132. if (this[`__$$stampSFn$$#${containerId}__`]) this[`__$$stampSFn$$#${containerId}__`]();
  8133. const container = this.getStampContainer7409_(containerId);
  8134. if(!container) return;
  8135.  
  8136. // console.log(388 , kRef(this[`__$$stampSpliceObj$$#${containerId}__`]))
  8137.  
  8138. const object = kRef(this[`__$$stampSpliceObj$$#${containerId}__`]);
  8139. // const elementKeys = new Set(Array.prototype.map.call((container.__domApi || container).children, e=>e[s52]));
  8140. const mapping = this.stampDom[stampKey].mapping;
  8141.  
  8142. const map = new Map();
  8143.  
  8144. const currentObjKeys = object.map(objEntry => {
  8145. const mappingKey = uA4(mapping, objEntry);
  8146. if(!mappingKey) return null;
  8147. const data = objEntry[mappingKey];
  8148. if (!data[s52]) data[s52] = genId();
  8149. map.set(data[s52], objEntry);
  8150. // return ({
  8151. // objEntry,
  8152. // data: data,
  8153. // mappingKey: mappingKey,
  8154. // key: data[s52],
  8155. // exist: elementKeys.has(data[s52])
  8156. // });
  8157. return data[s52]
  8158.  
  8159. });
  8160.  
  8161. const oldDomKeys = Array.prototype.map.call((container.__domApi || container).children, node=>node[s52]);
  8162.  
  8163. // console.log(currentObjKeys, oldDomKeys, diffSplices(oldDomKeys, currentObjKeys));
  8164.  
  8165. const splices = diffSplices(oldDomKeys, currentObjKeys);
  8166.  
  8167. // let myObject = object;
  8168. let indexSplicesObj_ = {
  8169. indexSplices: splices.map(splice => {
  8170. const index = splice[0];
  8171. const removedLen = splice[1];
  8172. const added = splice[2];
  8173. const addedCount = added.length;
  8174. const object = {};
  8175. object.length = index + addedCount;
  8176. for (let i = 0; i < addedCount; i++) {
  8177. object[index + i] = map.get(added[i]);
  8178. }
  8179. const removed = {};
  8180. removed.length = removedLen;
  8181.  
  8182. return { index, removed, object, addedCount }
  8183. })
  8184. };
  8185. map.clear();
  8186.  
  8187.  
  8188. this.__lat457__ = this.__lat457__ || new Set();
  8189. if(!container[wk]) container[wk] = mWeakRef(container);
  8190. this.__lat457__.add(container[wk]);
  8191. fixContainerApi(container);
  8192.  
  8193. // console.log(3882, indexSplicesObj_)
  8194. // let q = this.deferredBindingTasks_;
  8195. // this.deferredBindingTasks_ = [];
  8196. this.__qsd477__ = useMicroTaskQueue2 ? 2 : 1;
  8197. let e_;
  8198. try {
  8199. this.stampDomArraySplices7409_(stampKey, containerId, indexSplicesObj_);
  8200. } catch (e) { e_ = e; }
  8201. this.__qsd477__ = false;
  8202. indexSplicesObj_ = null;
  8203. stampKey = indexSplicesObj_ = null;
  8204. fixContainerApi(container);
  8205. // this.deferredBindingTasks_ = q;
  8206. if(e_ && e_.message !== 'e5bd8d2f') throw e_;
  8207. if (!e_) {
  8208. // container.setAttribute('ytx-flushing', '0');
  8209. }
  8210.  
  8211.  
  8212. });
  8213. this[`__$$stampSqq$$#${containerId}__`] = f;
  8214. useMicroTaskQueue2 ? addTask2(f) : f();
  8215. executeTasks();
  8216.  
  8217. // console.log(58802, this.hostElement.parentNode instanceof HTMLElement_);
  8218.  
  8219. return undefined;
  8220.  
  8221. }
  8222.  
  8223.  
  8224. const stampDomArrayWB_ = function (objWr, containerId, xxx_, renderJob0, dt0a) {
  8225. const dt0 = dt0a[0];
  8226. const dt1 = Date.now();
  8227. const obj = kRef(objWr);
  8228. if (!obj) return;
  8229. const xxx = obj[`__stampDomArrayArgs_xxx__#${containerId}__`];
  8230. if (xxx !== xxx_) return;
  8231. const dataList = obj[`__stampDomArrayArgs_dataList__#${containerId}__`];
  8232. const typeOrConfig = kRef(obj[`__stampDomArrayArgs_typeOrConfig__#${containerId}__`]);
  8233. const bReuse = obj[`__stampDomArrayArgs_bReuse__#${containerId}__`];
  8234. const bEventCb = obj[`__stampDomArrayArgs_bEventCb__#${containerId}__`];
  8235. const bStableList = obj[`__stampDomArrayArgs_bStableList__#${containerId}__`];
  8236. const renderJob1 = obj.renderJobsMap_[containerId]
  8237. // console.log(3188, dt0, dt1, renderJob0, renderJob1)
  8238. obj[`__quu477#${containerId}__`] = [renderJob0, (dt1 - dt0 >= 1), renderJob1];
  8239. let e_, r;
  8240. try {
  8241. r = obj.stampDomArray_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  8242. } catch (e) {
  8243. e_ = e;
  8244. }
  8245. obj[`__quu477#${containerId}__`] = false;
  8246. if (e_) throw e_;
  8247. return r;
  8248. };
  8249.  
  8250.  
  8251. stampDomArray_.bind = function (obj, ...args) {
  8252. let [dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList] = args;
  8253. if (!obj[wk]) obj[wk] = mWeakRef(obj);
  8254. obj[`__stampDomArrayArgs_dataList__#${containerId}__`] = dataList;
  8255. const typeOrConfig_ = typeof (typeOrConfig || 0) === 'object' ? (typeOrConfig[wk] || (typeOrConfig[wk] = mWeakRef(typeOrConfig))) : typeOrConfig;
  8256. obj[`__stampDomArrayArgs_typeOrConfig__#${containerId}__`] = typeOrConfig_;
  8257. obj[`__stampDomArrayArgs_bReuse__#${containerId}__`] = bReuse;
  8258. obj[`__stampDomArrayArgs_bEventCb__#${containerId}__`] = bEventCb;
  8259. obj[`__stampDomArrayArgs_bStableList__#${containerId}__`] = bStableList;
  8260. const xxx = obj[`__stampDomArrayArgs_xxx__#${containerId}__`] = `${Math.random()}_${Date.now()}`;
  8261.  
  8262.  
  8263. const renderJob = obj.renderJobsMap_[containerId];
  8264.  
  8265. const dt0a = [Date.now()];
  8266. queueMicrotask_(() => { dt0a[0] = 0 });
  8267. return stampDomArrayWB_.bind(null, obj[wk], containerId, xxx, renderJob, dt0a);
  8268. };
  8269.  
  8270. const stampDomArraySplicesWB_ = function (objWr, stampKey, containerId, indexSplicesObj, renderJob0, dt0a) {
  8271. const dt0 = dt0a[0];
  8272. const dt1 = Date.now();
  8273. const obj = kRef(objWr);
  8274. if (!obj) return;
  8275. const renderJob1 = obj.renderJobsMap_[containerId];
  8276. obj[`__quu477#${containerId}__`] = [renderJob0, (dt1 - dt0 >= 1), renderJob1];
  8277. let e_, r;
  8278. try {
  8279. r = obj.stampDomArraySplices_( stampKey, containerId, indexSplicesObj);
  8280. } catch (e) {
  8281. e_ = e;
  8282. }
  8283. obj[`__quu477#${containerId}__`] = false;
  8284. if (e_) throw e_;
  8285. return r;
  8286. };
  8287.  
  8288.  
  8289. stampDomArraySplices_.bind = function (obj, ...args) {
  8290. let [stampKey, containerId, indexSplicesObj] = args;
  8291. if (!obj[wk]) obj[wk] = mWeakRef(obj);
  8292.  
  8293. const renderJob = obj.renderJobsMap_[containerId];
  8294.  
  8295. const dt0a = [Date.now()];
  8296. queueMicrotask_(() => { dt0a[0] = 0 });
  8297. return stampDomArraySplicesWB_.bind(null, obj[wk], stampKey, containerId, indexSplicesObj, renderJob, dt0a);
  8298. };
  8299.  
  8300.  
  8301. return { getStampContainer_, createComponent_, deferRenderStamperBinding_, flushRenderStamperComponentBindings_, stampDomArray_, stampDomArraySplices_ };
  8302.  
  8303. }
  8304.  
  8305.  
  8306. const createStampDomFnsB_ = () => {
  8307.  
  8308. const config = ((win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0);
  8309.  
  8310. if (config.DEFERRED_DETACH === true) config.DEFERRED_DETACH = false;
  8311. if (config.REUSE_COMPONENTS === true) config.REUSE_COMPONENTS = false;
  8312.  
  8313.  
  8314. const rq0 = document.createElement('rp');
  8315. rq0.setAttribute('yt-element-placholder', '');
  8316.  
  8317. let activeStampContainerId = '';
  8318.  
  8319. const componentBasedTaskPool = new WeakMap();
  8320.  
  8321.  
  8322. Node.prototype.checkFF = function () {
  8323. const pTask = componentBasedTaskPool.get(this);
  8324. if (!pTask) return null;
  8325. return [pTask, taskList.filter(e => e.taskId === pTask.taskId), taskList.filter(e => e.componentWr === this[wk])];
  8326. }
  8327.  
  8328. Node.prototype.checkGG = function () {
  8329. window.me849 = this;
  8330. const pTask = componentBasedTaskPool.get(this);
  8331. if (!pTask) return null;
  8332. window.me848 = pTask.taskId;
  8333. debugger;
  8334. loopTask();
  8335. }
  8336.  
  8337. NodeList.prototype.last = function () {
  8338. return this[this.length - 1];
  8339. }
  8340.  
  8341. const getStampContainer_ = function (containerId) {
  8342.  
  8343. // if(this.__byPass828__) return this.getStampContainer7409_(containerId);
  8344.  
  8345. this.__activeContainerId929__ = containerId;
  8346.  
  8347. return this.getStampContainer7409_(containerId);
  8348.  
  8349. }
  8350.  
  8351.  
  8352.  
  8353. const it0 = Date.now() - 80000000000;
  8354. const genId = () => `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${(Date.now() - it0).toString(36)}`;
  8355.  
  8356.  
  8357. const createComponent_ = function (componentConfig, data, canReuse) {
  8358.  
  8359. this.___lastCreate3311__ = data;
  8360.  
  8361.  
  8362.  
  8363. if (this.__directProduction533__) {
  8364. const cName = this.getComponentName_(componentConfig, data);
  8365.  
  8366. return document.createElement(cName);
  8367. }
  8368.  
  8369. if (this.__byPass828__ || !this.__byPass348__) {
  8370.  
  8371. // console.log(39829004)
  8372. // console.log(new Error().stack)
  8373. return this.createComponent7409_(componentConfig, data, false);
  8374. }
  8375.  
  8376.  
  8377. const containerId = this.__activeContainerId929__;
  8378.  
  8379. // console.log(2883007, componentConfig, data, canReuse)
  8380.  
  8381. const r = rq0.cloneNode(false);
  8382.  
  8383. r.is = 'aa-bb-cc-dd';
  8384.  
  8385. return r;
  8386.  
  8387.  
  8388. }
  8389.  
  8390.  
  8391. const childrenObs = new MutationObserver((mutations) => {
  8392. loopTask();
  8393. });
  8394.  
  8395.  
  8396. class CTaskList {
  8397. constructor() {
  8398. this.head = this.tail = null;
  8399.  
  8400. // ref → {prev, next, level}
  8401. this.nodes = new Map();
  8402.  
  8403. // Per‑level sentinels
  8404. this.levelHead = [];
  8405. this.levelTail = [];
  8406.  
  8407. // Sorted list of non‑empty levels for O(log L) neighbour lookup
  8408. this.nonEmptyLevels = [];
  8409. this.counter = 0;
  8410. }
  8411.  
  8412. _ensure(level) {
  8413. while (this.levelTail.length <= level) {
  8414. this.levelTail.push(null);
  8415. this.levelHead.push(null);
  8416. }
  8417. }
  8418.  
  8419. // Binary‑search index inside nonEmptyLevels
  8420. _indexOfLevel(level) {
  8421. let lo = 0, hi = this.nonEmptyLevels.length;
  8422. while (lo < hi) {
  8423. const mid = (lo + hi) >> 1;
  8424. if (this.nonEmptyLevels[mid] < level) lo = mid + 1;
  8425. else hi = mid;
  8426. }
  8427. return lo;
  8428. }
  8429.  
  8430. _link(ref, prev, next, level) {
  8431.  
  8432.  
  8433. this.nodes.set(ref, { prev, next, level });
  8434.  
  8435. if (prev) this.nodes.get(prev).next = ref;
  8436. else this.head = ref;
  8437.  
  8438. if (next) this.nodes.get(next).prev = ref;
  8439. else this.tail = ref;
  8440.  
  8441. this.levelTail[level] = ref;
  8442. if (!this.levelHead[level]) this.levelHead[level] = ref;
  8443. }
  8444.  
  8445. _detach(ref) {
  8446. if (!ref || !this.nodes.has(ref)) return;
  8447.  
  8448.  
  8449. const { prev, next, level } = this.nodes.get(ref);
  8450.  
  8451. if (prev) this.nodes.get(prev).next = next;
  8452. else this.head = next;
  8453.  
  8454. if (next) this.nodes.get(next).prev = prev;
  8455. else this.tail = prev;
  8456.  
  8457. if (this.levelTail[level] === ref) {
  8458. this.levelTail[level] = prev && this.nodes.get(prev)?.level === level ? prev : null;
  8459. }
  8460. if (this.levelHead[level] === ref) {
  8461. this.levelHead[level] = next && this.nodes.get(next)?.level === level ? next : null;
  8462. }
  8463.  
  8464. if (this.levelTail[level] === null) {
  8465. const idx = this.nonEmptyLevels.indexOf(level);
  8466. if (idx !== -1) this.nonEmptyLevels.splice(idx, 1);
  8467. }
  8468.  
  8469. this.nodes.delete(ref);
  8470.  
  8471. }
  8472.  
  8473. push(component, level) {
  8474. if (!component) return;
  8475.  
  8476. // this.checkIntegrity();
  8477.  
  8478. const ref = component[wk] || (component[wk] = new WeakRef(component));
  8479.  
  8480. if (this.nodes.has(ref)) this._detach(ref);
  8481.  
  8482. this._ensure(level);
  8483.  
  8484. if (!this.levelTail[level]) {
  8485. // First node on this level
  8486. const idx = this._indexOfLevel(level);
  8487. const prevLvl = idx ? this.nonEmptyLevels[idx - 1] : null;
  8488. const nextLvl = idx < this.nonEmptyLevels.length ? this.nonEmptyLevels[idx] : null;
  8489.  
  8490. const prevRef = prevLvl !== null ? this.levelTail[prevLvl] : null;
  8491. const nextRef = nextLvl !== null ? this.levelHead[nextLvl] : null;
  8492.  
  8493. this._link(ref, prevRef, nextRef, level);
  8494. this.nonEmptyLevels.splice(idx, 0, level);
  8495. } else {
  8496. // Append to existing level
  8497. const prevRef = this.levelTail[level];
  8498. const nextRef = this.nodes.get(prevRef).next;
  8499. this._link(ref, prevRef, nextRef, level);
  8500. }
  8501.  
  8502. this.counter++;
  8503. // this.checkIntegrity();
  8504. }
  8505.  
  8506. remove(component) {
  8507. const ref = component && component.deref ? component : (component || 0)[wk];
  8508.  
  8509. // this.checkIntegrity();
  8510. this._detach(ref);
  8511.  
  8512. // this.checkIntegrity();
  8513. }
  8514.  
  8515. replace(componentOld, componentNew) {
  8516. if (!componentOld || !componentNew) {
  8517. throw new Error('replace failed: missing component');
  8518. }
  8519.  
  8520. if (componentOld === componentNew) {
  8521. return;
  8522. }
  8523.  
  8524. const refOld = componentOld[wk];
  8525. // ensure New has a weak‐ref
  8526. const refNew = componentNew[wk] || (componentNew[wk] = mWeakRef(componentNew));
  8527.  
  8528.  
  8529. if (refOld === refNew) {
  8530. return;
  8531. }
  8532.  
  8533. if (!refOld || !this.nodes.has(refOld)) {
  8534. throw new Error('replace failed: old component not found');
  8535. }
  8536.  
  8537. // this.checkIntegrity();
  8538.  
  8539. // If new is already in the list somewhere, detach it first
  8540. if (this.nodes.has(refNew)) {
  8541. this._detach(refNew);
  8542. }
  8543.  
  8544. // Pull out old pointers
  8545. const { prev, next, level } = this.nodes.get(refOld);
  8546.  
  8547. // Link into the main list
  8548. if (prev) {
  8549. this.nodes.get(prev).next = refNew;
  8550. } else {
  8551. this.head = refNew;
  8552. }
  8553.  
  8554. if (next) {
  8555. this.nodes.get(next).prev = refNew;
  8556. } else {
  8557. this.tail = refNew;
  8558. }
  8559.  
  8560. // Link into the per‐level sentinels
  8561. if (this.levelHead[level] === refOld) {
  8562. this.levelHead[level] = refNew;
  8563. }
  8564. if (this.levelTail[level] === refOld) {
  8565. this.levelTail[level] = refNew;
  8566. }
  8567.  
  8568. // Finally re‐key the Map entry
  8569. this.nodes.set(refNew, { prev, next, level });
  8570. this.nodes.delete(refOld);
  8571.  
  8572. // this.checkIntegrity();
  8573. }
  8574.  
  8575. _walk(ref, dir) {
  8576. if (!ref || !this.nodes.has(ref)) return null;
  8577.  
  8578. let cur = this.nodes.get(ref)[dir];
  8579. while (cur) {
  8580. if (cur.deref()) return cur;
  8581.  
  8582. // Clean up collected node
  8583. const nxt = this.nodes.get(cur)[dir];
  8584. this._detach(cur);
  8585. cur = nxt;
  8586. }
  8587. return null;
  8588. }
  8589.  
  8590. nextComp(component) {
  8591. const ref = component && component.deref ? component : (component || 0)[wk];
  8592. return this._walk(ref, 'next');
  8593. }
  8594.  
  8595. prevComp(component) {
  8596. const ref = component && component.deref ? component : (component || 0)[wk];
  8597. return this._walk(ref, 'prev');
  8598. }
  8599.  
  8600. hasComp(component) {
  8601. const ref = component && component.deref ? component : (component || 0)[wk];
  8602. return !!(ref && this.nodes.has(ref))
  8603. }
  8604.  
  8605. count() {
  8606. return this.counter;
  8607. }
  8608.  
  8609. countLevels() {
  8610. const r = [];
  8611. for (let i = 0; ; i++) {
  8612. if (!this.levelHead[i] || !this.levelTail[i]) break;
  8613. let cur = this.levelHead[i];
  8614. let curs = [];
  8615. while (cur && this.nodes.get(cur).level === i) {
  8616. curs.push((cur));
  8617. cur = taskListP.nextComp(cur);
  8618. }
  8619.  
  8620. if (curs[0] !== this.levelHead[i]) debugger;
  8621. if (curs[curs.length - 1] !== this.levelTail[i]) debugger;
  8622. r.push({
  8623. head: this.levelHead[i],
  8624. tail: this.levelTail[i],
  8625. curs: curs,
  8626. set: new Set(curs),
  8627. arrSize: curs.length,
  8628. setSize: (new Set(curs)).size
  8629.  
  8630. });
  8631. }
  8632. return r;
  8633. }
  8634.  
  8635.  
  8636. // // Integrity checker helper
  8637. // checkIntegrity() {
  8638. // const list = this;
  8639. // // Global head/tail pointers
  8640. // if (list.head !== null) {
  8641. // const headNode = list.nodes.get(list.head);
  8642. // assert(headNode.prev === null, "Integrity: head.prev must be null");
  8643. // }
  8644. // if (list.tail !== null) {
  8645. // const tailNode = list.nodes.get(list.tail);
  8646. // assert(tailNode.next === null, "Integrity: tail.next must be null");
  8647. // }
  8648.  
  8649. // // Per-level head/tail and level consistency
  8650. // list.nonEmptyLevels.forEach(level => {
  8651. // assert(list.levelHead[level] != null, `Integrity: levelHead[${level}] should not be null`);
  8652. // assert(list.levelTail[level] != null, `Integrity: levelTail[${level}] should not be null`);
  8653. // const headRef = list.levelHead[level];
  8654. // const tailRef = list.levelTail[level];
  8655. // const headNode = list.nodes.get(headRef);
  8656. // const tailNode = list.nodes.get(tailRef);
  8657. // assert(headNode.level === level, `Integrity: levelHead[${level}].level mismatch`);
  8658. // assert(tailNode.level === level, `Integrity: levelTail[${level}].level mismatch`);
  8659. // });
  8660.  
  8661. // // nonEmptyLevels sorted ascending
  8662. // for (let i = 1; i < list.nonEmptyLevels.length; i++) {
  8663. // assert(
  8664. // list.nonEmptyLevels[i] > list.nonEmptyLevels[i - 1],
  8665. // "Integrity: nonEmptyLevels must be sorted ascending"
  8666. // );
  8667. // }
  8668.  
  8669. // this.countLevels();
  8670. // }
  8671.  
  8672. }
  8673.  
  8674.  
  8675. const taskListP = new CTaskList();
  8676. const taskList = [];
  8677. let taskCounter = 0;
  8678. window.me55 = ()=>taskListP;
  8679.  
  8680. const taskPush = (component, pTask0, pTask1, deferred = false) => {
  8681. component = kRef(component);
  8682. if (!component) return;
  8683. if (!pTask0) pTask0 = pTask1; else Object.assign(pTask0, pTask1);
  8684. componentBasedTaskPool.set(component, pTask0);
  8685. const id = taskCounter = (taskCounter & 1073741823) + 1;
  8686. pTask0.taskId = id;
  8687. if (!pTask1.byPass) pTask0.byPass = false;
  8688. taskListP.push(component, 0);
  8689. if (!deferred) nonDeferredTask = component[wk];
  8690. // taskList.push({
  8691. // taskId: id,
  8692. // componentWr: component[wk]
  8693. // })
  8694. return pTask0;
  8695. }
  8696.  
  8697. const domComment_ = document.createComment('y');
  8698. const triggerDomChange = (node) => {
  8699. node.appendChild(domComment_).remove();
  8700. }
  8701.  
  8702.  
  8703. const performTask = (component, pTask = undefined) => {
  8704.  
  8705. if (pTask === undefined) pTask = componentBasedTaskPool.get(component);
  8706. if (!pTask || !component) return;
  8707. let { step, producer, containerId, typeOrConfig, data, flushing, selfProducer } = pTask;
  8708. producer = kRef(producer);
  8709. selfProducer = kRef(selfProducer);
  8710.  
  8711. const resolveSelf = () => {
  8712.  
  8713. const node = component;
  8714.  
  8715. const prevCur = taskListP.prevComp(node);
  8716.  
  8717. node.removeAttribute('ytx-flushing');
  8718.  
  8719. // if (selfProducer && flushing && flushing.length > 0 && selfProducer.hostElement && selfProducer.hostElement.isConnected) {
  8720.  
  8721. if (selfProducer && flushing && flushing.length > 0 && selfProducer.hostElement) {
  8722. const node = component;
  8723.  
  8724. let shouldMarkDirty = false;
  8725.  
  8726. const m = new Set();
  8727.  
  8728. const producer = selfProducer;
  8729.  
  8730. for (const [containerId, bEvent, hasData] of flushing) {
  8731. if (hasData || hasData === null) {
  8732. shouldMarkDirty = true;
  8733. if (bEvent) {
  8734. const container = producer.getStampContainer7409_(containerId);
  8735. // console.log(644221499, container)
  8736. m.add(container);
  8737. }
  8738. }
  8739. }
  8740. flushing.length = 0;
  8741.  
  8742. if (shouldMarkDirty) {
  8743. producer.markDirty && producer.markDirty();
  8744. let q = true;
  8745. for (const container of m) {
  8746. if (!q) producer.markDirty && producer.markDirty();
  8747. q = false;
  8748. dispatchYtEvent(producer.hostElement, "yt-rendererstamper-finished", {
  8749. container
  8750. });
  8751. }
  8752. }
  8753.  
  8754. }
  8755.  
  8756.  
  8757.  
  8758. const s = new Set();
  8759.  
  8760. const parentComponent = node.closest('[ytx-flushing]');
  8761. if (parentComponent && componentBasedTaskPool.has(parentComponent) && parentComponent[wk] && !parentComponent.querySelector('[ytx-flushing]')) {
  8762. if (!s.has(parentComponent[wk])) {
  8763. s.add(parentComponent[wk]);
  8764. }
  8765. }
  8766.  
  8767. const producerElement = producer ? producer.hostElement : null;
  8768.  
  8769. if (parentComponent && parentComponent !== producerElement) {
  8770.  
  8771. const parentComponent = producerElement;
  8772. if (parentComponent && componentBasedTaskPool.has(parentComponent) && parentComponent[wk] && !parentComponent.querySelector('[ytx-flushing]')) {
  8773. if (!s.has(parentComponent[wk])) {
  8774. s.add(parentComponent[wk])
  8775. }
  8776. }
  8777.  
  8778. }
  8779.  
  8780. for (const p of s) {
  8781. const node = kRef(p);
  8782. triggerDomChange(node);
  8783. }
  8784.  
  8785. if (!node.hasAttribute('ytx-flushing') && (!pTask.flushing || !pTask.flushing.length) && !pTask.typeOrConfig && !pTask.data) {
  8786. componentBasedTaskPool.delete(node);
  8787. taskListP.remove(node);
  8788. }
  8789.  
  8790.  
  8791. return {nextCur: (prevCur ? taskListP.nextComp(prevCur) || taskListP.head: taskListP.head), parents: [...s]};
  8792.  
  8793. }
  8794.  
  8795. if (pTask.step === 'creation') {
  8796.  
  8797. if (flushing) debugger;
  8798. if (!producer || !typeOrConfig) return;
  8799. if (component.parentNode && component.parentNode.id === containerId && component.parentNode === producer.getStampContainer7409_(containerId)) {
  8800. pTask.step = 'flushStamper'; pTask.pq33 = 3;
  8801.  
  8802. // const aNode = producer.createComponent7409_(typeOrConfig, data, false);
  8803.  
  8804. const prevCur = taskListP.prevComp(component);
  8805.  
  8806. const pTaskId = pTask.taskId;
  8807. const cName = producer.getComponentName_(typeOrConfig, data);
  8808. const aNode = document.createElement(cName);
  8809. const qNode = component;
  8810.  
  8811. aNode.setAttribute('ytx-stamp', 'flusher');
  8812. aNode.setAttribute('ytx-flushing', '2');
  8813. if (!aNode[wk]) aNode[wk] = mWeakRef(aNode);
  8814.  
  8815. taskListP.replace(qNode, aNode);
  8816.  
  8817. componentBasedTaskPool.delete(qNode);
  8818. componentBasedTaskPool.set(aNode, pTask); // pTask will be obtained and proceeded during "dom change" in the same micro task
  8819.  
  8820.  
  8821. const container = component.parentNode;
  8822. const containerApi = container.__domApi || container;
  8823.  
  8824. const frag = document.createDocumentFragment();
  8825. frag.appendChild(aNode);
  8826. containerApi.insertBefore(frag, qNode);
  8827. containerApi.removeChild(qNode);
  8828. return {nextCur: (prevCur ? taskListP.nextComp(prevCur) || taskListP.head: taskListP.head)};
  8829.  
  8830. }
  8831. } else if (pTask.step === 'flushStamper') {
  8832.  
  8833. if (flushing) debugger;
  8834.  
  8835. if (!producer || !typeOrConfig) return;
  8836. pTask.step = 'flushStamperWait';
  8837. pTask.typeOrConfig = null;
  8838. pTask.data = null;
  8839.  
  8840. const prevCur = taskListP.prevComp(component);
  8841.  
  8842. const node = component;
  8843. node.setAttribute('ytx-flushing', '3');
  8844.  
  8845. let taskB = { component: component, typeOrConfig: typeOrConfig, data: data };
  8846. // flushedObserver.observe(node, { subtree: true, childList: true });
  8847. producer.deferredBindingTasks_.push(taskB);
  8848. producer.flushRenderStamperComponentBindings7409_();
  8849. // try{Polymer.flush()}catch(e){}
  8850. return {nextCur: (prevCur ? taskListP.nextComp(prevCur) || taskListP.head: taskListP.head)};
  8851.  
  8852. } else if (pTask.step === 'flushStamperWait') {
  8853.  
  8854. if (flushing) debugger;
  8855. if (!producer) return;
  8856.  
  8857. // producer undetermined
  8858.  
  8859. const node = component;
  8860.  
  8861. if (!node.querySelector('[ytx-flushing]')) {
  8862.  
  8863. pTask.step = 'idleContainer';
  8864.  
  8865. return resolveSelf();
  8866.  
  8867.  
  8868. }
  8869.  
  8870. } else if (pTask.step === 'mightFlushAndWaitContainersRenderFinish') {
  8871.  
  8872. if (producer && typeOrConfig) {
  8873.  
  8874. pTask.typeOrConfig = null;
  8875. pTask.data = null;
  8876.  
  8877. const prevCur = taskListP.prevComp(component);
  8878.  
  8879. const node = component;
  8880. node.setAttribute('ytx-flushing', '3');
  8881.  
  8882. let taskB = { component: component, typeOrConfig: typeOrConfig, data: data };
  8883. // flushedObserver.observe(node, { subtree: true, childList: true });
  8884. producer.deferredBindingTasks_.push(taskB);
  8885. producer.flushRenderStamperComponentBindings7409_();
  8886. // try{Polymer.flush()}catch(e){}
  8887. return {nextCur: (prevCur ? taskListP.nextComp(prevCur) || taskListP.head: taskListP.head)};
  8888. }
  8889.  
  8890. const node = component;
  8891.  
  8892. if (!node.querySelector('[ytx-flushing]')) {
  8893. pTask.step = 'idleProducer';
  8894. return resolveSelf();
  8895. }
  8896. // const selfProducer = kRef(pTask.selfProducer);
  8897.  
  8898. }
  8899.  
  8900. };
  8901.  
  8902. const performTaskQueued = (component)=>{
  8903. queueMicrotask_(()=>{
  8904. performTask(component);
  8905. });
  8906. };
  8907.  
  8908. let isLooping = false;
  8909. let nonDeferredTask = null;
  8910. let loopTaskQ = 0;
  8911. const loopTask = () => {
  8912. if (isLooping) return ++loopTaskQ;
  8913. isLooping = true;
  8914. loopTaskQ = 0;
  8915. let t0 = 0;
  8916. let cur = taskListP.head;
  8917. let nextCur = cur;
  8918. const taskExec = () => {
  8919.  
  8920. if (!t0) {
  8921. t0 = nativeNow();
  8922. }
  8923.  
  8924. if (nonDeferredTask && nextCur && taskListP.nodes.has(nextCur) && taskListP.nodes.get(nextCur).level === 1) {
  8925. nextCur = nonDeferredTask
  8926. }
  8927.  
  8928. nonDeferredTask = null;
  8929.  
  8930. for (;cur = nextCur; ) {
  8931.  
  8932. nextCur = taskListP.nextComp(cur);
  8933. const nextCur0 = nextCur;
  8934.  
  8935. const taskComponent = kRef(cur);
  8936. if (taskComponent) {
  8937. if(taskComponent === window.me849) debugger;
  8938. const pTask = componentBasedTaskPool.get(taskComponent);
  8939. if (pTask) {
  8940. if (pTask.taskId > 0 && !pTask.byPass) {
  8941. if (pTask.taskId === window.me848) debugger;
  8942.  
  8943. let shouldPerformTask = false;
  8944. if (pTask.step === 'creation' && pTask.typeOrConfig) {
  8945. shouldPerformTask = true;
  8946. } else if (pTask.step === 'flushStamper' && pTask.typeOrConfig) {
  8947. shouldPerformTask = true;
  8948. } else if (pTask.step === 'flushStamperWait' && !taskComponent.querySelector('[ytx-flushing]')) {
  8949. shouldPerformTask = true;
  8950. } else if (pTask.step === 'mightFlushAndWaitContainersRenderFinish' && (pTask.typeOrConfig || !taskComponent.querySelector('[ytx-flushing]'))) {
  8951. shouldPerformTask = true;
  8952. }
  8953.  
  8954. let b = shouldPerformTask && taskComponent.parentNode;
  8955. if (b) {
  8956.  
  8957. const result = performTask(taskComponent, pTask);
  8958. let kbb = false;
  8959. if(typeof result ==='object' && result.nextCur === nextCur0){
  8960.  
  8961. } else if(taskListP.nextComp(cur) === null && taskListP.nextComp(cur) !== nextCur0) {
  8962. kbb = true;
  8963. }
  8964. if (typeof result === 'object' && result.parents instanceof Array) {
  8965.  
  8966. const nextCur_ = result.nextCur;
  8967. nextCur = nextCur_;
  8968. const parents = result.parents;
  8969. if (parents.length >= 1) {
  8970. const eSet = new Set(parents); // weak refs
  8971. eSet.add(nextCur_)
  8972. for (let cur_ = taskListP.head; cur_; cur_ = taskListP.nextComp(cur_)) {
  8973. if (eSet.has(cur_)) {
  8974. nextCur = cur_;
  8975. break;
  8976. }
  8977. }
  8978. }
  8979.  
  8980.  
  8981. } else if(typeof result === 'object' && result.nextCur){
  8982. nextCur = result.nextCur;
  8983. }
  8984.  
  8985.  
  8986. if (nativeNow() - t0 > 10) {
  8987. t0 = 0;
  8988. nextBrowserTick_(taskExec);
  8989. } else {
  8990. queueMicrotask_(taskExec);
  8991. }
  8992.  
  8993. return;
  8994.  
  8995. }
  8996.  
  8997. }
  8998.  
  8999. }
  9000.  
  9001. }
  9002.  
  9003. }
  9004.  
  9005. isLooping = false;
  9006.  
  9007. if(loopTaskQ > 0) nextBrowserTick_(loopTask);
  9008.  
  9009. };
  9010.  
  9011. queueMicrotask_(taskExec);
  9012.  
  9013. };
  9014.  
  9015.  
  9016. let q244 = new PromiseExternal();
  9017. let q248a = [];
  9018. let q248b = [];
  9019. let q248c = [];
  9020. const deferRenderStamperBinding_ = function (component, typeOrConfig, data) {
  9021.  
  9022. if(this.__byPass828__) {
  9023.  
  9024. return this.deferRenderStamperBinding7409_(component, typeOrConfig, data);
  9025. }
  9026.  
  9027. const isLastCreate = this.___lastCreate3311__ === data; // false for native element. true for RP or native element
  9028.  
  9029. this.___lastCreate3311__ = -0.125;
  9030.  
  9031.  
  9032. const containerId = this.__activeContainerId929__;
  9033. if (!component[wk]) component[wk] = mWeakRef(component);
  9034. if (!this[wk]) this[wk] = mWeakRef(this);
  9035.  
  9036. const pTask = componentBasedTaskPool.get(component);
  9037.  
  9038. const isSelfProducer = (pTask && pTask.selfProducer && pTask.flushing);
  9039.  
  9040.  
  9041. const abandonUnreadySubtree = () => {
  9042. for (const e of component.querySelectorAll('[ytx-flushing]')) {
  9043. const pTask = componentBasedTaskPool.get(e);
  9044. if (pTask) {
  9045. pTask.step = 'abandon';
  9046. pTask.taskId = 0;
  9047. if (pTask.flushing) pTask.flushing.length = 0;
  9048. pTask.flushing = null;
  9049.  
  9050. pTask.typeOrConfig = null
  9051. pTask.data = null
  9052.  
  9053. componentBasedTaskPool.delete(e);
  9054. taskListP.remove(e);
  9055. }
  9056. e.removeAttribute('ytx-flushing');
  9057. if (e.nodeName === 'RP') e.remove();
  9058. }
  9059. }
  9060.  
  9061. const flushNowTask = (componentWr, pTaskId, flag) => {
  9062. const component = kRef(componentWr);
  9063. if (!component) return;
  9064. const pTaskNew = componentBasedTaskPool.get(component);
  9065. if (!pTaskNew) return;
  9066. if (pTaskId !== pTaskNew.taskId) return;
  9067. pTaskNew.byPass = false;
  9068. if (flag & 1) {
  9069. performTaskQueued(component);
  9070. performTaskQueued(component);
  9071. performTaskQueued(component);
  9072. } else {
  9073. performTask(component);
  9074. performTask(component);
  9075. performTask(component);
  9076. }
  9077. return true;
  9078. }
  9079.  
  9080. const flushNow = (component) => {
  9081.  
  9082.  
  9083.  
  9084. const cName = this.getComponentName_(typeOrConfig, data);
  9085. const mDeferred = cName === 'ytd-playlist-panel-video-renderer' || this.is === 'ytd-playlist-panel-video-renderer';
  9086. // const mDeferred = typeof cName === 'string' && cName.length >= 17 && (cName === 'ytd-playlist-panel-video-renderer' || cName === 'ytd-menu-renderer' || cName.startsWith('ytd-thumbnail-overlay-'));
  9087.  
  9088. if(mDeferred) {
  9089. component.setAttribute('ytx-defer-stamp','');
  9090. this.hostElement.setAttribute('ytx-defer-stamp','');
  9091. }
  9092.  
  9093. const pTaskNew = taskPush(component, pTask, {
  9094. step: isSelfProducer ? 'mightFlushAndWaitContainersRenderFinish' : 'flushStamper',
  9095. producer: this[wk],
  9096. containerId: containerId,
  9097. typeOrConfig: typeOrConfig,
  9098. data: data,
  9099. byPass: true,
  9100. pq33: 7
  9101. }, mDeferred ? 1 : 0);
  9102.  
  9103. const pTaskId = pTaskNew.taskId;
  9104.  
  9105. const componentWr = component[wk];
  9106.  
  9107.  
  9108. if(!component.hasAttribute('ytx-flushing')) component.setAttribute('ytx-flushing', '2w');
  9109.  
  9110. if (mDeferred ) {
  9111.  
  9112. q248a.push([componentWr, pTaskId]);
  9113.  
  9114. setTimeout(() => {
  9115. const q248 = q248a;
  9116.  
  9117. if (!q248.length) return;
  9118. let q246 = q248.slice();
  9119. q248.length = 0;
  9120.  
  9121. let doLoop = false;
  9122. for (const [componentWr, pTaskId] of q246) {
  9123. // if(!)
  9124. // console.log(2188, kRef(componentWr).parentNode)
  9125. if (flushNowTask(componentWr, pTaskId, 1) === true) doLoop = true;
  9126. }
  9127. q246.length = 0;
  9128. q246 = null;
  9129. if (doLoop) loopTask();
  9130.  
  9131. }, 0);
  9132.  
  9133.  
  9134. } else {
  9135.  
  9136. if(!component.parentNode){
  9137.  
  9138. q248b.push([componentWr, pTaskId]);
  9139.  
  9140. (() => {
  9141.  
  9142. const q248 = q248b;
  9143.  
  9144. if (!q248.length) return;
  9145. let q246 = q248.slice();
  9146. q248.length = 0;
  9147. let doLoop = false;
  9148. for (const [componentWr, pTaskId] of q246) {
  9149. if (flushNowTask(componentWr, pTaskId, 0) === true) doLoop = true;
  9150. }
  9151. q246.length = 0;
  9152. q246 = null;
  9153. if (doLoop) loopTask();
  9154. })();
  9155.  
  9156. } else {
  9157.  
  9158.  
  9159. q248c.push([componentWr, pTaskId]);
  9160.  
  9161. nextBrowserTick_(() => {
  9162. const q248 = q248c;
  9163.  
  9164. if (!q248.length) return;
  9165. let q246 = q248.slice();
  9166. q248.length = 0;
  9167.  
  9168. let doLoop = false;
  9169. for (const [componentWr, pTaskId] of q246) {
  9170. if (flushNowTask(componentWr, pTaskId, 1) === true) doLoop = true;
  9171. }
  9172. q246.length = 0;
  9173. q246 = null;
  9174. if (doLoop) loopTask();
  9175.  
  9176. });
  9177.  
  9178. }
  9179.  
  9180. }
  9181.  
  9182.  
  9183.  
  9184. loopTask();
  9185.  
  9186. };
  9187.  
  9188. if (!isLastCreate) {
  9189.  
  9190. abandonUnreadySubtree();
  9191.  
  9192. flushNow(component);
  9193. return;
  9194.  
  9195. } else {
  9196. if (pTask) pTask.taskId = 0;
  9197. }
  9198.  
  9199. if (this.__byPass828__ || !this.__byPass348__) {
  9200. return this.deferRenderStamperBinding7409_(component, typeOrConfig, data);
  9201. }
  9202.  
  9203. if (pTask && pTask.step !== 'creation') {
  9204.  
  9205. if(!component.hasAttribute('ytx-flushing')) component.setAttribute('ytx-flushing', '2c');
  9206.  
  9207. abandonUnreadySubtree();
  9208.  
  9209. flushNow(component);
  9210.  
  9211. return;
  9212.  
  9213. } else {
  9214.  
  9215. if (component.nodeName === "RP") {
  9216.  
  9217. component.setAttribute('ytx-stamp', 'flusher');
  9218.  
  9219. component.setAttribute('ytx-flushing', '1');
  9220.  
  9221. const cName = this.getComponentName_(typeOrConfig, data);
  9222. const mDeferred = cName === 'ytd-playlist-panel-video-renderer' || this.is === 'ytd-playlist-panel-video-renderer';
  9223. // const mDeferred = typeof cName === 'string' && cName.length >= 17 && (cName === 'ytd-playlist-panel-video-renderer' || cName === 'ytd-menu-renderer' || cName.startsWith('ytd-thumbnail-overlay-'));
  9224.  
  9225. if(mDeferred) {
  9226. component.setAttribute('ytx-defer-stamp','');
  9227. this.hostElement.setAttribute('ytx-defer-stamp','');
  9228. }
  9229.  
  9230. taskPush(component, pTask, {
  9231. step: 'creation',
  9232. producer: this[wk],
  9233. containerId: containerId,
  9234. typeOrConfig: typeOrConfig,
  9235. data: data
  9236. }, mDeferred ? 1 : 0);
  9237. loopTask();
  9238.  
  9239. } else {
  9240.  
  9241.  
  9242. const aNode = component;
  9243. if (!aNode[wk]) aNode[wk] = mWeakRef(aNode);
  9244.  
  9245. aNode.setAttribute('ytx-stamp', 'flusher');
  9246. aNode.setAttribute('ytx-flushing', '2');
  9247.  
  9248. flushNow(component);
  9249.  
  9250. }
  9251.  
  9252. }
  9253.  
  9254.  
  9255. }
  9256. flushRenderStamperComponentBindings_ = function () {
  9257.  
  9258. if (!this.__byPass348__) {
  9259. return this.flushRenderStamperComponentBindings7409_();
  9260. }
  9261. if (this.__byPass828__) {
  9262. const wr = this[wk] || (this[wk] = mWeakRef(this));
  9263. queueMicrotask_(() => {
  9264. const producer = kRef(wr);
  9265. if (!producer) return;
  9266. producer.flushRenderStamperComponentBindings7409_();
  9267. });
  9268. throw new Error('5ii48');
  9269. }
  9270. throw new Error('5ii48')
  9271. }
  9272.  
  9273.  
  9274. const directComponentList = new Set([
  9275. // for YouTube Tabview Totara
  9276. "YTD-STRUCTURED-DESCRIPTION-CONTENT-RENDERER",
  9277. "YTD-VIDEO-DESCRIPTION-HEADER-RENDERER",
  9278. "YTD-ENGAGEMENT-PANEL-SECTION-LIST-RENDERER",
  9279. ]);
  9280.  
  9281.  
  9282. let kf33;
  9283. let kf3b = 0;
  9284.  
  9285. const sb88 = Symbol();
  9286.  
  9287. const onStampDone = (producer) =>{
  9288.  
  9289.  
  9290. const flushing_ = producer[sb88];
  9291.  
  9292. const flushing = flushing_.slice();
  9293. flushing_.length = 0;
  9294.  
  9295. if (flushing && flushing.length > 0) {
  9296.  
  9297. let shouldMarkDirty = false;
  9298.  
  9299. const m = new Set();
  9300.  
  9301. for (const [containerId, bEvent, hasData] of flushing) {
  9302. if (hasData || hasData === null) {
  9303. shouldMarkDirty = true;
  9304. if (bEvent) {
  9305. const container = producer.getStampContainer7409_(containerId);
  9306. // console.log(644221499, container)
  9307. m.add(container);
  9308. }
  9309. }
  9310. }
  9311. flushing.length = 0;
  9312.  
  9313. if (shouldMarkDirty) {
  9314. producer.markDirty && producer.markDirty();
  9315. let q = true;
  9316. for (const container of m) {
  9317. if (!q) producer.markDirty && producer.markDirty();
  9318. q = false;
  9319. dispatchYtEvent(producer.hostElement, "yt-rendererstamper-finished", {
  9320. container
  9321. });
  9322. }
  9323. }
  9324.  
  9325. }
  9326.  
  9327.  
  9328. }
  9329.  
  9330. stampDomArraySplices_ = function (stampKey, containerId, indexSplicesObj) {
  9331. // this.__byPass828__ = true;
  9332.  
  9333. // return this.stampDomArraySplices7409_(stampKey, containerId, indexSplicesObj);
  9334.  
  9335. const producer = this;
  9336. const hostElement = producer.hostElement;
  9337.  
  9338. let kf = false;
  9339. const kf3t = nativeNow();
  9340. const kf34 = Math.floor((kf3t - kf3b) / 8);
  9341.  
  9342. if (!kf33 || kf34 !== kf33) {
  9343. kf33 = kf34;
  9344. kf3b = kf3t - kf34 * 8;
  9345. kf = true;
  9346. }
  9347.  
  9348. const container = this.getStampContainer7409_(containerId);
  9349. if (container && !container.__rk75401__) {
  9350. container.__rk75401__ = true;
  9351. childrenObs.observe(container, { subtree: false, childList: true });
  9352. }
  9353.  
  9354. if (kf) this.__directProduction533__ = true;
  9355. else if (!this.isAttached) this.__directProduction533__ = true; // tbc
  9356. else if (this.onYtRendererstamperFinished && this.updateChildVisibilityProperties) this.__directProduction533__ = true;
  9357. else if (hostElement && directComponentList.has(hostElement.nodeName)) this.__directProduction533__ = true;
  9358. else if (hostElement && hostElement.closest('ytd-engagement-panel-section-list-renderer, [hidden], defs, noscript')) this.__directProduction533__ = true;
  9359. else this.__directProduction533__ = false;
  9360.  
  9361. this.__directProduction533__ = true;
  9362.  
  9363. // if (container.is === 'yt-img-shadow') this.__byPass828__ = true;
  9364.  
  9365. // if(this.hostElement.closest('ytd-comments')) this.__byPass828__ = true;
  9366.  
  9367. const bEventCb = this.stampDom[stampKey].events;
  9368.  
  9369. this.__activeContainerId929__ = containerId;
  9370.  
  9371. if (!this[wk]) this[wk] = mWeakRef(this);
  9372. if (!hostElement[wk]) hostElement[wk] = mWeakRef(hostElement);
  9373. if (hostElement.getAttribute('ytx-stamp') === 'flusher') {
  9374. hostElement.setAttribute('ytx-stamp', 'flusher|producer');
  9375. } else if (!hostElement.hasAttribute('ytx-stamp')) {
  9376. hostElement.setAttribute('ytx-stamp', 'producer');
  9377. }
  9378.  
  9379.  
  9380. if (this.__byPass828__) {
  9381.  
  9382. const flushing = this[sb88] || (this[sb88] = []);
  9383. flushing.push([containerId, bEventCb, null]);
  9384. let r, e_
  9385. try {
  9386. this.__byPass348__ = true;
  9387. this.stampDomArraySplices7409_(stampKey, containerId, indexSplicesObj);
  9388. } catch (e) {
  9389. e_ = e;
  9390. }
  9391. this.__byPass348__ = false;
  9392.  
  9393. nextBrowserTick_(() => {
  9394. onStampDone(this);
  9395. });
  9396.  
  9397. if (e_ && e_.message !== '5ii48') throw e_;
  9398. return;
  9399.  
  9400. }
  9401.  
  9402.  
  9403. const pTask = componentBasedTaskPool.get(hostElement); // can be flushStamperWait -> mightFlushAndWaitContainersRenderFinish
  9404.  
  9405. const flushing = pTask ? (pTask.flushing || []) : [];
  9406. flushing.push([containerId, bEventCb, null]);
  9407. hostElement.setAttribute('ytx-flushing', 's-1');
  9408.  
  9409. if (pTask) {
  9410. // pTask.taskId = -1;
  9411. pTask.byPass = true;
  9412. }
  9413. if (hostElement && !hostElement.__rk75401__) {
  9414. hostElement.__rk75401__ = true;
  9415. childrenObs.observe(hostElement, { subtree: false, childList: true });
  9416. }
  9417.  
  9418. let r, e_
  9419. try {
  9420. this.__byPass348__ = true;
  9421. this.stampDomArraySplices7409_(stampKey, containerId, indexSplicesObj);
  9422. } catch (e) {
  9423. e_ = e;
  9424. }
  9425. this.__byPass348__ = false;
  9426.  
  9427. taskPush(hostElement, pTask, {
  9428. step: 'mightFlushAndWaitContainersRenderFinish',
  9429. selfProducer: this[wk],
  9430. flushing
  9431. });
  9432. loopTask();
  9433.  
  9434. triggerDomChange(container);
  9435. triggerDomChange(hostElement);
  9436.  
  9437. if (e_ && e_.message !== '5ii48') throw e_;
  9438.  
  9439. };
  9440.  
  9441. stampDomArray_ = function (dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList) {
  9442. // this.__byPass828__ = true;
  9443.  
  9444.  
  9445.  
  9446. // return this.stampDomArray7409_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  9447.  
  9448. const producer = this;
  9449. const hostElement = producer.hostElement;
  9450.  
  9451. let kf = false;
  9452. const kf3t = nativeNow();
  9453. const kf34 = Math.floor((kf3t - kf3b) / 8);
  9454.  
  9455. if (!kf33 || kf34 !== kf33) {
  9456. kf33 = kf34;
  9457. kf3b = kf3t - kf34 * 8;
  9458. kf = true;
  9459. }
  9460.  
  9461. const container = this.getStampContainer7409_(containerId);
  9462. if (container && !container.__rk75401__) {
  9463. container.__rk75401__ = true;
  9464. childrenObs.observe(container, { subtree: false, childList: true });
  9465. }
  9466.  
  9467. if (kf) this.__directProduction533__ = true;
  9468. else if (!this.isAttached) this.__directProduction533__ = true; // tbc
  9469. else if (this.onYtRendererstamperFinished && this.updateChildVisibilityProperties) this.__directProduction533__ = true;
  9470. else if (hostElement && directComponentList.has(hostElement.nodeName)) this.__directProduction533__ = true;
  9471. else if (hostElement && hostElement.closest('ytd-engagement-panel-section-list-renderer, [hidden], defs, noscript')) this.__directProduction533__ = true;
  9472. else this.__directProduction533__ = false;
  9473.  
  9474. bReuse = false;
  9475.  
  9476. this.__directProduction533__ = true;
  9477.  
  9478. // if (container.is === 'yt-img-shadow') this.__byPass828__ = true;
  9479. // if(this.hostElement.closest('ytd-comments')) this.__byPass828__ = true;
  9480.  
  9481. this.__activeContainerId929__ = containerId;
  9482.  
  9483. if (!this[wk]) this[wk] = mWeakRef(this);
  9484. if (!hostElement[wk]) hostElement[wk] = mWeakRef(hostElement);
  9485. if (hostElement.getAttribute('ytx-stamp') === 'flusher') {
  9486. hostElement.setAttribute('ytx-stamp', 'flusher|producer');
  9487. } else if (!hostElement.hasAttribute('ytx-stamp')) {
  9488. hostElement.setAttribute('ytx-stamp', 'producer');
  9489. }
  9490.  
  9491.  
  9492. if (this.__byPass828__) {
  9493.  
  9494. const flushing = this[sb88] || (this[sb88] = []);
  9495. flushing.push([containerId, bEventCb, !!dataList]);
  9496. let r, e_
  9497. try {
  9498. this.__byPass348__ = true;
  9499. this.stampDomArray7409_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  9500. } catch (e) {
  9501. e_ = e;
  9502. }
  9503. this.__byPass348__ = false;
  9504.  
  9505. nextBrowserTick_(() => {
  9506. onStampDone(this);
  9507. });
  9508.  
  9509. if (e_ && e_.message !== '5ii48') throw e_;
  9510. return;
  9511.  
  9512. }
  9513.  
  9514.  
  9515. const pTask = componentBasedTaskPool.get(hostElement); // can be flushStamperWait -> mightFlushAndWaitContainersRenderFinish
  9516.  
  9517. const flushing = pTask ? (pTask.flushing || []) : [];
  9518. flushing.push([containerId, bEventCb, !!dataList]);
  9519. hostElement.setAttribute('ytx-flushing', 's-1');
  9520.  
  9521. if (pTask) {
  9522. pTask.byPass = true;
  9523. // pTask.taskId = -1;
  9524. }
  9525.  
  9526. if (hostElement && !hostElement.__rk75401__) {
  9527. hostElement.__rk75401__ = true;
  9528. childrenObs.observe(hostElement, { subtree: false, childList: true });
  9529. }
  9530.  
  9531. let r, e_
  9532. try {
  9533. this.__byPass348__ = true;
  9534. this.stampDomArray7409_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  9535. } catch (e) {
  9536. e_ = e;
  9537. }
  9538. this.__byPass348__ = false;
  9539.  
  9540. taskPush(hostElement, pTask, {
  9541. step: 'mightFlushAndWaitContainersRenderFinish',
  9542. selfProducer: this[wk],
  9543. flushing
  9544. });
  9545. loopTask();
  9546.  
  9547. triggerDomChange(container);
  9548. triggerDomChange(hostElement);
  9549.  
  9550. if (e_ && e_.message !== '5ii48') throw e_;
  9551.  
  9552. };
  9553.  
  9554. const stampDomArrayWB_ = function (objWr, containerId, xxx_) {
  9555.  
  9556. const obj = kRef(objWr);
  9557. if (!obj) return;
  9558. const xxx = obj[`__stampDomArrayArgs_xxx__#${containerId}__`];
  9559. if (xxx !== xxx_) return;
  9560. const dataList = obj[`__stampDomArrayArgs_dataList__#${containerId}__`];
  9561. const typeOrConfig = kRef(obj[`__stampDomArrayArgs_typeOrConfig__#${containerId}__`]);
  9562. const bReuse = obj[`__stampDomArrayArgs_bReuse__#${containerId}__`];
  9563. const bEventCb = obj[`__stampDomArrayArgs_bEventCb__#${containerId}__`];
  9564. const bStableList = obj[`__stampDomArrayArgs_bStableList__#${containerId}__`];
  9565. // console.log(12388002, containerId, dataList, typeOrConfig, bReuse, bEventCb, bStableList)
  9566. return obj.stampDomArray_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  9567. };
  9568.  
  9569.  
  9570. stampDomArray_.bind = function (obj, ...args) {
  9571. let [dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList] = args;
  9572. // console.log(12388001, containerId, dataList, typeOrConfig, bReuse, bEventCb, bStableList)
  9573. if (!obj[wk]) obj[wk] = mWeakRef(obj);
  9574. obj[`__stampDomArrayArgs_dataList__#${containerId}__`] = dataList;
  9575. if (!typeOrConfig[wk]) typeOrConfig[wk] = mWeakRef(typeOrConfig);
  9576. obj[`__stampDomArrayArgs_typeOrConfig__#${containerId}__`] = typeOrConfig[wk];
  9577. obj[`__stampDomArrayArgs_bReuse__#${containerId}__`] = bReuse;
  9578. obj[`__stampDomArrayArgs_bEventCb__#${containerId}__`] = bEventCb;
  9579. obj[`__stampDomArrayArgs_bStableList__#${containerId}__`] = bStableList;
  9580.  
  9581. // if (!obj[`__stampDomArrayBoundFn__#${containerId}__`]) obj[`__stampDomArrayBoundFn__#${containerId}__`] = stampDomArrayWB_.bind(null, obj[wk], containerId);
  9582. const xxx = obj[`__stampDomArrayArgs_xxx__#${containerId}__`] = `${Math.random()}_${Date.now()}`;
  9583. // const p = obj[wk];
  9584. // queueMicrotask_(()=>{
  9585. // const obj = kRef(p);
  9586. // if(!obj) return;
  9587. // if(!obj.hostElement) return;
  9588. // triggerDomChange(obj.hostElement);
  9589. // const container = obj.getStampContainer7409_(containerId);
  9590. // if(container instanceof Node) triggerDomChange(container);
  9591. // });
  9592. // return obj[`__stampDomArrayBoundFn__#${containerId}__`];
  9593.  
  9594. return stampDomArrayWB_.bind(null, obj[wk], containerId, xxx);
  9595. };
  9596.  
  9597. return { getStampContainer_, createComponent_, deferRenderStamperBinding_, flushRenderStamperComponentBindings_, stampDomArray_, stampDomArraySplices_ };
  9598.  
  9599. }
  9600.  
  9601. const setupDiscreteTasks = (h, rb) => {
  9602.  
  9603. if (typeof h.onYtRendererstamperFinished === 'function' && !(h.onYtRendererstamperFinished.km34)) {
  9604. const f = h.onYtRendererstamperFinished;
  9605. const g = ump3.get(f) || function () {
  9606. if (this.updateChildVisibilityProperties && !this.markDirty) {
  9607. return f.apply(this, arguments);
  9608. }
  9609. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9610. }
  9611. ump3.set(f, g);
  9612. g.km34 = 1;
  9613. h.onYtRendererstamperFinished = g;
  9614.  
  9615. }
  9616.  
  9617. if (typeof h.onYtUpdateDescriptionAction === 'function' && !(h.onYtUpdateDescriptionAction.km34)) {
  9618. const f = h.onYtUpdateDescriptionAction;
  9619. const g = ump3.get(f) || function (a) {
  9620. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9621. }
  9622. ump3.set(f, g);
  9623. g.km34 = 1;
  9624. h.onYtUpdateDescriptionAction = g;
  9625.  
  9626. }
  9627.  
  9628. if (typeof h.handleUpdateDescriptionAction === 'function' && !(h.handleUpdateDescriptionAction.km34)) {
  9629. const f = h.handleUpdateDescriptionAction;
  9630. const g = ump3.get(f) || function (a) {
  9631. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9632. }
  9633. ump3.set(f, g);
  9634. g.km34 = 1;
  9635. h.handleUpdateDescriptionAction = g;
  9636.  
  9637. }
  9638.  
  9639. if (typeof h.handleUpdateLiveChatPollAction === 'function' && !(h.handleUpdateLiveChatPollAction.km34)) {
  9640. const f = h.handleUpdateLiveChatPollAction;
  9641. const g = ump3.get(f) || function (a) {
  9642. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9643. }
  9644. ump3.set(f, g);
  9645. g.km34 = 1;
  9646. h.handleUpdateLiveChatPollAction = g;
  9647.  
  9648. }
  9649.  
  9650. if (typeof h.onTextChanged === 'function' && !(h.onTextChanged.km34)) {
  9651. const f = h.onTextChanged;
  9652. const g = ump3.get(f) || function () {
  9653. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9654. }
  9655. ump3.set(f, g);
  9656. g.km34 = 1;
  9657. h.onTextChanged = g;
  9658.  
  9659. }
  9660.  
  9661. if (typeof h.onVideoDataChange === 'function' && !(h.onVideoDataChange.km34)) {
  9662. const f = h.onVideoDataChange;
  9663. const g = ump3.get(f) || function (a) {
  9664. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9665. }
  9666. ump3.set(f, g);
  9667. g.km34 = 1;
  9668. h.onVideoDataChange = g;
  9669.  
  9670. }
  9671.  
  9672. if (typeof h.onVideoDataChange_ === 'function' && !(h.onVideoDataChange_.km34)) {
  9673. const f = h.onVideoDataChange_;
  9674. const g = ump3.get(f) || function () {
  9675. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9676. }
  9677. ump3.set(f, g);
  9678. g.km34 = 1;
  9679. h.onVideoDataChange_ = g;
  9680.  
  9681. }
  9682.  
  9683. if (typeof h.addTooltips_ === 'function' && !(h.addTooltips_.km34)) {
  9684.  
  9685. const f = h.addTooltips_;
  9686. const g = ump3.get(f) || function () {
  9687. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9688. }
  9689. ump3.set(f, g);
  9690. g.km34 = 1;
  9691. h.addTooltips_ = g;
  9692.  
  9693. }
  9694.  
  9695. if (typeof h.updateRenderedElements === 'function' && !(h.updateRenderedElements.km34)) {
  9696.  
  9697. const f = h.updateRenderedElements;
  9698. const g = ump3.get(f) || function () {
  9699. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9700. }
  9701. ump3.set(f, g);
  9702. g.km34 = 1;
  9703. h.updateRenderedElements = g;
  9704.  
  9705. }
  9706.  
  9707. if ((WEAK_REF_BINDING_CONTROL & 2) && typeof h.loadPage_ === 'function' && !(h.loadPage_.km34)) {
  9708. const f = h.loadPage_;
  9709. const g = ump3.get(f) || function (a) {
  9710. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9711. }
  9712. ump3.set(f, g);
  9713. g.km34 = 1;
  9714. h.loadPage_ = g;
  9715.  
  9716. }
  9717. // updatePageData_ : possible conflict with Omit ShadyDOM
  9718. if ((WEAK_REF_BINDING_CONTROL & 2) && typeof h.updatePageData_ === 'function' && !(h.updatePageData_.km34)) {
  9719. const f = h.updatePageData_;
  9720. const g = ump3.get(f) || function (a) {
  9721. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9722. }
  9723. ump3.set(f, g);
  9724. g.km34 = 1;
  9725. h.updatePageData_ = g;
  9726.  
  9727. }
  9728.  
  9729.  
  9730. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onFocus_ === 'function' && !(h.onFocus_.km34)) {
  9731.  
  9732. const f = h.onFocus_;
  9733. const g = ump3.get(f) || function () {
  9734. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9735. }
  9736. ump3.set(f, g);
  9737. g.km34 = 1;
  9738. h.onFocus_ = g;
  9739.  
  9740. }
  9741.  
  9742. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onBlur_ === 'function' && !(h.onBlur_.km34)) {
  9743.  
  9744. const f = h.onBlur_;
  9745. const g = ump3.get(f) || function () {
  9746. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9747. }
  9748. ump3.set(f, g);
  9749. g.km34 = 1;
  9750. h.onBlur_ = g;
  9751.  
  9752. }
  9753.  
  9754.  
  9755. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.buttonClassChanged_ === 'function' && !(h.buttonClassChanged_.km34)) {
  9756.  
  9757. const f = h.buttonClassChanged_;
  9758. const g = ump3.get(f) || function (a, b) {
  9759. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9760. }
  9761. ump3.set(f, g);
  9762. g.km34 = 1;
  9763. h.buttonClassChanged_ = g;
  9764.  
  9765. }
  9766.  
  9767. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.buttonIconChanged_ === 'function' && !(h.buttonIconChanged_.km34)) {
  9768.  
  9769. const f = h.buttonIconChanged_;
  9770. const g = ump3.get(f) || function (a) {
  9771. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9772. }
  9773. ump3.set(f, g);
  9774. g.km34 = 1;
  9775. h.buttonIconChanged_ = g;
  9776.  
  9777. }
  9778.  
  9779. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.dataChangedInBehavior_ === 'function' && !(h.dataChangedInBehavior_.km34)) {
  9780.  
  9781. const f = h.dataChangedInBehavior_;
  9782. const g = ump3.get(f) || function () {
  9783. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9784. }
  9785. ump3.set(f, g);
  9786. g.km34 = 1;
  9787. h.dataChangedInBehavior_ = g;
  9788.  
  9789. }
  9790.  
  9791. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.continuationsChanged_ === 'function' && !(h.continuationsChanged_.km34)) {
  9792.  
  9793. const f = h.continuationsChanged_;
  9794. const g = ump3.get(f) || function () {
  9795. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9796. }
  9797. ump3.set(f, g);
  9798. g.km34 = 1;
  9799. h.continuationsChanged_ = g;
  9800.  
  9801. }
  9802.  
  9803.  
  9804. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.forceChatPoll_ === 'function' && !(h.forceChatPoll_.km34)) {
  9805.  
  9806. const f = h.forceChatPoll_;
  9807. const g = ump3.get(f) || function (a) {
  9808. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9809. }
  9810. ump3.set(f, g);
  9811. g.km34 = 1;
  9812. h.forceChatPoll_ = g;
  9813.  
  9814. }
  9815.  
  9816. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onEndpointClick_ === 'function' && !(h.onEndpointClick_.km34)) {
  9817.  
  9818. const f = h.onEndpointClick_;
  9819. const g = ump3.get(f) || function (a) {
  9820. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9821. }
  9822. ump3.set(f, g);
  9823. g.km34 = 1;
  9824. h.onEndpointClick_ = g;
  9825.  
  9826. }
  9827.  
  9828. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onEndpointTap_ === 'function' && !(h.onEndpointTap_.km34)) {
  9829.  
  9830. const f = h.onEndpointTap_;
  9831. const g = ump3.get(f) || function (a) {
  9832. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9833. }
  9834. ump3.set(f, g);
  9835. g.km34 = 1;
  9836. h.onEndpointTap_ = g;
  9837.  
  9838. }
  9839.  
  9840. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.handleClick_ === 'function' && !(h.handleClick_.km34)) {
  9841.  
  9842. const f = h.handleClick_;
  9843. const g = ump3.get(f) || function (a, b) {
  9844. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9845. }
  9846. ump3.set(f, g);
  9847. g.km34 = 1;
  9848. h.handleClick_ = g;
  9849.  
  9850. }
  9851.  
  9852. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onReadyStateChange_ === 'function' && !(h.onReadyStateChange_.km34)) {
  9853.  
  9854. const f = h.onReadyStateChange_;
  9855. const g = ump3.get(f) || function () {
  9856. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9857. }
  9858. ump3.set(f, g);
  9859. g.km34 = 1;
  9860. h.onReadyStateChange_ = g;
  9861.  
  9862. }
  9863.  
  9864. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onReadyStateChangeEntryPoint_ === 'function' && !(h.onReadyStateChangeEntryPoint_.km34)) {
  9865.  
  9866. const f = h.onReadyStateChangeEntryPoint_;
  9867. const g = ump3.get(f) || function () {
  9868. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9869. }
  9870. ump3.set(f, g);
  9871. g.km34 = 1;
  9872. h.onReadyStateChangeEntryPoint_ = g;
  9873.  
  9874. }
  9875.  
  9876. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.readyStateChangeHandler_ === 'function' && !(h.readyStateChangeHandler_.km34)) {
  9877.  
  9878. const f = h.readyStateChangeHandler_;
  9879. const g = ump3.get(f) || function (a) {
  9880. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9881. }
  9882. ump3.set(f, g);
  9883. g.km34 = 1;
  9884. h.readyStateChangeHandler_ = g;
  9885.  
  9886. }
  9887.  
  9888. if (typeof h.xmlHttpHandler_ === 'function' && !(h.xmlHttpHandler_.km34)) {
  9889.  
  9890. const f = h.xmlHttpHandler_;
  9891. const g = ump3.get(f) || function (a) {
  9892. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9893. }
  9894. ump3.set(f, g);
  9895. g.km34 = 1;
  9896. h.xmlHttpHandler_ = g;
  9897.  
  9898. }
  9899.  
  9900. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.executeCallbacks_ === 'function' && !(h.executeCallbacks_.km34)) {
  9901.  
  9902. const f = h.executeCallbacks_; // overloaded
  9903. const g = ump3.get(f) || function (a) {
  9904. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9905. }
  9906. ump3.set(f, g);
  9907. g.km34 = 1;
  9908. h.executeCallbacks_ = g;
  9909.  
  9910. }
  9911.  
  9912. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.handleInvalidationData_ === 'function' && !(h.handleInvalidationData_.km34)) {
  9913.  
  9914. const f = h.handleInvalidationData_;
  9915. const g = ump3.get(f) || function (a, b) {
  9916. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9917. }
  9918. ump3.set(f, g);
  9919. g.km34 = 1;
  9920. h.handleInvalidationData_ = g;
  9921.  
  9922. }
  9923.  
  9924. if (typeof h.onInput_ === 'function' && !(h.onInput_.km34)) {
  9925.  
  9926. const f = h.onInput_;
  9927. const g = ump3.get(f) || function () {
  9928. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9929. }
  9930. ump3.set(f, g);
  9931. g.km34 = 1;
  9932. h.onInput_ = g;
  9933.  
  9934. }
  9935. if (typeof h.trigger_ === 'function' && !(h.trigger_.km34)) {
  9936.  
  9937. const f = h.trigger_;
  9938. const g = ump3.get(f) || function (a) {
  9939. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9940. }
  9941. ump3.set(f, g);
  9942. g.km34 = 1;
  9943. h.trigger_ = g;
  9944.  
  9945. }
  9946.  
  9947. if (typeof h.requestData_ === 'function' && !(h.requestData_.km34)) {
  9948.  
  9949. const f = h.requestData_;
  9950. const g = ump3.get(f) || function (a) {
  9951. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9952. }
  9953. ump3.set(f, g);
  9954. g.km34 = 1;
  9955. h.requestData_ = g;
  9956.  
  9957. }
  9958.  
  9959. if (typeof h.onLoadReloadContinuation_ === 'function' && !(h.onLoadReloadContinuation_.km34)) {
  9960.  
  9961. const f = h.onLoadReloadContinuation_;
  9962. const g = ump3.get(f) || function (a, b) {
  9963. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9964. }
  9965. ump3.set(f, g);
  9966. g.km34 = 1;
  9967. h.onLoadReloadContinuation_ = g;
  9968.  
  9969. }
  9970.  
  9971. if (typeof h.onLoadIncrementalContinuation_ === 'function' && !(h.onLoadIncrementalContinuation_.km34)) {
  9972.  
  9973. const f = h.onLoadIncrementalContinuation_;
  9974. const g = ump3.get(f) || function (a, b) {
  9975. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9976. }
  9977. ump3.set(f, g);
  9978. g.km34 = 1;
  9979. h.onLoadIncrementalContinuation_ = g;
  9980.  
  9981. }
  9982.  
  9983. if (typeof h.onLoadSeekContinuation_ === 'function' && !(h.onLoadSeekContinuation_.km34)) {
  9984.  
  9985. const f = h.onLoadSeekContinuation_;
  9986. const g = ump3.get(f) || function (a, b) {
  9987. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9988. }
  9989. ump3.set(f, g);
  9990. g.km34 = 1;
  9991. h.onLoadSeekContinuation_ = g;
  9992.  
  9993. }
  9994. if (typeof h.onLoadReplayContinuation_ === 'function' && !(h.onLoadReplayContinuation_.km34)) {
  9995.  
  9996. const f = h.onLoadReplayContinuation_;
  9997. const g = ump3.get(f) || function (a, b) {
  9998. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  9999. }
  10000. ump3.set(f, g);
  10001. g.km34 = 1;
  10002. h.onLoadReplayContinuation_ = g;
  10003.  
  10004. }
  10005. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onNavigate_ === 'function' && !(h.onNavigate_.km34)) {
  10006.  
  10007. const f = h.onNavigate_;
  10008. const g = ump3.get(f) || function (a) {
  10009. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10010. }
  10011. ump3.set(f, g);
  10012. g.km34 = 1;
  10013. h.onNavigate_ = g;
  10014.  
  10015. }
  10016.  
  10017. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.ytRendererBehaviorDataObserver_ === 'function' && !(h.ytRendererBehaviorDataObserver_.km34)) {
  10018.  
  10019. const f = h.ytRendererBehaviorDataObserver_;
  10020. const g = ump3.get(f) || function () {
  10021. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10022. }
  10023. ump3.set(f, g);
  10024. g.km34 = 1;
  10025. h.ytRendererBehaviorDataObserver_ = g;
  10026.  
  10027. }
  10028.  
  10029. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.ytRendererBehaviorTargetIdObserver_ === 'function' && !(h.ytRendererBehaviorTargetIdObserver_.km34)) {
  10030.  
  10031. const f = h.ytRendererBehaviorTargetIdObserver_;
  10032. const g = ump3.get(f) || function () {
  10033. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10034. }
  10035. ump3.set(f, g);
  10036. g.km34 = 1;
  10037. h.ytRendererBehaviorTargetIdObserver_ = g;
  10038.  
  10039. }
  10040.  
  10041. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.unregisterRenderer_ === 'function' && !(h.unregisterRenderer_.km34)) {
  10042.  
  10043. const f = h.unregisterRenderer_;
  10044. const g = ump3.get(f) || function (a) {
  10045. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10046. }
  10047. ump3.set(f, g);
  10048. g.km34 = 1;
  10049. h.unregisterRenderer_ = g;
  10050.  
  10051. }
  10052.  
  10053. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.textChanged_ === 'function' && !(h.textChanged_.km34)) {
  10054.  
  10055. const f = h.textChanged_;
  10056. const g = ump3.get(f) || function (a) {
  10057. if (void 0 !== this.isAttached) {
  10058. const hostElement = this.hostElement;
  10059. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  10060. return;
  10061. }
  10062. }
  10063. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10064. }
  10065. ump3.set(f, g);
  10066. g.km34 = 1;
  10067. h.textChanged_ = g;
  10068.  
  10069. }
  10070.  
  10071.  
  10072.  
  10073. /**
  10074. *
  10075. * Neglect following
  10076. *
  10077. * h.onYtAction_
  10078. * h.startLoadingWatch [ buggy for yt-player-updated ]
  10079. * h.deferRenderStamperBinding_
  10080. *
  10081. * h.stampDomArray_
  10082. * h.stampDomArraySplices_
  10083. *
  10084. */
  10085.  
  10086.  
  10087. // RP.prototype.searchChanged_ = RP.prototype.searchChanged_;
  10088. // RP.prototype.skinToneChanged_ = RP.prototype.skinToneChanged_;
  10089. // RP.prototype.onEmojiHover_ = RP.prototype.onEmojiHover_;
  10090. // RP.prototype.onSelectCategory_ = RP.prototype.onSelectCategory_;
  10091. // RP.prototype.onShowEmojiVariantSelector = RP.prototype.onShowEmojiVariantSelector;
  10092. // RP.prototype.updateCategoriesAndPlaceholder_ = RP.prototype.updateCategoriesAndPlaceholder_;
  10093.  
  10094. if (typeof h.searchChanged_ === 'function' && !(h.searchChanged_.km34)) {
  10095.  
  10096. const f = h.searchChanged_;
  10097. const g = ump3.get(f) || function () {
  10098. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10099. }
  10100. ump3.set(f, g);
  10101. g.km34 = 1;
  10102. h.searchChanged_ = g;
  10103.  
  10104. }
  10105.  
  10106. if (typeof h.skinToneChanged_ === 'function' && !(h.skinToneChanged_.km34)) {
  10107.  
  10108. const f = h.skinToneChanged_;
  10109. const g = ump3.get(f) || function (a) {
  10110. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10111. }
  10112. ump3.set(f, g);
  10113. g.km34 = 1;
  10114. h.skinToneChanged_ = g;
  10115.  
  10116. }
  10117.  
  10118. if (typeof h.onEmojiHover_ === 'function' && !(h.onEmojiHover_.km34)) {
  10119.  
  10120. const f = h.onEmojiHover_;
  10121. const g = ump3.get(f) || function (a) {
  10122. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10123. }
  10124. ump3.set(f, g);
  10125. g.km34 = 1;
  10126. h.onEmojiHover_ = g;
  10127.  
  10128. }
  10129.  
  10130. if (typeof h.onSelectCategory_ === 'function' && !(h.onSelectCategory_.km34)) {
  10131.  
  10132. const f = h.onSelectCategory_;
  10133. const g = ump3.get(f) || function (a) {
  10134. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10135. }
  10136. ump3.set(f, g);
  10137. g.km34 = 1;
  10138. h.onSelectCategory_ = g;
  10139.  
  10140. }
  10141.  
  10142. if (typeof h.onShowEmojiVariantSelector === 'function' && !(h.onShowEmojiVariantSelector.km34)) {
  10143.  
  10144. const f = h.onShowEmojiVariantSelector;
  10145. const g = ump3.get(f) || function (a) {
  10146. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10147. }
  10148. ump3.set(f, g);
  10149. g.km34 = 1;
  10150. h.onShowEmojiVariantSelector = g;
  10151.  
  10152. }
  10153.  
  10154. if (typeof h.updateCategoriesAndPlaceholder_ === 'function' && !(h.updateCategoriesAndPlaceholder_.km34)) {
  10155.  
  10156. const f = h.updateCategoriesAndPlaceholder_;
  10157. const g = ump3.get(f) || function () {
  10158. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10159. }
  10160. ump3.set(f, g);
  10161. g.km34 = 1;
  10162. h.updateCategoriesAndPlaceholder_ = g;
  10163.  
  10164. }
  10165.  
  10166. if (typeof h.watchPageActiveChanged_ === 'function' && !(h.watchPageActiveChanged_.km34)) {
  10167.  
  10168. const f = h.watchPageActiveChanged_;
  10169. const g = ump3.get(f) || function () {
  10170. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10171. }
  10172. ump3.set(f, g);
  10173. g.km34 = 1;
  10174. h.watchPageActiveChanged_ = g;
  10175.  
  10176. }
  10177.  
  10178. if (typeof h.activate_ === 'function' && !(h.activate_.km34)) {
  10179.  
  10180. const f = h.activate_;
  10181. const g = ump3.get(f) || function () {
  10182. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10183. }
  10184. ump3.set(f, g);
  10185. g.km34 = 1;
  10186. h.activate_ = g;
  10187.  
  10188. }
  10189. if (typeof h.onYtPlaylistDataUpdated_ === 'function' && !(h.onYtPlaylistDataUpdated_.km34)) {
  10190.  
  10191. const f = h.onYtPlaylistDataUpdated_;
  10192. const g = ump3.get(f) || function () {
  10193. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10194. }
  10195. ump3.set(f, g);
  10196. g.km34 = 1;
  10197. h.onYtPlaylistDataUpdated_ = g;
  10198.  
  10199. }
  10200.  
  10201.  
  10202.  
  10203. /**
  10204. *
  10205. * Neglect following
  10206. *
  10207. * h.rendererStamperObserver_
  10208. * h.rendererStamperApplyChangeRecord_
  10209. * h.flushRenderStamperComponentBindings_
  10210. * h.forwardRendererStamperChanges_
  10211. *
  10212. */
  10213.  
  10214. if (typeof h.tryRenderChunk_ === 'function' && !(h.tryRenderChunk_.km34)) {
  10215.  
  10216. const f = h.tryRenderChunk_;
  10217. const g = ump3.get(f) || function () {
  10218. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10219. }
  10220. ump3.set(f, g);
  10221. g.km34 = 1;
  10222. h.tryRenderChunk_ = g;
  10223.  
  10224. }
  10225.  
  10226.  
  10227. if (typeof h.renderChunk_ === 'function' && !(h.renderChunk_.km34)) {
  10228.  
  10229. const f = h.renderChunk_;
  10230. const g = ump3.get(f) || function () {
  10231. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10232. }
  10233. ump3.set(f, g);
  10234. g.km34 = 1;
  10235. h.renderChunk_ = g;
  10236.  
  10237. }
  10238.  
  10239. if (typeof h.deepLazyListObserver_ === 'function' && !(h.deepLazyListObserver_.km34)) {
  10240.  
  10241. const f = h.deepLazyListObserver_;
  10242. const g = ump3.get(f) || function () {
  10243. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10244. }
  10245. ump3.set(f, g);
  10246. g.km34 = 1;
  10247. h.deepLazyListObserver_ = g;
  10248.  
  10249. }
  10250.  
  10251. if (typeof h.onItemsUpdated_ === 'function' && !(h.onItemsUpdated_.km34)) {
  10252.  
  10253. const f = h.onItemsUpdated_;
  10254. const g = ump3.get(f) || function () {
  10255. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10256. }
  10257. ump3.set(f, g);
  10258. g.km34 = 1;
  10259. h.onItemsUpdated_ = g;
  10260.  
  10261. }
  10262.  
  10263. if (typeof h.requestRenderChunk_ === 'function' && !(h.requestRenderChunk_.km34)) {
  10264.  
  10265. const f = h.requestRenderChunk_;
  10266. const g = ump3.get(f) || function () {
  10267. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  10268. }
  10269. ump3.set(f, g);
  10270. g.km34 = 1;
  10271. h.requestRenderChunk_ = g;
  10272.  
  10273. }
  10274.  
  10275. /**
  10276. *
  10277. * Neglect following
  10278. *
  10279. * h.dataChanged_ [ buggy for page swtiching ]
  10280. *
  10281. * h.updateChangeRecord_ [ see https://github.com/cyfung1031/userscript-supports/issues/20 ]
  10282. *
  10283. * h.cancelPendingTasks_
  10284. * h.fillRange_
  10285. * h.addTextNodes_
  10286. * h.updateText_
  10287. * h.stampTypeChanged_
  10288. *
  10289. */
  10290.  
  10291.  
  10292. }
  10293.  
  10294. const keyStConnectedCallback = Symbol(); // avoid copying the value
  10295.  
  10296. const dmf = new WeakMap();
  10297.  
  10298.  
  10299. let nativeHTMLElement = Reflect.getPrototypeOf(HTMLFontElement);
  10300.  
  10301. try {
  10302.  
  10303. const q = document.createElement('template');
  10304. q.innerHTML = '<ytz-null361></ytz-null361>';
  10305. nativeHTMLElement = q.content.firstChild.constructor
  10306.  
  10307. } catch (e) { }
  10308.  
  10309. if (!nativeHTMLElement.prototype.connectedCallback) {
  10310. nativeHTMLElement.prototype.connectedCallback79 = nativeHTMLElement.prototype.connectedCallback;
  10311. nativeHTMLElement.prototype.connectedCallback = function () {
  10312. let r;
  10313. if (this.connectedCallback79) r = this.connectedCallback79.apply(this, arguments);
  10314. return r;
  10315. }
  10316. }
  10317. const pvr = Symbol()
  10318.  
  10319. let stampDomArrayFnStore = null;
  10320. const setupMap = new WeakSet();
  10321. const setupYtComponent = (cnt) => {
  10322. const cProto = Reflect.getPrototypeOf(cnt || 0) || 0;
  10323. if (!cProto || setupMap.has(cProto)) return;
  10324. setupMap.add(cProto);
  10325. if (FIX_stampDomArray && !(cProto[pvr] & 1) && 'stampDomArray_' in cProto) {
  10326. cProto[pvr] |= 1;
  10327.  
  10328.  
  10329.  
  10330. if (FIX_stampDomArray && !location.pathname.startsWith('/live_chat') && cProto.stampDomArray_) {
  10331. const b = cProto.stampDomArray_.length === 6
  10332. && cProto.getStampContainer_ && cProto.getStampContainer_.length === 1
  10333. && cProto.createComponent_ && cProto.createComponent_.length === 3
  10334. && cProto.deferRenderStamperBinding_ && cProto.deferRenderStamperBinding_.length === 3
  10335. && cProto.flushRenderStamperComponentBindings_ && cProto.flushRenderStamperComponentBindings_.length === 0
  10336. && cProto.deferRenderStamperBinding_ === cnt.deferRenderStamperBinding_
  10337. if (!b) {
  10338. console.warn("YouTube Coding Changed. createStampDomFns_() is not applied")
  10339. } else if(!cProto.createComponent7409_ && !cProto.deferRenderStamperBinding7409_ && !cProto.flushRenderStamperComponentBindings7409_) {
  10340. if(!stampDomArrayFnStore) stampDomArrayFnStore = createStampDomFnsC_();
  10341. const {getStampContainer_, createComponent_, deferRenderStamperBinding_, flushRenderStamperComponentBindings_, stampDomArray_, stampDomArraySplices_} = stampDomArrayFnStore;
  10342.  
  10343. cProto.getStampContainer7409_ = cProto.getStampContainer_;
  10344. cProto.createComponent7409_ = cProto.createComponent_;
  10345. cProto.deferRenderStamperBinding7409_ = cProto.deferRenderStamperBinding_;
  10346. cProto.flushRenderStamperComponentBindings7409_ = cProto.flushRenderStamperComponentBindings_;
  10347. cProto.stampDomArray7409_ = cProto.stampDomArray_;
  10348. cProto.stampDomArraySplices7409_ = cProto.stampDomArraySplices_;
  10349.  
  10350. cProto.getStampContainer_ = getStampContainer_;
  10351. cProto.createComponent_ = createComponent_;
  10352. cProto.deferRenderStamperBinding_ = deferRenderStamperBinding_;
  10353. cProto.flushRenderStamperComponentBindings_ = flushRenderStamperComponentBindings_;
  10354. cProto.stampDomArray_ = stampDomArray_;
  10355. cProto.stampDomArraySplices_ = stampDomArraySplices_;
  10356.  
  10357. }
  10358. }
  10359.  
  10360.  
  10361.  
  10362.  
  10363. // if(false && cProto._runEffectsForTemplate && !cProto._runEffectsForTemplate6344) {
  10364. // cProto._runEffectsForTemplate6344 = cProto._runEffectsForTemplate;
  10365.  
  10366. // if(cProto._runEffectsForTemplate6344.length === 4){
  10367.  
  10368. // cProto._runEffectsForTemplate = function (c, d, e, g) {
  10369. // const cnt = this;
  10370. // const { propertyEffects, nodeList, firstChild } = c;
  10371. // cnt._runEffectsForTemplate6344({ propertyEffects, nodeList, firstChild }, d, e, g);
  10372.  
  10373. // }
  10374.  
  10375. // }
  10376.  
  10377. // }
  10378.  
  10379. }
  10380. if (ENABLE_discreteTasking && !(cProto[pvr] & 2) && (typeof (cProto.is || 0) === 'string' || ('attached' in cProto) || ('isAttached' in cProto))) {
  10381. cProto[pvr] |= 2;
  10382. setupDiscreteTasks(cProto);
  10383. }
  10384. };
  10385.  
  10386. (ENABLE_discreteTasking || FIX_stampDomArray) && Object.defineProperty(Object.prototype, 'connectedCallback', {
  10387. get() {
  10388. const f = this[keyStConnectedCallback];
  10389. if (this.is) {
  10390. setupYtComponent(this);
  10391. }
  10392. return f;
  10393. },
  10394. set(nv) {
  10395. let gv = nv;
  10396. this[keyStConnectedCallback] = gv; // proto or object
  10397. return true;
  10398. },
  10399. enumerable: false,
  10400. configurable: true
  10401.  
  10402. });
  10403.  
  10404. const pLoad = new Promise(resolve => {
  10405. if (document.readyState !== 'loading') {
  10406. resolve();
  10407. } else {
  10408. window.addEventListener("DOMContentLoaded", resolve, false);
  10409. }
  10410. });
  10411.  
  10412. if (FIX_ACTIONS_TOOLTIPS) {
  10413. pLoad.then(() => {
  10414. addNewCSS("#actions .tp-yt-paper-tooltip{white-space:nowrap}");
  10415. });
  10416. }
  10417.  
  10418. if (FIX_fix_requestIdleCallback_timing && !window.requestIdleCallback471 && typeof window.requestIdleCallback === 'function') {
  10419. window.requestIdleCallback471 = window.requestIdleCallback;
  10420. window.requestIdleCallback = function (f, ...args) {
  10421. return (this || window).requestIdleCallback471(async function () {
  10422. await pLoad.then();
  10423. // await new Promise(nextBrowserTick_);
  10424. f.call(this, ...arguments)
  10425. }, ...args);
  10426. }
  10427. }
  10428.  
  10429. pLoad.then(() => {
  10430.  
  10431. let nonce = document.querySelector('style[nonce]');
  10432. nonce = nonce ? nonce.getAttribute('nonce') : null;
  10433. const st = document.createElement('style');
  10434. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  10435. st.textContent = "none-element-k47{order:0}";
  10436. st.addEventListener('load', () => {
  10437. pf31.resolve();
  10438. p59 = 1;
  10439. }, false);
  10440. (document.body || document.head || document.documentElement).appendChild(st);
  10441.  
  10442. });
  10443.  
  10444. const prepareLogs = [];
  10445.  
  10446. const skipAdsDetection = new Set(['/robots.txt', '/live_chat', '/live_chat_replay']);
  10447.  
  10448. let winError00 = window.onerror;
  10449.  
  10450. let fix_error_many_stack_state = !FIX_error_many_stack ? 0 : skipAdsDetection.has(location.pathname) ? 2 : 1;
  10451.  
  10452. if (!JSON || !('parse' in JSON)) fix_error_many_stack_state = 0;
  10453.  
  10454. ; FIX_Iframe_NULL_SRC && !isChatRoomURL && typeof kagi === 'undefined' && (() => {
  10455.  
  10456. const emptyBlobUrl = URL.createObjectURL(new Blob([], { type: 'text/html' }));
  10457. const lcOpt = { sensitivity: 'base' };
  10458. document.createElement24 = document.createElement;
  10459. document.createElement = function (t) {
  10460. if (typeof t === 'string' && t.length === 6) {
  10461. if (t.localeCompare('iframe', undefined, lcOpt) === 0) {
  10462. const p = this.createElement24(t);
  10463. try {
  10464. const stack = new Error().stack;
  10465. const isSearchbox = stack.includes('initializeSearchbox'); // see https://greasyfork.org/scripts/473972-youtube-js-engine-tamer/discussions/217084
  10466. if (!isSearchbox) {
  10467. p.src = emptyBlobUrl; // avoid iframe is appended to DOM without any url
  10468. }
  10469. } catch (e) { }
  10470. return p;
  10471. }
  10472. }
  10473. return this.createElement24.apply(this, arguments);
  10474. };
  10475.  
  10476. })();
  10477.  
  10478. ; fix_error_many_stack_state === 1 && (() => {
  10479.  
  10480.  
  10481. let p1 = winError00;
  10482.  
  10483. let stackNeedleDetails = null;
  10484.  
  10485. Object.defineProperty(Object.prototype, 'matchAll', {
  10486. get() {
  10487. stackNeedleDetails = this;
  10488. return true;
  10489. },
  10490. enumerable: true,
  10491. configurable: true
  10492. });
  10493.  
  10494. try {
  10495. JSON.parse("{}");
  10496. } catch (e) {
  10497. console.warn(e)
  10498. fix_error_many_stack_state = 0;
  10499. }
  10500.  
  10501. delete Object.prototype['matchAll'];
  10502.  
  10503. let p2 = window.onerror;
  10504.  
  10505. window.onerror = p1;
  10506.  
  10507. if (fix_error_many_stack_state === 0) return;
  10508.  
  10509. if (stackNeedleDetails) {
  10510. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  10511. stackNeedleDetails.matchAll = true;
  10512. }
  10513.  
  10514. if (p1 === p2) return (fix_error_many_stack_state = 0);
  10515.  
  10516. // p1!==p2
  10517. fix_error_many_stack_state = !stackNeedleDetails ? 4 : 3;
  10518.  
  10519. })();
  10520.  
  10521. ; fix_error_many_stack_state === 2 && (() => {
  10522.  
  10523.  
  10524. let p1 = winError00;
  10525.  
  10526. let objectPrune = null;
  10527. let stackNeedleDetails = null;
  10528.  
  10529. Object.defineProperty(Function.prototype, 'findOwner', {
  10530. get() {
  10531. objectPrune = this;
  10532. return this._findOwner;
  10533. },
  10534. set(nv) {
  10535. this._findOwner = nv;
  10536. return true;
  10537. },
  10538. enumerable: true,
  10539. configurable: true
  10540. });
  10541.  
  10542. Object.defineProperty(Object.prototype, 'matchAll', {
  10543. get() {
  10544. stackNeedleDetails = this;
  10545. return true;
  10546. },
  10547. enumerable: true,
  10548. configurable: true
  10549. });
  10550.  
  10551. try {
  10552. JSON.parse("{}");
  10553. } catch (e) {
  10554. console.warn(e)
  10555. fix_error_many_stack_state = 0;
  10556. }
  10557.  
  10558. delete Function.prototype['findOwner'];
  10559. delete Object.prototype['matchAll'];
  10560.  
  10561. let p2 = window.onerror;
  10562.  
  10563. if (p1 !== p2) return (fix_error_many_stack_state = 4); // p1 != p2
  10564.  
  10565. if (fix_error_many_stack_state == 0) return;
  10566.  
  10567. // the following will only execute when Brave's scriptlets.js is executed.
  10568.  
  10569. prepareLogs.push("fix_error_many_stack_state NB")
  10570.  
  10571. if (stackNeedleDetails) {
  10572. stackNeedleDetails.pattern = null;
  10573. stackNeedleDetails.re = null;
  10574. stackNeedleDetails.expect = null;
  10575. stackNeedleDetails.matchAll = true;
  10576. }
  10577.  
  10578. if (objectPrune) {
  10579. objectPrune.findOwner = objectPrune.mustProcess = objectPrune.logJson = () => { }
  10580. delete objectPrune._findOwner;
  10581. }
  10582.  
  10583. fix_error_many_stack_state = 3;
  10584. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  10585. JSON.parse.objectPrune = objectPrune;
  10586.  
  10587. })();
  10588.  
  10589. ; fix_error_many_stack_state === 3 && (() => {
  10590.  
  10591.  
  10592. let p1 = winError00;
  10593.  
  10594. try {
  10595. JSON.parse("{}");
  10596. } catch (e) {
  10597. console.warn(e)
  10598. fix_error_many_stack_state = 0;
  10599. }
  10600.  
  10601. let p2 = window.onerror;
  10602.  
  10603. if (p1 === p2) return;
  10604.  
  10605. window.onerror = p1;
  10606.  
  10607. if (fix_error_many_stack_state === 0) return;
  10608.  
  10609. fix_error_many_stack_state = 4; // p1 != p2
  10610.  
  10611.  
  10612. })();
  10613.  
  10614. fix_error_many_stack_state === 4 && (() => {
  10615.  
  10616. // the following will only execute when Brave's scriptlets.js is executed.
  10617.  
  10618. prepareLogs.push("fix_error_many_stack_state AB")
  10619.  
  10620. JSON.parseProxy = JSON.parse;
  10621.  
  10622. JSON.parse = ((parse) => {
  10623.  
  10624. parse = parse.bind(JSON); // get a new instance of the current JSON.parse
  10625. return function (text, reviver) {
  10626. const onerror = window.onerror;
  10627. window.onerror = null;
  10628. let r;
  10629. try {
  10630. r = parse(...arguments);
  10631. } catch (e) {
  10632. r = e;
  10633. }
  10634. window.onerror = onerror;
  10635. if (r instanceof Error) {
  10636. throw r;
  10637. }
  10638. return r;
  10639. }
  10640.  
  10641. })(JSON.parse);
  10642.  
  10643.  
  10644. })();
  10645.  
  10646.  
  10647. // << if FIX_yt_player >>
  10648.  
  10649. // credit to @nopeless (https://greasyfork.org/scripts/471489-youtube-player-perf/)
  10650. const PERF_471489_ = true;
  10651. // PERF_471489_ is not exactly the same to Youtube Player perf v0.7
  10652. // This script uses a much gentle way to tamer the JS engine instead.
  10653.  
  10654. // << end >>
  10655.  
  10656. const steppingScaleN = 200; // transform: scaleX(k/N); 0<k<N
  10657.  
  10658.  
  10659.  
  10660. const nilFn = () => { };
  10661.  
  10662. let isMainWindow = false;
  10663. try {
  10664. isMainWindow = window.document === window.top.document
  10665. } catch (e) { }
  10666.  
  10667. let NO_PRELOAD_GENERATE_204_BYPASS = NO_PRELOAD_GENERATE_204 ? false : true;
  10668. let headLinkCollection = null;
  10669.  
  10670.  
  10671. // const assertor = (f) => f() || console.assert(false, `${f}`);
  10672.  
  10673. const fnIntegrity = (f, d) => {
  10674. if (!f || typeof f !== 'function') {
  10675. console.warn('f is not a function', f);
  10676. return;
  10677. }
  10678. let p = `${f}`, s = 0, j = -1, w = 0;
  10679. for (let i = 0, l = p.length; i < l; i++) {
  10680. const t = p[i];
  10681. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  10682. if (j < i - 1) w++;
  10683. j = i;
  10684. } else {
  10685. s++;
  10686. }
  10687. }
  10688. let itz = `${f.length}.${s}.${w}`;
  10689. if (!d) {
  10690. return itz;
  10691. } else {
  10692. return itz === d;
  10693. }
  10694. };
  10695.  
  10696. const getZqOu = (_yt_player) => {
  10697.  
  10698. const w = 'ZqOu';
  10699.  
  10700. let arr = [];
  10701.  
  10702. for (const [k, v] of Object.entries(_yt_player)) {
  10703.  
  10704. const p = typeof v === 'function' ? v.prototype : 0;
  10705. if (p
  10706. && typeof p.start === 'function' && p.start.length === 0 // Ou
  10707. && typeof p.isActive === 'function' && p.isActive.length === 0
  10708. && typeof p.stop === 'function' && p.stop.length === 0
  10709. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  10710. && !p.send && !p.abort
  10711. && !p.sample && !p.initialize && !p.fail && !p.getName
  10712. // && !p.dispose && !p.isDisposed
  10713.  
  10714. ) {
  10715. arr = addProtoToArr(_yt_player, k, arr) || arr;
  10716.  
  10717.  
  10718. }
  10719.  
  10720. }
  10721.  
  10722. if (arr.length === 0) {
  10723.  
  10724. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10725. } else {
  10726.  
  10727. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10728. return arr[0];
  10729. }
  10730.  
  10731. }
  10732.  
  10733. const getZqQu = (_yt_player) => {
  10734.  
  10735. const w = 'ZqQu';
  10736.  
  10737. let arr = [];
  10738.  
  10739.  
  10740. for (const [k, v] of Object.entries(_yt_player)) {
  10741.  
  10742. const p = typeof v === 'function' ? v.prototype : 0;
  10743. if (p
  10744. && typeof p.start === 'function' && p.start.length === 1 // Qu
  10745. && typeof p.isActive === 'function' && p.isActive.length === 0
  10746. && typeof p.stop === 'function' && p.stop.length === 0
  10747. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  10748. && !p.send && !p.abort
  10749. && !p.sample && !p.initialize && !p.fail && !p.getName
  10750. // && !p.dispose && !p.isDisposed
  10751.  
  10752. ) {
  10753. arr = addProtoToArr(_yt_player, k, arr) || arr;
  10754.  
  10755.  
  10756. }
  10757.  
  10758. }
  10759.  
  10760. if (arr.length === 0) {
  10761.  
  10762. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10763. } else {
  10764.  
  10765. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10766. return arr[0];
  10767. }
  10768.  
  10769. }
  10770.  
  10771.  
  10772. const getVG = (_yt_player) => {
  10773. const w = 'VG';
  10774.  
  10775. let arr = [];
  10776.  
  10777. for (const [k, v] of Object.entries(_yt_player)) {
  10778.  
  10779. const p = typeof v === 'function' ? v.prototype : 0;
  10780. if (p
  10781. && typeof p.show === 'function' && p.show.length === 1
  10782. && typeof p.hide === 'function' && p.hide.length === 0
  10783. && typeof p.stop === 'function' && p.stop.length === 0) {
  10784.  
  10785. arr = addProtoToArr(_yt_player, k, arr) || arr;
  10786.  
  10787. }
  10788.  
  10789. }
  10790.  
  10791.  
  10792. if (arr.length === 0) {
  10793.  
  10794. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10795. } else {
  10796.  
  10797. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10798. return arr[0];
  10799. }
  10800.  
  10801.  
  10802.  
  10803. }
  10804.  
  10805.  
  10806. const getzo = (_yt_player) => {
  10807. const w = 'zo';
  10808.  
  10809. let arr = [];
  10810.  
  10811. for (const [k, v] of Object.entries(_yt_player)) {
  10812.  
  10813. if (
  10814. typeof v === 'function' && v.length === 3 && k.length < 3
  10815. ) {
  10816. const vt = `${v}`;
  10817. if (vt.length >= 21 && vt.includes(".style[")) {
  10818. if (/\((\w{1,3}),(\w{1,3}),(\w{1,3})\)\{[\s\S]*\1\.style\[\2\]=\3\W/.test(vt)) {
  10819. arr.push(k);
  10820. } else {
  10821. console.warn('[yt-js-engine-tamer] unexpected zo::vt', vt);
  10822. }
  10823. }
  10824. }
  10825.  
  10826. }
  10827.  
  10828. if (arr.length === 0) {
  10829.  
  10830. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10831. } else {
  10832.  
  10833. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10834. return arr[0];
  10835. }
  10836.  
  10837. }
  10838.  
  10839. const addProtoToArr = (parent, key, arr) => {
  10840.  
  10841.  
  10842. let isChildProto = false;
  10843. for (const sr of arr) {
  10844. if (parent[key].prototype instanceof parent[sr]) {
  10845. isChildProto = true;
  10846. break;
  10847. }
  10848. }
  10849.  
  10850. if (isChildProto) return;
  10851.  
  10852. arr = arr.filter(sr => {
  10853. if (parent[sr].prototype instanceof parent[key]) {
  10854. return false;
  10855. }
  10856. return true;
  10857. });
  10858.  
  10859. arr.push(key);
  10860.  
  10861. return arr;
  10862.  
  10863.  
  10864. }
  10865.  
  10866. const getuG = (_yt_player) => {
  10867.  
  10868. const w = 'uG';
  10869.  
  10870. let arr = [];
  10871.  
  10872. for (const [k, v] of Object.entries(_yt_player)) {
  10873.  
  10874.  
  10875. const p = typeof v === 'function' ? v.prototype : 0;
  10876.  
  10877. if (p
  10878. && typeof p.createElement === 'function' && p.createElement.length === 2
  10879. && typeof p.detach === 'function' && p.detach.length === 0
  10880. && typeof p.update === 'function' && p.update.length === 1
  10881. && typeof p.updateValue === 'function' && p.updateValue.length === 2
  10882. ) {
  10883.  
  10884. arr = addProtoToArr(_yt_player, k, arr) || arr;
  10885.  
  10886. }
  10887.  
  10888. }
  10889.  
  10890.  
  10891.  
  10892.  
  10893.  
  10894. if (arr.length === 0) {
  10895.  
  10896. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10897. } else {
  10898.  
  10899. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10900. return arr[0];
  10901. }
  10902.  
  10903. }
  10904.  
  10905.  
  10906. const getQT = (_yt_player) => {
  10907. const w = 'QT';
  10908.  
  10909. let arr = [];
  10910. let brr = new Map();
  10911.  
  10912. for (const [k, v] of Object.entries(_yt_player)) {
  10913.  
  10914. const p = typeof v === 'function' ? v.prototype : 0;
  10915. if (p) {
  10916. let q = 0;
  10917. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  10918. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  10919. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  10920.  
  10921. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q -= 600; // avoid SV
  10922.  
  10923. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  10924.  
  10925. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  10926. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  10927. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  10928. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  10929.  
  10930.  
  10931. // differentiate QT and DX
  10932.  
  10933. q += 280;
  10934. if (typeof p.cueVideoByPlayerVars === 'function') q += 4;
  10935. if (typeof p.loadVideoByPlayerVars === 'function') q += 4;
  10936. if (typeof p.preloadVideoByPlayerVars === 'function') q += 4;
  10937. if (typeof p.seekBy === 'function') q += 4;
  10938. if (typeof p.seekTo === 'function') q += 4;
  10939. if (typeof p.getStoryboardFormat === 'function') q += 4;
  10940. if (typeof p.getDuration === 'function') q += 4;
  10941. if (typeof p.loadModule === 'function') q += 4;
  10942. if (typeof p.unloadModule === 'function') q += 4;
  10943. if (typeof p.getOption === 'function') q += 4;
  10944. if (typeof p.getOptions === 'function') q += 4;
  10945. if (typeof p.setOption === 'function') q += 4;
  10946. if (typeof p.addCueRange === 'function') q += 4;
  10947. if (typeof p.getDebugText === 'function') q += 4;
  10948. if (typeof p.getCurrentBroadcastId === 'function') q += 4;
  10949. if (typeof p.setSizeStyle === 'function') q += 4;
  10950. if (typeof p.showControls === 'function') q += 4;
  10951. if (typeof p.hideControls === 'function') q += 4;
  10952. if (typeof p.getVideoContentRect === 'function') q += 4;
  10953. if (typeof p.toggleFullscreen === 'function') q += 4;
  10954. if (typeof p.isFullscreen === 'function') q += 4;
  10955. if (typeof p.cancelPlayback === 'function') q += 4;
  10956. if (typeof p.getProgressState === 'function') q += 4;
  10957. if (typeof p.isInline === 'function') q += 4;
  10958. if (typeof p.setInline === 'function') q += 4;
  10959. if (typeof p.toggleSubtitles === 'function') q += 4;
  10960. if (typeof p.getPlayerSize === 'function') q += 4;
  10961. if (typeof p.wakeUpControls === 'function') q += 4;
  10962. if (typeof p.setCenterCrop === 'function') q += 4;
  10963. if (typeof p.getLoopVideo === 'function') q += 4;
  10964. if (typeof p.setLoopVideo === 'function') q += 4;
  10965.  
  10966.  
  10967. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  10968.  
  10969. if (q > 0) brr.set(k, q);
  10970.  
  10971. }
  10972.  
  10973. }
  10974.  
  10975. if (arr.length === 0) {
  10976.  
  10977. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  10978. } else {
  10979.  
  10980. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  10981.  
  10982. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  10983.  
  10984. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  10985. return arr[0][0];
  10986. }
  10987.  
  10988.  
  10989.  
  10990. }
  10991.  
  10992.  
  10993.  
  10994. const getSV = (_yt_player) => {
  10995. const w = 'SV';
  10996.  
  10997. let arr = [];
  10998. let brr = new Map();
  10999.  
  11000. for (const [k, v] of Object.entries(_yt_player)) {
  11001.  
  11002. const p = typeof v === 'function' ? v.prototype : 0;
  11003. if (p) {
  11004. let q = 0;
  11005. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  11006. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  11007. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  11008.  
  11009. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q += 600; // SV
  11010.  
  11011. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  11012.  
  11013. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  11014. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  11015. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  11016. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  11017.  
  11018.  
  11019. // differentiate QT and DX
  11020.  
  11021.  
  11022. q += 280;
  11023.  
  11024. if (typeof p.cueVideoByPlayerVars === 'function') q -= 4;
  11025. if (typeof p.loadVideoByPlayerVars === 'function') q -= 4;
  11026. if (typeof p.preloadVideoByPlayerVars === 'function') q -= 4;
  11027. if (typeof p.seekBy === 'function') q -= 4;
  11028. if (typeof p.seekTo === 'function') q -= 4;
  11029. if (typeof p.getStoryboardFormat === 'function') q -= 4;
  11030. if (typeof p.getDuration === 'function') q -= 4;
  11031. if (typeof p.loadModule === 'function') q -= 4;
  11032. if (typeof p.unloadModule === 'function') q -= 4;
  11033. if (typeof p.getOption === 'function') q -= 4;
  11034. if (typeof p.getOptions === 'function') q -= 4;
  11035. if (typeof p.setOption === 'function') q -= 4;
  11036. if (typeof p.addCueRange === 'function') q -= 4;
  11037. if (typeof p.getDebugText === 'function') q -= 4;
  11038. if (typeof p.getCurrentBroadcastId === 'function') q -= 4;
  11039. if (typeof p.setSizeStyle === 'function') q -= 4;
  11040. if (typeof p.showControls === 'function') q -= 4;
  11041. if (typeof p.hideControls === 'function') q -= 4;
  11042. if (typeof p.getVideoContentRect === 'function') q -= 4;
  11043. if (typeof p.toggleFullscreen === 'function') q -= 4;
  11044. if (typeof p.isFullscreen === 'function') q -= 4;
  11045. if (typeof p.cancelPlayback === 'function') q -= 4;
  11046. if (typeof p.getProgressState === 'function') q -= 4;
  11047. if (typeof p.isInline === 'function') q -= 4;
  11048. if (typeof p.setInline === 'function') q -= 4;
  11049. if (typeof p.toggleSubtitles === 'function') q -= 4;
  11050. if (typeof p.getPlayerSize === 'function') q -= 4;
  11051. if (typeof p.wakeUpControls === 'function') q -= 4;
  11052. if (typeof p.setCenterCrop === 'function') q -= 4;
  11053. if (typeof p.getLoopVideo === 'function') q -= 4;
  11054. if (typeof p.setLoopVideo === 'function') q -= 4;
  11055.  
  11056.  
  11057. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  11058.  
  11059. if (q > 0) brr.set(k, q);
  11060.  
  11061. }
  11062.  
  11063. }
  11064.  
  11065. if (arr.length === 0) {
  11066.  
  11067. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  11068. } else {
  11069.  
  11070. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  11071.  
  11072. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  11073.  
  11074. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  11075. return arr[0][0];
  11076. }
  11077.  
  11078.  
  11079.  
  11080. }
  11081.  
  11082.  
  11083.  
  11084.  
  11085. const getDX = (_yt_player) => {
  11086. const w = 'DX';
  11087.  
  11088. let arr = [];
  11089. let brr = new Map();
  11090.  
  11091. for (const [k, v] of Object.entries(_yt_player)) {
  11092.  
  11093. const p = typeof v === 'function' ? v.prototype : 0;
  11094. if (p) {
  11095. let q = 0;
  11096. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  11097. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  11098. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  11099.  
  11100. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q -= 600; // avoid SV
  11101.  
  11102.  
  11103. if (!(typeof p.init === 'function' && p.init.length === 0)) q -= 300; // init is required
  11104.  
  11105. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  11106.  
  11107. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  11108. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  11109. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  11110. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  11111.  
  11112.  
  11113. // differentiate QT and DX
  11114.  
  11115.  
  11116. q += 280;
  11117.  
  11118. if (typeof p.cueVideoByPlayerVars === 'function') q -= 4;
  11119. if (typeof p.loadVideoByPlayerVars === 'function') q -= 4;
  11120. if (typeof p.preloadVideoByPlayerVars === 'function') q -= 4;
  11121. if (typeof p.seekBy === 'function') q -= 4;
  11122. if (typeof p.seekTo === 'function') q -= 4;
  11123. if (typeof p.getStoryboardFormat === 'function') q -= 4;
  11124. if (typeof p.getDuration === 'function') q -= 4;
  11125. if (typeof p.loadModule === 'function') q -= 4;
  11126. if (typeof p.unloadModule === 'function') q -= 4;
  11127. if (typeof p.getOption === 'function') q -= 4;
  11128. if (typeof p.getOptions === 'function') q -= 4;
  11129. if (typeof p.setOption === 'function') q -= 4;
  11130. if (typeof p.addCueRange === 'function') q -= 4;
  11131. if (typeof p.getDebugText === 'function') q -= 4;
  11132. if (typeof p.getCurrentBroadcastId === 'function') q -= 4;
  11133. if (typeof p.setSizeStyle === 'function') q -= 4;
  11134. if (typeof p.showControls === 'function') q -= 4;
  11135. if (typeof p.hideControls === 'function') q -= 4;
  11136. if (typeof p.getVideoContentRect === 'function') q -= 4;
  11137. if (typeof p.toggleFullscreen === 'function') q -= 4;
  11138. if (typeof p.isFullscreen === 'function') q -= 4;
  11139. if (typeof p.cancelPlayback === 'function') q -= 4;
  11140. if (typeof p.getProgressState === 'function') q -= 4;
  11141. if (typeof p.isInline === 'function') q -= 4;
  11142. if (typeof p.setInline === 'function') q -= 4;
  11143. if (typeof p.toggleSubtitles === 'function') q -= 4;
  11144. if (typeof p.getPlayerSize === 'function') q -= 4;
  11145. if (typeof p.wakeUpControls === 'function') q -= 4;
  11146. if (typeof p.setCenterCrop === 'function') q -= 4;
  11147. if (typeof p.getLoopVideo === 'function') q -= 4;
  11148. if (typeof p.setLoopVideo === 'function') q -= 4;
  11149.  
  11150.  
  11151. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  11152.  
  11153. if (q > 0) brr.set(k, q);
  11154.  
  11155. }
  11156.  
  11157. }
  11158.  
  11159. if (arr.length === 0) {
  11160.  
  11161. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  11162. } else {
  11163.  
  11164. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  11165.  
  11166. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  11167.  
  11168. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  11169. return arr[0][0];
  11170. }
  11171.  
  11172.  
  11173.  
  11174. }
  11175.  
  11176.  
  11177.  
  11178. const isPrepareCachedV = (FIX_avoid_incorrect_video_meta ? true : false) && (window === top);
  11179.  
  11180. let pageSetupVideoId = null; // set at finish; '' for indeterminate state
  11181. let pageSetupState = 0;
  11182.  
  11183. isPrepareCachedV && (() => {
  11184.  
  11185. pageSetupVideoId = '';
  11186. const clearCachedV = () => {
  11187. pageSetupVideoId = '';
  11188. pageSetupState = 0;
  11189. }
  11190. document.addEventListener('yt-navigate-start', clearCachedV, false); // user action
  11191. document.addEventListener('yt-navigate-cache', clearCachedV, false); // pop state
  11192. document.addEventListener('yt-page-data-fetched', clearCachedV, false); // still consider invalid until url is ready in yt-navigate-finish
  11193. document.addEventListener('yt-navigate-finish', () => {
  11194. pageSetupState = 1;
  11195. try {
  11196. const url = new URL(location.href);
  11197. if (!url || !isWatchPageURL(url)) {
  11198. pageSetupVideoId = '';
  11199. } else {
  11200. pageSetupVideoId = url.searchParams.get('v') || '';
  11201. }
  11202. } catch (e) {
  11203. pageSetupVideoId = '';
  11204. }
  11205. }, false);
  11206.  
  11207. })();
  11208.  
  11209. let videoPlayingY = null;
  11210.  
  11211. isPrepareCachedV && (() => {
  11212.  
  11213. let getNext = true;
  11214. let videoPlayingX = {
  11215. get videoId() {
  11216. if (getNext) {
  11217. getNext = false;
  11218.  
  11219. let elements = document.querySelectorAll('ytd-watch-flexy[video-id]');
  11220. const arr = [];
  11221. for (const element of elements) {
  11222. if (!element.closest('[hidden]')) arr.push(element);
  11223. }
  11224. if (arr.length !== 1) this.__videoId__ = '';
  11225. else {
  11226. this.__videoId__ = arr[0].getAttribute('video-id');
  11227. }
  11228.  
  11229. }
  11230. return this.__videoId__ || '';
  11231. }
  11232. }
  11233.  
  11234. videoPlayingY = videoPlayingX;
  11235. const handler = (evt) => {
  11236. const target = (evt || 0).target;
  11237. if (target instanceof HTMLVideoElement) {
  11238. getNext = true;
  11239. }
  11240. }
  11241. document.addEventListener('loadedmetadata', handler, true);
  11242. document.addEventListener('durationchange', handler, true);
  11243.  
  11244. })();
  11245.  
  11246.  
  11247.  
  11248. const cleanContext = async (win) => {
  11249. const waitFn = requestAnimationFrame; // shall have been binded to window
  11250. try {
  11251. let mx = 16; // MAX TRIAL
  11252. const frameId = 'vanillajs-iframe-v1';
  11253. /** @type {HTMLIFrameElement | null} */
  11254. let frame = document.getElementById(frameId);
  11255. let removeIframeFn = null;
  11256. if (!frame) {
  11257. frame = document.createElement('iframe');
  11258. frame.id = frameId;
  11259. const blobURL = typeof webkitCancelAnimationFrame === 'function' && typeof kagi === 'undefined' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  11260. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  11261. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  11262. n.appendChild(frame);
  11263. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  11264. const root = document.documentElement;
  11265. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  11266. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  11267.  
  11268. removeIframeFn = (setTimeout) => {
  11269. const removeIframeOnDocumentReady = (e) => {
  11270. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  11271. e = n;
  11272. n = win = removeIframeFn = 0;
  11273. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  11274. }
  11275. if (!setTimeout || document.readyState !== 'loading') {
  11276. removeIframeOnDocumentReady();
  11277. } else {
  11278. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  11279. }
  11280. }
  11281. }
  11282. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  11283. const fc = frame.contentWindow;
  11284. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  11285. try {
  11286. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle } = fc;
  11287. const res = { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle };
  11288. for (let k in res) res[k] = res[k].bind(win); // necessary
  11289. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  11290. res.animate = fc.HTMLElement.prototype.animate;
  11291. res.perfNow = fc.performance.now;
  11292. return res;
  11293. } catch (e) {
  11294. if (removeIframeFn) removeIframeFn();
  11295. return null;
  11296. }
  11297. } catch (e) {
  11298. console.warn(e);
  11299. return null;
  11300. }
  11301. };
  11302.  
  11303. const promiseForYtActionCalled = new Promise(resolve => {
  11304.  
  11305. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-app';
  11306. if (typeof AbortSignal !== 'undefined') {
  11307. let hn = () => {
  11308. if (!hn) return;
  11309. hn = null;
  11310. resolve(document.querySelector(appTag));
  11311. };
  11312. document.addEventListener('yt-action', hn, { capture: true, passive: true, once: true });
  11313. } else {
  11314. let hn = () => {
  11315. if (!hn) return;
  11316. document.removeEventListener('yt-action', hn, true);
  11317. hn = null;
  11318. resolve(document.querySelector(appTag));
  11319. };
  11320. document.addEventListener('yt-action', hn, true);
  11321. }
  11322. });
  11323.  
  11324. cleanContext(window).then(__CONTEXT__ => {
  11325. if (!__CONTEXT__) return null;
  11326.  
  11327. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, requestIdleCallback, getComputedStyle, perfNow } = __CONTEXT__;
  11328.  
  11329.  
  11330. performance.now17 = perfNow.bind(performance);
  11331.  
  11332.  
  11333.  
  11334. __requestAnimationFrame__ = requestAnimationFrame;
  11335.  
  11336.  
  11337. const isGPUAccelerationAvailable = (() => {
  11338. // https://gist.github.com/cvan/042b2448fcecefafbb6a91469484cdf8
  11339. try {
  11340. const canvas = document.createElement('canvas');
  11341. return !!(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
  11342. } catch (e) {
  11343. return false;
  11344. }
  11345. })();
  11346.  
  11347. const foregroundPromiseFn_noGPU = (() => {
  11348.  
  11349. if (isGPUAccelerationAvailable) return null;
  11350.  
  11351. const pd = Object.getOwnPropertyDescriptor(Document.prototype, 'visibilityState');
  11352. if (!pd || typeof pd.get !== 'function') return null;
  11353. const pdGet = pd.get;
  11354.  
  11355. let pr = null;
  11356.  
  11357. let hState = pdGet.call(document) === 'hidden';
  11358. // let cid = 0;
  11359. pureAddEventListener.call(document, 'visibilitychange', (evt) => {
  11360. const newHState = pdGet.call(document) === 'hidden';
  11361. if (hState !== newHState) {
  11362. // if (cid > 0) cid = clearInterval(cid);
  11363. hState = newHState;
  11364. if (!hState && pr) pr = pr.resolve();
  11365. }
  11366. });
  11367.  
  11368. // cid = setInterval(() => {
  11369. // const newHState = document.visibilityState === 'hidden';
  11370. // if (hState !== newHState) {
  11371. // hState = newHState;
  11372. // if (!hState && pr) pr = pr.resolve();
  11373. // }
  11374. // }, 100);
  11375.  
  11376.  
  11377. return (() => {
  11378. if (pr) return pr;
  11379. const w = ((!hState && setTimeout(() => {
  11380. if (!hState && pr === w) pr = pr.resolve();
  11381. })), (pr = new PromiseExternal()));
  11382. return w;
  11383. });
  11384.  
  11385. })();
  11386.  
  11387.  
  11388. let rafPromise = null;
  11389. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  11390. requestAnimationFrame(hRes => {
  11391. rafPromise = null;
  11392. resolve(hRes);
  11393. });
  11394. }));
  11395.  
  11396. const foregroundPromiseFn = foregroundPromiseFn_noGPU || getRafPromise;
  11397.  
  11398.  
  11399. const wmComputedStyle = new WeakMap();
  11400.  
  11401. if (!window.__native__getComputedStyle__ && !window.__jst__getComputedStyle__ && typeof window.getComputedStyle === 'function' && window.getComputedStyle.length === 1) {
  11402. window.__native__getComputedStyle__ = getComputedStyle;
  11403. if (ENABLE_COMPUTEDSTYLE_CACHE) {
  11404. window.__original__getComputedStyle__ = window.getComputedStyle;
  11405. window.getComputedStyle = function (elem) {
  11406. if (!(elem instanceof Element) || (arguments.length === 2 && arguments[1]) || (arguments.length > 2)) {
  11407. return window.__original__getComputedStyle__(...arguments);
  11408. }
  11409. let cs = wmComputedStyle.get(elem);
  11410. if (!cs) {
  11411. cs = window.__native__getComputedStyle__(elem);
  11412. wmComputedStyle.set(elem, cs);
  11413. }
  11414. return cs;
  11415. };
  11416. } else {
  11417. window.__original__getComputedStyle__ = null;
  11418. }
  11419. window.__jst__getComputedStyle__ = window.getComputedStyle;
  11420. }
  11421.  
  11422. NO_SCHEDULING_DUE_TO_COMPUTEDSTYLE && promiseForYtActionCalled.then(() => {
  11423. if (typeof window.__jst__getComputedStyle__ === 'function' && window.__jst__getComputedStyle__.length === 1 && window.__jst__getComputedStyle__ !== window.getComputedStyle) {
  11424. window.getComputedStyle = window.__jst__getComputedStyle__;
  11425. }
  11426. });
  11427.  
  11428. const isUrlInEmbed = location.href.includes('.youtube.com/embed/');
  11429. const isAbortSignalSupported = typeof AbortSignal !== "undefined";
  11430.  
  11431. const promiseForTamerTimeout = new Promise(resolve => {
  11432. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  11433. setTimeout(resolve, 480);
  11434. }, { capture: true, passive: true, once: true });
  11435. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  11436. setTimeout(resolve, 1200);
  11437. });
  11438. setTimeout(resolve, 3000);
  11439. });
  11440.  
  11441. const promiseForPageInitied = new Promise(resolve => {
  11442. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  11443. setTimeout(resolve, 450);
  11444. }, { capture: true, passive: true, once: true });
  11445. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  11446. setTimeout(resolve, 900);
  11447. });
  11448. setTimeout(resolve, 1800);
  11449. });
  11450.  
  11451. NO_PRELOAD_GENERATE_204_BYPASS || promiseForPageInitied.then(() => {
  11452. NO_PRELOAD_GENERATE_204_BYPASS = true;
  11453. headLinkCollection = null;
  11454. });
  11455.  
  11456.  
  11457. NATIVE_CANVAS_ANIMATION && (() => {
  11458.  
  11459. observablePromise(() => {
  11460. HTMLCanvasElement.prototype.animate = animate;
  11461. }, promiseForTamerTimeout).obtain();
  11462.  
  11463. })();
  11464.  
  11465.  
  11466.  
  11467.  
  11468. FIX_ytAction_ && (async () => {
  11469.  
  11470. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-app';
  11471.  
  11472. const ytdApp = await new Promise(resolve => {
  11473.  
  11474. whenCEDefined(appTag).then(() => {
  11475. const ytdApp = document.querySelector(appTag);
  11476. if (ytdApp) {
  11477. resolve(ytdApp);
  11478. return;
  11479. }
  11480. let mo = new MutationObserver(() => {
  11481. const ytdApp = document.querySelector(appTag);
  11482. if (!ytdApp) return;
  11483. if (mo) {
  11484. mo.disconnect();
  11485. mo.takeRecords();
  11486. mo = null;
  11487. }
  11488. resolve(ytdApp);
  11489. });
  11490. mo.observe(document, { subtree: true, childList: true });
  11491. });
  11492.  
  11493. });
  11494.  
  11495. if (!ytdApp) return;
  11496. const cProto = insp(ytdApp).constructor.prototype;
  11497.  
  11498. if (!cProto) return;
  11499. let mbd = 0;
  11500.  
  11501. const fixer = (_ytdApp) => {
  11502. const ytdApp = insp(_ytdApp);
  11503. if (ytdApp && typeof ytdApp.onYtActionBoundListener_ === 'function' && !ytdApp.onYtActionBoundListener57_) {
  11504. ytdApp.onYtActionBoundListener57_ = ytdApp.onYtActionBoundListener_;
  11505. ytdApp.onYtActionBoundListener_ = ytdApp.onYtAction_.bind(ytdApp);
  11506. mbd++;
  11507. }
  11508. }
  11509.  
  11510. observablePromise(() => {
  11511.  
  11512. if (typeof cProto.created === 'function' && !cProto.created56) {
  11513. cProto.created56 = cProto.created;
  11514. cProto.created = function (...args) {
  11515. const r = this.created56(...args);
  11516. fixer(this);
  11517. return r;
  11518. };
  11519. mbd++;
  11520. }
  11521.  
  11522. if (typeof cProto.onYtAction_ === 'function' && !cProto.onYtAction57_) {
  11523. cProto.onYtAction57_ = cProto.onYtAction_;
  11524. cProto.onYtAction_ = function (...args) {
  11525. Promise.resolve().then(() => this.onYtAction57_(...args));
  11526. };
  11527. mbd++;
  11528. }
  11529.  
  11530. if (ytdApp) fixer(ytdApp);
  11531.  
  11532. /*
  11533. const actionRouter_ = ytdApp ? ytdApp.actionRouter_ : null;
  11534. if (actionRouter_ && typeof actionRouter_.handleAction === 'function' && !actionRouter_.handleAction57) {
  11535. actionRouter_.handleAction57 = actionRouter_.handleAction;
  11536. actionRouter_.handleAction = function (...args) {
  11537. Promise.resolve().then(() => this.handleAction57(...args));
  11538. }
  11539. mbd++;
  11540. }
  11541. */
  11542.  
  11543. // if(mbd === 3) return 1;
  11544. if (mbd >= 3) return 1;
  11545.  
  11546. }, new Promise(r => setTimeout(r, 1000))).obtain();
  11547.  
  11548. })();
  11549.  
  11550.  
  11551. FORCE_NO_REUSEABLE_ELEMENT_POOL && promiseForYtActionCalled.then(async () => {
  11552.  
  11553. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-watch-flexy';
  11554.  
  11555. const app = await observablePromise(() => {
  11556.  
  11557. return document.querySelector(appTag);
  11558.  
  11559. }).obtain();
  11560.  
  11561. if (!app) return;
  11562.  
  11563. const appCnt = insp(app);
  11564. FORCE_NO_REUSEABLE_ELEMENT_POOL_fn(appCnt);
  11565.  
  11566.  
  11567.  
  11568.  
  11569. });
  11570.  
  11571.  
  11572. // let _yt_player_promise = null;
  11573. /*
  11574. const getYtPlayerPromise = () => {
  11575. if (!_yt_player_promise) {
  11576. _yt_player_promise = new Promise(resolve => {
  11577. let cid = setInterval(() => {
  11578. let t = (((window || 0)._yt_player || 0) || 0);
  11579. if (t) {
  11580. clearInterval(cid);
  11581. resolve(t);
  11582. }
  11583. }, 1);
  11584. promiseForTamerTimeout.then(() => {
  11585. resolve(null)
  11586. });
  11587. });
  11588. }
  11589. return _yt_player_promise;
  11590. }
  11591. */
  11592. const _yt_player_observable = observablePromise(() => {
  11593. const _yt_player = (((window || 0)._yt_player || 0) || 0);
  11594. if (_yt_player) {
  11595. _yt_player[`__is_yt_player__${Date.now()}`] = 1;
  11596. return _yt_player;
  11597. }
  11598. }, promiseForTamerTimeout);
  11599.  
  11600. const polymerObservable = observablePromise(() => {
  11601. const Polymer = window.Polymer;
  11602. if (typeof Polymer !== 'function') return;
  11603. if (!(Polymer.Base || 0).connectedCallback || !(Polymer.Base || 0).disconnectedCallback) return;
  11604. return Polymer;
  11605. }, promiseForTamerTimeout);
  11606.  
  11607. const schedulerInstanceObservable = observablePromise(() => {
  11608. return (((window || 0).ytglobal || 0).schedulerInstanceInstance_ || 0);
  11609. }, promiseForTamerTimeout);
  11610.  
  11611. const timelineObservable = observablePromise(() => {
  11612. let t = (((document || 0).timeline || 0) || 0);
  11613. if (t && typeof t._play === 'function') {
  11614. return t;
  11615. }
  11616. }, promiseForTamerTimeout);
  11617. const animationObservable = observablePromise(() => {
  11618. let t = (((window || 0).Animation || 0) || 0);
  11619. if (t && typeof t === 'function' && t.length === 2 && typeof t.prototype._updatePromises === 'function') {
  11620. return t;
  11621. }
  11622. }, promiseForTamerTimeout);
  11623.  
  11624.  
  11625. const getScreenInfo = {
  11626. screenWidth: 0,
  11627. screenHeight: 0,
  11628. valueReady: false,
  11629. onResize: () => {
  11630. getScreenInfo.valueReady = false;
  11631. },
  11632. sizeProvided: () => {
  11633. if (getScreenInfo.valueReady) return true;
  11634. getScreenInfo.screenWidth = screen.width;
  11635. getScreenInfo.screenHeight = screen.height;
  11636. if (getScreenInfo.screenWidth * getScreenInfo.screenHeight > 1) {
  11637. getScreenInfo.valueReady = true;
  11638. return true;
  11639. }
  11640. return false;
  11641. }
  11642. };
  11643.  
  11644. window.addEventListener('resize', getScreenInfo.onResize, true);
  11645.  
  11646.  
  11647. // const hookLeftPending = new WeakMap();
  11648.  
  11649. const isNaNx = Number.isNaN;
  11650.  
  11651. const hookLeftPD = {
  11652. get() {
  11653. const p = 'left';
  11654. // const o = hookLeftPending.get(this);
  11655. // if (o && o.key) {
  11656. // this.setProperty(p, o.value);
  11657. // o.key = null
  11658. // }
  11659. return this.getPropertyValue(p);
  11660. },
  11661. set(v) {
  11662.  
  11663. const p = 'left';
  11664. const cv = this.getPropertyValue(p);
  11665. const sv = v;
  11666.  
  11667. // const did = Math.floor(Math.random() * 314159265359 + 314159265359).toString(36);
  11668.  
  11669. // console.log(8380,did, cv, sv)
  11670. if (!cv && !sv) return true;
  11671. if (cv === sv) return true;
  11672.  
  11673. // skip 0~9px => L>=4
  11674.  
  11675. const qsv = `${sv}`.length >= 4 && `${sv}`.endsWith('px') ? +sv.slice(0, -2) : NaN;
  11676.  
  11677. if (!isNaNx(qsv)) {
  11678. const qcv = `${cv}`.length >= 4 && `${cv}`.endsWith('px') ? +cv.slice(0, -2) : NaN;
  11679.  
  11680. if (!isNaNx(qcv) && getScreenInfo.sizeProvided()) {
  11681. const { screenWidth, screenHeight } = getScreenInfo;
  11682. let pWidth = screenWidth + 1024;
  11683. let pHeight = screenHeight + 768;
  11684. const minRatio = 0.003;
  11685. const dw = pWidth * 0.0003; // min dw = 0.3072
  11686. const dh = pHeight * 0.0003; // min dh = 0.2304
  11687. // console.log(8381,did, Math.abs(qcv - qsv) < dw)
  11688. if (Math.abs(qcv - qsv) < dw) return true;
  11689. }
  11690.  
  11691. v = `${qsv > -1e-5 && qsv < 1e-5 ? 0 : qsv.toFixed(4)}px`;
  11692. if (`${v}`.length > `${sv}`.length) v = sv;
  11693. // console.log(8382, did, sv, nv, cv, this)
  11694. }
  11695.  
  11696. // Promise.resolve().then(() => {
  11697. // const o = hookLeftPending.get(this);
  11698. // if (o && o.key === did) {
  11699. // this.setProperty(p, o.value);
  11700. // o.key = null;
  11701. // }
  11702. // });
  11703. // hookLeftPending.set(this, {
  11704. // key: did,
  11705. // value: nv
  11706. // });
  11707.  
  11708. // if (nv != v) {
  11709. // console.log(8387, v, nv);
  11710. // }
  11711.  
  11712. this.setProperty(p, v);
  11713. // console.log(8383, did, this.getPropertyValue(p))
  11714. return true;
  11715. },
  11716. enumerable: true,
  11717. configurable: true
  11718. };
  11719.  
  11720.  
  11721. if (HOOK_CSSPD_LEFT) {
  11722.  
  11723.  
  11724. Object.defineProperty(CSSStyleDeclaration.prototype, 'left', hookLeftPD);
  11725.  
  11726. }
  11727.  
  11728.  
  11729.  
  11730.  
  11731.  
  11732. const generalEvtHandler = async (_evKey, _fvKey, _debug) => {
  11733.  
  11734. const evKey = `${_evKey}`;
  11735. const fvKey = `${_fvKey}`;
  11736. const debug = !!_debug;
  11737.  
  11738. const _yt_player = await _yt_player_observable.obtain();
  11739.  
  11740.  
  11741. if (!_yt_player || typeof _yt_player !== 'object') return;
  11742.  
  11743.  
  11744. const getArr = (_yt_player) => {
  11745.  
  11746. let arr = [];
  11747.  
  11748. for (const [k, v] of Object.entries(_yt_player)) {
  11749.  
  11750. const p = typeof v === 'function' ? v.prototype : 0;
  11751. if (p
  11752. && typeof p[evKey] === 'function' && p[evKey].length >= 0 && !p[fvKey]
  11753.  
  11754. ) {
  11755. arr = addProtoToArr(_yt_player, k, arr) || arr;
  11756.  
  11757. }
  11758.  
  11759. }
  11760.  
  11761. if (arr.length === 0) {
  11762.  
  11763. console.warn(`Key prop [${evKey}] does not exist.`);
  11764. } else {
  11765.  
  11766. return arr;
  11767. }
  11768.  
  11769. };
  11770.  
  11771. const arr = getArr(_yt_player);
  11772.  
  11773.  
  11774. if (!arr) return;
  11775.  
  11776. debug && console.log(`FIX_${evKey}`, arr);
  11777.  
  11778. const f = function (...args) {
  11779. Promise.resolve().then(() => this[fvKey](...args));
  11780. };
  11781.  
  11782.  
  11783. for (const k of arr) {
  11784.  
  11785. const g = _yt_player;
  11786. const gk = g[k];
  11787. const gkp = gk.prototype;
  11788.  
  11789. debug && console.log(237, k, gkp)
  11790.  
  11791. if (typeof gkp[evKey] == 'function' && !gkp[fvKey]) {
  11792. gkp[fvKey] = gkp[evKey];
  11793. gkp[evKey] = f;
  11794. }
  11795. }
  11796.  
  11797.  
  11798.  
  11799.  
  11800. }
  11801.  
  11802. if (!isChatRoomURL) {
  11803.  
  11804. FIX_onVideoDataChange && generalEvtHandler('onVideoDataChange', 'onVideoDataChange57');
  11805. // FIX_onClick && generalEvtHandler('onClick', 'onClick57');
  11806. FIX_onStateChange && generalEvtHandler('onStateChange', 'onStateChange57');
  11807. FIX_onLoopRangeChange && generalEvtHandler('onLoopRangeChange', 'onLoopRangeChange57');
  11808. if (FIX_VideoEVENTS_v2) {
  11809. const FIX_VideoEVENTS_DEBUG = 0;
  11810. generalEvtHandler('onVideoProgress', 'onVideoProgress57', FIX_VideoEVENTS_DEBUG); // --
  11811. // generalEvtHandler('onAutoplayBlocked', 'onAutoplayBlocked57', FIX_VideoEVENTS_DEBUG);
  11812. // generalEvtHandler('onLoadProgress', 'onLoadProgress57', FIX_VideoEVENTS_DEBUG); // << CAUSE ISSUE >>
  11813. generalEvtHandler('onFullscreenChange', 'onFullscreenChange57', FIX_VideoEVENTS_DEBUG); // --
  11814. // generalEvtHandler('onLoadedMetadata', 'onLoadedMetadata57', FIX_VideoEVENTS_DEBUG);
  11815. // generalEvtHandler('onDrmOutputRestricted', 'onDrmOutputRestricted57', FIX_VideoEVENTS_DEBUG);
  11816. // generalEvtHandler('onAirPlayActiveChange', 'onAirPlayActiveChange57', FIX_VideoEVENTS_DEBUG);
  11817. // generalEvtHandler('onAirPlayAvailabilityChange', 'onAirPlayAvailabilityChange57', FIX_VideoEVENTS_DEBUG);
  11818. // generalEvtHandler('onApiChange', 'onApiChange57', FIX_VideoEVENTS_DEBUG);
  11819.  
  11820. }
  11821. // onMutedAutoplayChange
  11822. // onVolumeChange
  11823. // onPlaybackRateChange
  11824.  
  11825. // onAirPlayActiveChange
  11826. // onAirPlayAvailabilityChange
  11827. // onApiChange
  11828. // onAutoplayBlocked
  11829. // onDrmOutputRestricted
  11830. // onFullscreenChange
  11831. // onLoadProgress
  11832. // onLoadedMetadata
  11833. // onVideoDataChange
  11834. // onVideoProgress
  11835.  
  11836. }
  11837.  
  11838.  
  11839. let isAmended_Polymer_RenderStatus = false;
  11840.  
  11841. (ENABLE_discreteTasking || FIX_Polymer_dom || FIX_Polymer_AF || FIX_stampDomArray) && (async () => {
  11842.  
  11843. const Polymer = await polymerObservable.obtain();
  11844. if (!Polymer) return;
  11845.  
  11846. if (FIX_Polymer_AF && Polymer && Polymer.RenderStatus && !isAmended_Polymer_RenderStatus) {
  11847. isAmended_Polymer_RenderStatus = true;
  11848.  
  11849. if (typeof Polymer.RenderStatus.beforeNextRender === 'function' && typeof Polymer.RenderStatus.afterNextRender === 'function' && Polymer.RenderStatus.beforeNextRender.length === 3 && Polymer.RenderStatus.afterNextRender.length === 3) {
  11850. let arrBefore = null, arrAfter = null;
  11851. const push = Array.prototype.push;
  11852. let arr = null;
  11853. Array.prototype.push = function () {
  11854. arr = this;
  11855. }
  11856. Polymer.RenderStatus.beforeNextRender({}, {}, {});
  11857. if (arr) arrBefore = arr;
  11858. arr = null;
  11859. Polymer.RenderStatus.afterNextRender({}, {}, {});
  11860. if (arr) arrAfter = arr;
  11861. arr = null;
  11862. Array.prototype.push = push;
  11863. Polymer.RenderStatus.arrBefore = arrBefore;
  11864. Polymer.RenderStatus.arrAfter = arrAfter;
  11865.  
  11866. if (arrBefore && arrAfter) {
  11867.  
  11868. Function.prototype.call7900 = Function.prototype.call;
  11869. Function.prototype.apply7900 = Function.prototype.apply;
  11870. Function.prototype.apply7948 = function (obj, args) {
  11871. const f = this;
  11872. let m = kRef(obj);
  11873. if (!m) return;
  11874. if (m.is && !m.nodeName) {
  11875. if (!m.isAttached || !m.hostElement) {
  11876. return;
  11877. }
  11878. }
  11879. try {
  11880. return !args ? f.call7900(m) : f.apply7900(m, args);
  11881. } catch (e) {
  11882. console.warn(e);
  11883. }
  11884. return null;
  11885. }
  11886.  
  11887. arrBefore.push = arrAfter.push = function (a) {
  11888. if (arguments.length !== 1 || !a || a.length === 0 || !a[0]) return push.apply(this, arguments);
  11889. if (a[0].deref) a[0] = kRef(a[0]);
  11890. const f = a[1]
  11891. const obj = a[0]
  11892. const args = a[2];
  11893. f.apply = f.apply7948;
  11894. if (!obj[wk]) obj[wk] = mWeakRef(obj);
  11895. a[0] = obj[wk]
  11896. // console.log(4992, a)
  11897. return push.call(this, a);
  11898. }
  11899.  
  11900. }
  11901.  
  11902.  
  11903. }
  11904. // Polymer.RenderStatus.beforeNextRender
  11905. }
  11906.  
  11907. if (FIX_Polymer_dom) {
  11908.  
  11909. const checkPDFuncValue = (pd) => {
  11910. return pd && pd.writable && pd.enumerable && pd.configurable && typeof pd.value == 'function'
  11911. }
  11912. const checkPDFuncValue2 = (pd) => {
  11913. return pd && typeof pd.value == 'function'
  11914. }
  11915.  
  11916. const checkPDFuncGet = (pd) => {
  11917. return pd && typeof pd.get == 'function'
  11918. }
  11919.  
  11920. const domX = Polymer.dom(document.createElement('null'));
  11921. const domXP = (((domX || 0).constructor || 0).prototype || 0);
  11922. const pd1 = Object.getOwnPropertyDescriptor(domXP, 'getOwnerRoot');
  11923. const pd2 = Object.getOwnPropertyDescriptor(Node.prototype, 'parentElement');
  11924. const pd3 = Object.getOwnPropertyDescriptor(domXP, 'querySelector'); // undefined
  11925. const pd4 = Object.getOwnPropertyDescriptor(Element.prototype, 'querySelector');
  11926. const pd4b = Object.getOwnPropertyDescriptor(Document.prototype, 'querySelector');
  11927. const pd5 = Object.getOwnPropertyDescriptor(domXP, 'querySelectorAll'); // undefined
  11928. const pd6 = Object.getOwnPropertyDescriptor(Element.prototype, 'querySelectorAll');
  11929. const pd6b = Object.getOwnPropertyDescriptor(Document.prototype, 'querySelectorAll');
  11930.  
  11931.  
  11932. // getOwnerRoot - to be reviewed
  11933. if (0 && checkPDFuncValue(pd1) && checkPDFuncGet(pd2) && !domXP.getOwnerRoot15 && typeof domXP.getOwnerRoot === 'function') {
  11934.  
  11935. domXP.getOwnerRoot15 = domXP.getOwnerRoot;
  11936. domXP.getOwnerRoot = function () {
  11937. try {
  11938. const p = this.node;
  11939.  
  11940. if (p instanceof HTMLElement_) {
  11941. const pp = pd2.get.call(p);
  11942. if (pp instanceof HTMLElement_ && pp.isConnected === true) {
  11943. return pp.getRootNode();
  11944. }
  11945.  
  11946. }
  11947. } catch (e) { }
  11948. return this.getOwnerRoot15();
  11949. }
  11950.  
  11951. Polymer.__fixedGetOwnerRoot__ = 1;
  11952. }
  11953.  
  11954.  
  11955.  
  11956.  
  11957. if ((!pd3 || checkPDFuncValue(pd3)) && checkPDFuncValue2(pd4) && checkPDFuncValue2(pd4b) && !('querySelector15' in domXP)) {
  11958.  
  11959. domXP.querySelector15 = domXP.querySelector;
  11960.  
  11961. const querySelectorFn = function (query) {
  11962. try {
  11963. const p = this.node;
  11964.  
  11965. if (p instanceof Document && p.isConnected === true) {
  11966. return pd4b.value.call(p, query);
  11967. }
  11968.  
  11969. } catch (e) { }
  11970. return this.querySelector15(query);
  11971. }
  11972.  
  11973. Object.defineProperty(domXP, 'querySelector', {
  11974. get() {
  11975. return querySelectorFn;
  11976. },
  11977. set(nv) {
  11978. if (nv === querySelectorFn) return true;
  11979. this.querySelector15 = nv;
  11980. return true;
  11981. },
  11982.  
  11983. enumerable: false,
  11984. configurable: true
  11985. });
  11986.  
  11987. Polymer.__fixedQuerySelector__ = 1;
  11988. }
  11989.  
  11990. if ((!pd5 || checkPDFuncValue(pd5)) && checkPDFuncValue2(pd6) && checkPDFuncValue2(pd6b) && !('querySelectorAll15' in domXP)) {
  11991.  
  11992. domXP.querySelectorAll15 = domXP.querySelectorAll;
  11993.  
  11994. const querySelectorAllFn = function (query) {
  11995.  
  11996. try {
  11997.  
  11998. const p = this.node;
  11999.  
  12000. if (p instanceof Document && p.isConnected === true) {
  12001. return pd6b.value.call(p, query);
  12002. }
  12003.  
  12004. } catch (e) {
  12005.  
  12006. }
  12007. return this.querySelectorAll15(query);
  12008. }
  12009.  
  12010. Object.defineProperty(domXP, 'querySelectorAll', {
  12011. get() {
  12012. return querySelectorAllFn;
  12013. },
  12014. set(nv) {
  12015. if (nv === querySelectorAllFn) return true;
  12016. this.querySelectorAll15 = nv;
  12017. return true;
  12018. },
  12019.  
  12020. enumerable: false,
  12021. configurable: true
  12022. });
  12023.  
  12024. Polymer.__fixedQuerySelectorAll__ = 1;
  12025. }
  12026. }
  12027.  
  12028.  
  12029. if (ENABLE_discreteTasking || FIX_stampDomArray) {
  12030.  
  12031. Polymer.Base.__connInit__ = function () {
  12032. setupYtComponent(this);
  12033. }
  12034.  
  12035.  
  12036. /** @type {Function} */
  12037. const connectedCallbackK = function (...args) {
  12038. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  12039. const r = this[qm53](...args);
  12040. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  12041. this.mh35 = 1;
  12042. return r;
  12043. };
  12044.  
  12045. connectedCallbackK.m353 = 1;
  12046.  
  12047.  
  12048. const qt53 = Polymer.Base.connectedCallback;
  12049. Polymer.Base[qm53] = dmf.get(qt53) || qt53;
  12050.  
  12051. Polymer.Base.connectedCallback = connectedCallbackK;
  12052.  
  12053.  
  12054. /** @type {Function} */
  12055. const createdK = function (...args) {
  12056. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  12057. const r = this[qn53](...args);
  12058. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  12059. this.mh36 = 1;
  12060. return r;
  12061. };
  12062.  
  12063.  
  12064. createdK.m353 = 1;
  12065. Polymer.Base[qn53] = Polymer.Base.created;
  12066. Polymer.Base.created = createdK;
  12067.  
  12068.  
  12069.  
  12070.  
  12071.  
  12072.  
  12073.  
  12074.  
  12075.  
  12076.  
  12077.  
  12078. }
  12079.  
  12080. })();
  12081.  
  12082.  
  12083. /*
  12084.  
  12085. e.nativeAppendChild = d.prototype.appendChild,
  12086. d.prototype.appendChild = function(h) {
  12087. return function(l) {
  12088. if (l instanceof DocumentFragment) {
  12089. var m = Array.from(l.children);
  12090. l = h.nativeAppendChild.call(this, l);
  12091. if (this.isConnected) {
  12092. m = g(m);
  12093. for (var p = m.next(); !p.done; p = m.next())
  12094. YD(p.value)
  12095. }
  12096. return l
  12097. }
  12098. m = l instanceof Element && l.isConnected;
  12099. p = h.nativeAppendChild.call(this, l);
  12100. m && ZD(l);
  12101. this.isConnected && YD(l);
  12102. return p
  12103. }
  12104. }(e),
  12105.  
  12106. */
  12107.  
  12108. CHANGE_appendChild && !Node.prototype.appendChild73 && Node.prototype.appendChild && (() => {
  12109.  
  12110. const f = Node.prototype.appendChild73 = Node.prototype.appendChild;
  12111. if (f) Node.prototype.appendChild = function (a) {
  12112. if (this instanceof Element) { // exclude DocumentFragment
  12113. try {
  12114. let checkFragmentA = (a instanceof DocumentFragment);
  12115. if (!NO_PRELOAD_GENERATE_204_BYPASS && document.head === this) {
  12116. if (headLinkCollection === null) headLinkCollection = document.head.getElementsByTagName('LINK');
  12117. for (const node of headLinkCollection) {
  12118. if (node.rel === 'preload' && node.as === 'fetch') {
  12119. node.rel = 'prefetch'; // see https://github.com/GoogleChromeLabs/quicklink
  12120. }
  12121. }
  12122. } else if (checkFragmentA && this.nodeName.startsWith('YT-')) { // yt-animated-rolling-number, yt-attributed-string
  12123. checkFragmentA = false;
  12124. }
  12125. if (checkFragmentA && a.firstElementChild === null) {
  12126. // no element in fragmentA
  12127. let doNormal = false;
  12128. for (let child = a.firstChild; child instanceof Node; child = child.nextSibling) {
  12129. if (child.nodeType === 3) { doNormal = true; break; }
  12130. }
  12131. if (!doNormal) return a;
  12132. }
  12133. } catch (e) {
  12134. console.log(e);
  12135. }
  12136. }
  12137. return arguments.length === 1 ? f.call(this, a) : f.apply(this, arguments);
  12138. }
  12139.  
  12140. })();
  12141.  
  12142. if (FIX_Shady) {
  12143.  
  12144. observablePromise(() => {
  12145. const { ShadyDOM, ShadyCSS } = window;
  12146. if (ShadyDOM) {
  12147. ShadyDOM.handlesDynamicScoping = false; // 9 of 10
  12148. ShadyDOM.noPatch = true; // 1 of 10
  12149. ShadyDOM.patchOnDemand = false; // 1 of 10
  12150. ShadyDOM.preferPerformance = true; // 1 of 10
  12151. ShadyDOM.querySelectorImplementation = undefined; // 1 of 10
  12152. }
  12153. if (ShadyCSS) {
  12154. ShadyCSS.nativeCss = true; // 1 of 10
  12155. ShadyCSS.nativeShadow = true; // 6 of 10
  12156. ShadyCSS.cssBuild = undefined; // 1 of 10
  12157. ShadyCSS.disableRuntime = true; // 1 of 10
  12158. }
  12159. if (ShadyDOM && ShadyCSS) return 1;
  12160. }, promiseForTamerTimeout).obtain(); // clear until 1 is return
  12161.  
  12162. }
  12163.  
  12164.  
  12165. // let schedulerInstancePropOfTimerType = '';
  12166. // let schedulerInstancePropOfTimerId = '';
  12167. (FIX_schedulerInstanceInstance & 2) && (async () => {
  12168.  
  12169. const schedulerInstanceInstance_ = await schedulerInstanceObservable.obtain();
  12170.  
  12171. if (!schedulerInstanceInstance_) return;
  12172.  
  12173. const checkOK = typeof schedulerInstanceInstance_.start === 'function' && !schedulerInstanceInstance_.start993 && !schedulerInstanceInstance_.stop && !schedulerInstanceInstance_.cancel && !schedulerInstanceInstance_.terminate && !schedulerInstanceInstance_.interupt;
  12174. if (checkOK) {
  12175.  
  12176. let resolveRendering = null;
  12177.  
  12178. let cmPr = new PromiseExternal();
  12179. const cm = document.createComment('0');
  12180. const cmObs = new MutationObserver(() => {
  12181. if (resolveRendering) {
  12182. resolveRendering();
  12183. resolveRendering = null;
  12184. }
  12185. cmPr.resolve();
  12186. cmPr = new PromiseExternal();
  12187. });
  12188. cmObs.observe(cm, {characterData: true})
  12189.  
  12190. let web_emulated_idle_callback_delay_val = null;
  12191.  
  12192. const getRenderIdleCallbackMs = () => {
  12193. if (typeof web_emulated_idle_callback_delay_val === 'number') return web_emulated_idle_callback_delay_val;
  12194. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  12195. const delay = (config.EXPERIMENT_FLAGS || 0).web_emulated_idle_callback_delay || (config.EXPERIMENTS_FORCED_FLAGS || 0).web_emulated_idle_callback_delay;
  12196. if (typeof delay === 'number') web_emulated_idle_callback_delay_val = delay;
  12197. return web_emulated_idle_callback_delay_val;
  12198. }
  12199. let isDelayRenderFn_firstCheck = true;
  12200. let isDelayRenderFn_key = null;
  12201. const isDelayRenderFn = (f) => {
  12202. if (!isDelayRenderFn_firstCheck) return (typeof ytglobal === 'undefined' ? false : ((ytglobal || 0).schedulerInstanceInstance_ || 0)[isDelayRenderFn_key] === f);
  12203. isDelayRenderFn_firstCheck = false;
  12204. if (typeof ytglobal === 'undefined') return false;
  12205. const globalInstance = ((ytglobal || 0).schedulerInstanceInstance_ || 0);
  12206. if (!globalInstance) return false;
  12207. for (const entry of Object.entries(Object.getOwnPropertyDescriptors(globalInstance))) {
  12208. if (entry[1].value === f && entry[1].enumerable && entry[1].writable && entry[1].configurable) {
  12209. isDelayRenderFn_key = entry[0]
  12210. console.log('[yt-js-engine-tamer] web_emulated_idle_callback fix applied');
  12211. return true;
  12212. }
  12213. }
  12214. return false;
  12215. }
  12216.  
  12217. schedulerInstanceInstance_.start993 = schedulerInstanceInstance_.start;
  12218.  
  12219. let requestingFn = null;
  12220. let requestingArgs = null;
  12221.  
  12222. const f = function () {
  12223. requestingFn = this.fn;
  12224. requestingArgs = [...arguments];
  12225. return 12373;
  12226. };
  12227.  
  12228. const fakeFns = [
  12229. f.bind({ fn: requestAnimationFrame }),
  12230. f.bind({ fn: setInterval }),
  12231. f.bind({ fn: setTimeout }),
  12232. f.bind({ fn: requestIdleCallback })
  12233. ];
  12234.  
  12235. let mzt = 0;
  12236.  
  12237. let _fnSelectorProp = null;
  12238. const mkFns = new Array(4);
  12239.  
  12240. /*
  12241. case 1:
  12242. var a = this.K;
  12243. this.g = this.I ? window.requestIdleCallback(a, {
  12244. timeout: 3E3
  12245. }) : window.setTimeout(a, ma);
  12246. break;
  12247. case 2:
  12248. this.g = window.setTimeout(this.M, this.N);
  12249. break;
  12250. case 3:
  12251. this.g = window.requestAnimationFrame(this.L);
  12252. break;
  12253. case 4:
  12254. this.g = window.setTimeout(this.J, 0)
  12255. }
  12256.  
  12257. */
  12258. const startFnHandler = {
  12259. get(target, prop, receiver) {
  12260. if (prop === '$$12377$$') return true;
  12261. if (prop === '$$12378$$') return target;
  12262.  
  12263. // console.log('get',prop)
  12264. return target[prop]
  12265. },
  12266. set(target, prop, value, receiver) {
  12267. // console.log('set', prop, value)
  12268.  
  12269.  
  12270. if (value >= 1 && value <= 4) _fnSelectorProp = prop;
  12271. if (value === 12373 && _fnSelectorProp) {
  12272.  
  12273. const schedulerTypeSelection = target[_fnSelectorProp];
  12274. const timerIdProp = prop;
  12275.  
  12276. // console.log(3991, requestingFn, requestingArgs[0], requestingArgs[1])
  12277. // if (schedulerTypeSelection && schedulerTypeSelection >= 1 && schedulerTypeSelection <= 4 && timerIdProp) {
  12278. // schedulerInstancePropOfTimerType = _fnSelectorProp || '';
  12279. // schedulerInstancePropOfTimerId = timerIdProp || '';
  12280. // }
  12281.  
  12282. if (schedulerTypeSelection === 3 && requestingFn === requestAnimationFrame) { // rAF(fn)
  12283. target[timerIdProp] = baseRAF.apply(window, requestingArgs);
  12284. } else if (schedulerTypeSelection === 2 && requestingFn === setTimeout) { // setTimeout(fn, delay)
  12285. // rare
  12286. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  12287. } else if (schedulerTypeSelection === 4 && requestingFn === setTimeout && !requestingArgs[1]) { // setTimeout(fn, 0)
  12288. // often
  12289. if ((FIX_schedulerInstanceInstance & 4)) {
  12290. const f = requestingArgs[0];
  12291. const tir = ++mzt;
  12292. nextBrowserTick_(() => {
  12293. if (target[timerIdProp] === -tir) f();
  12294. });
  12295. target[_fnSelectorProp] = 940;
  12296. target[timerIdProp] = -tir;
  12297. } else {
  12298. const f = requestingArgs[0];
  12299. const tir = ++mzt;
  12300. Promise.resolve().then(() => {
  12301. if (target[timerIdProp] === -tir) f();
  12302. });
  12303. target[_fnSelectorProp] = 930;
  12304. target[timerIdProp] = -tir;
  12305. }
  12306. } else if (schedulerTypeSelection === 1 && (requestingFn === requestIdleCallback || requestingFn === setTimeout)) { // setTimeout(requestIdleCallback)
  12307. // often
  12308. if (requestingFn === requestIdleCallback && (requestingArgs[0] || 0).name === "bound " && (requestingArgs[1] || 0).timeout === 3000 && isDelayRenderFn(requestingArgs[0])) {
  12309. cm.data = (cm.data & 7) + 1;
  12310. let renderFn = requestingArgs[0];
  12311. const resolveRendering_ = () => {
  12312. const renderFn_ = renderFn;
  12313. if (renderFn_) {
  12314. renderFn = null;
  12315. renderFn_();
  12316. }
  12317. };
  12318. resolveRendering = resolveRendering_;
  12319. // console.log(299,requestingArgs[0], requestingArgs[0].name)
  12320. target[timerIdProp] = requestIdleCallback(resolveRendering_, { timeout: 300 });
  12321.  
  12322. // cm.data = (cm.data & 7) + 1;
  12323. // target[timerIdProp] = Math.random();
  12324.  
  12325. } else if (requestingFn === setTimeout && (requestingArgs[0] || 0).name === "bound " && (requestingArgs[1] === getRenderIdleCallbackMs()) && isDelayRenderFn(requestingArgs[0])) {
  12326.  
  12327. cm.data = (cm.data & 7) + 1;
  12328.  
  12329. let renderFn = requestingArgs[0];
  12330. const resolveRendering_ = () => {
  12331. const renderFn_ = renderFn;
  12332. if (renderFn_) {
  12333. renderFn = null;
  12334. renderFn_();
  12335. }
  12336. };
  12337. resolveRendering = resolveRendering_;
  12338.  
  12339. target[timerIdProp] = mkFns[2].call(window, resolveRendering_, 300);
  12340.  
  12341.  
  12342. } else {
  12343. if (requestingFn === requestIdleCallback) {
  12344. target[timerIdProp] = requestIdleCallback.apply(window, requestingArgs);
  12345. } else {
  12346. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  12347. }
  12348. }
  12349. } else {
  12350. target[_fnSelectorProp] = 0;
  12351. target[timerIdProp] = 0;
  12352. }
  12353. } else {
  12354. target[prop] = value;
  12355. }
  12356. return true;
  12357. }
  12358. };
  12359.  
  12360. let startBusy = false;
  12361. schedulerInstanceInstance_.start = function () {
  12362. if (startBusy) return;
  12363. startBusy = true;
  12364. try {
  12365. mkFns[0] = window.requestAnimationFrame;
  12366. mkFns[1] = window.setInterval;
  12367. mkFns[2] = window.setTimeout;
  12368. mkFns[3] = window.requestIdleCallback;
  12369. const tThis = this['$$12378$$'] || this;
  12370. window.requestAnimationFrame = fakeFns[0]
  12371. window.setInterval = fakeFns[1]
  12372. window.setTimeout = fakeFns[2]
  12373. window.requestIdleCallback = fakeFns[3]
  12374. _fnSelectorProp = null;
  12375. tThis.start993.call(new Proxy(tThis, startFnHandler));
  12376. _fnSelectorProp = null;
  12377. window.requestAnimationFrame = mkFns[0];
  12378. window.setInterval = mkFns[1];
  12379. window.setTimeout = mkFns[2];
  12380. window.requestIdleCallback = mkFns[3];
  12381. } catch (e) {
  12382. console.warn(e);
  12383. }
  12384. startBusy = false;
  12385. }
  12386.  
  12387. schedulerInstanceInstance_.start.toString = schedulerInstanceInstance_.start993.toString.bind(schedulerInstanceInstance_.start993);
  12388.  
  12389. }
  12390. })();
  12391.  
  12392. FIX_yt_player && !isChatRoomURL && (async () => {
  12393.  
  12394. const fOption = 1 | 2 | 4;
  12395.  
  12396. const _yt_player = await _yt_player_observable.obtain();
  12397.  
  12398. if (!_yt_player || typeof _yt_player !== 'object') return;
  12399.  
  12400. const g = _yt_player;
  12401. let k;
  12402.  
  12403. if (fOption & 1) {
  12404.  
  12405. // rAf scheduling
  12406.  
  12407. const keyZqOu = getZqOu(_yt_player);
  12408. if (!keyZqOu) {
  12409. console.warn('[yt-js-engine-tamer] FIX_yt_player::keyZqOu error');
  12410. return;
  12411. }
  12412. k = keyZqOu
  12413.  
  12414. const gk = g[k];
  12415. if (typeof gk !== 'function') {
  12416. console.warn('[yt-js-engine-tamer] FIX_yt_player::g[keyZqOu] error');
  12417. return;
  12418. }
  12419. const gkp = gk.prototype;
  12420.  
  12421. const dummyObject = new gk;
  12422. const nilFunc = () => { };
  12423.  
  12424. const nilObj = {};
  12425.  
  12426. // console.log(1111111111)
  12427.  
  12428. let keyBoolD = '';
  12429. let keyWindow = '';
  12430. let keyFuncC = '';
  12431. let keyCidj = '';
  12432.  
  12433. for (const [t, y] of Object.entries(dummyObject)) {
  12434. if (y instanceof Window) keyWindow = t;
  12435. }
  12436.  
  12437. const dummyObjectProxyHandler = {
  12438. get(target, prop) {
  12439. let v = target[prop]
  12440. if (v instanceof Window && !keyWindow) {
  12441. keyWindow = t;
  12442. }
  12443. let y = typeof v === 'function' ? nilFunc : typeof v === 'object' ? nilObj : v;
  12444. if (prop === keyWindow) y = {
  12445. requestAnimationFrame(f) {
  12446. return 3;
  12447. },
  12448. cancelAnimationFrame() {
  12449.  
  12450. }
  12451. }
  12452. if (!keyFuncC && typeof v === 'function' && !(prop in target.constructor.prototype)) {
  12453. keyFuncC = prop;
  12454. }
  12455. // console.log('[get]', prop, typeof target[prop])
  12456.  
  12457.  
  12458. return y;
  12459. },
  12460. set(target, prop, value) {
  12461.  
  12462. if (typeof value === 'boolean' && !keyBoolD) {
  12463. keyBoolD = prop;
  12464. }
  12465. if (typeof value === 'number' && !keyCidj && value >= 2) {
  12466. keyCidj = prop;
  12467. }
  12468.  
  12469. // console.log('[set]', prop, value)
  12470. target[prop] = value;
  12471.  
  12472. return true;
  12473. }
  12474. };
  12475.  
  12476. dummyObject.start.call(new Proxy(dummyObject, dummyObjectProxyHandler));
  12477.  
  12478. // console.log('gkp.start',gkp.start);
  12479. // console.log('gkp.stop',gkp.stop);
  12480. gkp._activation = false;
  12481.  
  12482. gkp.start = function () {
  12483. // p59 || console.log(12100)
  12484. if (!this._activation) {
  12485. this._activation = true;
  12486. foregroundPromiseFn().then(() => {
  12487. this._activation = false;
  12488. if (this[keyCidj]) {
  12489. Promise.resolve().then(this[keyFuncC]);
  12490. }
  12491. });
  12492. }
  12493. this[keyCidj] = 1;
  12494. this[keyBoolD] = true;
  12495. };
  12496.  
  12497. gkp.stop = function () {
  12498. this[keyCidj] = null;
  12499. };
  12500.  
  12501.  
  12502. /*
  12503. g[k].start = function() {
  12504. this.stop();
  12505. this.D = true;
  12506. var a = requestAnimationFrame
  12507. , b = cancelAnimationFrame;
  12508. this.j = a.call(this.B, this.C)
  12509. }
  12510. ;
  12511. g[k].stop = function() {
  12512. if (this.isActive()) {
  12513. var a = requestAnimationFrame
  12514. , b = cancelAnimationFrame;
  12515. b.call(this.B, this.j)
  12516. }
  12517. this.j = null
  12518. }
  12519. */
  12520. }
  12521.  
  12522. if (fOption & 2) {
  12523. const keyzo = PERF_471489_ ? getzo(_yt_player) : null;
  12524.  
  12525. if (keyzo) {
  12526.  
  12527. k = keyzo;
  12528.  
  12529. const attrUpdateFn = g[k];
  12530. // console.log(5992, attrUpdateFn)
  12531. g['$$original$$' + k] = attrUpdateFn;
  12532. const zoTransform = async (a, c) => {
  12533.  
  12534. let transformType = '';
  12535. let transformValue = 0;
  12536. let transformUnit = '';
  12537. let transformTypeI = 0;
  12538.  
  12539. const aStyle = a.style;
  12540.  
  12541. let cType = 0;
  12542.  
  12543. const cl = c.length;
  12544.  
  12545. if (cl >= 8) {
  12546. // scale(1)
  12547. if (c.startsWith('scale') && c.charCodeAt(6) === 40 && c.charCodeAt(cl - 1) === 41) {
  12548. cType = 1;
  12549. let t = c.charCodeAt(5);
  12550. if (t === 88 || t === 120) cType = 1 | 4;
  12551. if (t === 89 || t === 121) cType = 1 | 8;
  12552. } else if (c.startsWith('translate') && c.charCodeAt(10) === 40 && c.charCodeAt(cl - 1) === 41) {
  12553. cType = 2;
  12554. let t = c.charCodeAt(9);
  12555. if (t === 88 || t === 120) cType = 2 | 4;
  12556. if (t === 89 || t === 121) cType = 2 | 8;
  12557. }
  12558. let w = 0;
  12559. if (w = (cType === 5) ? 1 : (cType === 9) ? 2 : 0) {
  12560. let p = c.substring(7, cl - 1);
  12561. let q = p.length >= 1 ? parseFloat(p) : NaN;
  12562. if (typeof q === 'number' && !isNaNx(q)) {
  12563. transformType = w === 1 ? 'scaleX' : 'scaleY';
  12564. transformValue = q;
  12565. transformUnit = '';
  12566. transformTypeI = 1;
  12567. } else {
  12568. cType = 256;
  12569. }
  12570. } else if (w = (cType === 6) ? 1 : (cType === 10) ? 2 : 0) {
  12571. if (c.endsWith('px)')) {
  12572. let p = c.substring(11, cl - 3);
  12573. let q = p.length >= 1 ? parseFloat(p) : NaN;
  12574. if (typeof q === 'number' && !isNaNx(q)) {
  12575. transformType = w === 1 ? 'translateX' : 'translateY';
  12576. transformValue = q;
  12577. transformUnit = 'px';
  12578. transformTypeI = 2;
  12579. } else if (p === 'NaN') {
  12580. return;
  12581. }
  12582. } else {
  12583. cType = 256;
  12584. }
  12585. } else if (cType > 0) {
  12586. cType = 256;
  12587. }
  12588. }
  12589.  
  12590.  
  12591. if (cType === 256) {
  12592. console.log('[yt-js-engine-tamer] zoTransform undefined', c);
  12593. }
  12594.  
  12595. if (transformTypeI === 1) {
  12596. const q = Math.round(transformValue * steppingScaleN) / steppingScaleN;
  12597. const vz = toFixed2(q, 3);
  12598. c = `${transformType}(${vz})`;
  12599. const cv = aStyle.transform;
  12600. if (c === cv) return;
  12601. aStyle.transform = c;
  12602. } else if (transformTypeI === 2) {
  12603. const q = transformValue;
  12604. const vz = toFixed2(q, 1);
  12605. c = `${transformType}(${vz}${transformUnit})`;
  12606. const cv = aStyle.transform;
  12607. if (c === cv) return;
  12608. aStyle.transform = c;
  12609. } else { // eg empty
  12610. const cv = aStyle.transform;
  12611. if (!c && !cv) return;
  12612. else if (c === cv) return;
  12613. aStyle.transform = c;
  12614. }
  12615.  
  12616. };
  12617.  
  12618. const elmTransformTemp = new WeakMap();
  12619. const elmPropTemps = {
  12620. 'display': new WeakMap(),
  12621. 'width': new WeakMap(),
  12622. 'height': new WeakMap(),
  12623. 'outlineWidth': new WeakMap(),
  12624. 'position': new WeakMap(),
  12625. 'padding': new WeakMap(),
  12626. "cssText": new WeakMap(),
  12627. "right": new WeakMap(),
  12628. "left": new WeakMap(),
  12629. "top": new WeakMap(),
  12630. "bottom": new WeakMap(),
  12631. "transitionDelay": new WeakMap(),
  12632. "marginLeft": new WeakMap(),
  12633. "marginTop": new WeakMap(),
  12634. "marginRight": new WeakMap(),
  12635. "marginBottom": new WeakMap(),
  12636. }
  12637.  
  12638. const ns5 = Symbol();
  12639. const nextModify = (a, c, m, f, immediate) => {
  12640. const a_ = a;
  12641. const m_ = m;
  12642. const noKey = !m_.has(a_);
  12643. if (immediate || noKey) {
  12644. m_.set(a_, ns5);
  12645. f(a_, c);
  12646. noKey && nextBrowserTick_(() => {
  12647. const d = m_.get(a_);
  12648. if (d === undefined) return;
  12649. m_.delete(a_);
  12650. if (d !== ns5) f(a_, d);
  12651. });
  12652. } else {
  12653. m_.set(a_, c);
  12654. }
  12655. };
  12656.  
  12657. const set66 = new Set();
  12658. const log77 = new Map();
  12659. // const set77 = new Set(['top', 'left', 'bottom', 'right']); // caption positioning - immediate change
  12660.  
  12661. const modifiedFn = function (a, b, c, immediateChange = false) { // arrow function does not have function.prototype
  12662.  
  12663. // console.log(140000, a, b, c);
  12664. if (typeof c === 'number' && typeof b === 'string' && a instanceof HTMLElement_) {
  12665. const num = c;
  12666. c = `${num}`;
  12667. if (c.length > 5) c = (num < 10 && num > -10) ? toFixed2(num, 3) : toFixed2(num, 1);
  12668. }
  12669.  
  12670. if (typeof b === 'string' && typeof c === 'string' && a instanceof HTMLElement_) {
  12671.  
  12672. let elmPropTemp = null;
  12673.  
  12674. if (b === "transform") {
  12675. // div.ytp-hover-progress.ytp-hover-progress-light
  12676. // div.ytp-play-progress.ytp-swatch-background-color
  12677.  
  12678. nextModify(a, c, elmTransformTemp, zoTransform, immediateChange);
  12679. return;
  12680.  
  12681. } else if (elmPropTemp = elmPropTemps[b]) {
  12682.  
  12683. // if (c.length > 5 && c.includes('.')) {
  12684. // console.log(123213, c)
  12685. // }
  12686.  
  12687. const b_ = b;
  12688. nextModify(a, c, elmPropTemp, (a, c) => {
  12689. const style = a.style;
  12690. const cv = style[b_];
  12691. if (!cv && !c) return;
  12692. if (cv === c) return;
  12693. style[b_] = c;
  12694. }, immediateChange);
  12695. return;
  12696.  
  12697. } else if (b === "outline-width") {
  12698.  
  12699. const b_ = 'outlineWidth';
  12700. elmPropTemp = elmPropTemps[b_];
  12701. nextModify(a, c, elmPropTemp, (a, c) => {
  12702. const style = a.style;
  12703. const cv = style[b_];
  12704. if (!cv && !c) return;
  12705. if (cv === c) return;
  12706. style[b_] = c;
  12707. }, immediateChange);
  12708. return;
  12709.  
  12710. } else if (b === 'maxWidth' || b === 'maxHeight') {
  12711. // I think these can be directly assigned.
  12712.  
  12713. const b_ = b;
  12714. const style = a.style;
  12715. const cv = style[b_];
  12716. if (!cv && !c) return;
  12717. if (cv === c) return;
  12718. style[b_] = c;
  12719. return;
  12720.  
  12721. } else {
  12722. // if(immediate && elmPropTemps[b]){
  12723. // console.log(5191, b)
  12724. // }
  12725. // caption-window
  12726. // margin-left max-height max-width font-family fill color font-size background white-space margin
  12727. // text-align background-color
  12728. // console.log(27304, a, b, c)
  12729. if (!set66.has(b)) {
  12730. set66.add(b);
  12731. nextBrowserTick_(() => {
  12732. if (!a.classList.contains('caption-window') && !a.classList.contains('ytp-caption-segment')) {
  12733. console.log(27304, a, b, c)
  12734. }
  12735. })
  12736. }
  12737. }
  12738.  
  12739. attrUpdateFn.call(this, a, b, c);
  12740. return;
  12741. } else if (typeof (b || 0) === 'object') {
  12742.  
  12743. // this is to fix caption positioning
  12744. // const immediate = (a.id || 0).length > 14 && (('top' in b) || ('left' in b) || ('right' in b) || ('bottom' in b));
  12745. const immediate = (a.id || 0).length > 14;
  12746. for (const [k, v] of Object.entries(b)) {
  12747. modifiedFn.call(this, a, k, v, immediate);
  12748. }
  12749.  
  12750. } else {
  12751.  
  12752. // a = circle, b = stroke-dasharray, c= "1.8422857142857143 32"
  12753. // ytp-ad-timed-pie-countdown-inner
  12754.  
  12755. if (typeof b === 'string') {
  12756.  
  12757. let m = log77.get(b);
  12758. if (!m) {
  12759. m = [];
  12760. console.log('attrUpdateFn.debug.27304', m);
  12761. log77.set(b, m);
  12762. }
  12763. m.push([a, b, c]);
  12764.  
  12765. } else {
  12766. console.log('attrUpdateFn.debug.27306', a, b, c);
  12767. }
  12768.  
  12769. attrUpdateFn.call(this, a, b, c);
  12770. return;
  12771. }
  12772.  
  12773. // console.log(130000, a, b, c);
  12774.  
  12775. };
  12776. g[k] = modifiedFn;
  12777.  
  12778.  
  12779. /*
  12780.  
  12781. g.zo = function(a, b, c) {
  12782. if ("string" === typeof b)
  12783. (b = yo(a, b)) && (a.style[b] = c);
  12784. else
  12785. for (var d in b) {
  12786. c = a;
  12787. var e = b[d]
  12788. , f = yo(c, d);
  12789. f && (c.style[f] = e)
  12790. }
  12791. }
  12792.  
  12793.  
  12794. */
  12795.  
  12796.  
  12797. }
  12798. }
  12799.  
  12800. if (fOption & 4) {
  12801. const keyuG = PERF_471489_ ? getuG(_yt_player) : null;
  12802.  
  12803. if (keyuG) {
  12804.  
  12805. k = keyuG;
  12806.  
  12807. const gk = g[k];
  12808. const gkp = gk.prototype;
  12809.  
  12810.  
  12811. /** @type { Map<string, WeakMap<any, any>> } */
  12812. const ntLogs = new Map();
  12813.  
  12814. if (typeof gkp.updateValue === 'function' && gkp.updateValue.length === 2 && !gkp.updateValue31) {
  12815.  
  12816. gkp.updateValue31 = gkp.updateValue;
  12817. gkp.updateValue = function (a, b) {
  12818. if (typeof a !== 'string') return this.updateValue31(a, b);
  12819.  
  12820. const element = this.element;
  12821. if (!(element instanceof HTMLElement_)) return this.updateValue31(a, b);
  12822.  
  12823. let ntLog = ntLogs.get(a);
  12824. if (!ntLog) ntLogs.set(a, (ntLog = new WeakMap()));
  12825.  
  12826. let cache = ntLog.get(element);
  12827. if (cache && cache.value === b) {
  12828. return;
  12829. }
  12830. if (!cache) {
  12831. this.__oldValueByUpdateValue__ = null;
  12832. ntLog.set(element, cache = { value: b });
  12833. } else {
  12834. this.__oldValueByUpdateValue__ = cache.value;
  12835. cache.value = b;
  12836. }
  12837.  
  12838. return this.updateValue31(a, b);
  12839. }
  12840.  
  12841. /*
  12842. g.k.update = function(a) {
  12843. for (var b = g.u(Object.keys(a)), c = b.next(); !c.done; c = b.next())
  12844. c = c.value,
  12845. this.updateValue(c, a[c])
  12846. }
  12847. ;
  12848. g.k.updateValue = function(a, b) {
  12849. (a = this.Td["{{" + a + "}}"]) && wG(this, a[0], a[1], b)
  12850. }
  12851. */
  12852.  
  12853. }
  12854.  
  12855.  
  12856. }
  12857. }
  12858.  
  12859.  
  12860.  
  12861. })();
  12862.  
  12863.  
  12864. FIX_yt_player && !isChatRoomURL && FIX_SHORTCUTKEYS > 0 && (async () => {
  12865. // keyboard shortcut keys controller
  12866.  
  12867. const _yt_player = await _yt_player_observable.obtain();
  12868.  
  12869. if (!_yt_player || typeof _yt_player !== 'object') return;
  12870.  
  12871. keyboardController(_yt_player);
  12872.  
  12873. })();
  12874.  
  12875. FIX_yt_player && !isChatRoomURL && (async () => {
  12876. // timer scheduling
  12877.  
  12878. const _yt_player = await _yt_player_observable.obtain();
  12879.  
  12880. if (!_yt_player || typeof _yt_player !== 'object') return;
  12881.  
  12882. let keyZqQu = getZqQu(_yt_player);
  12883.  
  12884. if (!keyZqQu) return;
  12885.  
  12886. const g = _yt_player
  12887. let k = keyZqQu
  12888.  
  12889. const gk = g[k];
  12890. if (typeof gk !== 'function') return;
  12891. const gkp = gk.prototype;
  12892.  
  12893. const extractKeysZqQu = () => {
  12894.  
  12895.  
  12896. let _keyeC = '';
  12897. try {
  12898. gkp.stop.call(new Proxy({
  12899. isActive: () => { }
  12900. }, {
  12901. set(target, prop, value) {
  12902. if (value === 0) _keyeC = prop;
  12903. return true;
  12904. }
  12905. }));
  12906. } catch (e) { }
  12907. if (!_keyeC) return;
  12908. const keyeC = _keyeC;
  12909.  
  12910. let keyC = ''; // this.C = this.ST.bind(this)
  12911. let keyhj = ''; // 1000ms
  12912. try {
  12913. gkp.start.call(new Proxy({
  12914. stop: () => { },
  12915. [keyeC]: 0,
  12916. }, {
  12917. get(target, prop) {
  12918. if (prop in target) return target[prop];
  12919. if (!keyC) {
  12920. keyC = prop;
  12921. return null; // throw error
  12922. }
  12923. else if (!keyhj) {
  12924. keyhj = prop;
  12925. }
  12926.  
  12927. }
  12928. }));
  12929. } catch (e) {
  12930. if (!keyC || !keyhj) {
  12931. console.log(e)
  12932. }
  12933. }
  12934.  
  12935. if (!keyC || !keyhj) return;
  12936. let keyST = '';
  12937. let keyj = '';
  12938. let keyB = '';
  12939. let keyxa = '';
  12940.  
  12941. const possibleKs = new Set();
  12942.  
  12943. for (const [k, v] of Object.entries(gkp)) {
  12944. if (k === 'stop' || k === 'start' || k === 'isActive' || k === 'constructor' || k === keyeC || k === keyC || k === keyhj) {
  12945. continue;
  12946. }
  12947. if (typeof v === 'function') {
  12948. const m = /this\.(\w+)\.call\(this\.(\w+)\)/.exec(v + '');
  12949. if (m) {
  12950. keyST = k;
  12951. keyj = m[1];
  12952. keyB = m[2];
  12953. } else {
  12954. possibleKs.add(k);
  12955. }
  12956. }
  12957. }
  12958.  
  12959. if (!keyST || !keyj || !keyB) return;
  12960.  
  12961. for (const k of possibleKs) {
  12962. if (k === keyST || k === keyj || k === keyB) {
  12963. continue;
  12964. }
  12965. const v = gkp[k];
  12966. if (typeof v === 'function' && (v + '').includes(`this.stop();delete this.${keyj};delete this.${keyB}`)) {
  12967. keyxa = k;
  12968. }
  12969. }
  12970.  
  12971. return [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa];
  12972.  
  12973. }
  12974.  
  12975. const keys = extractKeysZqQu();
  12976. if (!keys || !keys.length) return;
  12977. const [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa] = keys; // [timerId, binded executorFn, 1000ms, executorFn, dataJ, objectB, disposeFn]
  12978.  
  12979. if (!keyeC || !keyC || !keyhj || !keyST || !keyj || !keyB || !keyxa) return;
  12980.  
  12981. let disposeKeys = null;
  12982.  
  12983. gkp[keyxa] = function () {
  12984. // dispose
  12985. if (!disposeKeys) {
  12986. disposeKeys = Object.getOwnPropertyNames(this).filter(key => {
  12987. if (key != keyeC && key != keyC && key != keyhj && key != keyST && key != keyj && key != keyB && key != keyxa) {
  12988. const t = typeof this[key];
  12989. return t === 'undefined' || t === 'object'
  12990. }
  12991. return false;
  12992. });
  12993. }
  12994. for (const key of disposeKeys) {
  12995. const v = this[key];
  12996. if ((v || 0).length >= 1) v.length = 0; // function (){if(this.fn)for(;this.fn.length;)this.fn.shift()()}
  12997. }
  12998. if (this[keyeC] > 0) this.stop();
  12999. this[keyj] = null;
  13000. this[keyB] = null;
  13001. };
  13002.  
  13003. gkp.start = function (a) {
  13004. if (this[keyeC] > 0) this.stop();
  13005. const delay = void 0 !== a ? a : this[keyhj];
  13006. this[keyeC] = window.setTimeout(this[keyC], delay);
  13007. };
  13008. gkp.stop = function () {
  13009. if (this[keyeC] > 0) {
  13010. window.clearTimeout(this[keyeC]);
  13011. this[keyeC] = 0;
  13012. }
  13013. };
  13014.  
  13015. gkp.isActive = function () {
  13016. return this[keyeC] > 0;
  13017. };
  13018.  
  13019. gkp[keyST] = function () {
  13020. this.stop(); // this[keyeC] = 0;
  13021. const fn = this[keyj];
  13022. const obj = this[keyB];
  13023. let skip = false;
  13024. if (!fn) skip = true;
  13025. else if (IGNORE_bufferhealth_CHECK && obj) {
  13026. let m;
  13027. if ((m = obj[keyC]) instanceof Map || (m = obj[keyj]) instanceof Map) {
  13028. if (m.has("bufferhealth")) skip = true;
  13029. }
  13030. }
  13031. if (!skip) {
  13032. fn.call(obj);
  13033. }
  13034. };
  13035.  
  13036.  
  13037.  
  13038.  
  13039. /*
  13040.  
  13041. g.k.eC = 0;
  13042. g.k.xa = function() {
  13043. g.Qu.Vf.xa.call(this);
  13044. this.stop();
  13045. delete this.j;
  13046. delete this.B
  13047. }
  13048. ;
  13049. g.k.start = function(a) {
  13050. this.stop();
  13051. this.eC = g.gg(this.C, void 0 !== a ? a : this.hj)
  13052. }
  13053. ;
  13054. g.k.stop = function() {
  13055. this.isActive() && g.Sa.clearTimeout(this.eC);
  13056. this.eC = 0
  13057. }
  13058. ;
  13059. g.k.isActive = function() {
  13060. return 0 != this.eC
  13061. }
  13062. ;
  13063. g.k.ST = function() {
  13064. this.eC = 0;
  13065. this.j && this.j.call(this.B)
  13066. }
  13067. ;
  13068. */
  13069.  
  13070.  
  13071.  
  13072.  
  13073. })();
  13074.  
  13075. FIX_Animation_n_timeline && (async () => {
  13076.  
  13077. const [timeline, Animation] = await Promise.all([timelineObservable.obtain(), animationObservable.obtain()]);
  13078.  
  13079. if (!timeline || !Animation) return;
  13080.  
  13081. const animationsFix = (timeline) => {
  13082. const animations = (timeline || 0)._animations || 0;
  13083. const c = animations[0];
  13084. if (c) {
  13085. if (c && !c.id && c._isGroup === false && c._holdTime === 0 && c._paused === false && !c._callback && Number.isNaN(c._sequenceNumber) && c.effect.target instanceof HTMLCanvasElement) {
  13086. animations.shift(); // keep animating but no looping
  13087. // c.effect.remove();
  13088. }
  13089. }
  13090. }
  13091.  
  13092. const aniProto = Animation.prototype;
  13093. // aniProto.sequenceNumber = 0; // native YouTube engine bug - sequenceNumber is not set
  13094.  
  13095. const getXroto = (x) => {
  13096. try {
  13097. return x.__proto__;
  13098. } catch (e) { }
  13099. return null;
  13100. }
  13101. const timProto = getXroto(timeline);
  13102. if (!timProto) return;
  13103. if (
  13104. (
  13105. typeof timProto.getAnimations === 'function' && typeof timProto.play === 'function' &&
  13106. typeof timProto._discardAnimations === 'function' && typeof timProto._play === 'function' &&
  13107. typeof timProto._updateAnimationsPromises === 'function' && !timProto.nofCQ &&
  13108. typeof aniProto._updatePromises === 'function' && !aniProto.nofYH
  13109. )
  13110.  
  13111. ) {
  13112.  
  13113. timProto.nofCQ = 1;
  13114. aniProto.nofYH = 1;
  13115.  
  13116. const originalAnimationsWithPromises = ((_updateAnimationsPromises) => {
  13117.  
  13118.  
  13119. /*
  13120. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  13121. return c._updatePromises();
  13122. });
  13123. */
  13124.  
  13125. const p = Array.prototype.filter;
  13126.  
  13127. let res = null;
  13128. Array.prototype.filter = function () {
  13129.  
  13130. res = this;
  13131. return this;
  13132.  
  13133. };
  13134.  
  13135. _updateAnimationsPromises.call({});
  13136.  
  13137. Array.prototype.filter = p;
  13138.  
  13139. if (res && typeof res.length === 'number') {
  13140. /** @type {any[]} */
  13141. const _res = res;
  13142. return _res;
  13143. }
  13144.  
  13145.  
  13146. return null;
  13147.  
  13148.  
  13149.  
  13150.  
  13151. })(timProto._updateAnimationsPromises);
  13152.  
  13153. if (!originalAnimationsWithPromises || typeof originalAnimationsWithPromises.length !== 'number') return;
  13154.  
  13155. // console.log('originalAnimationsWithPromises', originalAnimationsWithPromises)
  13156.  
  13157. aniProto._updatePromises31 = aniProto._updatePromises;
  13158.  
  13159. /*
  13160. aniProto._updatePromises = function(){
  13161. console.log('eff',this._oldPlayState, this.playState)
  13162. return this._updatePromises31.apply(this, arguments)
  13163. }
  13164. */
  13165.  
  13166. aniProto._updatePromises = function () {
  13167. var oldPlayState = this._oldPlayState;
  13168. var newPlayState = this.playState;
  13169. // console.log('ett', oldPlayState, newPlayState)
  13170. if (newPlayState !== oldPlayState) {
  13171. this._oldPlayState = newPlayState;
  13172. if (this._readyPromise) {
  13173. if ("idle" == newPlayState) {
  13174. this._rejectReadyPromise();
  13175. this._readyPromise = void 0;
  13176. } else if ("pending" == oldPlayState) {
  13177. this._resolveReadyPromise();
  13178. } else if ("pending" == newPlayState) {
  13179. this._readyPromise = void 0;
  13180. }
  13181. }
  13182. if (this._finishedPromise) {
  13183. if ("idle" == newPlayState) {
  13184. this._rejectFinishedPromise();
  13185. this._finishedPromise = void 0;
  13186. } else if ("finished" == newPlayState) {
  13187. this._resolveFinishedPromise();
  13188. } else if ("finished" == oldPlayState) {
  13189. this._finishedPromise = void 0;
  13190. }
  13191. }
  13192. }
  13193. return this._readyPromise || this._finishedPromise;
  13194. };
  13195.  
  13196.  
  13197. let restartWebAnimationsNextTickFlag = false;
  13198.  
  13199. const looperMethodT = () => {
  13200.  
  13201. const runnerFn = (hRes) => {
  13202. var b = timeline;
  13203. b.currentTime = hRes;
  13204. b._discardAnimations();
  13205. FIX_Animation_n_timeline_cinematic && animationsFix(b);
  13206. if (0 == b._animations.length) {
  13207. restartWebAnimationsNextTickFlag = false;
  13208. } else {
  13209. getRafPromise().then(runnerFn);
  13210. }
  13211. }
  13212.  
  13213. const restartWebAnimationsNextTick = () => {
  13214. if (!restartWebAnimationsNextTickFlag) {
  13215. restartWebAnimationsNextTickFlag = true;
  13216. getRafPromise().then(runnerFn);
  13217. }
  13218. }
  13219.  
  13220. return { restartWebAnimationsNextTick }
  13221. };
  13222.  
  13223.  
  13224. const looperMethodN = () => {
  13225.  
  13226. const acs = document.createElement('a-f');
  13227. acs.id = 'a-f';
  13228.  
  13229. if (!document.getElementById('afscript')) {
  13230. const style = document.createElement('style');
  13231. style.id = 'afscript';
  13232. style.textContent = `
  13233. @keyFrames aF1 {
  13234. 0% {
  13235. order: 0;
  13236. }
  13237. 100% {
  13238. order: 1;
  13239. }
  13240. }
  13241. #a-f[id] {
  13242. visibility: collapse !important;
  13243. position: fixed !important;
  13244. display: block !important;
  13245. top: -100px !important;
  13246. left: -100px !important;
  13247. margin:0 !important;
  13248. padding:0 !important;
  13249. outline:0 !important;
  13250. border:0 !important;
  13251. z-index:-1 !important;
  13252. width: 0px !important;
  13253. height: 0px !important;
  13254. contain: strict !important;
  13255. pointer-events: none !important;
  13256. animation: 1ms steps(2, jump-none) 0ms infinite alternate forwards running aF1 !important;
  13257. }
  13258. `;
  13259. (document.head || document.documentElement).appendChild(style);
  13260. }
  13261.  
  13262. document.documentElement.insertBefore(acs, document.documentElement.firstChild);
  13263.  
  13264. const _onanimationiteration = function (evt) {
  13265. const hRes = evt.timeStamp;
  13266. var b = timeline;
  13267. b.currentTime = hRes;
  13268. b._discardAnimations();
  13269. FIX_Animation_n_timeline_cinematic && animationsFix(b);
  13270. if (0 == b._animations.length) {
  13271. restartWebAnimationsNextTickFlag = false;
  13272. acs.onanimationiteration = null;
  13273. } else {
  13274. acs.onanimationiteration = _onanimationiteration;
  13275. }
  13276.  
  13277. }
  13278.  
  13279.  
  13280.  
  13281. const restartWebAnimationsNextTick = () => {
  13282. if (!restartWebAnimationsNextTickFlag) {
  13283. restartWebAnimationsNextTickFlag = true;
  13284. acs.onanimationiteration = _onanimationiteration;
  13285.  
  13286. }
  13287. }
  13288.  
  13289. return { restartWebAnimationsNextTick }
  13290. };
  13291.  
  13292.  
  13293.  
  13294. const { restartWebAnimationsNextTick } = ('onanimationiteration' in document.documentElement) ? looperMethodN() : looperMethodT();
  13295.  
  13296.  
  13297. // console.log(571, timProto);
  13298. timProto._play = function (c) {
  13299. c = new Animation(c, this);
  13300. this._animations.push(c);
  13301. restartWebAnimationsNextTick();
  13302. c._updatePromises();
  13303. c._animation.play();
  13304. c._updatePromises();
  13305. return c
  13306. }
  13307.  
  13308. const animationsWithPromisesMap = new Set(originalAnimationsWithPromises);
  13309. originalAnimationsWithPromises.length = 0;
  13310. originalAnimationsWithPromises.push = null;
  13311. originalAnimationsWithPromises.splice = null;
  13312. originalAnimationsWithPromises.slice = null;
  13313. originalAnimationsWithPromises.indexOf = null;
  13314. originalAnimationsWithPromises.unshift = null;
  13315. originalAnimationsWithPromises.shift = null;
  13316. originalAnimationsWithPromises.pop = null;
  13317. originalAnimationsWithPromises.filter = null;
  13318. originalAnimationsWithPromises.forEach = null;
  13319. originalAnimationsWithPromises.map = null;
  13320.  
  13321.  
  13322. const _updateAnimationsPromises = () => {
  13323. animationsWithPromisesMap.forEach(c => {
  13324. if (!c._updatePromises()) animationsWithPromisesMap.delete(c);
  13325. });
  13326. /*
  13327. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  13328. return c._updatePromises();
  13329. });
  13330. */
  13331. }
  13332.  
  13333. timProto._updateAnimationsPromises31 = timProto._updateAnimationsPromises;
  13334.  
  13335. timProto._updateAnimationsPromises = _updateAnimationsPromises;
  13336.  
  13337. delete timProto._updateAnimationsPromises;
  13338. Object.defineProperty(timProto, '_updateAnimationsPromises', {
  13339. get() {
  13340. if (animationsWithPromisesMap.size === 0) return nilFn;
  13341. return _updateAnimationsPromises;
  13342. },
  13343. set(nv) {
  13344. delete this._updateAnimationsPromises;
  13345. this._updateAnimationsPromises = nv;
  13346. },
  13347. enumerable: true,
  13348. configurable: true,
  13349. });
  13350.  
  13351.  
  13352. let pdFinished = Object.getOwnPropertyDescriptor(aniProto, 'finished');
  13353. aniProto.__finished_native_get__ = pdFinished.get;
  13354. if (typeof pdFinished.get === 'function' && !pdFinished.set && pdFinished.configurable === true && pdFinished.enumerable === true) {
  13355.  
  13356.  
  13357. Object.defineProperty(aniProto, 'finished', {
  13358. get() {
  13359. this._finishedPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  13360. this._finishedPromise = new Promise((resolve, reject) => {
  13361. this._resolveFinishedPromise = function () {
  13362. resolve(this)
  13363. };
  13364. this._rejectFinishedPromise = function () {
  13365. reject({
  13366. type: DOMException.ABORT_ERR,
  13367. name: "AbortError"
  13368. })
  13369. };
  13370. }),
  13371. "finished" == this.playState && this._resolveFinishedPromise());
  13372. return this._finishedPromise
  13373. },
  13374. set: undefined,
  13375. enumerable: true,
  13376. configurable: true
  13377. });
  13378.  
  13379. }
  13380.  
  13381.  
  13382.  
  13383. let pdReady = Object.getOwnPropertyDescriptor(aniProto, 'ready');
  13384. aniProto.__ready_native_get__ = pdReady.get;
  13385. if (typeof pdReady.get === 'function' && !pdReady.set && pdReady.configurable === true && pdReady.enumerable === true) {
  13386.  
  13387. Object.defineProperty(aniProto, 'ready', {
  13388. get() {
  13389. this._readyPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  13390. this._readyPromise = new Promise((resolve, reject) => {
  13391. this._resolveReadyPromise = function () {
  13392. resolve(this)
  13393. };
  13394. this._rejectReadyPromise = function () {
  13395. reject({
  13396. type: DOMException.ABORT_ERR,
  13397. name: "AbortError"
  13398. })
  13399. };
  13400. }),
  13401. "pending" !== this.playState && this._resolveReadyPromise());
  13402. return this._readyPromise
  13403. },
  13404. set: undefined,
  13405. enumerable: true,
  13406. configurable: true
  13407. });
  13408.  
  13409. }
  13410.  
  13411.  
  13412. if (IGNORE_bindAnimationForCustomEffect && typeof aniProto._rebuildUnderlyingAnimation === 'function' && !aniProto._rebuildUnderlyingAnimation21 && aniProto._rebuildUnderlyingAnimation.length === 0) {
  13413.  
  13414. aniProto._rebuildUnderlyingAnimation21 = aniProto._rebuildUnderlyingAnimation;
  13415. const _rebuildUnderlyingAnimation = function () {
  13416. // if (isNaN(this._sequenceNumber)) return; // do not rebuild underlying animation if native animation is used.
  13417. this.effect && this.effect._onsample && (this.effect._onsample = null);
  13418. return this._rebuildUnderlyingAnimation21();
  13419. }
  13420. aniProto._rebuildUnderlyingAnimation = _rebuildUnderlyingAnimation;
  13421. // delete aniProto._rebuildUnderlyingAnimation;
  13422. // Object.defineProperty(aniProto, '_rebuildUnderlyingAnimation', {
  13423. // get() {
  13424. // if (isNaN(this._sequenceNumber)) return nilFn;
  13425. // return this._rebuildUnderlyingAnimation21;
  13426. // },
  13427. // set(nv) {
  13428. // delete this._rebuildUnderlyingAnimation;
  13429. // this._rebuildUnderlyingAnimation = nv;
  13430. // },
  13431. // enumerable: true,
  13432. // configurable: true
  13433. // });
  13434. }
  13435.  
  13436.  
  13437. /*
  13438.  
  13439.  
  13440. function f(c) {
  13441. var b = v.timeline;
  13442. b.currentTime = c;
  13443. b._discardAnimations();
  13444. 0 == b._animations.length ? d = !1 : requestAnimationFrame(f)
  13445. }
  13446. var h = window.requestAnimationFrame;
  13447. window.requestAnimationFrame = function(c) {
  13448. return h(function(b) {
  13449. v.timeline._updateAnimationsPromises();
  13450. c(b);
  13451. v.timeline._updateAnimationsPromises()
  13452. })
  13453. }
  13454. ;
  13455. v.AnimationTimeline = function() {
  13456. this._animations = [];
  13457. this.currentTime = void 0
  13458. }
  13459. ;
  13460. v.AnimationTimeline.prototype = {
  13461. getAnimations: function() {
  13462. this._discardAnimations();
  13463. return this._animations.slice()
  13464. },
  13465. _updateAnimationsPromises: function() {
  13466. v.animationsWithPromises = v.animationsWithPromises.filter(function(c) {
  13467. return c._updatePromises()
  13468. })
  13469. },
  13470. _discardAnimations: function() {
  13471. this._updateAnimationsPromises();
  13472. this._animations = this._animations.filter(function(c) {
  13473. return "finished" != c.playState && "idle" != c.playState
  13474. })
  13475. },
  13476. _play: function(c) {
  13477. c = new v.Animation(c,this);
  13478. this._animations.push(c);
  13479. v.restartWebAnimationsNextTick();
  13480. c._updatePromises();
  13481. c._animation.play();
  13482. c._updatePromises();
  13483. return c
  13484. },
  13485. play: function(c) {
  13486. c && c.remove();
  13487. return this._play(c)
  13488. }
  13489. };
  13490. var d = !1;
  13491. v.restartWebAnimationsNextTick = function() {
  13492. d || (d = !0,
  13493. requestAnimationFrame(f))
  13494. }
  13495. ;
  13496. var a = new v.AnimationTimeline;
  13497. v.timeline = a;
  13498. try {
  13499. Object.defineProperty(window.document, "timeline", {
  13500. configurable: !0,
  13501. get: function() {
  13502. return a
  13503. }
  13504. })
  13505. } catch (c) {}
  13506. try {
  13507. window.document.timeline = a
  13508. } catch (c) {}
  13509.  
  13510. */
  13511.  
  13512.  
  13513.  
  13514. /*
  13515.  
  13516. var g = window.getComputedStyle;
  13517. Object.defineProperty(window, "getComputedStyle", {
  13518. configurable: !0,
  13519. enumerable: !0,
  13520. value: function() {
  13521. v.timeline._updateAnimationsPromises();
  13522. var e = g.apply(this, arguments);
  13523. h() && (e = g.apply(this, arguments));
  13524. v.timeline._updateAnimationsPromises();
  13525. return e
  13526. }
  13527. });
  13528.  
  13529. */
  13530.  
  13531.  
  13532.  
  13533.  
  13534. }
  13535.  
  13536.  
  13537.  
  13538.  
  13539. })();
  13540.  
  13541. !isUrlInEmbed && Promise.resolve().then(() => {
  13542.  
  13543. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  13544.  
  13545.  
  13546.  
  13547. class LimitedSizeSet extends Set {
  13548. constructor(n) {
  13549. super();
  13550. this.limit = n;
  13551. }
  13552.  
  13553. add(key) {
  13554. if (!super.has(key)) {
  13555. super.add(key);
  13556. let n = super.size - this.limit;
  13557. if (n > 0) {
  13558. const iterator = super.values();
  13559. do {
  13560. const firstKey = iterator.next().value; // Get the first (oldest) key
  13561. super.delete(firstKey); // Delete the oldest key
  13562. } while (--n > 0)
  13563. }
  13564. }
  13565. }
  13566.  
  13567. removeAdd(key) {
  13568. super.delete(key);
  13569. this.add(key);
  13570. }
  13571.  
  13572. }
  13573.  
  13574. // const wk3 = new WeakMap();
  13575.  
  13576. // let mtxVideoId = '';
  13577. // let aje3 = [];
  13578. const mfvContinuationRecorded = new LimitedSizeSet(8); // record all success continuation keys
  13579. const mfyContinuationIgnored = new LimitedSizeSet(8); // ignore continuation keys by copying the keys in the past
  13580. let mtzlastAllowedContinuation = ''; // the key stored at the last success; clear when scheduling changes
  13581. let mtzCount = 0; // the key keeps unchanged
  13582. // let mjtNextMainKey = '';
  13583. let mjtRecordedPrevKey = ''; // the key stored at the last success (no clear)
  13584. let mjtLockPreviousKey = ''; // the key before fetch() should be discarded. (uncertain continuation)
  13585. let mbCId322 = 0; // cid for delay fetchUpdatedMetadata
  13586. // let allowNoDelay322=false;
  13587. let mbDelayBelowNCalls = 0; // after N calls, by pass delay; reset when scheduling changes
  13588.  
  13589. let mpKey22 = ''; // last success continutation key & url pair
  13590. let mpUrl22 = ''; // last success continutation key & url pair
  13591. let mpKey21 = ''; // latest requested continutation key & url pair
  13592. let mpUrl21 = ''; // latest requested continutation key & url pair
  13593.  
  13594.  
  13595. async function sha1Hex(message) {
  13596. const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
  13597. const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8); // hash the message
  13598. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  13599. const hashHex = hashArray
  13600. .map((b) => b.toString(16).padStart(2, "0"))
  13601. .join(""); // convert bytes to hex string
  13602. return hashHex;
  13603. }
  13604.  
  13605. async function continuationLog(a, ...args) {
  13606. let b = a;
  13607. try {
  13608. if (advanceLogging) b = await sha1Hex(a);
  13609. let c = args.map(e => {
  13610. return e === a ? b : e
  13611. });
  13612. console.log(...c)
  13613. } catch (e) { console.warn(e) }
  13614. }
  13615.  
  13616. function copyPreviousContiuationToIgnored374(toClearRecorded) {
  13617.  
  13618.  
  13619. if (mfvContinuationRecorded.length > 0) {
  13620. for (const [e, d] of mfvContinuationRecorded) {
  13621. mfyContinuationIgnored.removeAdd(e);
  13622. }
  13623. toClearRecorded && mfvContinuationRecorded.clear();
  13624. }
  13625.  
  13626. }
  13627.  
  13628. function setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr) {
  13629.  
  13630. const tmProto = taskMgr.constructor.prototype;
  13631. if (tmProto && typeof tmProto.addJob === 'function' && tmProto.addJob.length === 3 && typeof tmProto.cancelJob === 'function' && tmProto.cancelJob.length === 1) {
  13632.  
  13633. if (!tmProto.addJob714) {
  13634.  
  13635. tmProto.addJob714 = tmProto.addJob;
  13636.  
  13637. tmProto.addJob = function (a, b, c) {
  13638. const jobId = this.addJob714(a, b, c);
  13639. if (jobId > 0) {
  13640. // const ez = wk3.get(this);
  13641. // const dz = ez ? ez.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint : null;
  13642. // aje3.push({mtx, jobId, a,b,c, element: this, dz, data: (ez?.data || null) })
  13643.  
  13644. this.__lastJobId863__ = jobId;
  13645. }
  13646. return jobId;
  13647. }
  13648.  
  13649. }
  13650.  
  13651. if (!tmProto.cancelJob714) {
  13652.  
  13653. tmProto.cancelJob714 = tmProto.cancelJob;
  13654.  
  13655. tmProto.cancelJob = function (a) {
  13656. const res = this.cancelJob714(a);
  13657. // if (a > 0) {
  13658. // for (const e of aje3) {
  13659. // if (e.jobId === a) e.cancelled = true;
  13660. // }
  13661. // }
  13662. return res;
  13663. }
  13664.  
  13665. }
  13666.  
  13667. }
  13668. }
  13669.  
  13670.  
  13671. const FIX_avoid_incorrect_video_meta_bool = FIX_avoid_incorrect_video_meta && isPrepareCachedV && check_for_set_key_order && !isChatRoomURL;
  13672.  
  13673.  
  13674. FIX_avoid_incorrect_video_meta_bool && whenCEDefined('ytd-video-primary-info-renderer').then(() => {
  13675. let dummy;
  13676. let cProto;
  13677. // let mc = 4;
  13678. // dummy = await observablePromise(() => {
  13679. // const r = document.querySelector('ytd-video-primary-info-renderer');
  13680. // if (!r) return;
  13681. // let cProto = insp(r).constructor.prototype;
  13682. // if (cProto.fetchUpdatedMetadata) return r;
  13683. // if (--mc < 0) return -1;
  13684. // return null;
  13685. // }).obtain();
  13686. dummy = document.createElement('ytd-video-primary-info-renderer');
  13687. if (!(dummy instanceof Element)) return;
  13688. // console.log(5022, dummy)
  13689. cProto = insp(dummy).constructor.prototype;
  13690.  
  13691. cProto.__getEmittorTaskMgr859__ = function () {
  13692. let taskMgr_ = null;
  13693. try {
  13694. taskMgr_ = (this.ytTaskEmitterBehavior || 0).getTaskManager() || null;
  13695. } catch (e) { }
  13696. return taskMgr_;
  13697. }
  13698. if (typeof cProto.fetchUpdatedMetadata === 'function' && cProto.fetchUpdatedMetadata.length === 1 && !cProto.fetchUpdatedMetadata717) {
  13699. // console.log(1234, cProto, cProto.is)
  13700. cProto.fetchUpdatedMetadata717 = cProto.fetchUpdatedMetadata;
  13701.  
  13702. let c_;
  13703. cProto.fetchUpdatedMetadata718 = function (a) {
  13704. // delay or immediate call the actual fetchUpdatedMetadata
  13705.  
  13706. let doImmediately = false;
  13707. if (a && typeof a === 'string' && mjtRecordedPrevKey && mjtRecordedPrevKey === mpKey22 && a === mpKey22 && (!pageSetupVideoId || pageSetupVideoId !== mpUrl22)) {
  13708.  
  13709. if (!pageSetupVideoId && videoPlayingY.videoId === mpUrl22) doImmediately = true;
  13710.  
  13711. } else if (typeof a !== 'string' || mbDelayBelowNCalls > 3 || !mpKey22 || (mpKey22 === a && mpKey22 !== mjtLockPreviousKey) || (mjtLockPreviousKey && mjtLockPreviousKey !== a)) {
  13712.  
  13713. doImmediately = true;
  13714.  
  13715. }
  13716.  
  13717. if (mbCId322) {
  13718. clearTimeout(mbCId322);
  13719. mbCId322 = 0;
  13720. }
  13721.  
  13722. if (doImmediately) return this.fetchUpdatedMetadata717(a);
  13723.  
  13724. let delay = mjtLockPreviousKey === a ? 8000 : 800;
  13725.  
  13726. mbCId322 = setTimeout(() => {
  13727. this.fetchUpdatedMetadata717(a);
  13728. }, delay);
  13729.  
  13730. console.log('[yt-js-engine-tamer]', '5190 delayed fetchUpdatedMetadata', delay);
  13731.  
  13732. }
  13733.  
  13734. cProto.fetchUpdatedMetadata = function (a) {
  13735.  
  13736. if (!pageSetupState) {
  13737. if (c_) clearTimeout(c_);
  13738. c_ = setTimeout(() => {
  13739. this.fetchUpdatedMetadata718(a);
  13740. }, 300);
  13741. return;
  13742. }
  13743.  
  13744. // pageSetupState == 0
  13745.  
  13746. try {
  13747.  
  13748. mbDelayBelowNCalls++;
  13749.  
  13750. if (arguments.length > 1 || !(a === undefined || (typeof a === 'string' && a))) {
  13751. console.warn("CAUTION: fetchUpdatedMetadata coding might have to be updated.");
  13752. }
  13753.  
  13754. // console.log('fum377', a)
  13755. if (typeof a === 'string' && mfyContinuationIgnored.has(a)) {
  13756. console.log('[yt-js-engine-tamer]', '5040 skip fetchUpdatedMetadata', a);
  13757. return;
  13758. }
  13759.  
  13760. if (!a && (this.data || 0).updatedMetadataEndpoint) {
  13761. if (mjtRecordedPrevKey && mjtLockPreviousKey !== mjtRecordedPrevKey) {
  13762. mjtLockPreviousKey = mjtRecordedPrevKey;
  13763. LOG_FETCHMETA_UPDATE && continuationLog(mjtLockPreviousKey, '5150 Lock Key', mjtLockPreviousKey);
  13764. }
  13765. // mjtNextMainKey = true;
  13766. mtzlastAllowedContinuation = '';
  13767. mtzCount = 0;
  13768. // allowNoDelay322 = false;
  13769. // fetch new metadata, cancel all previous continuations
  13770. copyPreviousContiuationToIgnored374(true);
  13771. } else if (typeof a === 'string') {
  13772. const videoPlayingId = videoPlayingY.videoId;
  13773.  
  13774. // if(mjtNextMainKey === true) mjtNextMainKey = a;
  13775.  
  13776. let update21 = !!pageSetupVideoId;
  13777. if (mpKey22 === a && mpUrl22 === videoPlayingId && mpUrl22 && videoPlayingId && (!pageSetupVideoId || pageSetupVideoId === videoPlayingId)) {
  13778. update21 = true;
  13779. } else if (mpKey22 === a && mpUrl22 !== pageSetupVideoId) {
  13780. LOG_FETCHMETA_UPDATE && continuationLog(mpKey22, '5060 mpUrl22 mismatched', mpKey22, mpUrl22, pageSetupVideoId || '(null)', videoPlayingId || '(null)');
  13781. return;
  13782. }
  13783. if (update21) {
  13784. mpKey21 = a;
  13785. mpUrl21 = pageSetupVideoId || videoPlayingId;
  13786. }
  13787.  
  13788. if (!mfvContinuationRecorded.has(a)) mfvContinuationRecorded.add(a);
  13789. }
  13790. LOG_FETCHMETA_UPDATE && continuationLog(a, '5180 fetchUpdatedMetadata\t', a, pageSetupVideoId || '(null)', videoPlayingY.videoId || '(null)');
  13791. // if (!pageSetupVideoId && typeof a === 'string' && a.length > 40) return; // ignore incorrect continuation
  13792. // if(a === mjtNextMainKey) allowNoDelay322 = false;
  13793. return this.fetchUpdatedMetadata718(a);
  13794.  
  13795. } catch (e) {
  13796. console.log('Code Error in fetchUpdatedMetadata', e);
  13797. }
  13798. return this.fetchUpdatedMetadata717(a)
  13799. }
  13800. }
  13801.  
  13802.  
  13803. if (typeof cProto.scheduleInitialUpdatedMetadataRequest === 'function' && cProto.scheduleInitialUpdatedMetadataRequest.length === 0 && !cProto.scheduleInitialUpdatedMetadataRequest717) {
  13804. // console.log(1234, cProto, cProto.is)
  13805. cProto.scheduleInitialUpdatedMetadataRequest717 = cProto.scheduleInitialUpdatedMetadataRequest;
  13806. let mJob = null;
  13807.  
  13808. cProto.scheduleInitialUpdatedMetadataRequest = function () {
  13809.  
  13810. try {
  13811.  
  13812. if (arguments.length > 0) {
  13813. console.warn("CAUTION: scheduleInitialUpdatedMetadataRequest coding might have to be updated.");
  13814. }
  13815. // mfy = mfv;
  13816.  
  13817. // mjtNextMainKey = '';
  13818. mtzlastAllowedContinuation = '';
  13819. mtzCount = 0;
  13820. if (mbCId322) {
  13821. clearTimeout(mbCId322);
  13822. mbCId322 = 0;
  13823. }
  13824. mbDelayBelowNCalls = 0;
  13825. // allowNoDelay322 = false;
  13826. copyPreviousContiuationToIgnored374(true);
  13827.  
  13828. const taskMgr = this.__getEmittorTaskMgr859__();
  13829. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714 && taskMgr.addJob && taskMgr.cancelJob) setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr);
  13830. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714) {
  13831. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 507');
  13832. }
  13833.  
  13834. // prevent depulicated schedule job by clearing previous JobId
  13835. if (taskMgr && typeof taskMgr.addLowPriorityJob === 'function' && taskMgr.addLowPriorityJob.length === 2 && typeof taskMgr.cancelJob === 'function' && taskMgr.cancelJob.length === 1) {
  13836.  
  13837. let res;
  13838.  
  13839. if (mJob) {
  13840. const job = mJob;
  13841. mJob = null;
  13842. console.log('cancelJob', job)
  13843. taskMgr.cancelJob(job); // clear previous [Interval Meta Update] job
  13844. // p.cancelJob(a,b);
  13845. }
  13846.  
  13847. // const updatedMetadataEndpoint = this.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint
  13848.  
  13849. let pza = taskMgr.__lastJobId863__;
  13850. try { res = this.scheduleInitialUpdatedMetadataRequest717(); } catch (e) { }
  13851. let pzb = taskMgr.__lastJobId863__
  13852. if (pza !== pzb) {
  13853. mJob = pzb; // set [Interval Meta Update] jobId
  13854. }
  13855.  
  13856. // if (updatedMetadataEndpoint && updatedMetadataEndpoint.videoId) {
  13857. // mtxVideoId = updatedMetadataEndpoint.videoId || ''; // set the current target VideoId
  13858. // } else {
  13859. // mtxVideoId = ''; // sometimes updatedMetadataEndpoint is not ready
  13860. // }
  13861.  
  13862. return res;
  13863.  
  13864. } else {
  13865. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 601');
  13866. }
  13867.  
  13868. } catch (e) {
  13869. console.log('Code Error in scheduleInitialUpdatedMetadataRequest', e);
  13870. }
  13871.  
  13872.  
  13873. return this.scheduleInitialUpdatedMetadataRequest717();
  13874. }
  13875. }
  13876.  
  13877.  
  13878. });
  13879.  
  13880. FIX_avoid_incorrect_video_meta_bool && promiseForYtActionCalled.then((ytAppDom) => {
  13881. let dummy;
  13882. let cProto;
  13883. dummy = ytAppDom;
  13884. if (!(dummy instanceof Element)) return;
  13885. cProto = insp(dummy).constructor.prototype;
  13886. if (typeof cProto.sendServiceAjax_ === 'function' && cProto.sendServiceAjax_.length === 4 && !cProto.sendServiceAjax717_) {
  13887. // console.log(1234, cProto, cProto.is);
  13888. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  13889. // cProto.handleServiceRequest_ = function (a, b, c, d) {
  13890. // console.log(123401, arguments);
  13891. // return this.handleServiceRequest717_(a, b, c, d);
  13892. // }
  13893.  
  13894. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  13895.  
  13896. // cProto.handleServiceRequest_ = function(a,b,c,d){
  13897. // console.log(59901, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  13898. // if(a?.is === 'ytd-video-primary-info-renderer' && b?.updatedMetadataEndpoint?.videoId && c?.continuation && typeof c?.continuation ==='string'){
  13899. // console.log('mfv', c.continuation);
  13900. // mfv.add( c.continuation);
  13901. // }
  13902. // return this.handleServiceRequest717_(a,b,c,d);
  13903. // }
  13904.  
  13905. function extraArguments322(a, b, c) {
  13906. let is = (a || 0).is;
  13907. let videoId = ((b || 0).updatedMetadataEndpoint || 0).videoId;
  13908. let continuation = (c || 0).continuation;
  13909. if (typeof is !== 'string') is = null;
  13910. if (typeof videoId !== 'string') videoId = null;
  13911. if (typeof continuation !== 'string') continuation = null;
  13912. return { is, videoId, continuation };
  13913. }
  13914.  
  13915. cProto.sendServiceAjax717_ = cProto.sendServiceAjax_;
  13916. cProto.sendServiceAjax_ = function (a, b, c, d) {
  13917.  
  13918. // console.log(8001)
  13919. try {
  13920.  
  13921. const { is, videoId, continuation } = extraArguments322(a, b, c);
  13922.  
  13923. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  13924. console.warn("CAUTION: sendServiceAjax_ coding might have to be updated.");
  13925. }
  13926.  
  13927. if (pageSetupVideoId && videoId && continuation) {
  13928. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  13929. mfyContinuationIgnored.removeAdd(continuation);
  13930. mfvContinuationRecorded.delete(continuation);
  13931. return;
  13932. }
  13933. }
  13934.  
  13935. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  13936. copyPreviousContiuationToIgnored374(false);
  13937. mfyContinuationIgnored.delete(continuation);
  13938. mfvContinuationRecorded.removeAdd(continuation);
  13939. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  13940. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  13941. mjtLockPreviousKey = '';
  13942. }
  13943. // if (mjtNextMainKey === continuation) {
  13944. // copyPreviousContiuationToIgnored(false);
  13945. // mfyContinuationIgnored.delete(continuation);
  13946. // mfvContinuationRecorded.add(continuation);
  13947. // }
  13948.  
  13949.  
  13950. if (mfyContinuationIgnored && continuation) {
  13951. if (mfyContinuationIgnored.has(continuation)) {
  13952. LOG_FETCHMETA_UPDATE && continuationLog(continuation, '5260 matched01', continuation)
  13953. return;
  13954. }
  13955. }
  13956.  
  13957. // console.log(59902, a?.is, b,c,d)
  13958. // console.log(59903, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  13959. if (is === 'ytd-video-primary-info-renderer' && videoId && continuation && !mfvContinuationRecorded.has(continuation)) {
  13960. // console.log('mfv377', continuation);
  13961. mfvContinuationRecorded.add(continuation);
  13962. }
  13963.  
  13964. // if (videoId) {
  13965. // if (!pageSetupVideoId) return; // ignore page not ready
  13966. // // if (mtxVideoId && b.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  13967. // if (videoId !== pageSetupVideoId) {
  13968. // return;
  13969. // }
  13970. // }
  13971.  
  13972. } catch (e) {
  13973. console.log('Coding Error in sendServiceAjax_', e)
  13974. }
  13975. // console.log(8002)
  13976. // console.log(123402, arguments);
  13977. // console.log(5162, 'a',a?.is,'b',b,'c',c,'d',d);
  13978.  
  13979. // console.log(5211, b?.updatedMetadataEndpoint?.kdkw33);
  13980. // if(b &&b.updatedMetadataEndpoint && !b.updatedMetadataEndpoint.kdkw33){
  13981. // b.updatedMetadataEndpoint = new Proxy(b.updatedMetadataEndpoint, {
  13982. // get(target, prop, receiver){
  13983. // console.log('xxs99', target.videoId, mtx)
  13984. // if(prop ==='kdkw33') return 1;
  13985. // console.log(3322, prop, target)
  13986. // if(prop === 'initialDelayMs') {
  13987. // throw new Error("ABCC");
  13988. // }
  13989. // return target[prop];
  13990. // },
  13991. // set(target, prop, value, receiver){
  13992.  
  13993. // if(prop ==='kdkw33') return true;
  13994. // target[prop]=value;
  13995. // return true;
  13996. // }
  13997. // });
  13998. // }
  13999. // console.log(5533, b?.updatedMetadataEndpoint?.kdkw33)
  14000. return this.sendServiceAjax717_(a, b, c, d);
  14001. }
  14002. }
  14003.  
  14004. function delayClearOtherKeys(lztContinuation) {
  14005. // // schedule delayed removal if mfyContinuationIgnored is not empty
  14006. // getRafPromise().then(() => {
  14007. // // assume the repeat continuation could be only for popstate which is triggered by user interaction
  14008. // // foreground page only
  14009.  
  14010. // });
  14011.  
  14012.  
  14013. if (lztContinuation !== mtzlastAllowedContinuation) return;
  14014. if (lztContinuation !== mpKey21 || lztContinuation !== mpKey22) return;
  14015. if (!mfyContinuationIgnored.size) return;
  14016. if (mfyContinuationIgnored.size > 1) {
  14017. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, 'delayClearOtherKeys, current = ', lztContinuation);
  14018. }
  14019. mfyContinuationIgnored.forEach((value, key) => {
  14020. if (key !== lztContinuation) {
  14021. mfyContinuationIgnored.delete(key);
  14022. LOG_FETCHMETA_UPDATE && continuationLog(key, 'previous continuation removed from ignored store', key);
  14023. }
  14024. });
  14025.  
  14026. }
  14027. if (typeof cProto.getCancellableNetworkPromise_ === 'function' && cProto.getCancellableNetworkPromise_.length === 5 && !cProto.getCancellableNetworkPromise717_) {
  14028. cProto.getCancellableNetworkPromise717_ = cProto.getCancellableNetworkPromise_;
  14029. cProto.getCancellableNetworkPromise_ = function (a, b, c, d, e) {
  14030.  
  14031. // console.log(8003)
  14032. try {
  14033.  
  14034.  
  14035. const { is, videoId, continuation } = extraArguments322(b, c, d);
  14036.  
  14037. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  14038. console.warn("CAUTION: getCancellableNetworkPromise_ coding might have to be updated.");
  14039. }
  14040.  
  14041. if (pageSetupVideoId && videoId && continuation) {
  14042. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  14043. mfyContinuationIgnored.removeAdd(continuation);
  14044. mfvContinuationRecorded.delete(continuation);
  14045. return;
  14046. }
  14047. }
  14048.  
  14049. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  14050. copyPreviousContiuationToIgnored374(false);
  14051. mfyContinuationIgnored.delete(continuation);
  14052. mfvContinuationRecorded.removeAdd(continuation);
  14053. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  14054. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  14055. mjtLockPreviousKey = '';
  14056. }
  14057.  
  14058. // if (mjtNextMainKey === continuation) {
  14059. // copyPreviousContiuationToIgnored(false);
  14060. // mfyContinuationIgnored.delete(continuation);
  14061. // mfvContinuationRecorded.add(continuation);
  14062. // }
  14063.  
  14064. const lztContinuation = continuation;
  14065.  
  14066. if (mfyContinuationIgnored && lztContinuation && typeof lztContinuation === 'string') {
  14067. if (mfyContinuationIgnored.has(lztContinuation)) {
  14068. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5360 matched02', lztContinuation)
  14069. return;
  14070. }
  14071. }
  14072.  
  14073. // if (videoId) {
  14074. // if (!pageSetupVideoId) return; // ignore page not ready
  14075. // // if (mtxVideoId && c.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  14076. // if (videoId !== pageSetupVideoId) {
  14077. // return;
  14078. // }
  14079. // }
  14080.  
  14081. if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation !== lztContinuation) {
  14082. mtzlastAllowedContinuation = lztContinuation;
  14083. // console.log(70401, lztContinuation, mfyContinuationIgnored.size)
  14084.  
  14085. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5382 Continuation sets to\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  14086. mjtRecordedPrevKey = lztContinuation;
  14087. if (mjtLockPreviousKey === lztContinuation) mjtLockPreviousKey = '';
  14088. // if (mfyContinuationIgnored.size > 0) {
  14089. // delayClearOtherKeys(lztContinuation);
  14090. // }
  14091. mtzCount = 0;
  14092. // allowNoDelay322 = false;
  14093. } else if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation && mtzlastAllowedContinuation === lztContinuation) {
  14094. // repeated
  14095. if (++mtzCount > 1e9) mtzCount = 1e4;
  14096. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5386 Same Continuation\t\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  14097.  
  14098. // if (mtzCount >= 3) allowNoDelay322 = true;
  14099. if (mtzCount >= 3 && mfyContinuationIgnored.size > 0) {
  14100. Promise.resolve(lztContinuation).then(delayClearOtherKeys).catch(console.warn);
  14101. }
  14102. if (mtzCount === 5) {
  14103. mfvContinuationRecorded.clear();
  14104. mfvContinuationRecorded.add(lztContinuation);
  14105. }
  14106.  
  14107. }
  14108.  
  14109. if (typeof lztContinuation === 'string' && lztContinuation && (pageSetupVideoId || videoPlayingY.videoId)) {
  14110. mpKey22 = lztContinuation;
  14111. mpUrl22 = pageSetupVideoId || videoPlayingY.videoId;
  14112. }
  14113.  
  14114. if (mbCId322) {
  14115. clearTimeout(mbCId322);
  14116. mbCId322 = 0;
  14117. }
  14118. } catch (e) {
  14119. console.log('Coding Error in getCancellableNetworkPromise_', e)
  14120. }
  14121.  
  14122. // console.log(8004)
  14123. // console.log(123403, arguments);
  14124. // if(c.updatedMetadataEndpoint) console.log(123404, pageSetupVideoId, JSON.stringify(c.updatedMetadataEndpoint))
  14125.  
  14126. // console.log(5163, a?.is,b,c,d,e);
  14127. return this.getCancellableNetworkPromise717_(a, b, c, d, e);
  14128. }
  14129. }
  14130. });
  14131.  
  14132. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  14133.  
  14134.  
  14135. FIX_ytdExpander_childrenChanged && !isChatRoomURL && whenCEDefined('ytd-expander').then(() => {
  14136.  
  14137. let dummy;
  14138. let cProto;
  14139.  
  14140. dummy = document.createElement('ytd-expander');
  14141. cProto = insp(dummy).constructor.prototype;
  14142.  
  14143. if (fnIntegrity(cProto.initChildrenObserver, '0.48.21') && fnIntegrity(cProto.childrenChanged, '0.40.22')) {
  14144.  
  14145. cProto.initChildrenObserver14 = cProto.initChildrenObserver;
  14146. cProto.childrenChanged14 = cProto.childrenChanged;
  14147.  
  14148. cProto.initChildrenObserver = function () {
  14149. var a = this;
  14150. this.observer = new MutationObserver(function () {
  14151. a.childrenChanged()
  14152. }
  14153. );
  14154. this.observer.observe(this.content, {
  14155. subtree: !0,
  14156. childList: !0,
  14157. attributes: !0,
  14158. characterData: !0
  14159. });
  14160. this.childrenChanged()
  14161. }
  14162. ;
  14163. cProto.childrenChanged = function () {
  14164. if (this.alwaysToggleable) {
  14165. this.canToggle = this.alwaysToggleable;
  14166. } else if (!this.canToggleJobId) {
  14167. this.canToggleJobId = 1;
  14168. foregroundPromiseFn().then(() => {
  14169. this.canToggleJobId = 0;
  14170. this.calculateCanCollapse()
  14171. })
  14172. }
  14173. }
  14174.  
  14175. // console.log(cProto.initChildrenObserver)
  14176. console.debug('ytd-expander-fix-childrenChanged');
  14177.  
  14178. }
  14179.  
  14180. });
  14181.  
  14182.  
  14183. FIX_paper_ripple_animate && whenCEDefined('paper-ripple').then(() => {
  14184.  
  14185. let dummy;
  14186. let cProto;
  14187. dummy = document.createElement('paper-ripple');
  14188. cProto = insp(dummy).constructor.prototype;
  14189.  
  14190. if (fnIntegrity(cProto.animate, '0.74.5')) {
  14191.  
  14192.  
  14193. cProto.animate34 = cProto.animate;
  14194. cProto.animate = function () {
  14195. if (this._animating) {
  14196. var a;
  14197. const ripples = this.ripples;
  14198. for (a = 0; a < ripples.length; ++a) {
  14199. var b = ripples[a];
  14200. b.draw();
  14201. this.$.background.style.opacity = b.outerOpacity;
  14202. b.isOpacityFullyDecayed && !b.isRestingAtMaxRadius && this.removeRipple(b)
  14203. }
  14204. if ((this.shouldKeepAnimating || 0) !== ripples.length) {
  14205. if (!this._boundAnimate38) this._boundAnimate38 = this.animate.bind(this);
  14206. foregroundPromiseFn().then(this._boundAnimate38);
  14207. } else {
  14208. this.onAnimationComplete();
  14209. }
  14210. }
  14211. }
  14212.  
  14213. console.debug('FIX_paper_ripple_animate')
  14214.  
  14215. // console.log(cProto.animate)
  14216.  
  14217. }
  14218.  
  14219. });
  14220.  
  14221. if (FIX_doIdomRender) {
  14222.  
  14223. const xsetTimeout = function (f, d) {
  14224. if (xsetTimeout.m511 === 1 && !d) {
  14225. xsetTimeout.m511 = 2;
  14226. xsetTimeout.m568 = f;
  14227. } else {
  14228. return setTimeout.apply(window, arguments)
  14229. }
  14230.  
  14231. }
  14232.  
  14233. /**
  14234. *
  14235. IGb = function(a) {
  14236. var b, c = null == (b = a.requestAninmationFrameResolver) ? void 0 : b.promise;
  14237. c || (a.requestAninmationFrameResolver = new Vi,
  14238. c = a.requestAninmationFrameResolver.promise,
  14239. Da.requestAnimationFrame(function() {
  14240. var d;
  14241. null == (d = a.requestAninmationFrameResolver) || d.resolve();
  14242. a.requestAninmationFrameResolver = null
  14243. }));
  14244. return c
  14245. }
  14246.  
  14247.  
  14248. */
  14249.  
  14250. const xrequestAnimationFrame = function (f) {
  14251. const h = `${f}`;
  14252. if (h.startsWith("function(){setTimeout(function(){") && h.endsWith("})}")) {
  14253. let t = null;
  14254. xsetTimeout.m511 = 1;
  14255. f();
  14256. if (xsetTimeout.m511 === 2) {
  14257. t = xsetTimeout.m568;
  14258. xsetTimeout.m568 = null;
  14259. }
  14260. xsetTimeout.m511 = 0;
  14261. if (typeof t === 'function') {
  14262. foregroundPromiseFn().then(t);
  14263. }
  14264. } else if (h.includes("requestAninmationFrameResolver")) {
  14265. foregroundPromiseFn().then(f);
  14266. } else {
  14267. return requestAnimationFrame.apply(window, arguments);
  14268. }
  14269. }
  14270.  
  14271. let busy = false;
  14272. const doIdomRender = function () {
  14273.  
  14274. if (!this) return;
  14275. if (busy) {
  14276. return this.doIdomRender13(...arguments);
  14277. }
  14278. busy = true;
  14279. const { requestAnimationFrame, setTimeout } = window;
  14280. window.requestAnimationFrame = xrequestAnimationFrame;
  14281. window.setTimeout = xsetTimeout;
  14282. let r = this.doIdomRender13(...arguments);
  14283. window.requestAnimationFrame = requestAnimationFrame;
  14284. window.setTimeout = setTimeout;
  14285. busy = false;
  14286. return r;
  14287. };
  14288. for (const ytTag of ['ytd-lottie-player', 'yt-attributed-string', 'yt-image', 'yt-icon-shape', 'yt-button-shape', 'yt-button-view-model', 'yt-icon-badge-shape']) {
  14289.  
  14290.  
  14291. whenCEDefined(ytTag).then(() => {
  14292.  
  14293. let dummy;
  14294. let cProto;
  14295. dummy = document.createElement(ytTag);
  14296. cProto = insp(dummy).constructor.prototype;
  14297.  
  14298. cProto.doIdomRender13 = cProto.doIdomRender;
  14299. cProto.doIdomRender = doIdomRender;
  14300.  
  14301. if (cProto.doIdomRender13 === cProto.templatingFn) cProto.templatingFn = doIdomRender;
  14302.  
  14303. console.debug('[yt-js-engine-tamer] FIX_doIdomRender', ytTag)
  14304.  
  14305.  
  14306.  
  14307. });
  14308.  
  14309. }
  14310.  
  14311. }
  14312.  
  14313.  
  14314.  
  14315.  
  14316. FIX_POPUP_UNIQUE_ID && whenCEDefined('ytd-popup-container').then(async () => {
  14317.  
  14318. const sMap = new Map();
  14319.  
  14320. const ZTa = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
  14321. const ZT = function () {
  14322. for (var a = Array(36), b = 0, c, d = 0; d < 36; d++)
  14323. d == 8 || d == 13 || d == 18 || d == 23 ? a[d] = "-" : d == 14 ? a[d] = "4" : (b <= 2 && (b = 33554432 + Math.random() * 16777216 | 0),
  14324. c = b & 15,
  14325. b >>= 4,
  14326. a[d] = ZTa[d == 19 ? c & 3 | 8 : c]);
  14327. return a.join("")
  14328. };
  14329.  
  14330.  
  14331. const popupContainerCollection = document.getElementsByTagName('ytd-popup-container');
  14332.  
  14333. const popupContainer = await observablePromise(() => {
  14334. return popupContainerCollection[0];
  14335. }).obtain();
  14336.  
  14337.  
  14338. let cProto;
  14339. cProto = insp(popupContainer).constructor.prototype;
  14340.  
  14341.  
  14342. if (!cProto || typeof cProto.handleOpenPopupAction !== 'function' || cProto.handleOpenPopupAction3868 || cProto.handleOpenPopupAction.length !== 2) {
  14343. console.log('FIX_POPUP_UNIQUE_ID NG')
  14344. return;
  14345. }
  14346. cProto.handleOpenPopupAction3868 = cProto.handleOpenPopupAction;
  14347.  
  14348. cProto.handleOpenPopupAction = function (a, b) {
  14349.  
  14350. if (typeof (a || 0) === 'object' && !a.__jOdQA__) {
  14351.  
  14352. a.__jOdQA__ = true;
  14353.  
  14354. try {
  14355.  
  14356. const h = this.hostElement;
  14357.  
  14358. if (h instanceof HTMLElement_) {
  14359.  
  14360. const map = h.__skme44__ = h.__skme44__ || new Map();
  14361.  
  14362. let mKey = '';
  14363. const wKey = firstObjectKey(a);
  14364. const wObj = wKey ? a[wKey] : null;
  14365. if (wKey && wObj && typeof (wObj.popup || 0) === 'object') {
  14366. const pKey = firstObjectKey(wObj.popup)
  14367. const pObj = pKey ? wObj.popup[pKey] : null;
  14368. let contentKey = '';
  14369. let headerKey = '';
  14370.  
  14371. if (pObj && pObj.identifier && pObj.content && pObj.header) {
  14372. contentKey = firstObjectKey(pObj.content)
  14373. headerKey = firstObjectKey(pObj.header)
  14374. }
  14375. if (contentKey && headerKey) {
  14376.  
  14377. mKey = `${wKey}(popupType:${wObj.popupType},popup(${pKey}(content(${contentKey}:...),header(${headerKey}:...),identifer(surface:${pObj.identifier.surface}))))`
  14378.  
  14379. if (mKey) {
  14380.  
  14381. if (!wObj.uniqueId) {
  14382. for (let i = 0; i < 8; i++) {
  14383. wObj.uniqueId = ZT();
  14384. if (!sMap.has(wObj.uniqueId)) break;
  14385. }
  14386. }
  14387. const oId = wObj.uniqueId
  14388.  
  14389. let nId_ = map.get(mKey);
  14390. if (!nId_) {
  14391. map.set(mKey, nId_ = oId);
  14392. }
  14393.  
  14394. wObj.uniqueId = nId_ || wObj.uniqueId;
  14395.  
  14396. const nId = wObj.uniqueId
  14397.  
  14398. sMap.set(oId, nId);
  14399. sMap.set(nId, nId);
  14400.  
  14401. wObj.uniqueId = nId;
  14402. pObj.targetId = nId;
  14403. pObj.identifier.tag = nId;
  14404.  
  14405. if (oId !== nId) {
  14406. console.log('FIX_POPUP_UNIQUE_ID', oId, nId);
  14407. }
  14408.  
  14409. }
  14410.  
  14411. }
  14412. }
  14413.  
  14414. // console.log(12213, mKey, a, b, h)
  14415.  
  14416. }
  14417.  
  14418. } catch (e) {
  14419. console.warn(e)
  14420. }
  14421.  
  14422. try {
  14423.  
  14424. const results = searchNestedObject(a, (x) => {
  14425. if (typeof x === 'string' && x.length === 36) {
  14426. if (/[a-zA-Z\d]{8}-[a-zA-Z\d]{4}-[a-zA-Z\d]{4}-[a-zA-Z\d]{4}-[a-zA-Z\d]{12}/.test(x)) return true;
  14427. }
  14428. return false;
  14429. });
  14430. for (const [obj, key] of results) {
  14431. const oId = obj[key];
  14432. const nId = sMap.get(oId);
  14433. if (nId) obj[key] = nId;
  14434. }
  14435. } catch (e) {
  14436. console.warn(e)
  14437. }
  14438.  
  14439.  
  14440. }
  14441.  
  14442. return this.handleOpenPopupAction3868(...arguments)
  14443. }
  14444.  
  14445. console.log('FIX_POPUP_UNIQUE_ID OK')
  14446.  
  14447.  
  14448. });
  14449.  
  14450.  
  14451. FIX_TRANSCRIPT_SEGMENTS && !isChatRoomURL && whenCEDefined('yt-formatted-string').then(async () => {
  14452.  
  14453. let dummy;
  14454. let cProto;
  14455. dummy = document.createElement('yt-formatted-string');
  14456. cProto = insp(dummy).constructor.prototype;
  14457.  
  14458. if (!cProto || typeof cProto.setNodeStyle_ !== 'function' || cProto.setNodeStyle17_ || cProto.setNodeStyle_.length !== 2) {
  14459. console.log('FIX_TRANSCRIPT_SEGMENTS(2) NG');
  14460. return;
  14461. }
  14462.  
  14463. cProto.setNodeStyle17_ = cProto.setNodeStyle_;
  14464. cProto.setNodeStyle_ = function (a, b) {
  14465. if (b instanceof HTMLElement_ && typeof (a || 0) === 'object') b.classList.toggle('yt-formatted-string-block-line', !!a.blockLine);
  14466. return this.setNodeStyle17_(a, b);
  14467. }
  14468.  
  14469. console.log('FIX_TRANSCRIPT_SEGMENTS(2) OK');
  14470. });
  14471.  
  14472. });
  14473.  
  14474. });
  14475.  
  14476.  
  14477.  
  14478.  
  14479. if (isMainWindow) {
  14480.  
  14481. console.groupCollapsed(
  14482. "%cYouTube JS Engine Tamer",
  14483. "background-color: #EDE43B ; color: #000 ; font-weight: bold ; padding: 4px ;"
  14484. );
  14485.  
  14486.  
  14487.  
  14488. console.log("Script is loaded.");
  14489. console.log("This script changes the core mechanisms of the YouTube JS engine.");
  14490.  
  14491. console.log("This script is experimental and subject to further changes.");
  14492.  
  14493. console.log("This might boost your YouTube performance.");
  14494.  
  14495. console.log("CAUTION: This might break your YouTube.");
  14496.  
  14497.  
  14498. if (prepareLogs.length >= 1) {
  14499. console.log(" =========================================================================== ");
  14500.  
  14501. for (const msg of prepareLogs) {
  14502. console.log(msg)
  14503. }
  14504.  
  14505. console.log(" =========================================================================== ");
  14506. }
  14507.  
  14508. console.groupEnd();
  14509.  
  14510. }
  14511.  
  14512.  
  14513.  
  14514. })();