YouTube JS Engine Tamer

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

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

  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.31.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 NATIVE_CANVAS_ANIMATION = false; // for #cinematics
  35. const FIX_schedulerInstanceInstance = 2 | 4;
  36. const FIX_yt_player = true; // DONT CHANGE
  37. const FIX_Animation_n_timeline = true;
  38. const NO_PRELOAD_GENERATE_204 = false;
  39. const ENABLE_COMPUTEDSTYLE_CACHE = true;
  40. const NO_SCHEDULING_DUE_TO_COMPUTEDSTYLE = true;
  41. const CHANGE_appendChild = true; // discussions#236759
  42. const FIX_bind_self_this = false; // EXPERIMENTAL !!!!! this affect page switch after live ends
  43. const FIX_weakMap_weakRef = false; // EXPERIMENTAL !!!!! Might Incompatible to some userscripts (as the strong relationship is removed)
  44.  
  45. const FIX_error_many_stack = true; // should be a bug caused by uBlock Origin
  46. // const FIX_error_many_stack_keepAliveDuration = 200; // ms
  47. // const FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than = 8;
  48.  
  49. const FIX_Iframe_NULL_SRC = false;
  50.  
  51. const IGNORE_bindAnimationForCustomEffect = true; // prevent `v.bindAnimationForCustomEffect(this);` being executed
  52.  
  53. const FIX_ytdExpander_childrenChanged = true;
  54. const FIX_paper_ripple_animate = true;
  55. const FIX_avoid_incorrect_video_meta = true; // omit the incorrect yt-animated-rolling-number
  56. const FIX_avoid_incorrect_video_meta_emitterBehavior = true;
  57.  
  58. const FIX_doIdomRender = true;
  59.  
  60. const FIX_Shady = true;
  61.  
  62. // [[ 2024.04.24 ]]
  63. const MODIFY_ShadyDOM_OBJ = true;
  64. // << if MODIFY_ShadyDOM_OBJ >>
  65. const WEAKREF_ShadyDOM = true;
  66. const OMIT_ShadyDOM_EXPERIMENTAL = 1 | 0; // 1 => enable; 2 => composedPath
  67. const OMIT_ShadyDOM_settings = 0 | 0 | 0; // 1: inUse; 2: handlesDynamicScoping; 4: force // {{ PRELIM TESTING PURPOSE }}
  68. // << end >>
  69.  
  70. const WEAK_REF_BINDING_CONTROL = 1 | 2; // 2 - conflict control with ShadyDOM weakref
  71.  
  72. const FIX_ytAction_ = true; // ytd-app
  73. const FIX_onVideoDataChange = false;
  74. // const FIX_onClick = true;
  75. const FIX_onStateChange = true;
  76. const FIX_onLoopRangeChange = true;
  77. // const FIX_maybeUpdateFlexibleMenu = true; // ytd-menu-renderer
  78. const FIX_VideoEVENTS_v2 = true; // true might cause bug in switching page
  79.  
  80. const ENABLE_discreteTasking = false; // removed since 0.20.0
  81. const FIX_stampDomArray_ = true; // v0.30.0
  82. const FIX_stampDomArray = FIX_stampDomArray_ && typeof WeakRef === "function" && typeof FinalizationRegistry === "function";
  83. const stampDomArray_MemoryFix_Flag001 = false;
  84. const XFlag = true; // DON'T CHANGE
  85. const MemoryFix_Flag002 = 1 | 2 | 4 | 8 | 0 | 32 | 64 | 0 | 256;
  86. // 32 required for new stampDomArray
  87. // 128 to be tested
  88.  
  89. const FIX_perfNow = true; // history state issue; see https://bugzilla.mozilla.org/show_bug.cgi?id=1756970
  90. const ENABLE_ASYNC_DISPATCHEVENT = false; // problematic
  91.  
  92. const FIX_Polymer_dom = true;
  93. const FIX_Polymer_AF = true;
  94.  
  95. const SCRIPTLET_REMOVE_PRUNE_propNeedles = true; // brave scriptlet related
  96. const DEBUG_removePrune = false; // true for DEBUG
  97.  
  98. const FIX_XHR_REQUESTING = true;
  99.  
  100. const LOG_FETCHMETA_UPDATE = false; // for DEBUG
  101.  
  102. const IGNORE_bufferhealth_CHECK = false; // experimental; true will make "Stats for nerds" no info.
  103.  
  104. const DENY_requestStorageAccess = true; // remove document.requestStorageAccess
  105. const DISABLE_IFRAME_requestStorageAccess = true; // no effect if DENY_requestStorageAccess is true
  106.  
  107. const DISABLE_COOLDOWN_SCROLLING = true; // YT cause scroll hang in MacOS
  108.  
  109. const FIX_removeChild = true;
  110. const FIX_fix_requestIdleCallback_timing = true;
  111.  
  112. const HOOK_CSSPD_LEFT = true; // global css hack for style.left
  113. const FORCE_NO_REUSEABLE_ELEMENT_POOL = true;
  114.  
  115. const FIX_TRANSCRIPT_SEGMENTS = true; // Based on Tabview Youtube's implementation
  116.  
  117. const FIX_POPUP_UNIQUE_ID = true; // currently only for channel about popup;
  118.  
  119. // ----------------------------- POPUP UNIQUE ID ISSUE -----------------------------
  120. // example. https://www.youtube.com/channel/UCgPev1KKSCMbnNRsvN83Hag/about
  121. // first tp-yt-paper-dialog: show once the page is loaded.
  122. // second tp-yt-paper-dialog: click "...more"
  123. // third tp-yt-paper-dialog: click "... and 3 more links"
  124. // check with document.querySelectorAll('ytd-popup-container tp-yt-paper-dialog').length
  125. // currently, uniqueId is preassigned by the network resolveCommand.
  126. // so don't modify the source side, just modify the display side (popup display) via handleOpenPopupAction
  127. // other related functions e.g. handleClosePopupCommand_, getAndMaybeCreatePopup_, handleClosePopupAction_, getAndMaybeCreatePopup_
  128.  
  129. // handleOpenPopupAction -> createCacheKey
  130. // handleClosePopupAction_ -> createCacheKey
  131. // handleGetPopupOpenedAction_ -> createCacheKey
  132. // getAndMaybeCreatePopup_ -> createCacheKey
  133. // closePopup -> createCacheKey
  134.  
  135. // yt-close-popup-command -> handleClosePopupCommand_
  136.  
  137. // ensurePopup_ -> getAndMaybeCreatePopup_
  138.  
  139. // yt-close-popup-action -> handleClosePopupAction_
  140. // closePopup -> handleClosePopupAction_
  141. // handleOpenPopupAction -> handleClosePopupAction_
  142. // handleClosePopupCommand_ -> handleClosePopupAction_
  143. // closeSheet -> handleClosePopupAction_("yt-sheet-view-model")
  144.  
  145. // yt-open-popup-action -> handleOpenPopupAction
  146.  
  147.  
  148. // yt-close-popup-action -> handleClosePopupAction_ -> createCacheKey
  149. // yt-close-popup-command -> handleClosePopupCommand_ -> handleClosePopupAction_ -> createCacheKey
  150.  
  151. // Experimental flag "ytpopup_disable_default_html_caching" is disabled by default.
  152. // Not sure enabling it can make GC or not (Yt Components are usually not GC-able)
  153. // ----------------------------- POPUP UNIQUE ID ISSUE -----------------------------
  154.  
  155.  
  156. const FIX_DOM_IF_REPEAT = true; // semi-experimental (added in 0.17.0)
  157. const FIX_DOM_IF_TEMPLATE = true;
  158. // const FIX_DOM_REPEAT_TEMPLATE = true; // to be implemented
  159. const FIX_DOM_IFREPEAT_RenderDebouncerChange = false; // semi-experimental (added in 0.17.0) // found buggy for chat ticker sizing
  160. const DEBUG_DBR847 = false;
  161. const DEBUG_xx847 = false;
  162. const FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME = true; // default true. false might be required for future change
  163. const DEBUG_renderDebounceTs = false;
  164.  
  165. const FIX_ICON_RENDER = true;
  166.  
  167. const FIX_VIDEO_PLAYER_MOUSEHOVER_EVENTS = true; // avoid unnecessary reflows due to cursor moves on the web player.
  168.  
  169. /*
  170.  
  171. FIX_DOM_IFREPEAT_RenderDebouncerChange
  172.  
  173. avoid Polymer.flush
  174. // https://www.youtube.com/s/desktop/26a583e4/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  175.  
  176. var Is = function() {
  177. do {
  178. var a = window.ShadyDOM && ShadyDOM.flush();
  179. window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush();
  180. var b = NNa()
  181. } while (a || b)
  182. };
  183.  
  184. , NNa = function() {
  185. var a = !!ts.size;
  186. ts.forEach(function(b) {
  187. try {
  188. b.flush()
  189. } catch (c) {
  190. setTimeout(function() {
  191. throw c
  192. })
  193. }
  194. });
  195. return a
  196. };
  197.  
  198. // why flush twice after all ts are completed? (!!ts.size => true => loop again)
  199. // this coding logic should be incorrect (mistake).
  200.  
  201. */
  202.  
  203.  
  204.  
  205. // ----------------------------- Shortkey Keyboard Control -----------------------------
  206. // dependency: FIX_yt_player
  207.  
  208. const FIX_SHORTCUTKEYS = 2; // 0 - no fix; 1 - basic fix; 2 - advanced fix
  209. // [0] no fix - not recommended
  210. // [1] basic fix - just fix the global focus detection variable
  211. // [2] advanced fix - call the shortcut actions directly, auto foucs change, direct control of spacebar behavior, etc
  212. // (note) 0 or 1 if you find conflict with other userscripts/plugin
  213.  
  214. const CHANGE_SPEEDMASTER_SPACEBAR_CONTROL = 0; // 0 - disable; 1 - force true; 2 - force false
  215. const USE_IMPROVED_PAUSERESUME_UNDER_NO_SPEEDMASTER = true; // only for SPEEDMASTER = false & FIX_SHORTCUTKEYS = 2
  216.  
  217. const PROP_OverReInclusion_AVOID = true;
  218. const PROP_OverReInclusion_DEBUGLOG = false;
  219. const PROP_OverReInclusion_LIST = new Set([
  220. 'hostElement72',
  221. 'parentComponent72',
  222. 'localVisibilityObserver_72',
  223. 'cachedProviderNode_72',
  224. '__template72',
  225. '__templatizeOwner72',
  226. '__templateInfo72',
  227. '__dataHost72',
  228. '__CE_shadowRoot72',
  229. 'elements_72',
  230.  
  231. 'ky36',
  232. 'kz62',
  233. 'm822',
  234.  
  235.  
  236.  
  237. // To be reviewed.
  238.  
  239. // chat messages
  240. 'disabled', 'allowedProps',
  241. 'filledButtonOverrides', 'openPopupConfig', 'supportsInlineActionButtons', 'allowedProps',
  242.  
  243. 'dimension', 'loadTime', 'pendingPaint',
  244.  
  245. 'countdownDurationMs', 'countdownMs', 'lastCountdownTimeMs', 'rafId', 'playerProgressSec', 'detlaSincePausedSecs', 'behaviorActionMap', 'selected', 'maxLikeCount', 'maxReplyCount', 'isMouseOver',
  246.  
  247. 'respectLangDir', 'noEndpoints',
  248.  
  249.  
  250. 'objectURL',
  251. 'buttonOverrides', 'queuedMessages',
  252. 'STEP', 'BLOCK_ON', 'MIN_PROGESS', 'MAX_PROGESS',
  253. 'DISMISSED_CONTENT_KEYSPACE', 'followUpDialogPromise', 'followUpDialogPromiseResolve', 'followUpDialogPromiseReject',
  254. 'hoverJobId', 'JSC$14573_touched',
  255.  
  256.  
  257. // tbc
  258. 'toggleable', 'isConnected',
  259. 'scrollDistance', 'dragging', 'dragMouseStart', 'dragOffsetStart', 'containerWidthDiff',
  260. 'disableDeselectEvent',
  261. 'emojiSize',
  262.  
  263. 'buttonOverride',
  264. 'shouldUseStickyPreferences', 'longPressTimeoutId',
  265.  
  266. // others
  267. 'observeVisibleOption', 'observeHiddenOption', 'observePrescanOption', 'visibilityMonitorKeys',
  268. // 'filledButtonOverrides', 'openPopupConfig', 'supportsInlineActionButtons',
  269. 'observeVisibleOption', 'observeHiddenOption', 'observePrescanOption', 'visibilityMonitorKeys',
  270. // 'dimension', 'loadTime', 'pendingPaint',
  271. // 'disabled', 'allowedProps',
  272.  
  273.  
  274. // 'enableMssLazyLoad', 'popupContainerConfig', 'actionRouterNode', 'actionRouterIsRoot', 'actionMap', 'dynamicActionMap',
  275. // 'actionMap',
  276.  
  277. // 'sharedTooltipPosition', 'sharedTooltipAnimationDelay', 'disableEmojiPickerIncrementalLoading', 'useResolveCommand', 'activeRequest', 'popoutWindowCheckIntervalId', 'supportedTooltipTargets', 'closeActionPanelTimerId', 'delayCloseActionPanelTimerId', 'tooltipTimerIds', 'queuedTooltips', 'isPopupConfigReady', 'popoutWindow', 'actionMap',
  278.  
  279. 'clearTimeout',
  280. 'switchTemplateAtRegistration', 'hasUnmounted',
  281. 'switchTemplateAtRegistration', 'stopKeyboardEventPropagation',
  282. 'tangoConfiguration',
  283. 'itemIdToDockDurationMap',
  284. 'actionMap',
  285.  
  286. 'emojiManager', 'inputMethodEditorActive', 'suggestionIndex', 'JSC$10745_lastSuggestionRange',
  287. 'actionMap', 'asyncHandle', 'shouldAnimateIn', 'lastFrameTimestamp', 'scrollClampRaf',
  288. 'scrollRatePixelsPerSecond', 'scrollStartTime', 'scrollStopHandle'
  289.  
  290. // 'buttonOverrides', 'queuedMessages', 'clearTimeout', 'actionMap',
  291. // 'stopKeyboardEventPropagation', 'emojiSize',
  292. // 'switchTemplateAtRegistration', 'hasUnmounted',
  293. // 'buttonOverrides', 'queuedMessages', 'clearTimeout', 'actionMap',
  294. // 'isReusable', 'tangoConfiguration',
  295. // 'itemIdToDockDurationMap', 'bottomAlignMessages', 'actionMap',
  296. // */
  297.  
  298. ]);
  299.  
  300.  
  301. // const CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE = false; // NO USE; TO BE REVIEWED
  302.  
  303. // ----------------------------- Shortkey Keyboard Control -----------------------------
  304.  
  305. /*
  306. window.addEventListener('edm',()=>{
  307. let p = [...this.onerror.errorTokens][0].token; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  308. });
  309.  
  310. window.addEventListener('edn',()=>{
  311. let p = [...this.onerror.errorTokens][0].token+"X"; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  312. });
  313. window.addEventListener('edr',()=>{
  314. let p = '123'; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  315. });
  316. */
  317.  
  318. // only for macOS with Chrome/Firefox 100+
  319. const advanceLogging = typeof AbortSignal !== 'undefined' && typeof (AbortSignal || 0).timeout === 'function' && typeof navigator !== 'undefined' && /\b(Macintosh|Mac\s*OS)\b/i.test((navigator || 0).userAgent || '');
  320.  
  321. const win = this instanceof Window ? this : window;
  322.  
  323. // Create a unique key for the script and check if it is already running
  324. const hkey_script = 'jswylcojvzts';
  325. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  326. win[hkey_script] = true;
  327.  
  328.  
  329.  
  330. const wk = Symbol();
  331.  
  332. // const [setTimeoutX0, clearTimeoutX0] = [setTimeout, clearTimeout];
  333.  
  334. let BY_PASS_KEYBOARD_CONTROL = false;
  335.  
  336.  
  337. // const setImmediate = ((self || 0).jmt || 0).setImmediate;
  338. /** @type {(f: ()=>{})=>{}} */
  339. const nextBrowserTick_ = nextBrowserTick;
  340. if (typeof nextBrowserTick_ !== "function" || (nextBrowserTick_.version || 0) < 2) {
  341. console.log('nextBrowserTick is not found.');
  342. return;
  343. }
  344.  
  345. let p59 = 0;
  346.  
  347. const Promise = (async () => { })().constructor;
  348.  
  349. const PromiseExternal = ((resolve_, reject_) => {
  350. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  351. return class PromiseExternal extends Promise {
  352. constructor(cb = h) {
  353. super(cb);
  354. if (cb === h) {
  355. /** @type {(value: any) => void} */
  356. this.resolve = resolve_;
  357. /** @type {(reason?: any) => void} */
  358. this.reject = reject_;
  359. }
  360. }
  361. };
  362. })();
  363.  
  364. const FinalizationRegistry_ = typeof FinalizationRegistry !== "undefined" ? FinalizationRegistry : class FinalizationRegistry__ {
  365. constructor(callback = undefined) {
  366.  
  367. }
  368. register(target, heldValue, unregisterToken = undefined) {
  369.  
  370. }
  371. unregister(unregisterToken) {
  372.  
  373. }
  374. }
  375.  
  376. let ttpHTML = (s) => {
  377. ttpHTML = s => s;
  378. if (typeof trustedTypes !== 'undefined' && trustedTypes.defaultPolicy === null) {
  379. let s = s => s;
  380. trustedTypes.createPolicy('default', { createHTML: s, createScriptURL: s, createScript: s });
  381. }
  382. return s;
  383. }
  384.  
  385.  
  386. /** @type { typeof HTMLElement } */
  387. const HTMLElement_ = Reflect.getPrototypeOf(HTMLTitleElement);
  388. const nativeAppendE = HTMLElement_.prototype.append;
  389. const nativeRemoveE = HTMLElement_.prototype.remove;
  390. const DocumentFragment_ = DocumentFragment;
  391. const nativeAppendD = DocumentFragment_.prototype.append;
  392. const Node_ = Node;
  393.  
  394. /**
  395. @param {number} x
  396. @param {number} d */
  397. const toFixed2 = (x, d) => {
  398. let t = x.toFixed(d);
  399. let y = `${+t}`;
  400. return y.length > t.length ? t : y;
  401. }
  402.  
  403.  
  404. const isChatRoomURL = location.pathname.startsWith('/live_chat');
  405.  
  406.  
  407. const TRANSLATE_DEBUG = false;
  408.  
  409.  
  410. let xdeadc00 = null; // a deteched node with __domApi
  411. let xlivec00 = null; // a deteched node with __domApi
  412.  
  413. let removeTNodeRM = null;
  414. let removeTNodeBP = false;
  415.  
  416.  
  417.  
  418.  
  419. let FORCE_NO_REUSEABLE_ELEMENT_POOL_fired = false;
  420.  
  421. const FORCE_NO_REUSEABLE_ELEMENT_POOL_fn = (mainCnt) => {
  422.  
  423. if (FORCE_NO_REUSEABLE_ELEMENT_POOL_fired) return;
  424.  
  425. FORCE_NO_REUSEABLE_ELEMENT_POOL_fired = true;
  426.  
  427.  
  428. if (typeof mainCnt.createComponent_ !== 'function' || mainCnt.createComponent_.length != 3) {
  429. console.warn('FORCE_NO_REUSEABLE_ELEMENT_POOL_fn failed.')
  430. return;
  431. }
  432.  
  433.  
  434. const mapGet = Map.prototype.get;
  435. const setHas = Set.prototype.has;
  436.  
  437.  
  438. /** @type {Map | null} */
  439. let qcMap = null;
  440.  
  441. Set.prototype.has = function (a) {
  442. if (a === 'dummy-4718') return false; // false to allow re-use?
  443. return setHas.call(this, a);
  444. }
  445.  
  446. Map.prototype.get = function (a) {
  447. if (a === 'dummy-4718') qcMap = this;
  448. return mapGet.call(this, a);
  449. };
  450. let r;
  451. try {
  452. r = mainCnt.createComponent_('dummy-4718', {}, true);
  453. } catch (e) {
  454.  
  455. }
  456.  
  457. Map.prototype.get = mapGet;
  458. Set.prototype.has = setHas;
  459.  
  460. if (r && (r.nodeName || '').toLowerCase() === 'dummy-4718') {
  461.  
  462.  
  463. // clearInterval(ckId);
  464. // ckId = 0;
  465.  
  466. if (qcMap !== null && qcMap instanceof Map) {
  467.  
  468. console.log('[yt-js-engine-tamer] qcMap', qcMap);
  469. qcMap.__qcMap8781__ = true;
  470.  
  471. const setArrayC = (c) => {
  472. if (c instanceof Array) {
  473. c.length = 0;
  474. c.push = function () { };
  475. c.pop = function () { };
  476. c.shift = function () { };
  477. c.unshift = function () { };
  478. c.splice = function () { };
  479. c.sort = function () { };
  480. c.reverse = function () { };
  481. }
  482. }
  483.  
  484. const cleaning = function (m) {
  485. m.forEach(setArrayC);
  486. m.clear();
  487. }
  488.  
  489. qcMap.set = function (b, c) {
  490. if (!this.__qcMap8781__) return Map.prototype.set.call(this, b, c);
  491.  
  492. setArrayC(c);
  493.  
  494. // console.log('qcMap.set', b, c);
  495.  
  496. if (this.size > 0) {
  497. // play safe
  498.  
  499. console.log('[yt-js-engine-tamer] qcMap', 'clear 01')
  500. cleaning(this);
  501. }
  502.  
  503. }
  504. qcMap.get = function (b) {
  505. if (!this.__qcMap8781__) return Map.prototype.get.call(this, b);
  506.  
  507. // console.log('qcMap.get', b);
  508.  
  509. if (this.size > 0) {
  510. // play safe
  511.  
  512. console.log('[yt-js-engine-tamer] qcMap', 'clear 02')
  513. cleaning(this);
  514. }
  515.  
  516. }
  517.  
  518.  
  519. if (qcMap.size > 0) {
  520.  
  521. console.log('[yt-js-engine-tamer] qcMap', 'clear 03')
  522. cleaning(qcMap);
  523. }
  524.  
  525. }
  526.  
  527. }
  528.  
  529. r = null;
  530. qcMap = null;
  531.  
  532. }
  533.  
  534.  
  535. const dispatchYtEvent = function (a, b, c, d) {
  536. d || (d = {
  537. bubbles: !0,
  538. cancelable: !1,
  539. composed: !0
  540. });
  541. c !== null && c !== void 0 && (d.detail = c);
  542. b = new CustomEvent(b, d);
  543. a.dispatchEvent(b);
  544. return b
  545. };
  546.  
  547.  
  548. if (XFlag) {
  549.  
  550. const cMap = new Set();
  551. cMap.add = cMap.addOriginal || cMap.add;
  552. const yMap = new Set();
  553. yMap.add = yMap.addOriginal || yMap.add;
  554.  
  555.  
  556. const ydMap = new Set();
  557. ydMap.add = ydMap.addOriginal || ydMap.add;
  558.  
  559. window.yMap = yMap;
  560. window.cMap = cMap;
  561. window.ydMap = ydMap;
  562.  
  563. const constructAts = new Set();
  564. constructAts.add = constructAts.addOriginal || constructAts.add;
  565. window.constructAts = constructAts;
  566.  
  567. const kMap = new WeakMap();
  568.  
  569. const kRefProp = (wr, prop)=>{
  570. let o = kRef(wr);
  571. return o ? o[prop] : null;
  572. }
  573.  
  574. const wrObj = (objRef, props) => {
  575. let wr = mWeakRef(objRef);
  576. if (wr === objRef || !props || !props.length) return wr;
  577. let properties = {};
  578. props.forEach(k => {
  579. properties[k] = {
  580. get() {
  581. return kRefProp(this, k)
  582. },
  583. enumerable: false,
  584. configurable: true
  585. };
  586. });
  587. Object.defineProperties(wr, properties);
  588. return wr;
  589. }
  590.  
  591. const sProtos = {};
  592.  
  593. const setupCProto = function (cProto) {
  594.  
  595. if(cProto === Object.prototype) return;
  596.  
  597. if (!kMap.get(cProto)) kMap.set(cProto, `protoKey0_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${Date.now()}`);
  598. cProto[kMap.get(cProto)] = true;
  599. // debugger;
  600.  
  601. 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];
  602. constructAts.add(constructAt)
  603.  
  604. if (MemoryFix_Flag002 & 32) {
  605. if (!cProto.dk322 && (cProto.__attachInstance || cProto.__detachInstance)) {
  606. fixDetachFn(cProto);
  607. }
  608. }
  609.  
  610. if (cProto.stampDomArray_ && !cProto.__stampDX38__) {
  611.  
  612. cProto.__stampDX38__ = true;
  613.  
  614. if (cProto.stampDomArray_.length === 6) {
  615. const pendingFinishContainers = new Map();
  616. const producerMap2 = new WeakMap();
  617. const mutObs = new MutationObserver((mutations) => {
  618. if (pendingFinishContainers.size === 0) return;
  619. let dirtyProducers = new Map();
  620. pendingFinishContainers.forEach((p, containerWr) => {
  621. const container = kRef(containerWr);
  622. if (!container) return pendingFinishContainers.delete(containerWr);
  623. const producerWr = producerMap2.get(container);
  624. if (!producerWr) return pendingFinishContainers.delete(containerWr);
  625. const producer = kRef(producerWr);
  626. if (!producer) return pendingFinishContainers.delete(containerWr);
  627. let dirtyVal = dirtyProducers.get(producer);
  628. if (dirtyVal === false) return;
  629. if (!dirtyVal) {
  630. const hostElement = producer.hostElement;
  631. if (!hostElement) return pendingFinishContainers.delete(containerWr);
  632. if (hostElement.querySelector('rp[yt-element-placholder], [ytx-stamping], [ytx-flushing]')) {
  633. dirtyProducers.set(producer, false);
  634. return;
  635. }
  636. }
  637. pendingFinishContainers.delete(containerWr);
  638. if (!dirtyVal) dirtyProducers.set(producer, (dirtyVal = new Set()));
  639. let o = dirtyVal;
  640. if (p === 'e') {
  641. o.add(container);
  642. }
  643. });
  644. if (dirtyProducers.size === 0) return;
  645. dirtyProducers.forEach((o, producer) => {
  646. if (o instanceof Set) {
  647. const hostElement = producer.hostElement;
  648. hostElement.removeAttribute('ytx-debug-0173');
  649. producer.markDirty && producer.markDirty();
  650. for (const container of o) {
  651. dispatchYtEvent(hostElement, "yt-rendererstamper-finished", {
  652. container
  653. });
  654. }
  655. o.clear();
  656. }
  657. });
  658. dirtyProducers.clear();
  659. dirtyProducers = null;
  660. });
  661.  
  662.  
  663. /*
  664. cProto.stampDomArray8581_ = cProto.stampDomArray_;
  665.  
  666. cProto.stampDomArray_ = function (dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList) {
  667.  
  668. const lastByPass01 = this.__lastByPass__
  669. if (this.__stampTaskMap488__ instanceof Map) this.__stampTaskMap488__.delete(containerId);
  670.  
  671. const b = this.flushRenderStamperComponentBindings_;
  672. this.flushRenderStamperComponentBindings_ = function () {
  673. b.call(this);
  674. throw new Error('82919');
  675. }
  676. let r, e_;
  677. try {
  678. r = this.stampDomArray8581_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  679. } catch (e) {
  680. e_ = e;
  681. }
  682. if (Reflect.getPrototypeOf(this).flushRenderStamperComponentBindings_ === b) {
  683. delete this.flushRenderStamperComponentBindings_;
  684. }
  685. if (this.flushRenderStamperComponentBindings_ !== b) {
  686. this.flushRenderStamperComponentBindings_ = b;
  687. }
  688.  
  689. const lastByPass02 = this.__lastByPass__
  690. if (e_ && e_.message !== '82919') throw e_;
  691. if (e_ && e_.message === '82919') {
  692.  
  693. if (lastByPass01 !== lastByPass02 && (lastByPass02 & 1)) {
  694. console.log(123288, this.hostElement.nodeName)
  695. const producer = this;
  696. const container = producer.getStampContainer_(containerId);
  697. const hostElement = producer.hostElement;
  698. hostElement.setAttribute('ytx-debug-0173', '')
  699. if (!producer[wk]) producer[wk] = mWeakRef(producer);
  700. if (!container[wk]) container[wk] = mWeakRef(container);
  701. producerMap2.set(container, producer[wk]);
  702. const currentVal = pendingFinishContainers.get(container[wk]);
  703. const newVal = bEventCb ? 'e' : '1';
  704. if (newVal === 'e' && currentVal !== newVal) {
  705. pendingFinishContainers.set(container[wk], newVal);
  706. } else if (newVal === '1' && !currentVal) {
  707. pendingFinishContainers.set(container[wk], newVal);
  708. }
  709. mutObs.observe(hostElement, { subtree: true, childList: true });
  710. hostElement.appendChild(document.createComment('-')).remove();
  711. }
  712. }
  713. return r;
  714. }
  715. */
  716.  
  717.  
  718. // if (MemoryFix_Flag002 & 1) {
  719. // cProto.stampDomArray_.bind = sProtos.stampDomArray_$bind || (sProtos.stampDomArray_$bind = function (obj, ...args) {
  720. // let wobj = obj[wk] || (obj[wk] = mWeakRef(obj));
  721. // return () => {
  722. // const obj = kRef(wobj);
  723. // let u = Reflect.apply(this, obj, args);
  724. // args.length = 0;
  725. // wobj = null;
  726. // return u;
  727. // };
  728. // });
  729. // }
  730. }
  731.  
  732. }
  733.  
  734. if (MemoryFix_Flag002 & 2) {
  735. if (cProto._setPendingProperty && !cProto.__setPropDX38__) {
  736. cProto.__setPropDX38__ = true;
  737.  
  738. if (cProto._setPendingProperty.length === 3) {
  739. cProto._setPendingProperty.bind = sProtos._setPendingProperty$bind || (sProtos._setPendingProperty$bind = function (obj, ...args) {
  740. let wobj = obj[wk] || (obj[wk] = mWeakRef(obj));
  741. return () => {
  742. const obj = kRef(wobj);
  743. let u = Reflect.apply(this, obj, args);
  744. args.length = 0;
  745. wobj = null;
  746. return u;
  747. };
  748. });
  749. }
  750.  
  751. }
  752. }
  753.  
  754. if (MemoryFix_Flag002 & 4) {
  755. if (cProto._runEffectsForTemplate && !cProto.__runEffectDX38__) {
  756. cProto.__runEffectDX38__ = true;
  757.  
  758. if (cProto._runEffectsForTemplate.length === 4) {
  759. cProto._runEffectsForTemplate3858 = cProto._runEffectsForTemplate;
  760. cProto._runEffectsForTemplate = sProtos._runEffectsForTemplate || (sProtos._runEffectsForTemplate = function (c, d, e, g) {
  761. if (c && c.runEffects) {
  762. let wr = wrObj(c, ['propertyEffects', 'nodeList', 'firstChild']);
  763. // console.log(12837)
  764. if (!this[wk]) this[wk] = mWeakRef(this);
  765. if ((typeof (e || 0) === "object") && !e[wk]) e[wk] = mWeakRef(e);
  766. let cntWr = this[wk];
  767. let eWr = (typeof (e || 0) === "object") ? e[wk] : e;
  768. c.runEffects((n, r) => {
  769. // console.log(12838)
  770. const cnt = kRef(cntWr);
  771. const e = kRef(eWr);
  772. if (cnt) {
  773. cnt._runEffectsForTemplate3858(wr, n, e, r);
  774. }
  775. wr = cntWr = d = e = g = null;
  776. }, d, g);
  777. } else {
  778. let { propertyEffects, nodeList, firstChild } = c;
  779. let o = { propertyEffects, nodeList, firstChild }
  780. this._runEffectsForTemplate3858(o, d, e, g);
  781. o.propertyEffects = o.nodeList = o.firstChild = null;
  782. propertyEffects = nodeList = firstChild = null;
  783. o = null;
  784. }
  785.  
  786. });
  787.  
  788. cProto._runEffectsForTemplate.bind = sProtos._runEffectsForTemplate$bind || (sProtos._runEffectsForTemplate$bind = function (obj, ...args) {
  789. // console.log(12993, args)
  790. let wobj = obj[wk] || (obj[wk] = mWeakRef(obj));
  791. return () => {
  792. const obj = kRef(wobj);
  793. let u = Reflect.apply(this, obj, args);
  794. args.length = 0;
  795. wobj = null;
  796. return u;
  797. };
  798. });
  799. }
  800.  
  801. }
  802. }
  803.  
  804.  
  805.  
  806.  
  807.  
  808. const cProtoConstructor = cProto.constructor;
  809.  
  810. if (MemoryFix_Flag002 & 8) {
  811. if (cProtoConstructor._parseBindings && !cProtoConstructor.__parseBindingsDX38__) {
  812. cProtoConstructor.__parseBindingsDX38__ = true;
  813.  
  814. ydMap.add(cProtoConstructor);
  815.  
  816. if (cProtoConstructor._parseBindings.length === 2) {
  817.  
  818. cProtoConstructor._parseBindings3858 = cProtoConstructor._parseBindings;
  819.  
  820. cProtoConstructor._parseBindings = sProtos._parseBindings || (sProtos._parseBindings = function (c, d) {
  821. let p = this._parseBindings3858(c, d);
  822. this.__bindingsArrs__ = this.__bindingsArrs__ || [];
  823. if (p) this.__bindingsArrs__.push(p);
  824. return p;
  825. });
  826.  
  827. }
  828. }
  829. }
  830.  
  831. /*
  832. a.prototype._initializeProperties = function() {
  833. if (Em && this.hasAttribute("disable-upgrade"))
  834. this.__isUpgradeDisabled = !0;
  835. else {
  836. var e = Object.getPrototypeOf(this);
  837. e.hasOwnProperty("__hasRegisterFinished") || (this._registered(),
  838. e.__hasRegisterFinished = !0);
  839. b.prototype._initializeProperties.call(this);
  840. this.root = this;
  841. this.created();
  842. fpb && !this._legacyForceObservedAttributes && (this.hasAttributes() ? this._takeAttributes() : this.parentNode || (this.__needsAttributesAtConnected = !0));
  843. this._applyListeners()
  844. }
  845. }
  846. */
  847. /*
  848. bOa = function(a, b, c) {
  849. var d = bya(a.prototype, $Na, a.prototype.behaviors);
  850. d.prototype.is = b;
  851. d.prototype.localName = b;
  852. c && aOa(d, c);
  853. return function(e) {
  854. e && (d.prototype.hostElement = e);
  855. var g = new d;
  856. g.root = g;
  857. g.hostElement = e;
  858. return g
  859. }
  860. }
  861. */
  862.  
  863.  
  864. }
  865. const symDH = Symbol();
  866.  
  867. const wfStore = new WeakMap();
  868.  
  869. const wrapF = function (f, key) {
  870. if (wfStore.get(f)) return wfStore.get(f);
  871.  
  872. let g = function () {
  873. const o = kRef(this);
  874. if (!o) return;
  875. const cnt = insp(o);
  876. // if (cnt === o) return;
  877. // if (!('ready' in cnt)) return;
  878. return f.apply(o, arguments);
  879. };
  880. g.key38 = key;
  881. g.originalFunc38 = f;
  882. g.__wrapF84__ = true;
  883. wfStore.set(f, g);
  884. wfStore.set(g, g);
  885. return g;
  886. };
  887.  
  888. if (MemoryFix_Flag002 & 16) {
  889. ['_createPropertyAccessor', '_addPropertyToAttributeMap', '_definePropertyAccessor', 'ready', '_initializeProperties', '_initializeInstanceProperties', '_setProperty', '_getProperty', '_setPendingProperty', '_isPropertyPending', '_invalidateProperties', '_enableProperties', '_flushProperties', '_shouldPropertiesChange', '_propertiesChanged', '_shouldPropertyChange', 'attributeChangedCallback', '_attributeToProperty', '_propertyToAttribute', '_valueToNodeAttribute', '_serializeValue', '_deserializeValue'].forEach(key => {
  890.  
  891. Object.defineProperty(Node.prototype, key, {
  892. get() {
  893. return this[`__a0939${key}__`];
  894. },
  895. set(nv) {
  896. if (typeof nv !== 'function') return;
  897. const g = (nv.__wrapF84__) ? nv : wrapF(nv, key);
  898. this[`__a0939${key}__`] = g;
  899. return true;
  900. }
  901. });
  902.  
  903.  
  904. });
  905. }
  906.  
  907.  
  908. const fragQ = document.createDocumentFragment(); // for cleaup removal
  909. const fixDetachFn = (tpProto) => {
  910.  
  911. if (tpProto.dk322) return;
  912. tpProto.dk322 = true;
  913.  
  914. tpProto.__detachInstance994 = tpProto.__detachInstance;
  915. if (typeof tpProto.__detachInstance994 === 'function' && tpProto.__detachInstance994.length === 1) {
  916. tpProto.__detachInstance = function (a) {
  917. const u = this.__instances[a];
  918. if (u && u.root) {
  919. const children = u ? u.children : null;
  920. if (children && children.length >= 1) {
  921. this.__detachInstance994(a);
  922. }
  923. } else if (u && !u.root) {
  924. const children = u ? u.children : null;
  925. if (children && children.length >= 1) {
  926. for (let i = 0, l = children.length; i < l; i++) {
  927. const node = children[i];
  928. fragQ.appendChild(node); // for cleanup
  929. Promise.resolve(node).then(node => (node.parentNode === fragQ) && !!node.remove());
  930. }
  931. }
  932. }
  933. return u;
  934. }
  935. }
  936.  
  937.  
  938.  
  939. tpProto.__attachInstance994 = tpProto.__attachInstance;
  940. if (typeof tpProto.__attachInstance994 === 'function' && tpProto.__attachInstance994.length === 2) {
  941. tpProto.__attachInstance = function (a, b) {
  942. const u = this.__instances[a];
  943. if (u && u.root && b) {
  944. fragQ.appendChild(u.root); // for cleanup
  945. return this.__attachInstance994(a, b);
  946. }
  947. }
  948. }
  949.  
  950. }
  951. const ytTemplateDomEntry = (tpProto) => {
  952.  
  953. console.log('ytTemplateDomEntry triggered')
  954.  
  955.  
  956. const convertToWeakArr = (arr) => {
  957.  
  958.  
  959. if (arr.isWeak) return;
  960.  
  961. for (let i = 0, l = arr.length; i < l; i++) {
  962. const o = arr[i]
  963. if (o) {
  964. let p = kRef(o)
  965. if (!p) arr[i] = null;
  966. else {
  967. if (!o[wk]) o[wk] = mWeakRef(o);
  968. arr[i] = o[wk];
  969. }
  970. }
  971. }
  972. arr.isWeak = true;
  973.  
  974. }
  975.  
  976. const convertToNormalArr = (arr) => {
  977.  
  978. if (!arr.isWeak) return;
  979.  
  980. for (let i = 0, l = arr.length; i < l; i++) {
  981. const o = arr[i]
  982. if (o) {
  983. let p = kRef(o)
  984. arr[i] = p;
  985. }
  986. }
  987. arr.isWeak = false;
  988.  
  989. }
  990.  
  991. if (MemoryFix_Flag002 & 256) {
  992. Object.defineProperty(tpProto, '__instances', {
  993. get() {
  994. this.dk322 || fixDetachFn(Reflect.getPrototypeOf(this));
  995. let arr = this.__instances_actual471__;
  996. convertToNormalArr(arr);
  997. Promise.resolve(arr).then(convertToWeakArr);
  998. return arr;
  999. },
  1000. set(nv) {
  1001. this.dk322 || fixDetachFn(Reflect.getPrototypeOf(this));
  1002. this.__instances_actual471__ = nv;
  1003. Promise.resolve(nv).then(convertToWeakArr);
  1004. return true;
  1005. },
  1006. enumerable: false,
  1007. configurable: true
  1008. });
  1009. }
  1010.  
  1011. // console.log(91901, tpProto.__detachInstance)
  1012. if (MemoryFix_Flag002 & 32) {
  1013. if (tpProto.__detachInstance) {
  1014. fixDetachFn(tpProto);
  1015. } else {
  1016. Promise.resolve(tpProto).then((tpProto) => {
  1017. // console.log(91902, tpProto.__detachInstance)
  1018. fixDetachFn(tpProto);
  1019. })
  1020. }
  1021. }
  1022.  
  1023. }
  1024.  
  1025. if (MemoryFix_Flag002 & 32) {
  1026. Object.defineProperty(Object.prototype, '__ensureTemplatized', {
  1027. set(nv) {
  1028. if (nv === true) return false;
  1029. tpProto = this;
  1030. if ('connectedCallback' in tpProto && tpProto !== Node.prototype && !tpProto.__domDX37__) {
  1031. tpProto.__domDX37__ = true;
  1032. ytTemplateDomEntry(tpProto);
  1033. }
  1034. this.__ensureTemplatized949__ = nv;
  1035. return true;
  1036. },
  1037. get() {
  1038. return this.__ensureTemplatized949__;
  1039. }
  1040. });
  1041. }
  1042.  
  1043.  
  1044. if (MemoryFix_Flag002 & 64) {
  1045. HTMLElement_.prototype.__dataHostBinding374 = true;
  1046. Object.defineProperty(HTMLElement_.prototype, '__dataHost', {
  1047. get() {
  1048. return kRef(this.__dataHostWr413__);
  1049. },
  1050. set(nv) {
  1051. if (nv && typeof nv === 'object' && !nv.deref) {
  1052. if (!nv[wk]) nv[wk] = mWeakRef(nv);
  1053. nv = nv[wk];
  1054. }
  1055. this.__dataHostWr413__ = nv;
  1056. return true;
  1057. }
  1058. });
  1059. }
  1060.  
  1061.  
  1062. const setupYProto = function (yProto) {
  1063.  
  1064. if(yProto === Object.prototype) return;
  1065.  
  1066. if (!kMap.get(yProto)) kMap.set(yProto, `protoKey1_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${Date.now()}`);
  1067. yProto[kMap.get(yProto)] = true;
  1068.  
  1069. if (MemoryFix_Flag002 & 32) {
  1070. if (!yProto.dk322 && (yProto.__attachInstance || yProto.__detachInstance)) {
  1071. fixDetachFn(yProto);
  1072. }
  1073. }
  1074.  
  1075. if (MemoryFix_Flag002 & 128) {
  1076. if (!yProto.__dataHostBinding374) {
  1077. yProto.__dataHostBinding374 = true;
  1078. Object.defineProperty(yProto, '__dataHost', {
  1079. set(nv) {
  1080. let dh = nv;
  1081. if (dh && typeof dh === 'object' && !dh.deref) {
  1082. const wr = dh[wk] || (dh[wk] = mWeakRef(dh));
  1083. dh = wr;
  1084. }
  1085. this[symDH] = dh;
  1086. return true;
  1087. },
  1088. get() {
  1089. let wr = this[symDH];
  1090. let obj = typeof wr === 'object' ? kRef(wr) : wr;
  1091. return obj;
  1092. },
  1093. enumerable: false,
  1094. configurable: true
  1095. });
  1096. }
  1097.  
  1098.  
  1099.  
  1100. if (yProto._registerHost && yProto._enqueueClient && yProto.__enableOrFlushClients && !yProto._registerHostDX38__) {
  1101. yProto._registerHostDX38__ = true;
  1102.  
  1103. // yProto._registerHost7133 = yProto._registerHost;
  1104.  
  1105. yProto.__enableOrFlushClients = function () {
  1106. const c_ = this.__dataPendingClients;
  1107. if (c_) {
  1108. const c = c_.slice();
  1109. c_.length = 0;
  1110. for (let d = 0, l = c.length; d < l; d++) {
  1111. let e = kRef(c[d]);
  1112. if (e) {
  1113. e.__dataEnabled ? e.__dataPending && e._flushProperties() : e._enableProperties()
  1114. }
  1115. }
  1116. }
  1117. }
  1118.  
  1119. yProto._enqueueClient = function (c) {
  1120. if (c === this || !c || typeof c !== 'object') return;
  1121. if (c.deref) c = kRef(c);
  1122. const m = this.__dataPendingClients || (this.__dataPendingClients = []);
  1123. if (!c[wk]) c[wk] = mWeakRef(c);
  1124. m.push(c[wk]);
  1125. }
  1126.  
  1127. }
  1128. }
  1129.  
  1130.  
  1131.  
  1132. }
  1133. const setupRendering = function () {
  1134.  
  1135. const cnt = this;
  1136. const cProto = Reflect.getPrototypeOf(cnt);
  1137. let yProto = Reflect.getPrototypeOf(cProto);
  1138.  
  1139. const yProtos = new Set();
  1140.  
  1141. if (!yMap.has(yProto)) {
  1142. // capture all ancenstor constructors of a and b (non-specific component type)
  1143.  
  1144. do {
  1145. if (yProto === Object.prototype || yProto === null) break;
  1146. if (yProto === Element.prototype || yProto === Node.prototype || yProto === EventTarget.prototype || yProto === HTMLElement_.prototype) break;
  1147. yProtos.add(yProto);
  1148. yProto = Reflect.getPrototypeOf(yProto);
  1149. } while (!yProtos.has(yProto));
  1150.  
  1151. for (const yProto of yProtos) {
  1152. yMap.add(yProto);
  1153. setupYProto(yProto)
  1154. }
  1155.  
  1156. }
  1157.  
  1158.  
  1159. if (!cMap.has(cProto)) {
  1160. cMap.add(cProto); // cProto constrcutor is either a or b? (specific component type)
  1161. setupCProto(cProto);
  1162. }
  1163.  
  1164. }
  1165.  
  1166. const selfRef = {}; // no change. just key
  1167.  
  1168.  
  1169. let wm3 = new WeakMap();
  1170.  
  1171. Object.defineProperty(Object.prototype, 'root', {
  1172. get() {
  1173. const p = this ? kRef(this) : null;
  1174. const r = p ? wm3.get(p) : null;
  1175. const r2 = r ? kRef(r) : null;
  1176. if (r === selfRef) return p;
  1177. return r2;
  1178. },
  1179. set(nv) {
  1180. const p = this ? kRef(this) : null;
  1181. const mv = nv ? kRef(nv) : null;
  1182. if (typeof mv !== 'object') return;
  1183. if (mv && (mv instanceof Node) && !p.__setupRendered399__) {
  1184. p.__setupRendered399__ = true;
  1185. setupRendering.call(p);
  1186. }
  1187. if (mv && mv.is && !mv.__setupRendered399__) {
  1188. mv.__setupRendered399__ = true;
  1189. setupRendering.call(mv);
  1190. }
  1191. if (mv === p) {
  1192. wm3.set(p, selfRef)
  1193. return true;
  1194. }
  1195. let gv = nv;
  1196. if (nv && !nv[wk]) {
  1197. gv = nv[wk] = mWeakRef(nv);
  1198. }
  1199. if (p) {
  1200. wm3.set(p, gv);
  1201. }
  1202. return true;
  1203. },
  1204. enumerable: false,
  1205. configurable: true
  1206. });
  1207.  
  1208.  
  1209.  
  1210. }
  1211.  
  1212. function getTranslate() {
  1213.  
  1214. pLoad.then(() => {
  1215.  
  1216. let nonce = document.querySelector('style[nonce]');
  1217. nonce = nonce ? nonce.getAttribute('nonce') : null;
  1218. const st = document.createElement('style');
  1219. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  1220. st.textContent = ".yt-formatted-string-block-line{display:block;}";
  1221. let parent;
  1222. if (parent = document.head) parent.appendChild(st);
  1223. else if (parent = (document.body || document.documentElement)) parent.insertBefore(st, parent.firstChild);
  1224.  
  1225. });
  1226.  
  1227. const snCache = new Map();
  1228.  
  1229. if (TRANSLATE_DEBUG) {
  1230. console.log(11)
  1231. }
  1232.  
  1233. /** @type {(str: string?) => string} */
  1234. function _snippetText(str) {
  1235. // str can be underfinded
  1236. if (!str || typeof str !== 'string') return '';
  1237. let res = snCache.get(str);
  1238. if (res === undefined) {
  1239. let b = false;
  1240. res = str.replace(/[\s\u3000\u200b]*[\u200b\xA0\x20\n]+[\s\u3000\u200b]*/g, (m) => {
  1241. b = true;
  1242. return m.includes('\n') ? '\n' : m.replace(/\u200b/g, '').replace(/[\xA0\x20]+/g, ' ');
  1243. });
  1244. res = res.replace(/^[\s\u3000]+|[\u3000\s]+$/g, () => {
  1245. b = true;
  1246. return '';
  1247. });
  1248. if (b) {
  1249. snCache.set(str, res);
  1250. snCache.set(res, null);
  1251. } else {
  1252. res = null;
  1253. snCache.set(str, null);
  1254. }
  1255. }
  1256. return res === null ? str : res;
  1257. }
  1258.  
  1259. /** @type {(snippet: Object) => string} */
  1260. function snippetText(snippet) {
  1261. let runs = snippet.runs;
  1262. const n = runs.length;
  1263. if (n === 1) return _snippetText(runs[0].text);
  1264. let res = new Array(n);
  1265. let ci = 0;
  1266. for (const s of runs) {
  1267. res[ci++] = _snippetText(s.text);
  1268. }
  1269. return res.join('\n');
  1270. }
  1271.  
  1272. const _DEBUG_szz = (t) => t.map(x => {
  1273. const tsr = x.transcriptSegmentRenderer;
  1274. return ({
  1275. t: tsr.snippet.runs.map(x => x.text).join('//'),
  1276. a: tsr.startMs,
  1277. b: tsr.endMs
  1278. });
  1279. });
  1280.  
  1281. const fixRuns = (runs) => {
  1282. if (runs.length === 1 && runs[0]?.text?.includes('\n')) {
  1283. // https://www.youtube.com/watch?v=dmHJJ5k_G-A
  1284. const text = runs[0].text;
  1285. const nlc = text.includes('\r\n') ? '\r\n' : text.includes('\n\r') ? '\n\r' : text.includes('\r') ? '\r' : '\n';
  1286. const s = text.split(nlc);
  1287. let bi = 0;
  1288. runs.length = s.length;
  1289. for (const text of s) {
  1290. runs[bi++] = { ...runs[0], text, ...{blockLine: true} };
  1291. }
  1292. }
  1293. for (const s of runs) {
  1294. s.text = _snippetText(s.text);
  1295. }
  1296. }
  1297.  
  1298. function translate(initialSegments) {
  1299. // 2023.07.13 - fix initialSegments with transcriptSectionHeaderRenderer
  1300.  
  1301. if (!initialSegments) return initialSegments;
  1302.  
  1303. if (TRANSLATE_DEBUG) {
  1304. console.log(12);
  1305. Promise.resolve(JSON.stringify(initialSegments)).then((r) => {
  1306. let obj = JSON.parse(r);
  1307. console.log(7558, 1, obj)
  1308. return obj;
  1309. }).then(p => {
  1310. let obj = _DEBUG_szz(p)
  1311. console.log(7558, 2, obj)
  1312. })
  1313. }
  1314.  
  1315.  
  1316. //let mapRej = new WeakSet();
  1317.  
  1318. const n1 = initialSegments.length;
  1319. if (!n1) return fRes;
  1320. let n2 = 0;
  1321.  
  1322.  
  1323. const fRes = new Array(n1);
  1324. // -----------------------------------------------------------------------------------------
  1325.  
  1326. const s8 = Symbol();
  1327.  
  1328. {
  1329.  
  1330. /** @type {Map<String, Object>} */
  1331. let cacheTexts = new Map(); // avoid duplicate with javascript object properties
  1332.  
  1333. // /-* * @type {Map<String, number>} *-/
  1334. // let mh1 = new Map(); // avoid duplicate with javascript object properties
  1335. // 1: ok
  1336. // 2: abandoned effect text
  1337.  
  1338. for (const initialSegment of initialSegments) {
  1339. const transcript = (initialSegment || 0).transcriptSegmentRenderer;
  1340. if (!transcript) {
  1341. // https://www.youtube.com/watch?v=dmHJJ5k_G-A - transcriptSectionHeaderRenderer
  1342. fRes[n2++] = initialSegment;
  1343. continue;
  1344. }
  1345. const runs = transcript.snippet.runs
  1346. if (!runs || runs.length === 0) {
  1347. initialSegment[s8] = true;
  1348. continue;
  1349. }
  1350. let startMs = (+transcript.startMs || 0); //integer
  1351. let endMs = (+transcript.endMs || 0); //integer
  1352. if (startMs === endMs) {
  1353. // effect text
  1354. // https://www.youtube.com/watch?v=Ud73fm4Uoq0
  1355. //mapRej.add(initialSegment)
  1356. continue;
  1357. }
  1358. if (endMs - startMs < 30) {
  1359. continue;
  1360. }
  1361. const text = snippetText(transcript.snippet);
  1362. const hEntry = cacheTexts.get(text);
  1363. const mh1e = hEntry === undefined ? 0 : hEntry === null ? 2 : 1;
  1364. if (mh1e === 2) continue;
  1365. const entry = {
  1366. startMs,
  1367. endMs,
  1368. initialSegment,
  1369. text
  1370. };
  1371. if (mh1e === 0) {
  1372. if (/^[,.\x60\x27\x22\u200b\xA0\x20;-]*$/.test(text)) {
  1373. initialSegment[s8] = true;
  1374. cacheTexts.set(text, null);
  1375. //effect only
  1376. // https://www.youtube.com/watch?v=zLak0dxBKpM
  1377. //mapRej.add(initialSegment)
  1378. continue;
  1379. }
  1380. } else if (hEntry) {
  1381.  
  1382. const timeDiff = entry.startMs - hEntry.endMs;
  1383. let shouldMerge = false;
  1384.  
  1385. if (timeDiff >= 0) {
  1386.  
  1387. if (timeDiff < 25) {
  1388. shouldMerge = true;
  1389. } else if (timeDiff < 450 && entry.endMs - entry.startMs < 900) {
  1390. shouldMerge = true;
  1391. } else if (timeDiff < 150 && entry.endMs - entry.startMs > 800) {
  1392. shouldMerge = true;
  1393. }
  1394.  
  1395. if (shouldMerge && hEntry.endMs <= endMs && startMs <= endMs) {
  1396. // abandon the current entry.
  1397. // absorbed by previous entry
  1398. hEntry.endMs = entry.endMs;
  1399. hEntry.initialSegment.transcriptSegmentRenderer.endMs = entry.initialSegment.transcriptSegmentRenderer.endMs; // update fRes & initialSegments as well using object reference
  1400. //mapRej.add(entry.initialSegment);
  1401. continue;
  1402. }
  1403.  
  1404. } else if (entry.startMs < hEntry.startMs && hEntry.startMs < entry.endMs) {
  1405.  
  1406. // abandon the current entry.
  1407. // absorbed by previous entry
  1408. if (entry.endMs > hEntry.endMs) {
  1409. hEntry.endMs = entry.endMs;
  1410. hEntry.initialSegment.transcriptSegmentRenderer.endMs = entry.initialSegment.transcriptSegmentRenderer.endMs; // update fRes & initialSegments as well using object reference
  1411. }
  1412. //mapRej.add(entry.initialSegment);
  1413. continue;
  1414.  
  1415. }
  1416.  
  1417. }
  1418. //if not abandoned
  1419. cacheTexts.set(text, entry); //replace the previous valid entry object if any
  1420. // for (const s of runs) {
  1421. // s.text = _snippetText(s.text);
  1422. // }
  1423. fixRuns(runs);
  1424. fRes[n2++] = initialSegment;
  1425. }
  1426.  
  1427. // cacheTexts.clear(); // let GC do it.
  1428. cacheTexts = null;
  1429. // mh1.clear(); // let GC do it.
  1430. // mh1 = null;
  1431.  
  1432. }
  1433.  
  1434. const si_length = fRes.length = n2;
  1435. const sj_length = n1;
  1436.  
  1437. if (si_length !== sj_length) { // for equal length, no fix is required & ignore spacing fix
  1438. // collect the abandon text to become second subtitle
  1439.  
  1440. let sj_start = 0;
  1441. let invalid_sj = -1;
  1442. for (let si = 0; si < si_length; si++) {
  1443. const segment = fRes[si];
  1444. let transcript = segment.transcriptSegmentRenderer;
  1445. if (!transcript) continue; // e.g. transcriptSectionHeaderRenderer
  1446. const runs = transcript.snippet.runs;
  1447. // fixRuns(runs);
  1448. if (runs.length > 1 || runs[0].text.includes('\n')) continue; // skip multi lines
  1449. const main_startMs = (+transcript.startMs || 0);
  1450. const main_endMs = (+transcript.endMs || 0);
  1451. transcript = null;
  1452.  
  1453. /** @type {Map<string, number>} */
  1454. let tMap = new Map(); // avoid duplicate with javascript object properties
  1455.  
  1456. // assume that it is asc-ordered array of key startMs;
  1457. for (let sj = sj_start; sj < sj_length; sj++) {
  1458. const initialSegment = initialSegments[sj];
  1459.  
  1460. if (!initialSegment || initialSegment[s8]) continue; // should invalid_sj be set ?
  1461.  
  1462. const tSegment = initialSegment.transcriptSegmentRenderer;
  1463.  
  1464. if (!tSegment) {
  1465. // https://www.youtube.com/watch?v=dmHJJ5k_G-A - transcriptSectionHeaderRenderer
  1466. invalid_sj = sj; // should invalid_sj be set ?
  1467. continue;
  1468. }
  1469.  
  1470. const startMs = (+tSegment.startMs || 0)
  1471. const isStartValid = startMs >= main_startMs;
  1472. if (!isStartValid) {
  1473. invalid_sj = sj;
  1474. continue;
  1475. }
  1476. // isStartValid must be true
  1477. if (startMs > main_endMs) {
  1478. sj_start = invalid_sj + 1;
  1479. break;
  1480. }
  1481.  
  1482. const endMs = (+tSegment.endMs || 0)
  1483. if (endMs <= main_endMs) {
  1484. const mt = snippetText(tSegment.snippet);
  1485. const prev = tMap.get(mt);
  1486. if (endMs >= startMs) {
  1487. tMap.set(mt, (prev || 0) + 1 + (endMs - startMs));
  1488. }
  1489. }
  1490.  
  1491. }
  1492.  
  1493. if (tMap.size <= 1) continue; // no second line
  1494. let rg = [...tMap.entries()]; // N x 2 2D-array [string,number][]
  1495. tMap = null;
  1496.  
  1497. // https://www.youtube.com/watch?v=Ud73fm4Uoq0
  1498.  
  1499. rg.sort((a, b) => b[1] - a[1]); //descending order of number
  1500.  
  1501. let targetZ = rg[1][1];
  1502. if (targetZ > 4) {
  1503. let az = 0;
  1504. let fail = false;
  1505. for (let idx = 2, rgl = rg.length; idx < rgl; idx++) {
  1506. az += rg[idx][1];
  1507. if (az >= targetZ) {
  1508. fail = true;
  1509. break;
  1510. }
  1511. }
  1512. if (!fail) {
  1513. const rgA = rg[0][0];
  1514. const rgB = rg[1][0];
  1515. const isDiff = rgB.replace(/\s/g, '') !== rgA.replace(/\s/g, '');
  1516. if (isDiff && rgA === _snippetText(runs[0].text)) {
  1517. if (runs[0] && runs[0].text) runs[0].blockLine = true;
  1518. runs.push({ text: rgB, blockLine: true });
  1519. }
  1520. }
  1521. }
  1522. rg = null;
  1523. }
  1524.  
  1525. TRANSLATE_DEBUG && Promise.resolve(fRes).then((r) => {
  1526.  
  1527. let obj = r;
  1528. console.log(7559, 1, obj)
  1529. return obj;
  1530. }).then(p => {
  1531. let obj = _DEBUG_szz(p)
  1532. console.log(7559, 2, obj)
  1533.  
  1534. });
  1535. }
  1536.  
  1537. // -----------------------------------------------------------------------------------------
  1538. snCache.clear();
  1539. return fRes;
  1540.  
  1541. }
  1542.  
  1543.  
  1544. return translate
  1545.  
  1546. }
  1547.  
  1548.  
  1549. let translateFn = null;
  1550.  
  1551. FIX_TRANSCRIPT_SEGMENTS && !isChatRoomURL && (() => {
  1552.  
  1553. const wmx = new WeakMap();
  1554.  
  1555. function fixSegments(ytObj) {
  1556. let a, b;
  1557. let seg = ((a = ytObj.data) == null ? void 0 : a[b = 'searchResultSegments']) || ((a = ytObj.data) == null ? void 0 : a[b = 'initialSegments']) || [];
  1558. if (!seg || !a || !b || typeof (seg || 0) !== 'object' || !Number.isFinite(seg.length * 1)) return;
  1559. translateFn = translateFn || getTranslate();
  1560. let cSeg;
  1561. cSeg = wmx.get(seg);
  1562. if (!cSeg) {
  1563. let vSeg = null;
  1564. try {
  1565. vSeg = translateFn(seg);
  1566. } catch (e) {
  1567. }
  1568. if (seg && typeof seg === 'object' && seg.length >= 1 && vSeg && typeof vSeg === 'object' && vSeg.length >= 1) {
  1569. // console.log('translated', vSeg);
  1570. cSeg = vSeg;
  1571. wmx.set(seg, cSeg);
  1572. wmx.set(cSeg, cSeg);
  1573. }
  1574. }
  1575. if (cSeg && cSeg !== seg) {
  1576. a[b] = cSeg;
  1577. }
  1578. }
  1579.  
  1580. const dfn = Symbol();
  1581. const Object_ = Object;
  1582. Object_[dfn] = Object_.defineProperties;
  1583. let activation = true;
  1584. Object_.defineProperties = function (obj, pds) {
  1585. let segments, get_;
  1586. if (activation && pds && (segments = pds.segments) && (get_ = segments.get)) {
  1587. activation = false;
  1588. segments.get = function () {
  1589. fixSegments(this);
  1590. return get_.call(this);
  1591. };
  1592. }
  1593. return Object_[dfn](obj, pds);
  1594. };
  1595.  
  1596. })();
  1597.  
  1598.  
  1599. let pf31 = new PromiseExternal();
  1600.  
  1601. // native RAF
  1602. let __requestAnimationFrame__ = typeof webkitRequestAnimationFrame === 'function' ? window.webkitRequestAnimationFrame.bind(window) : window.requestAnimationFrame.bind(window);
  1603.  
  1604. // 1st wrapped RAF
  1605. const baseRAF = (callback) => {
  1606. return p59 ? __requestAnimationFrame__(callback) : __requestAnimationFrame__((hRes) => {
  1607. pf31.then(() => {
  1608. callback(hRes);
  1609. });
  1610. });
  1611. };
  1612.  
  1613. // 2nd wrapped RAF
  1614. window.requestAnimationFrame = baseRAF;
  1615.  
  1616. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  1617. const indr = o => insp(o).$ || o.$ || 0;
  1618.  
  1619. const prototypeInherit = (d, b) => {
  1620. const m = Object.getOwnPropertyDescriptors(b);
  1621. for (const p in m) {
  1622. if (!Object.getOwnPropertyDescriptor(d, p)) {
  1623. Object.defineProperty(d, p, m[p]);
  1624. }
  1625. }
  1626. };
  1627.  
  1628.  
  1629. const firstObjectKey = (obj) => {
  1630. for (const key in obj) {
  1631. if (obj.hasOwnProperty(key) && typeof obj[key] === 'object') return key;
  1632. }
  1633. return null;
  1634. };
  1635.  
  1636. function searchNestedObject(obj, predicate, maxDepth = 64) {
  1637. // normal case: depth until 36
  1638. const result = [];
  1639. const visited = new WeakSet();
  1640.  
  1641. function search(obj, depth) {
  1642. visited.add(obj);
  1643. for (const [key, value] of Object.entries(obj)) {
  1644. // Recursively search nested objects and arrays
  1645. if (value !== null && typeof value === 'object') {
  1646. // Prevent infinite loops by checking if the object is already visited or depth exceeded
  1647. if (depth + 1 <= maxDepth && !visited.has(value)) {
  1648. search(value, depth + 1);
  1649. }
  1650. } else if (predicate(value)) {
  1651. result.push([obj, key]);
  1652. }
  1653. }
  1654. }
  1655.  
  1656. typeof (obj || 0) === 'object' && search(obj, 0);
  1657. return result;
  1658. }
  1659.  
  1660. /** @type {(o: Object | null) => WeakRef | null} */
  1661. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  1662.  
  1663. /** @type {(wr: Object | null) => Object | null} */
  1664. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  1665.  
  1666. const isIterable = (obj) => (Symbol.iterator in Object_(obj));
  1667.  
  1668. if (typeof Document.prototype.requestStorageAccessFor === 'function') {
  1669. if (DENY_requestStorageAccess) {
  1670. // https://developer.mozilla.org/en-US/docs/Web/API/Document/requestStorageAccessFor
  1671. Document.prototype.requestStorageAccessFor = undefined;
  1672. console.log('[yt-js-engine-tamer]', 'requestStorageAccessFor is removed.');
  1673. } else if (DISABLE_IFRAME_requestStorageAccess && window !== top) {
  1674. Document.prototype.requestStorageAccessFor = function () {
  1675. return new Promise((resolve, reject) => {
  1676. reject();
  1677. });
  1678. };
  1679. }
  1680. }
  1681.  
  1682. const traceStack = (stack) => {
  1683. let result = new Set();
  1684. let p = new Set();
  1685. let u = ''
  1686. for (const s of stack.split('\n')) {
  1687. if (s.split(':').length < 3) continue;
  1688. let m = /(([\w-_\.]+):\d+:\d+)[^:\r\n]*/.exec(s);
  1689. if (!m) continue;
  1690. p.add(m[2]);
  1691. if (p.size >= 3) break;
  1692. if(!u) u = m[2];
  1693. else if(p.size === 2 && u && u=== m[2]) break;
  1694. result.add(s);
  1695. }
  1696. return [...result].join('\n');
  1697. }
  1698.  
  1699. if (FIX_bind_self_this && !Function.prototype.bind488 && !Function.prototype.bind588) {
  1700. // window.m3bb = new Set();
  1701.  
  1702. // const smb = Symbol();
  1703. const vmb = 'dtz02' // Symbol(); // return kThis for thisArg
  1704. const vmc = 'dtz04' // Symbol(); // whether it is proxied fn
  1705. const vmd = 'dtz08' // Symbol(); // self fn proxy (fn--fn)
  1706.  
  1707. const thisConversionFn = (thisArg) => {
  1708. if (!thisArg) return null;
  1709. const kThis = thisArg[vmb];
  1710. if (kThis) {
  1711. const ref = kThis.ref;
  1712. return (ref ? kRef(ref) : null) || null;
  1713. }
  1714. return thisArg;
  1715. }
  1716.  
  1717. const pFnHandler2 = {
  1718. get(target, prop) {
  1719. if (prop === vmc) return target;
  1720. return Reflect.get(target, prop);
  1721. },
  1722. apply(target, thisArg, argumentsList) {
  1723. thisArg = thisConversionFn(thisArg);
  1724. if (thisArg) return Reflect.apply(target, thisArg, argumentsList);
  1725. }
  1726. }
  1727.  
  1728.  
  1729. const proxySelfHandler = {
  1730. get(target, prop) {
  1731. if(prop === vmb) return target;
  1732. const ref = target.ref;
  1733. const cnt = kRef(ref);
  1734. if (!cnt) return;
  1735. if (typeof cnt[prop] === 'function' && !cnt[prop][vmc] && !cnt[prop][vmb]) {
  1736. if (!cnt[prop][vmd]) cnt[prop][vmd] = new Proxy(cnt[prop], pFnHandler2);
  1737. return cnt[prop][vmd];
  1738. }
  1739. return cnt[prop];
  1740. },
  1741. set(target, prop, value) {
  1742. const cnt = kRef(target.ref);
  1743. if (!cnt) return true;
  1744. if(value && (value[vmc] || value[vmb])){
  1745. cnt[prop] = value[vmc] || thisConversionFn(value);
  1746. return true;
  1747. }
  1748. cnt[prop] = value;
  1749. return true;
  1750. }
  1751. };
  1752.  
  1753. const weakWrap = (thisArg) => {
  1754. thisArg = thisConversionFn(thisArg);
  1755. if (!thisArg) {
  1756. console.error('thisArg is not found');
  1757. return null;
  1758. }
  1759. return new Proxy({ ref: mWeakRef(thisArg) }, proxySelfHandler);
  1760. }
  1761.  
  1762. if (!window.getComputedStyle533 && typeof window.getComputedStyle === 'function') {
  1763. window.getComputedStyle533 = window.getComputedStyle;
  1764. window.getComputedStyle = function (a, ...args) {
  1765. a = thisConversionFn(a);
  1766. if (a) {
  1767. return getComputedStyle533(a, ...args);
  1768. }
  1769. return null;
  1770. }
  1771. }
  1772.  
  1773. Function._count_bind_00 = 0;
  1774. // Function._count_bind_01 = 0;
  1775.  
  1776. // let matchNativeCode = (Object+"");
  1777. // let matchNativeCode1 = matchNativeCode.includes("[native code]");
  1778. // let matchNativeLen = matchNativeCode.length - Object.name.length;
  1779.  
  1780. // const matchConstructor = (thisArg) => {
  1781. // const f = `${(thisArg || 0).constructor}`;
  1782. // if (f.length > 45) return true;
  1783. // if (matchNativeCode1 && f.length - thisArg.constructor.name.length === matchNativeLen) {
  1784. // if (f.includes('[native code]')){
  1785. // return false;
  1786. // }
  1787. // return true;
  1788. // }
  1789. // return false;
  1790. // }
  1791.  
  1792. // const acceptThis = (thisArg)=>{
  1793. // // if(!thisArg || typeof thisArg !=='object') return false;
  1794. // // // if((((thisArg||0).constructor||0).name || 'XXXXXXXX').length < 3) return true;
  1795. // // if(typeof thisArg.path === 'string') return true;
  1796. // // if(typeof thisArg.fn === 'function') return true;
  1797. // // if(typeof thisArg.id === 'string') return true;
  1798. // // if(typeof thisArg.isLoaded === 'boolean') return true;
  1799. // return false;
  1800. // }
  1801.  
  1802. const patchFn = (fn) => {
  1803.  
  1804. let s = `${fn}`;
  1805. if (s.length < 11 || s.includes('\n')) return false;
  1806. if(s.includes('bind(this')) return true;
  1807. if(s.includes('=this') && /[,\s][a-zA-Z_][a-zA-Z0-9_]*=this[;,]/.test(s) ) return true;
  1808. // var a=this;
  1809. // f.bind(this)
  1810.  
  1811.  
  1812. return false;
  1813. }
  1814.  
  1815. Function.prototype.bind488 = Function.prototype.bind;
  1816. Function.prototype.bind = function(thisArg, ...args){
  1817.  
  1818. if (thisConversionFn(thisArg) !== thisArg) {
  1819. return this.bind488(thisArg, ...args);
  1820. }
  1821. if( thisArg && patchFn(this) ){
  1822.  
  1823. // console.log(599,`${this}`)
  1824.  
  1825. try {
  1826. // let b1 = thisArg && typeof thisArg === 'object' && typeof thisArg.isAttached === 'boolean' && !thisArg.dtz06; // ready cnt
  1827. // let b2 = !b1 && thisArg && (thisArg instanceof Node) && typeof thisArg.nodeName === 'string' && !thisArg.dtz06; // dom
  1828. // let b3 = !b1 && !b2 && thisArg && typeof thisArg === 'object' && typeof thisArg.is === 'string' && !thisArg.dtz06; // init stage ?
  1829. // // let b4 = !b1 && !b2 && !b3 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && matchConstructor(thisArg);
  1830. // // let b5 = !b1 && !b2 && !b3 && !b4 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && acceptThis(thisArg);
  1831. // // let b5 = !b1 && !b2 && !b3 && thisArg && typeof thisArg === 'object' && !thisArg.dtz06 && !(thisArg instanceof Window);
  1832. // // let b4 = false;
  1833. // let b4 = !b1 && !b2 && !b3 && thisArg && !thisArg.dtz06;
  1834.  
  1835. // // b3 = false;
  1836. // // b4 = false;
  1837. // // b5 = false;
  1838.  
  1839. // if (b1 || b2 || b3 ||b4 ) {
  1840. const f = this;
  1841. const ps = thisArg.__proxySelf0__ || (thisArg.__proxySelf0__ = weakWrap(thisArg));
  1842. if (ps && ps[vmb]) {
  1843. Function._count_bind_00++;
  1844. return f.bind488(ps, ...args)
  1845. }
  1846. // }
  1847. } catch (e) {
  1848. console.warn(e)
  1849. }
  1850. }
  1851. return this.bind488(thisArg, ...args);
  1852. }
  1853. Function.prototype.bind588 = 1;
  1854. }
  1855.  
  1856.  
  1857. if (FIX_weakMap_weakRef && !window.WeakMapOriginal && typeof window.WeakMap === 'function' && typeof WeakRef === 'function') {
  1858. const WeakMapOriginal = window.WeakMapOriginal = window.WeakMap;
  1859. const wm6 = new WeakMapOriginal();
  1860.  
  1861. const skipW = new WeakSet();
  1862.  
  1863.  
  1864. window.WeakMap = class WeakMap extends WeakMapOriginal {
  1865. constructor(iterable = undefined) {
  1866. super();
  1867. if (iterable && iterable[Symbol.iterator]) {
  1868. for (const entry of iterable) {
  1869. entry && this.set(entry[0], entry[1]);
  1870. }
  1871. }
  1872. }
  1873. delete(a) {
  1874. if (!this.has(a)) return false;
  1875. super.delete(a);
  1876. return true;
  1877. }
  1878. get(a) {
  1879. const p = super.get(a);
  1880. if (p && typeof p === 'object' && p.deref && !skipW.has(p)) {
  1881. let v = kRef(p);
  1882. if (!v) {
  1883. super.delete(a);
  1884. }
  1885. return v || undefined;
  1886. }
  1887. return p;
  1888. }
  1889. has(a) {
  1890. if (!super.has(a)) return false;
  1891. const p = super.get(a);
  1892. if (p && typeof p === 'object' && p.deref && !skipW.has(p)) {
  1893. if (!kRef(p)) {
  1894. super.delete(a);
  1895. return false;
  1896. }
  1897. }
  1898. return true;
  1899. }
  1900. set(a, b) {
  1901. let wq = b;
  1902. if (b && (typeof b === 'function' || typeof b === 'object')) {
  1903. if (b.deref) {
  1904. skipW.add(b);
  1905. wq = b;
  1906. } else {
  1907. wq = wm6.get(b);
  1908. if (!wq) {
  1909. wq = mWeakRef(b);
  1910. wm6.set(b, wq);
  1911. }
  1912. }
  1913. }
  1914. super.set(a, wq);
  1915. return this;
  1916. }
  1917. }
  1918. Object.defineProperty(window.WeakMap, Symbol.toStringTag, {
  1919. configurable: true,
  1920. enumerable: false,
  1921. value: "WeakMap",
  1922. writable: false
  1923. });
  1924. }
  1925.  
  1926. const isWatchPageURL = (url) => {
  1927. url = url || location;
  1928. return location.pathname === '/watch' || location.pathname.startsWith('/live/')
  1929. };
  1930.  
  1931. const isCustomElementsProvided = typeof customElements !== "undefined" && typeof (customElements || 0).whenDefined === "function";
  1932.  
  1933. const promiseForCustomYtElementsReady = isCustomElementsProvided ? Promise.resolve(0) : new Promise((callback) => {
  1934. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  1935. if (typeof customElements === 'undefined') {
  1936. if (!('__CE_registry' in document)) {
  1937. // https://github.com/webcomponents/polyfills/
  1938. Object.defineProperty(document, '__CE_registry', {
  1939. get() {
  1940. // return undefined
  1941. },
  1942. set(nv) {
  1943. if (typeof nv == 'object') {
  1944. delete this.__CE_registry;
  1945. this.__CE_registry = nv;
  1946. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  1947. }
  1948. return true;
  1949. },
  1950. enumerable: false,
  1951. configurable: true
  1952. })
  1953. }
  1954. let eventHandler = (evt) => {
  1955. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1956. const f = callback;
  1957. callback = null;
  1958. eventHandler = null;
  1959. f();
  1960. };
  1961. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1962. } else {
  1963. callback();
  1964. }
  1965. });
  1966.  
  1967. const whenCEDefined = isCustomElementsProvided
  1968. ? (nodeName) => customElements.whenDefined(nodeName)
  1969. : (nodeName) => promiseForCustomYtElementsReady.then(() => customElements.whenDefined(nodeName));
  1970.  
  1971. FIX_perfNow && performance.timeOrigin > 9 && (() => {
  1972. if (performance.now23 || performance.now16 || typeof Performance.prototype.now !== 'function') return;
  1973. const f = performance.now23 = Performance.prototype.now;
  1974.  
  1975. let k = 0; // 0 <= k < 9998m
  1976. let u = 0;
  1977. let s = ((performance.timeOrigin % 7) + 1) / 7 - 1e-2 / 7; // s > 0.14
  1978.  
  1979. // By definition, performance.now() is mono increasing.
  1980. // Fixing in YouTube.com is required to ensure performance.now() is strictly increasing.
  1981. performance.now = performance.now16 = function () {
  1982. /**
  1983. * Bug 1842437 - When attempting to go back on youtube.com, the content remains the same
  1984. *
  1985. * If consecutive session history entries had history.state.entryTime set to same value,
  1986. * back button doesn't work as expected. The entryTime value is coming from performance.now()
  1987. * and modifying its return value slightly to make sure two close consecutive calls don't
  1988. * get the same result helped with resolving the issue.
  1989. */
  1990. // see https://bugzilla.mozilla.org/show_bug.cgi?id=1756970
  1991. // see https://bugzilla.mozilla.org/show_bug.cgi?id=1842437
  1992.  
  1993. const v = typeof (this || 0).now23 === 'function' ? this.now23() + s : f.call(performance) + s; // v > 0.14
  1994. if (u + 0.0015 < (u = v)) k = 0; // note: hRes should be accurate to 5 µs in isolated contexts
  1995. else if (k < 0.001428) k += 1e-6 / 7; // M = 10000 * m; m * 9996 = 0.001428
  1996. else { // more than 9998 consecutive calls
  1997. /**
  1998. *
  1999. * max no. of consecutive calls
  2000. *
  2001. * Sample Size: 4800
  2002. * Sample Avg = 1565.375
  2003. * Sample Median = 1469.5
  2004. * Sample Max = 5660 << 7500 << 9999
  2005. *
  2006. *
  2007. * */
  2008. k = 0;
  2009. s += 1 / 7;
  2010. }
  2011. return v + k; // 0 < v - M < v - M + k < v
  2012. }
  2013.  
  2014. let loggerMsg = '';
  2015. if (`${performance.now()}` === `${performance.now()}`) {
  2016. const msg1 = 'performance.now is modified but performance.now() is not strictly increasing.';
  2017. const msg2 = 'performance.now cannot be modified and performance.now() is not strictly increasing.';
  2018. loggerMsg = performance.now !== performance.now16 ? msg1 : msg2; // might not able to set in Firefox
  2019. }
  2020. loggerMsg && console.warn(loggerMsg);
  2021. })();
  2022.  
  2023. FIX_removeChild && (() => {
  2024. if (typeof Node.prototype.removeChild === 'function' && typeof Node.prototype.removeChild062 !== 'function') {
  2025. const fragD = document.createDocumentFragment();
  2026. Node.prototype.removeChild062 = Node.prototype.removeChild;
  2027. Node.prototype.removeChild = function (child) {
  2028. if (typeof this.__shady_native_removeChild !== 'function' || ((child instanceof Node) && child.parentNode === this)) {
  2029. let ok = false;
  2030. try {
  2031. this.removeChild062(child);
  2032. ok = true;
  2033. } catch (e) {
  2034.  
  2035. }
  2036. if (!ok) {
  2037. try {
  2038. fragD.appendChild(child)
  2039. } catch (e) {
  2040. console.warn(e);
  2041. }
  2042. try {
  2043. child.remove();
  2044. } catch (e) {
  2045. console.warn(e);
  2046. }
  2047. }
  2048. } else if ((child instanceof Element) && child.is === 'tp-yt-paper-tooltip') {
  2049. // tooltip bug
  2050. } else {
  2051. console.warn('[yt-js-engine-tamer] Node is not removed from parent', { parent: this, child: child })
  2052. }
  2053. return child;
  2054. }
  2055. }
  2056. })();
  2057.  
  2058.  
  2059. FIX_VIDEO_PLAYER_MOUSEHOVER_EVENTS && !isChatRoomURL && (() => {
  2060.  
  2061. const [setIntervalX0, clearIntervalX0] = [setInterval, clearInterval];
  2062.  
  2063. // let cid = 0;
  2064.  
  2065. let mousemoveFn = null;
  2066. let mousemoveDT = 0;
  2067. let mousemoveCount = 0;
  2068. // let qv = false;
  2069. const cif = () => {
  2070. if (!mousemoveFn) return;
  2071. const ct = Date.now();
  2072. if (mousemoveDT + 1200 > ct) { // avoid setTimeout delay too long without execution
  2073. mousemoveFn && mousemoveFn();
  2074. }
  2075. mousemoveFn = null;
  2076. };
  2077. let mousemoveCId = 0;
  2078. let mouseoverFn = null;
  2079. HTMLElement_.prototype.addEventListener4882 = HTMLElement_.prototype.addEventListener;
  2080. HTMLElement_.prototype.addEventListener = function (a, b, c) {
  2081. if (this.id == 'movie_player' && `${a}`.startsWith('mouse') && c === undefined) {
  2082. const bt = `${b}`;
  2083. if (bt.length >= 61 && bt.length <= 71 && bt.startsWith('function(){try{return ') && bt.includes('.apply(this,arguments)}catch(')) {
  2084. b[`__$$${a}$$1926__`] = true;
  2085. this[`__$$${a}$$1937__`] = (this[`__$$${a}$$1937__`] || 0) + 1;
  2086. if (this[`__$$${a}$$1937__`] > 1073741823) this[`__$$${a}$$1937__`] -= 536870911;
  2087. // console.log(3928, a, this[`__$$${a}$$1937__`])
  2088. if (!this[`__$$${a}$$1938__`]) {
  2089. this[`__$$${a}$$1938__`] = b;
  2090. if (a === 'mousemove') {
  2091. this.addEventListener4882('mouseenter', (evt) => {
  2092. if (mousemoveCId) return;
  2093. mousemoveCId = setIntervalX0(cif, 380);
  2094. });
  2095. this.addEventListener4882('mouseleave', (evt) => {
  2096. clearIntervalX0(mousemoveCId);
  2097. mousemoveCId = 0;
  2098. });
  2099. }
  2100. this.addEventListener4882(a, (evt) => {
  2101. const evt_ = evt;
  2102. if (!this[`__$$${a}$$1937__`]) return;
  2103. if (!this[`__$$${a}$$1938__`]) return;
  2104. if (a === 'mousemove') {
  2105. mouseoverFn && mouseoverFn();
  2106. if (mousemoveDT + 350 > (mousemoveDT = Date.now())) {
  2107. (++mousemoveCount > 1e9) && (mousemoveCount = 9);
  2108. } else {
  2109. mousemoveCount = 0;
  2110. }
  2111. const f = mousemoveFn = () => {
  2112. if (f !== mousemoveFn) return;
  2113. mousemoveFn = null;
  2114. this[`__$$${a}$$1938__`](evt_);
  2115. };
  2116. if (mousemoveCount <= 1) mousemoveFn();
  2117. } else {
  2118. if (a === 'mouseout' || a === 'mouseleave') {
  2119. mousemoveFn = null;
  2120. mousemoveDT = 0;
  2121. mousemoveCount = 0;
  2122. this[`__$$${a}$$1938__`](evt_);
  2123. mouseoverFn && mouseoverFn();
  2124. } else { // mouseover, mouseenter
  2125. mousemoveFn = null;
  2126. mousemoveDT = 0;
  2127. mousemoveCount = 0;
  2128. mouseoverFn && mouseoverFn(); // just in case
  2129. const f = mouseoverFn = () => {
  2130. if (f !== mouseoverFn) return;
  2131. mouseoverFn = null;
  2132. this[`__$$${a}$$1938__`](evt_);
  2133. }
  2134. nextBrowserTick_(mouseoverFn);
  2135. }
  2136. }
  2137. }, c);
  2138.  
  2139.  
  2140. return;
  2141. } else {
  2142.  
  2143. return;
  2144. }
  2145. }
  2146.  
  2147. }
  2148. return this.addEventListener4882(a, b, c)
  2149. }
  2150.  
  2151.  
  2152.  
  2153.  
  2154. HTMLElement_.prototype.removeEventListener4882 = HTMLElement_.prototype.removeEventListener;
  2155. HTMLElement_.prototype.removeEventListener = function (a, b, c) {
  2156. if (this.id == 'movie_player' && `${a}`.startsWith('mouse') && c === undefined) {
  2157.  
  2158. if (b[`__$$${a}$$1926__`]) {
  2159. b[`__$$${a}$$1926__`] = false;
  2160.  
  2161. if (this[`__$$${a}$$1937__`]) this[`__$$${a}$$1937__`] -= 1;
  2162.  
  2163. // console.log(3929, a, this[`__$$${a}$$1937__`], b[`__$$${a}$$1926__`])
  2164.  
  2165. return;
  2166.  
  2167. }
  2168.  
  2169. }
  2170. return this.removeEventListener4882(a, b, c)
  2171. }
  2172.  
  2173.  
  2174. })();
  2175.  
  2176.  
  2177. FIX_DOM_IF_REPEAT && (() => {
  2178. // https://www.youtube.com/s/desktop/26a583e4/jsbin/live_chat_polymer.vflset/live_chat_polymer.js
  2179. // DOM-IF is still a core class of Polymer, so no polymerController is available.
  2180. // Be careful of the mixture of polymer functions and native Element functions
  2181. // Be careful of the coding design is different with the modern Yt elements
  2182.  
  2183.  
  2184. /*
  2185.  
  2186.  
  2187. function Ks(a, b, c) {
  2188. if (kj && !BOa(a))
  2189. throw Error("strictTemplatePolicy: template owner not trusted");
  2190. c = c || {};
  2191. if (a.__templatizeOwner)
  2192. throw Error("A <template> can only be templatized once");
  2193. a.__templatizeOwner = b;
  2194. var d = (b ? b.constructor : Js)._parseTemplate(a)
  2195. , e = d.templatizeInstanceClass;
  2196. e || (e = COa(a, d, c),
  2197. d.templatizeInstanceClass = e);
  2198. var g = BOa(a);
  2199. EOa(a, d, c, g);
  2200. c = function() {
  2201. return e.apply(this, arguments) || this
  2202. }
  2203. ;
  2204. h(c, e);
  2205. c.prototype._methodHost = g;
  2206. c.prototype.__dataHost = a;
  2207. c.prototype.__templatizeOwner = b;
  2208. c.prototype.__hostProps = d.hostProps;
  2209. return c
  2210. }
  2211.  
  2212. */
  2213.  
  2214. // Polymer.enqueueDebouncer
  2215.  
  2216. const s81 = Symbol();
  2217. const s83 = Symbol();
  2218. const s84 = Symbol();
  2219. const s85 = Symbol();
  2220. const s85b = Symbol();
  2221. const s85c = Symbol();
  2222.  
  2223. let renderDebounceTs = null;
  2224.  
  2225. let renderDebouncePromise = null;
  2226. let qp;
  2227.  
  2228. let cme = 0;
  2229.  
  2230. const shadyFlushMO = new MutationObserver(() => {
  2231.  
  2232. if (!renderDebounceTs) return;
  2233.  
  2234. if (renderDebounceTs.size > 0) {
  2235. console.warn('renderDebounceTs.size is incorect', renderDebounceTs.size);
  2236. try {
  2237. Polymer.flush();
  2238. return;
  2239. } catch (e) { }
  2240. }
  2241.  
  2242. renderDebouncePromise && Promise.resolve().then(() => {
  2243.  
  2244. if (renderDebouncePromise) {
  2245. renderDebouncePromise && renderDebouncePromise.resolve();
  2246. renderDebouncePromise = null;
  2247. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by MutationObserver')
  2248. }
  2249.  
  2250. });
  2251.  
  2252. // Polymer.flush
  2253.  
  2254. window.ShadyDOM && ShadyDOM.flush();
  2255. window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush();
  2256.  
  2257.  
  2258. });
  2259.  
  2260. if (FIX_DOM_IFREPEAT_RenderDebouncerChange) {
  2261.  
  2262. const observablePromise = (proc, timeoutPromise) => {
  2263. let promise = null;
  2264. return {
  2265. obtain() {
  2266. if (!promise) {
  2267. promise = new Promise(resolve => {
  2268. let mo = null;
  2269. const f = () => {
  2270. let t = proc();
  2271. if (t) {
  2272. mo.disconnect();
  2273. mo.takeRecords();
  2274. mo = null;
  2275. resolve(t);
  2276. }
  2277. }
  2278. mo = new MutationObserver(f);
  2279. mo.observe(document, { subtree: true, childList: true })
  2280. f();
  2281. timeoutPromise && timeoutPromise.then(() => {
  2282. resolve(null)
  2283. });
  2284. });
  2285. }
  2286. return promise
  2287. }
  2288. }
  2289. }
  2290.  
  2291.  
  2292. let p = 0;
  2293. qp = observablePromise(() => {
  2294. if (!(p & 1)) {
  2295.  
  2296. if (window.ShadyDOM && ShadyDOM.flush) {
  2297. p |= 1;
  2298. if (!ShadyDOM.flush847) {
  2299.  
  2300. ShadyDOM.flush847 = ShadyDOM.flush;
  2301. ShadyDOM.flush = function () {
  2302.  
  2303. DEBUG_xx847 && console.log('xx847 ShadyDOM.flush')
  2304. renderDebouncePromise && Promise.resolve().then(() => {
  2305. if (renderDebouncePromise) {
  2306.  
  2307. renderDebouncePromise && renderDebouncePromise.resolve();
  2308. renderDebouncePromise = null;
  2309.  
  2310. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by ShadyDOM.flush')
  2311.  
  2312. }
  2313.  
  2314. });
  2315. let r = this.flush847(...arguments);
  2316. if (r) {
  2317. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  2318. }
  2319. return r
  2320. }
  2321.  
  2322. }
  2323. }
  2324. }
  2325.  
  2326. if (!(p & 2)) {
  2327.  
  2328. if (window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush) {
  2329. p |= 2;
  2330. const ScopingShim = window.ShadyCSS && window.ShadyCSS.ScopingShim;
  2331. if (!ScopingShim.flush848) {
  2332.  
  2333. ScopingShim.flush848 = ScopingShim.flush;
  2334. ScopingShim.flush = function () {
  2335.  
  2336. DEBUG_xx847 && console.log('xx847 ScopingShim.flush')
  2337.  
  2338. renderDebouncePromise && Promise.resolve().then(() => {
  2339.  
  2340. if (renderDebouncePromise) {
  2341.  
  2342. renderDebouncePromise && renderDebouncePromise.resolve();
  2343. renderDebouncePromise = null;
  2344.  
  2345. DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by ScopingShim.flush')
  2346.  
  2347.  
  2348.  
  2349. }
  2350.  
  2351. });
  2352. return this.flush848(...arguments);
  2353. }
  2354.  
  2355. }
  2356. }
  2357. }
  2358. if (p === 3) {
  2359. p |= 8;
  2360.  
  2361. let r = (window.ShadyDOM && ShadyDOM.flush && ShadyDOM.flush847
  2362. && window.ShadyCSS && window.ShadyCSS.ScopingShim &&
  2363. window.ShadyCSS.ScopingShim.flush && window.ShadyCSS.ScopingShim.flush848);
  2364.  
  2365. if (r) {
  2366. let w = Set.prototype.add;
  2367. let u = null;
  2368. Set.prototype.add = function () {
  2369. u = this;
  2370. throw new Error();
  2371. }
  2372. try {
  2373. Polymer.enqueueDebouncer()
  2374. } catch (e) { }
  2375. Set.prototype.add = w;
  2376. if (u !== null) {
  2377. renderDebounceTs = u;
  2378. if (DEBUG_renderDebounceTs) {
  2379. renderDebounceTs.add58438 = renderDebounceTs.add;
  2380. renderDebounceTs.add = function () {
  2381. console.log('renderDebounceTs.add')
  2382. console.log(traceStack((new Error()).stack))
  2383. // debugger;
  2384. return this.add58438(...arguments)
  2385. }
  2386.  
  2387. renderDebounceTs.delete58438 = renderDebounceTs.delete;
  2388. renderDebounceTs.delete = function () {
  2389. console.log('renderDebounceTs.delete')
  2390. const stack = `${(new Error()).stack}`
  2391. let isCallbackRemoval = false;
  2392. if (stack) {
  2393. let t = stack.replace(/[^\r\n]+renderDebounceTs\.delete[^\r\n]+/, '').replace('://','');
  2394. const s = t.split(':');
  2395. if (s.length === 3 && +s[1] > 0 && +s[2] > 0) {
  2396. isCallbackRemoval = true;
  2397. }
  2398. }
  2399. if (isCallbackRemoval) {
  2400. return this.delete58438(...arguments)
  2401. }
  2402. console.log(traceStack((new Error()).stack))
  2403. // debugger;
  2404. return this.delete58438(...arguments)
  2405. }
  2406. }
  2407. DEBUG_renderDebounceTs && (window.renderDebounceTs = renderDebounceTs);
  2408. console.log('renderDebounceTs', renderDebounceTs, `debug=${DEBUG_renderDebounceTs}`);
  2409. }
  2410. }
  2411.  
  2412. return true;
  2413. }
  2414. })
  2415.  
  2416. // if(window.ShadyDOM && ShadyDOM.flush){
  2417. // console.log('FIX_DOM_IF_RenderDebouncerChange X1')
  2418.  
  2419. // }
  2420. // if(window.ShadyCSS && window.ShadyCSS.ScopingShim && window.ShadyCSS.ScopingShim.flush){
  2421.  
  2422. // console.log('FIX_DOM_IF_RenderDebouncerChange X2')
  2423. // }
  2424.  
  2425. // console.log('FIX_DOM_IF_RenderDebouncerChange X3')
  2426.  
  2427. }
  2428.  
  2429. Object.defineProperty(Object.prototype, '_lastIf', {
  2430. get() {
  2431. return this[s81];
  2432. },
  2433. set(nv) {
  2434. if (nv === false && this.nodeName === "DOM-IF" && this.__renderDebouncer === null && this[s81] === undefined) {
  2435. // DOM-IF initialization
  2436. nv = null; // avoid (this.if == this._lastIf) primitive type conversion (object vs false)
  2437.  
  2438. this.__xiWB8__ = 2;
  2439.  
  2440. const cProto = this.__proto__;
  2441. if (cProto && !cProto.__xiWB7__) {
  2442. cProto.__xiWB7__ = 1;
  2443.  
  2444. // dom-if __template
  2445. // dom-repeat template
  2446. if (FIX_DOM_IF_TEMPLATE && !cProto.__template && !cProto.__template847) {
  2447. cProto.__template847 = true;
  2448. try {
  2449. // note: this is not "_template" in Polymer ( see POLYMER_COMPONENT_DEFINITION )
  2450. Object.defineProperty(cProto, '__template', {
  2451. get() {
  2452. const v = this[s84];
  2453. return (typeof (v || 0) === 'object' && v.deref) ? kRef(v) : v;
  2454. },
  2455. set(nv) {
  2456. if (typeof (nv || 0) === 'object' && !nv.deref) nv = mWeakRef(nv);
  2457. this[s84] = nv;
  2458. return true;
  2459. }
  2460. });
  2461. } catch (e) {
  2462. console.warn(e);
  2463. }
  2464.  
  2465. console.log('FIX_DOM_IF - __template')
  2466. }
  2467.  
  2468. // dom-if __ensureTemplate
  2469. // dom-repeat __ensureTemplatized
  2470. if (FIX_DOM_IF_TEMPLATE && !cProto.__ensureTemplate847 && typeof cProto.__ensureTemplate === 'function' && cProto.__ensureTemplate.length === 0 && this instanceof HTMLElement_ && `${cProto.__ensureTemplate}`.length > 20) {
  2471. // note that "_templateInfo" diffs the different version of DOM-IF
  2472.  
  2473. cProto.__ensureTemplate847 = cProto.__ensureTemplate;
  2474. cProto.__ensureTemplate = function () {
  2475. if (!(this instanceof HTMLElement_) || arguments.length > 0) return this.__ensureTemplate847(...arguments);
  2476. if (!this.__template) {
  2477. let b;
  2478. if (this._templateInfo) {
  2479. b = this;
  2480. } else {
  2481. if (!this.__templateCollection011__) this.__templateCollection011__ = this.getElementsByTagName('template');
  2482. b = this.__templateCollection011__[0];
  2483. if (!b) {
  2484. if (!this[wk]) this[wk] = mWeakRef(this);
  2485. let a = this[wk];
  2486. let c = new MutationObserver(function () {
  2487. if (!this.__templateCollection011__[0]) throw Error("dom-if requires a <template> child"); // to be reviewed
  2488. if (c && a) {
  2489. c.disconnect();
  2490. a = kRef(a);
  2491. a && a.__render();
  2492. a && (a.__templateCollection011__ = null);
  2493. }
  2494. c = null;
  2495. a = null;
  2496. });
  2497. c && c.observe(this, {
  2498. childList: !0
  2499. });
  2500. return !1
  2501. } else {
  2502. this.__templateCollection011__ = null;
  2503. }
  2504. }
  2505. this.__template = b
  2506. }
  2507. return !0
  2508. }
  2509.  
  2510. console.log('FIX_DOM_IF - __ensureTemplate')
  2511.  
  2512. }
  2513.  
  2514.  
  2515. // if(!cProto.__createAndInsertInstance847 && typeof cProto.__createAndInsertInstance === 'function' && cProto.__createAndInsertInstance.length === 1 && `${cProto.__createAndInsertInstance}`.length >20){
  2516.  
  2517. // cProto.__createAndInsertInstance847 = cProto.__createAndInsertInstance;
  2518.  
  2519. // cProto.__createAndInsertInstance = function (a) {
  2520. // Promise.resolve().then(()=>{
  2521. // console.log('__createAndInsertInstance')
  2522. // window.lm5 = window.lm5 || [];
  2523. // window.lm5.push([mWeakRef(this), mWeakRef(this.__instance)])
  2524. // });
  2525. // return this.__createAndInsertInstance847(a);
  2526. // }
  2527.  
  2528. // }
  2529.  
  2530.  
  2531. // if(!cProto._bindTemplate847 && typeof cProto._bindTemplate === 'function' && cProto._bindTemplate.length === 2){
  2532.  
  2533. // cProto._bindTemplate847 = cProto._bindTemplate;
  2534.  
  2535. // cProto._bindTemplate = function (a, b) {
  2536. // return this._bindTemplate847(kRef(a), b); // might throw Error as a -> null inside _bindTemplate847
  2537. // }
  2538.  
  2539. // }
  2540. // if(!cProto._stampTemplate847 && typeof cProto._stampTemplate === 'function' && cProto._stampTemplate.length === 2){
  2541.  
  2542. // cProto._stampTemplate847 = cProto._stampTemplate;
  2543.  
  2544. // cProto._stampTemplate = function (a, b) {
  2545. // return this._stampTemplate847(kRef(a), b); // might throw Error as a -> null inside _stampTemplate847
  2546. // }
  2547.  
  2548. // }
  2549. console.log('FIX_DOM_IF OK', Object.keys(cProto))
  2550. }
  2551.  
  2552.  
  2553. // need to fix __observeEffects
  2554. // this.__observeEffects.if[0].info.method === this.__debounceRender
  2555. const f = () => {
  2556.  
  2557. const __observeEffects = this.__observeEffects;
  2558.  
  2559. if (__observeEffects && __observeEffects.if && isIterable(__observeEffects.if)) {
  2560. for (const effect of __observeEffects.if) {
  2561. const info = effect.info;
  2562. if (info && typeof info.method === 'function') {
  2563.  
  2564. if (info.method === this.__debounceRender847 || info.method === this.__debounceRender) {
  2565. info.method = FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME ? '__debounceRender' : this.__debounceRender;
  2566. }
  2567.  
  2568. }
  2569. }
  2570. }
  2571.  
  2572.  
  2573. if (__observeEffects && __observeEffects.restamp && isIterable(__observeEffects.restamp)) {
  2574. for (const effect of __observeEffects.restamp) {
  2575. const info = effect.info;
  2576. if (info && typeof info.method === 'function') {
  2577.  
  2578. if (info.method === this.__debounceRender847 || info.method === this.__debounceRender) {
  2579. info.method = FIX_DOM_IFREPEAT_RenderDebouncerChange_SET_TO_PROPNAME ? '__debounceRender' : this.__debounceRender;
  2580. }
  2581.  
  2582. }
  2583. }
  2584. }
  2585.  
  2586. // console.log(5881, this.__observeEffects)
  2587. }
  2588. if (FIX_DOM_IFREPEAT_RenderDebouncerChange) {
  2589. f();
  2590. Promise.resolve().then(f);
  2591. // afterward, don't care adding fn directly (the fn is already modified)
  2592. }
  2593.  
  2594. }
  2595. this[s81] = nv;
  2596. return true;
  2597. }
  2598. });
  2599.  
  2600.  
  2601. Object.defineProperty(Object.prototype, '__renderDebouncer', {
  2602. get() {
  2603. return this[s85];
  2604. },
  2605. set(nv) {
  2606. if (nv === null && this[s85] === undefined) {
  2607. // DOM-IF / DOM-REPEAT initialization
  2608.  
  2609.  
  2610. const cProto = this.__proto__;
  2611. if (qp) {
  2612. qp.obtain();
  2613. qp = null;
  2614. shadyFlushMO.observe(document.documentElement, { attributes: ['nw3a24np'] });
  2615. }
  2616. if (FIX_DOM_IFREPEAT_RenderDebouncerChange && !cProto.__debounceRender847 && typeof cProto.__debounceRender === 'function' && !(`${cProto.__debounceRender}`.includes("{}"))) {
  2617.  
  2618. cProto.__debounceRender847 = cProto.__debounceRender;
  2619.  
  2620. if (cProto.__debounceRender.length === 2) {
  2621.  
  2622. cProto.__debounceRender = function (a, b) {
  2623.  
  2624. if (!renderDebounceTs) return this.__debounceRender847(a, b);
  2625.  
  2626. b = b === void 0 ? 0 : b;
  2627.  
  2628. /*
  2629. b = b === void 0 ? 0 : b;
  2630. this.__renderDebouncer = us(this.__renderDebouncer, b > 0 ? Rr.after(b) : Tr, a.bind(this));
  2631. vs(this.__renderDebouncer)
  2632. */
  2633.  
  2634. this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  2635.  
  2636. if (!renderDebouncePromise) {
  2637. renderDebouncePromise = new PromiseExternal();
  2638. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  2639. }
  2640.  
  2641. renderDebouncePromise.then(async () => {
  2642. if (b > 0) await delayPn(b);
  2643.  
  2644. const f = this.__dsIRYqw1__;
  2645. if (f === cme) return;
  2646. this.__dsIRYqw1__ = cme;
  2647. a.call(this);
  2648. DEBUG_DBR847 && console.log(`__DBR847__ done 01 (delay=${b})`, this.__DBR848__)
  2649.  
  2650. });
  2651.  
  2652. DEBUG_DBR847 && console.log(`__DBR847__ add 01 (delay=${b})`, this.__DBR848__)
  2653. }
  2654.  
  2655. } else if (cProto.__debounceRender.length === 0) {
  2656.  
  2657.  
  2658. cProto.__debounceRender = function () {
  2659.  
  2660. if (!renderDebounceTs) return this.__debounceRender847();
  2661.  
  2662. this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  2663. /*
  2664. var a = this;
  2665. this.__renderDebouncer = us(this.__renderDebouncer, Tr, function() {
  2666. return a.__render()
  2667. });
  2668. vs(this.__renderDebouncer)
  2669. */
  2670.  
  2671. if (!renderDebouncePromise) {
  2672. renderDebouncePromise = new PromiseExternal();
  2673. document.documentElement.setAttribute('nw3a24np', (cme = (cme % 511 + 1)));
  2674. }
  2675. renderDebouncePromise.then(() => {
  2676. const f = this.__dsIRYqw1__;
  2677. if (f === cme) return;
  2678. this.__dsIRYqw1__ = cme;
  2679. this.__render()
  2680. DEBUG_DBR847 && console.log('__DBR847__ done 02', this.__DBR848__)
  2681. });
  2682. DEBUG_DBR847 && console.log('__DBR847__ add 02', this.__DBR848__)
  2683.  
  2684.  
  2685. }
  2686. }
  2687. }
  2688.  
  2689.  
  2690.  
  2691. // if(FIX_DOM_IFREPEAT_RenderDebouncerChange && !cProto.render847 && typeof cProto.render === 'function' && cProto.render.length === 0 && !(`${cProto.render}`.includes("{}"))){
  2692. // cProto.render847 = cProto.render;
  2693. // cProto.render = function(){
  2694.  
  2695. // this.__DBR848__ = this.__DBR848__ || `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  2696. // try{
  2697. // this.render847();
  2698. // }catch(e){}
  2699. // // if(this.__DBR847__){
  2700. // // this.__DBR847__.resolve();
  2701. // // DEBUG_DBR847 && console.log('__DBR847__ resolve', this.__DBR848__)
  2702. // // }
  2703.  
  2704. // // renderDebouncePromise && renderDebouncePromise.resolve()
  2705. // // renderDebouncePromise = null;
  2706. // // DEBUG_DBR847 && console.log('__DBR847__ renderDebouncePromise.resolve by render', this.__DBR848__)
  2707.  
  2708. // }
  2709. // console.log('FIX_DOM_IF - render', `${cProto.render847}`, cProto.render847)
  2710. // }
  2711.  
  2712. }
  2713. this[s85] = nv;
  2714. return true;
  2715. }
  2716. });
  2717.  
  2718. // PS-DOM-REPEAT
  2719.  
  2720. Object.defineProperty(Object.prototype, 'JSC$10034_renderDebouncer', {
  2721. get() {
  2722. return this[s85b];
  2723. },
  2724. set(nv) {
  2725.  
  2726. this[s85b] = nv;
  2727. return true;
  2728. }
  2729. })
  2730.  
  2731. Object.defineProperty(Object.prototype, 'JSC$10027_renderDebouncer', {
  2732. get() {
  2733. return this[s85c];
  2734. },
  2735. set(nv) {
  2736.  
  2737. this[s85c] = nv;
  2738. return true;
  2739. }
  2740. })
  2741.  
  2742.  
  2743. })();
  2744.  
  2745. const setupXdeadC = (cnt)=>{
  2746.  
  2747. let xdeadc = xdeadc00;
  2748. if(!xdeadc){
  2749. setupSDomWrapper(); // just in case
  2750. const hostElement = cnt.hostElement;
  2751. const el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  2752. hostElement.insertAdjacentHTML('beforeend', ttpHTML('<!---->'));
  2753. hostElement.lastChild.replaceWith(el);
  2754. el.insertAdjacentHTML('afterbegin', ttpHTML(`<div></div>`));
  2755. const rid = `xdead_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  2756. el.firstElementChild.id = rid;
  2757. cnt.$[rid] = el.firstElementChild;
  2758. cnt.stampDomArray9682_(null, rid, null, false, false, false);
  2759.  
  2760. xdeadc = cnt.getStampContainer_(rid);
  2761. el.remove();
  2762. xdeadc00 = xdeadc;
  2763. // console.log(xdeadc.__domApi)
  2764. // debugger;
  2765. // const xdeadv = xdeadc.__domApi;
  2766. }
  2767.  
  2768. let xlivec = xlivec00;
  2769. if(!xlivec){
  2770. setupSDomWrapper(); // just in case
  2771. const hostElement = cnt.hostElement;
  2772. const el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
  2773. hostElement.insertAdjacentHTML('beforeend', ttpHTML('<!---->'));
  2774. hostElement.lastChild.replaceWith(el);
  2775. el.insertAdjacentHTML('afterbegin', ttpHTML(`<div></div>`));
  2776. const rid = `xlive_${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}`;
  2777. el.firstElementChild.id = rid;
  2778. cnt.$[rid] = el.firstElementChild;
  2779. cnt.stampDomArray9682_(null, rid, null, false, false, false);
  2780.  
  2781. xlivec = cnt.getStampContainer_(rid);
  2782. xlivec00 = xlivec;
  2783. // console.log(xdeadc.__domApi)
  2784. // debugger;
  2785. // const xdeadv = xdeadc.__domApi;
  2786. }
  2787.  
  2788. return xdeadc00;
  2789. }
  2790.  
  2791. let standardWrap_ = null;
  2792.  
  2793. const setupSDomWrapper = () => {
  2794.  
  2795. const sdwProto = ShadyDOM.Wrapper.prototype;
  2796.  
  2797. if (sdwProto.__pseudo__isConnected__ !== null) {
  2798. sdwProto.__pseudo__isConnected__ = null;
  2799. const isConnectedPd = Object.getOwnPropertyDescriptor(sdwProto, 'isConnected');
  2800. if (isConnectedPd && isConnectedPd.get && isConnectedPd.configurable === true) {
  2801. const get = isConnectedPd.get;
  2802. isConnectedPd.get = function () {
  2803. const pseudoVal = this.__pseudo__isConnected__;
  2804. return typeof pseudoVal === 'boolean' ? pseudoVal : get.call(this);
  2805. }
  2806. Object.defineProperty(sdwProto, 'isConnected', { ...isConnectedPd });
  2807. }
  2808.  
  2809. // debugger;
  2810. // new xdeadc.__domApi.constructor(document.createElement('div'));
  2811. }
  2812.  
  2813. }
  2814.  
  2815. let domApiConstructor = null;
  2816. const setupDomApi = (daProto) => {
  2817.  
  2818. daProto.__daHook377__ = true;
  2819.  
  2820. domApiConstructor = daProto.constructor; // TBC
  2821.  
  2822. // TBC
  2823.  
  2824. }
  2825.  
  2826.  
  2827. // WEAKREF_ShadyDOM
  2828.  
  2829. MODIFY_ShadyDOM_OBJ && ((WeakRef) => {
  2830.  
  2831. const setupPlainShadyDOM = (b) => {
  2832. (OMIT_ShadyDOM_settings & 1) && (b.inUse === true) && (b.inUse = false);
  2833. (OMIT_ShadyDOM_settings & 2) && (b.handlesDynamicScoping === true) && (b.handlesDynamicScoping = false);
  2834. (OMIT_ShadyDOM_settings & 4) && (b.force === true) && (b.force = false);
  2835. b.patchOnDemand = true;
  2836. b.preferPerformance = true;
  2837. b.noPatch = true;
  2838. }
  2839.  
  2840. const isPlainObject = (b, m) => {
  2841. if (!b || typeof b !== 'object') return false;
  2842. const e = Object.getOwnPropertyDescriptors(b);
  2843. if (e.length <= m) return false;
  2844. let pr = 0;
  2845. for (const k in e) {
  2846. const d = e[k];
  2847. if (!d || d.get || d.set || !d.enumerable || !d.configurable) return false;
  2848. if (!('value' in d) || typeof d.value === 'function') return false;
  2849. pr++;
  2850. }
  2851. return pr > m;
  2852. }
  2853.  
  2854. let b;
  2855.  
  2856. let lz = 0;
  2857.  
  2858. const sdp = Object.getOwnPropertyDescriptor(window, 'ShadyDOM');
  2859. if (sdp && sdp.configurable && sdp.value && sdp.enumerable && sdp.writable) {
  2860.  
  2861. // Brave - ShadyDOM exists before userscripting
  2862. b = sdp.value;
  2863.  
  2864. if (b && typeof b === 'object' && isPlainObject(b, 0)) {
  2865. OMIT_ShadyDOM_EXPERIMENTAL && setupPlainShadyDOM(b);
  2866. lz = 1;
  2867. }
  2868.  
  2869. }
  2870.  
  2871.  
  2872. if (sdp && sdp.configurable && sdp.value && sdp.enumerable && sdp.writable && !sdp.get && !sdp.set) {
  2873. } else if (!sdp) {
  2874. } else {
  2875. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM is not applied [ PropertyDescriptor issue ]', sdp);
  2876. return;
  2877. }
  2878.  
  2879. const shadyDOMNodeWRM = new WeakMap();
  2880.  
  2881. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 01 >>', b);
  2882.  
  2883. const weakWrapperNodeHandlerFn = () => ({
  2884. get() {
  2885. const wv = this[wk];
  2886. if (typeof wv === 'undefined') return undefined;
  2887. let node = kRef(wv);
  2888. if (!node) this[wk] = undefined;
  2889. return node || undefined;
  2890. },
  2891. set(nv) {
  2892. const wv = nv ? (nv[wk] || (nv[wk] = mWeakRef(nv))) : nv;
  2893. this[wk] = wv;
  2894. return true;
  2895. },
  2896. enumerable: true,
  2897. configurable: true
  2898. });
  2899.  
  2900.  
  2901. function weakWrapper(_ShadyDOM) {
  2902. const ShadyDOM = _ShadyDOM;
  2903. if (WEAKREF_ShadyDOM && lz < 3 && typeof WeakRef === 'function' && typeof ShadyDOM.Wrapper === 'function' && ShadyDOM.Wrapper.length === 1 && typeof (ShadyDOM.Wrapper.prototype || 0) === 'object') {
  2904. let nullElement = { node: null };
  2905. Object.setPrototypeOf(nullElement, Element.prototype);
  2906. let p = new ShadyDOM.Wrapper(nullElement);
  2907. let d = Object.getOwnPropertyDescriptor(p, 'node');
  2908. if (d.configurable && d.enumerable && !d.get && !d.set && d.writable && d.value === nullElement && !Object.getOwnPropertyDescriptor(ShadyDOM.Wrapper.prototype, 'node')) {
  2909. Object.defineProperty(ShadyDOM.Wrapper.prototype, 'node', weakWrapperNodeHandlerFn());
  2910. console.log('[yt-js-engine-tamer] FIX::ShadyDOM << WEAKREF_ShadyDOM >>')
  2911. }
  2912.  
  2913. }
  2914. if (typeof (((ShadyDOM || 0).Wrapper || 0).prototype || 0) === 'object') {
  2915. try {
  2916. setupSDomWrapper();
  2917. } catch (e) { }
  2918. }
  2919.  
  2920. }
  2921.  
  2922. let previousWrapStore = null;
  2923.  
  2924. const standardWrap = function (a) {
  2925. // if(a && a.deref) a= a.deref();
  2926. if(!a) return a;
  2927. if (a instanceof ShadowRoot || a instanceof ShadyDOM.Wrapper) return a;
  2928. if (previousWrapStore) {
  2929. const s = kRef(previousWrapStore.get(a)); // kRef for play safe only
  2930. if (s) {
  2931. previousWrapStore.delete(a);
  2932. shadyDOMNodeWRM.set(a, mWeakRef(s));
  2933. }
  2934. }
  2935. let u = kRef(shadyDOMNodeWRM.get(a));
  2936. if (!u) {
  2937. u = new ShadyDOM.Wrapper(a);
  2938. shadyDOMNodeWRM.set(a, mWeakRef(u));
  2939. }
  2940. return u;
  2941. }
  2942.  
  2943. standardWrap_ = standardWrap;
  2944.  
  2945.  
  2946. function setupWrapFunc(_ShadyDOM) {
  2947. const ShadyDOM = _ShadyDOM;
  2948.  
  2949.  
  2950. const wmPD = Object.getOwnPropertyDescriptor(WeakMap.prototype, 'get');
  2951. if (!(wmPD && wmPD.writable && !wmPD.enumerable && wmPD.configurable && wmPD.value && !wmPD.get && !wmPD.set)) {
  2952. return;
  2953. }
  2954. let mm = new Set();
  2955. const pget = wmPD.value;
  2956. WeakMap.prototype.get = function (a) {
  2957. mm.add(this);
  2958. return a;
  2959. }
  2960. try {
  2961. let nullElement = { node: null };
  2962. Object.setPrototypeOf(nullElement, Element.prototype);
  2963. ShadyDOM.wrapIfNeeded(nullElement)
  2964. ShadyDOM.wrap(nullElement)
  2965. } catch (e) { }
  2966. WeakMap.prototype.get = pget;
  2967. if (mm.size !== 1) {
  2968. mm.clear();
  2969. return;
  2970. }
  2971. const p = mm.values().next().value;
  2972. if (!(p instanceof WeakMap)) return;
  2973. // p.clear();
  2974. // p.get = function (a) { return a }
  2975. // p.set = function (a, b) { return this }
  2976. // console.log(188, window.n2n = mm, window.n2p = p)
  2977.  
  2978. // console.log(34929,p.size)
  2979. previousWrapStore = p;
  2980.  
  2981. if (typeof ShadyDOM.wrap === 'function' && ShadyDOM.wrap.length === 1) {
  2982. ShadyDOM.wrap = function (a) { 0 && console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - wrap'); return standardWrap(a) }
  2983. }
  2984. if (typeof ShadyDOM.wrapIfNeeded === 'function' && ShadyDOM.wrapIfNeeded.length === 1) {
  2985. ShadyDOM.wrapIfNeeded = function (a) { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - wrapIfNeeded'); return standardWrap(a) }
  2986. }
  2987.  
  2988. }
  2989.  
  2990. function setupLZ3(nv) {
  2991.  
  2992. const ShadyDOM = nv;
  2993.  
  2994. const ShadyDOMSettings = ShadyDOM.settings;
  2995. if (!(ShadyDOMSettings.inUse === true && ShadyDOM.inUse === true && (ShadyDOMSettings.handlesDynamicScoping || ShadyDOM.handlesDynamicScoping) === true)) {
  2996. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [02]', window.ShadyDOM);
  2997. return false;
  2998. }
  2999.  
  3000. weakWrapper(ShadyDOM);
  3001.  
  3002. if (OMIT_ShadyDOM_EXPERIMENTAL && lz < 3) {
  3003.  
  3004. setupPlainShadyDOM(ShadyDOMSettings);
  3005. setupPlainShadyDOM(ShadyDOM);
  3006.  
  3007. ShadyDOM.isShadyRoot = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - isShadyRoot'); return false; }
  3008.  
  3009. setupWrapFunc(ShadyDOM);
  3010. ShadyDOM.patchElementProto = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - patchElementProto') }
  3011. ShadyDOM.patch = function () { console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM) function call - patch') }
  3012.  
  3013. // To be confirmed
  3014. if (OMIT_ShadyDOM_EXPERIMENTAL & 2) {
  3015. ShadyDOM.composedPath = function (e) {
  3016. const t = (e || 0).target || null;
  3017. if (!(t instanceof HTMLElement_)) {
  3018. console.log(3719, '[yt-js-engine-tamer] (OMIT_ShadyDOM&2) composedPath', t)
  3019. }
  3020. return t instanceof HTMLElement_ ? [t] : [];
  3021. };
  3022. }
  3023.  
  3024. }
  3025.  
  3026. }
  3027.  
  3028.  
  3029. function setupLZ6(nv) {
  3030.  
  3031. const ShadyDOM = nv;
  3032.  
  3033. const ShadyDOMSettings = ShadyDOM.settings;
  3034.  
  3035. if (!(ShadyDOMSettings.inUse === true && ShadyDOM.inUse === true && (ShadyDOMSettings.handlesDynamicScoping || ShadyDOM.handlesDynamicScoping) === true)) {
  3036. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [02]', window.ShadyDOM);
  3037. return false;
  3038. }
  3039.  
  3040. weakWrapper(ShadyDOM);
  3041.  
  3042. if (OMIT_ShadyDOM_EXPERIMENTAL && lz < 3) {
  3043.  
  3044. setupPlainShadyDOM(ShadyDOMSettings);
  3045. setupPlainShadyDOM(ShadyDOM);
  3046.  
  3047. setupWrapFunc(ShadyDOM);
  3048.  
  3049. }
  3050.  
  3051. }
  3052.  
  3053. if (b && typeof b.Wrapper === 'function' && typeof b.settings === 'object' && typeof b.wrap === 'function') {
  3054.  
  3055. const nv = b;
  3056.  
  3057. if (setupLZ6(nv) === false) return;
  3058.  
  3059. lz = 6;
  3060.  
  3061. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 02b >>', nv)
  3062.  
  3063. return;
  3064. }
  3065.  
  3066. delete window.ShadyDOM;
  3067.  
  3068. Object.defineProperty(window, 'ShadyDOM', {
  3069. get() {
  3070. return b;
  3071. },
  3072. set(nv) {
  3073. let ret = 0;
  3074. try {
  3075. do {
  3076. if (!nv || !nv.settings) {
  3077. if (lz < 1 && nv && typeof nv === 'object' && isPlainObject(nv, 0)) {
  3078. OMIT_ShadyDOM_EXPERIMENTAL && setupPlainShadyDOM(nv);
  3079. lz = 1;
  3080. break;
  3081. } else {
  3082. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM is not applied [nv:null]', nv);
  3083. break;
  3084. }
  3085. }
  3086.  
  3087. const sdp = Object.getOwnPropertyDescriptor(this || {}, 'ShadyDOM');
  3088. if (!(sdp && sdp.configurable && sdp.get && sdp.set)) {
  3089. console.log(3719, '[yt-js-engine-tamer] OMIT_ShadyDOM is not applied [ incorrect PropertyDescriptor ]', nv);
  3090. break;
  3091. }
  3092.  
  3093. if (setupLZ3(nv) === false) break;
  3094.  
  3095. lz = 3;
  3096.  
  3097. console.log(3719, '[yt-js-engine-tamer] FIX::ShadyDOM << 02a >>', nv)
  3098.  
  3099. ret = 1;
  3100.  
  3101. } while (0);
  3102. } catch (e) {
  3103. console.log('[yt-js-engine-tamer] FIX::ShadyDOM << ERROR >>', e)
  3104. }
  3105.  
  3106. if (!ret) b = nv;
  3107. else {
  3108. delete this.ShadyDOM;
  3109. this.ShadyDOM = nv;
  3110. }
  3111. return true;
  3112. },
  3113. enumerable: false,
  3114. configurable: true
  3115. });
  3116.  
  3117. })(typeof WeakRef !== 'undefined' ? WeakRef : function () { });
  3118.  
  3119. if (ENABLE_ASYNC_DISPATCHEVENT) {
  3120. const filter = new Set([
  3121. 'yt-action',
  3122. // 'iframe-src-replaced',
  3123. 'shown-items-changed',
  3124. 'can-show-more-changed', 'collapsed-changed',
  3125.  
  3126. 'yt-navigate', 'yt-navigate-start', 'yt-navigate-cache',
  3127. 'yt-player-updated', 'yt-page-data-fetched', 'yt-page-type-changed', 'yt-page-data-updated',
  3128. 'yt-navigate-finish',
  3129.  
  3130. // 'data-changed','yt-watch-comments-ready'
  3131. ])
  3132. EventTarget.prototype.dispatchEvent938 = EventTarget.prototype.dispatchEvent;
  3133. EventTarget.prototype.dispatchEvent = function (event) {
  3134. const type = (event || 0).type;
  3135. if (typeof type === 'string' && event.isTrusted === false && (event instanceof CustomEvent) && event.cancelable === false) {
  3136. if (!filter.has(type) && !type.endsWith('-changed')) {
  3137. if (this instanceof Node || this instanceof Window) {
  3138. nextBrowserTick_(() => this.dispatchEvent938(event));
  3139. return true;
  3140. }
  3141. }
  3142. }
  3143. return this.dispatchEvent938(event);
  3144. }
  3145. }
  3146.  
  3147. // avoid REGEXP testPattern execution in Brave's scriptlet for performance boost
  3148. SCRIPTLET_REMOVE_PRUNE_propNeedles && (() => {
  3149. // const xhr = new XMLHttpRequest;
  3150. const pdOri = Object.getOwnPropertyDescriptor(Map.prototype, 'size');
  3151. if (!pdOri || pdOri.configurable !== true) return;
  3152. let propNeedles = null;
  3153. const pdNew = {
  3154. configurable: true,
  3155. enumerable: true,
  3156. get: function () {
  3157. propNeedles = this;
  3158. if (DEBUG_removePrune) debugger; // to locate Brave scriptlets
  3159. throw new Error();
  3160. }
  3161. }
  3162. Object.defineProperty(Map.prototype, 'size', pdNew);
  3163. try {
  3164. XMLHttpRequest.prototype.open.call(0);
  3165. // xhr.open.call(null)
  3166. } catch (e) { }
  3167. Object.defineProperty(Map.prototype, 'size', pdOri);
  3168. if (!propNeedles) return;
  3169. const entries = [...propNeedles.entries()];
  3170. propNeedles.clear();
  3171. console.log('[yt-js-engine-tamer] propNeedles is cleared from scriptlet', entries, propNeedles);
  3172. })();
  3173.  
  3174. if (FIX_XHR_REQUESTING) {
  3175.  
  3176. const URL = window.URL || new Function('return URL')();
  3177. const createObjectURL = URL.createObjectURL.bind(URL);
  3178.  
  3179. XMLHttpRequest = (() => {
  3180. const XMLHttpRequest_ = XMLHttpRequest;
  3181. if ('__xmMc8__' in XMLHttpRequest_.prototype) return XMLHttpRequest_;
  3182. const url0 = createObjectURL(new Blob([], { type: 'text/plain' }));
  3183. const c = class XMLHttpRequest extends XMLHttpRequest_ {
  3184. constructor(...args) {
  3185. super(...args);
  3186. }
  3187. open(method, url, ...args) {
  3188. let skip = false;
  3189. if (!url || typeof url !== 'string') skip = true;
  3190. else if (typeof url === 'string') {
  3191. let turl = url[0] === '/' ? `.youtube.com${url}` : `${url}`;
  3192. if (turl.includes('googleads') || turl.includes('doubleclick.net')) {
  3193. skip = true;
  3194. } else if (turl.includes('.youtube.com/pagead/')) {
  3195. skip = true;
  3196. } else if (turl.includes('.youtube.com/ptracking')) {
  3197. skip = true;
  3198. } else if (turl.includes('.youtube.com/youtubei/v1/log_event?')) {
  3199. skip = true;
  3200. } else if (turl.includes('.youtube.com/api/stats/')) { // /api/stats/
  3201. if (turl.includes('.youtube.com/api/stats/qoe?')) {
  3202. skip = true;
  3203. } else if (turl.includes('.youtube.com/api/stats/ads?')) {
  3204. skip = true;
  3205. } else {
  3206. // skip = true; // for user activity logging e.g. watched videos
  3207. }
  3208. } else if (turl.includes('play.google.com/log')) {
  3209. skip = true;
  3210. } else if (turl.includes('.youtube.com//?')) { // //?cpn=
  3211. skip = true;
  3212. }
  3213. }
  3214. if (!skip) {
  3215. this.__xmMc8__ = 1;
  3216. return super.open(method, url, ...args);
  3217. } else {
  3218. this.__xmMc8__ = 2;
  3219. return super.open('GET', url0);
  3220. }
  3221. }
  3222. send(...args) {
  3223. if (this.__xmMc8__ === 1) {
  3224. return super.send(...args);
  3225. } else if (this.__xmMc8__ === 2) {
  3226. return super.send();
  3227. } else {
  3228. console.log('[yt-js-engine-tamer]', 'xhr warning');
  3229. return super.send(...args);
  3230. }
  3231. }
  3232. }
  3233. c.prototype.__xmMc8__ = 0;
  3234. prototypeInherit(c.prototype, XMLHttpRequest_.prototype);
  3235. return c;
  3236. })();
  3237. }
  3238.  
  3239. // Alternative HACK -> Tabview Youtube
  3240. if (DISABLE_COOLDOWN_SCROLLING && typeof EventTarget.prototype.addEventListener52178 !== 'function' && typeof EventTarget.prototype.addEventListener === 'function') {
  3241.  
  3242. // ---- << this.overscrollConfig HACK >> -----
  3243.  
  3244. // 2024.04.19 - Playlist in Single Column Mode cannot be scrolled correctly.
  3245.  
  3246. /*
  3247.  
  3248. ;function gZb(a, b) {
  3249. b = void 0 === b ? !0 : b;
  3250. a.addEventListener("wheel", hZb);
  3251. a.overscrollConfig = {
  3252. cooldown: b
  3253. }
  3254. }
  3255. function iZb(a) {
  3256. a.overscrollConfig = void 0;
  3257. a.removeEventListener("wheel", hZb)
  3258. }
  3259. function hZb(a) {
  3260. var b = a.deltaY
  3261. , c = a.target
  3262. , d = null;
  3263. if (window.Polymer && window.Polymer.Element) {
  3264. if (c = a.path || a.composedPath && a.composedPath()) {
  3265. c = g(c);
  3266. for (var e = c.next(); !e.done && (e = e.value,
  3267. !jZb(e, b)); e = c.next())
  3268. if (e.overscrollConfig) {
  3269. d = e;
  3270. break
  3271. }
  3272. }
  3273. } else
  3274. for (; c && !jZb(c, b); ) {
  3275. if (c.overscrollConfig) {
  3276. d = c;
  3277. break
  3278. }
  3279. c = c.parentElement
  3280. }
  3281. d && (b = d.overscrollConfig,
  3282. b.cooldown ? (d = a.deltaY,
  3283. c = b.lastDeltaY || 0,
  3284. b.lastDeltaY = d,
  3285. e = b.lastStopped || 0,
  3286. c && e && 0 < c == 0 < d ? Math.abs(c) >= Math.abs(d) ? (d = e + 1200,
  3287. c = !1) : (d = e + 600,
  3288. c = !0) : (d = Date.now() + 600,
  3289. c = !0),
  3290. d > Date.now() && (a.preventDefault(),
  3291. c && (b.lastStopped = Date.now()))) : a.preventDefault())
  3292. }
  3293. */
  3294.  
  3295. let wheelHandler = function (a) {
  3296. if (window.Polymer && window.Polymer.Element) {
  3297. let c;
  3298. if (c = a.path || a.composedPath && a.composedPath()) {
  3299. for (const e of c) {
  3300. const cnt = insp(e);
  3301. if (e.overscrollConfig) e.overscrollConfig = void 0;
  3302. if (cnt.overscrollConfig) cnt.overscrollConfig = void 0;
  3303. }
  3304. }
  3305. } else {
  3306. let e = a.target;
  3307. for (; e instanceof Element; e = e.parentElement) {
  3308. const cnt = insp(e);
  3309. if (e.overscrollConfig) e.overscrollConfig = void 0;
  3310. if (cnt.overscrollConfig) cnt.overscrollConfig = void 0;
  3311. }
  3312. }
  3313. };
  3314.  
  3315. let checkWheelListenerObjs = null;
  3316.  
  3317. let getObjsFn = () => {
  3318. let euyVal = 0;
  3319. const eukElm = {};
  3320. Object.setPrototypeOf(eukElm, HTMLElement_.prototype);
  3321. const euzObj = new Proxy(eukElm, {
  3322. get(target, prop) {
  3323. throw `ErrorF31.get(${prop})`
  3324. },
  3325. set(target, prop, value) {
  3326. throw `ErrorF33.set(${prop}, ${value})`
  3327. }
  3328. });
  3329. const euxElm = new Proxy(eukElm, {
  3330. get(target, prop) {
  3331. if (prop === 'scrollTop') {
  3332. euyVal = euyVal | 8;
  3333. return 0;
  3334. }
  3335. if (prop === 'overscrollConfig') {
  3336. euyVal = euyVal | 16;
  3337. return void 0;
  3338. }
  3339. if (prop === 'scrollHeight' || prop === 'clientHeight' || prop === 'offsetHeight') {
  3340. return 640;
  3341. }
  3342. if (prop === 'scrollLeft') {
  3343. euyVal = euyVal | 8;
  3344. return 0;
  3345. }
  3346. if (prop === 'scrollWidth' || prop === 'clientWidth' || prop === 'offsetWidth') {
  3347. return 800;
  3348. }
  3349. throw `ErrorF45.get(${prop})`
  3350. },
  3351. set(target, prop, value) {
  3352. throw `ErrorF47.set(${prop}, ${value})`
  3353. }
  3354. });
  3355. const eukEvt = {};
  3356. Object.setPrototypeOf(eukEvt, WheelEvent.prototype);
  3357. const euyEvt = new Proxy(eukEvt, {
  3358. get(target, prop) {
  3359. if (prop === 'deltaY' || prop === 'deltaX') {
  3360. euyVal = euyVal | 1;
  3361. return -999;
  3362. }
  3363. if (prop === 'target') {
  3364. euyVal = euyVal | 2;
  3365. return euxElm
  3366. }
  3367. if (prop === 'path' || prop === 'composedPath') {
  3368. euyVal = euyVal | 2;
  3369. return [euxElm]
  3370. }
  3371. throw `ErrorF51.get(${prop})`
  3372. },
  3373. set(target, prop, value) {
  3374. throw `ErrorF53.set(${prop}, ${value})`
  3375. }
  3376. });
  3377. const setVal = (v) => {
  3378. euyVal = v;
  3379. }
  3380. const getVal = () => {
  3381. return euyVal;
  3382. }
  3383. return { euzObj, euyEvt, setVal, getVal };
  3384. }
  3385.  
  3386. let checkWheelListener = (callback) => {
  3387.  
  3388. let callbackIdentifier = '';
  3389.  
  3390. let res = null;
  3391. try {
  3392. const { euzObj, euyEvt, getVal, setVal } = checkWheelListenerObjs || (checkWheelListenerObjs = getObjsFn());
  3393. setVal(0);
  3394. if (callback.call(euzObj, euyEvt) !== void 0) throw 'ErrorF99';
  3395. throw `RESULT${getVal()}`;
  3396. } catch (e) {
  3397. res = e;
  3398. }
  3399.  
  3400. res = `${res}` || `${null}`;
  3401. if (res.length > 20) res = `${res.substring(0, 20)}...`;
  3402.  
  3403. callbackIdentifier = res;
  3404. if (callbackIdentifier === 'RESULT27') 0;
  3405. else if (callbackIdentifier === 'RESULT0') {
  3406. // a.isSearch && !a.disableWheelScroll && B("desktop_enable_dmpanel_wheel_scroll")
  3407. } else if (callbackIdentifier.startsWith('RESULT')) {
  3408. console.log('wheel eventListener - RESULT', callbackIdentifier, callback)
  3409. }
  3410. return callbackIdentifier;
  3411.  
  3412. };
  3413.  
  3414. let callbackFound = false;
  3415. EventTarget.prototype.addEventListener52178 = EventTarget.prototype.addEventListener;
  3416. EventTarget.prototype.addEventListener = function (type, callback, option = void 0) {
  3417. // M-youtube-js-engine-tamer.52178
  3418. if (type === 'wheel' && !option && typeof callback === 'function' && callback.length === 1) {
  3419. // (( match with signature `a.addEventListener("wheel", hZb);` )) [subject to further review]
  3420. const callbackIdentifier = callback.yaujmoms || (callbackFound ? 'IGNORE' : (callback.yaujmoms = checkWheelListener(callback)));
  3421. // RESULTXX / ErrorFXX / Other...
  3422. if (callbackIdentifier === 'RESULT27') {
  3423. this.overscrollConfigDisable = true;
  3424. if (!callbackFound) {
  3425. callbackFound = true; // suppose only one function is assigned to overscrollConfig cooldown [no function binding]
  3426. getObjsFn = checkWheelListener = null;
  3427. checkWheelListenerObjs = null;
  3428. wheelHandler = null;
  3429. }
  3430. return void 0;
  3431. } else if (!callbackFound && !this.overscrollConfigDisable) {
  3432. this.overscrollConfigDisable = true;
  3433. this.addEventListener52178('wheel', wheelHandler, { passive: false });
  3434. }
  3435. }
  3436. return this.addEventListener52178(type, callback, option);
  3437. };
  3438.  
  3439. // ---- << this.overscrollConfig HACK >> -----
  3440.  
  3441. }
  3442.  
  3443. const { pageMediaWatcher, shortcutKeysFixer, keyboardController } = (() => {
  3444.  
  3445. let p_a_objWR = null;
  3446. let isSpaceKeyImmediate = false; // for ADVANCED_FIX_SHORTCUTKEYS
  3447. let ytPageReady = 0;
  3448.  
  3449. let isSpeedMastSpacebarControlEnabled = false; // youtube experimental feature // can be forced by CHANGE_SPEEDMASTER_SPACEBAR_CONTROL
  3450. let isGlobalSpaceControl = true;
  3451. let mediaPlayerElementWR = null;
  3452. let focusedElementAtSelection = null;
  3453.  
  3454. // let want_control_video = false;
  3455.  
  3456. let spaceBarControl_keyG = '';
  3457.  
  3458. let lastUserAction = 0;
  3459.  
  3460. const wmKeyControlPhase = new WeakMap();
  3461.  
  3462. let currentSelectionText = null;
  3463.  
  3464. const getCurrentSelectionText = () => {
  3465. if (currentSelectionText !== null) return currentSelectionText
  3466. return (currentSelectionText = `${getSelection()}`)
  3467. }
  3468.  
  3469. const pageMediaWatcher = () => {
  3470.  
  3471. // CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE && document.addEventListener('wheel', () => {
  3472. // want_control_video = false;
  3473. // }, { capture: true, passive: true });
  3474.  
  3475. document.addEventListener('yt-navigate', () => {
  3476. ytPageReady = 0;
  3477. });
  3478. document.addEventListener('yt-navigate-start', () => {
  3479. ytPageReady = 0;
  3480. });
  3481. document.addEventListener('yt-navigate-cache', () => {
  3482. ytPageReady = 0;
  3483. });
  3484.  
  3485. document.addEventListener('yt-navigate-finish', () => {
  3486. ytPageReady = 1;
  3487. });
  3488.  
  3489. document.addEventListener('durationchange', () => {
  3490. for (const elm of document.querySelectorAll('#movie_player video[src], #movie_player audio[src]')) {
  3491. if (elm.duration > 0.01) {
  3492. if (elm.closest('[hidden]')) continue;
  3493. mediaPlayerElementWR = mWeakRef(elm);
  3494. return;
  3495. }
  3496. }
  3497. }, { capture: true, passive: true });
  3498.  
  3499. document.addEventListener('selectionchange', (evt) => {
  3500. if (!evt || !evt.isTrusted || !(evt instanceof Event)) return;
  3501. currentSelectionText = null;
  3502. if (!(evt.target instanceof Node)) return;
  3503. focusedElementAtSelection = evt.target;
  3504. }, { capture: true, passive: true })
  3505.  
  3506. document.addEventListener('pointerdown', (evt) => {
  3507. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  3508. }, { capture: true, passive: true });
  3509.  
  3510.  
  3511. document.addEventListener('pointerup', (evt) => {
  3512. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  3513. }, { capture: true, passive: true });
  3514.  
  3515.  
  3516. document.addEventListener('keydown', (evt) => {
  3517. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  3518. }, { capture: true, passive: true });
  3519.  
  3520. document.addEventListener('keyup', (evt) => {
  3521. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  3522. }, { capture: true, passive: true });
  3523.  
  3524. };
  3525.  
  3526.  
  3527. const checkKeyB = (p_a_obj) => {
  3528.  
  3529. const boolList = new Set();
  3530. const p_a_obj_api = p_a_obj.api;
  3531.  
  3532. const nilFunc0 = function () {
  3533. return void 0
  3534. };
  3535. const mt = new Proxy({}, {
  3536. get(target, prop) {
  3537. if (prop === 'get') return nilFunc0;
  3538. return mt;
  3539. }
  3540. });
  3541. const nilFunc = function () {
  3542. return mt
  3543. };
  3544. const mw = new Proxy({}, {
  3545. get(target, prop) {
  3546. if (prop in p_a_obj_api) {
  3547. if (typeof p_a_obj_api.constructor.prototype[prop] === 'function') return nilFunc;
  3548. let q = Object.getOwnPropertyDescriptor(p_a_obj_api, prop);
  3549. if (q && q.value) {
  3550. if (!q.writable) return q.value;
  3551. if (typeof q.value === 'string') return '';
  3552. if (typeof q.value === 'number') return 0;
  3553. if (typeof q.value === 'boolean') return false;
  3554. if (q.value && typeof q.value === 'object') return {};
  3555. }
  3556. }
  3557. return undefined;
  3558. },
  3559. set(target, prop) {
  3560. throw 'mwSet';
  3561. }
  3562. });
  3563.  
  3564. const mq = new Proxy({}, {
  3565. get(target, prop) {
  3566. if (prop === 'api') return mw;
  3567. if (prop in p_a_obj) {
  3568. if (typeof p_a_obj.constructor.prototype[prop] === 'function') return nilFunc;
  3569. let q = Object.getOwnPropertyDescriptor(p_a_obj, prop);
  3570. if (q && q.value) {
  3571. if (!q.writable) return q.value;
  3572. if (typeof q.value === 'string') return '';
  3573. if (typeof q.value === 'number') return 0;
  3574. if (typeof q.value === 'boolean') return false;
  3575. if (q.value && typeof q.value === 'object') return {};
  3576. }
  3577. }
  3578. return undefined;
  3579. },
  3580. set(target, prop, val) {
  3581. if (typeof val === 'boolean') boolList.add(prop)
  3582. throw `mqSet(${prop},${val})`;
  3583. }
  3584. });
  3585.  
  3586. let res = ''
  3587. try {
  3588. res = `RESULT::${p_a_obj.handleGlobalKeyUp.call(mq, 9, false, false, false, false, "Tab", "Tab")}`;
  3589. } catch (e) {
  3590. res = `ERROR::${e}`;
  3591. }
  3592.  
  3593. if (boolList.size === 1) {
  3594. const value = boolList.values().next().value;
  3595. if (res === `ERROR::mqSet(${value},${true})`) {
  3596. p_a_obj.__uZWaD__ = value;
  3597. }
  3598. }
  3599.  
  3600. console.log('[yt-js-engine-tamer] global shortcut control', { '__uZWaD__': p_a_obj.__uZWaD__ });
  3601.  
  3602. }
  3603.  
  3604.  
  3605. let pm_p_a = null;
  3606.  
  3607. const p_a_init = function () {
  3608. const r = this.init91();
  3609. const keyBw = this.__cPzfo__ || '__NIL__';
  3610. const p_a_obj = this[keyBw];
  3611. if (!p_a_obj) return;
  3612. try {
  3613. checkKeyB(p_a_obj);
  3614. } catch (e) { }
  3615. p_a_objWR = mWeakRef(p_a_obj);
  3616. if (FIX_SHORTCUTKEYS > 0) {
  3617. if (p_a_obj && !p_a_obj.hVhtg) {
  3618. p_a_obj.hVhtg = 1;
  3619.  
  3620. p_a_obj.handleGlobalKeyUp91 = p_a_obj.handleGlobalKeyUp;
  3621. p_a_obj.handleGlobalKeyUp = p_a_xt.handleGlobalKeyUp;
  3622. p_a_obj.handleGlobalKeyDown91 = p_a_obj.handleGlobalKeyDown;
  3623. p_a_obj.handleGlobalKeyDown = p_a_xt.handleGlobalKeyDown;
  3624. p_a_obj.__handleGlobalKeyBefore__ = p_a_xt.__handleGlobalKeyBefore__;
  3625. p_a_obj.__handleGlobalKeyAfter__ = p_a_xt.__handleGlobalKeyAfter__;
  3626.  
  3627. }
  3628. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE && p_a_obj && p_a_obj.api && !p_a_obj.api.hVhtg) {
  3629. // const api = p_a_obj.api
  3630. // api.hVhtg = 1;
  3631. // api.playVideo91 = api.playVideo;
  3632. // api.playVideo = p_a_jt.playVideo;
  3633. // api.pauseVideo91 = api.pauseVideo;
  3634. // api.pauseVideo = p_a_jt.pauseVideo;
  3635. // }
  3636. }
  3637. if (pm_p_a) {
  3638. pm_p_a.resolve();
  3639. pm_p_a = null;
  3640. }
  3641. return r;
  3642. };
  3643.  
  3644. const p_a_xt = {
  3645.  
  3646. __handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) {
  3647.  
  3648. if (FIX_SHORTCUTKEYS === 2) {
  3649.  
  3650. // if (flagSpeedMaster !== false && !getGlobalSpacebarControlFlag()) return false;
  3651.  
  3652. if (activeElement) {
  3653.  
  3654. const controlPhaseCache = wmKeyControlPhase.get(activeElement);
  3655.  
  3656. if (controlPhaseCache === 6 && getCurrentSelectionText() !== "") void 0;
  3657. else if (controlPhaseCache === 1 || controlPhaseCache === 2 || controlPhaseCache === 5) return false;
  3658. else if ((controlPhaseCache !== 6 || focusedElementAtSelection === document.activeElement) && getCurrentSelectionText() !== "") return false;
  3659.  
  3660. }
  3661.  
  3662. const isSpaceBar = a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space';
  3663. const isDelayedSpaceBar = FIX_SHORTCUTKEYS === 2 && isSpaceBar && !isSpaceKeyImmediate && (isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag());
  3664. // console.log(582, isDelayedSpaceBar)
  3665. if (isDelayedSpaceBar) return void 0; // accept delay spacebar under isSpeedMastSpacebarControlEnabled (no rejection)
  3666.  
  3667. if (activeElement && (h === 'Space' || h === 'Enter')) {
  3668. const controlPhase = wmKeyControlPhase.get(activeElement);
  3669. if (controlPhase === 4 || controlPhase === 5) return false;
  3670. }
  3671. if (focusedElementAtSelection === activeElement && getCurrentSelectionText() !== "") return false;
  3672. // if (!isSpeedMastSpacebarControlEnabled && a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space') {
  3673. // if (!isSpaceKeyImmediate) return false;
  3674. // }
  3675. }
  3676.  
  3677. },
  3678.  
  3679. __handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret) {
  3680.  
  3681. if (FIX_SHORTCUTKEYS === 2 && ret && a >= 32 && ytPageReady === 1 && Date.now() - lastUserAction < 40 && activeElement === document.activeElement) {
  3682.  
  3683. const isSpaceBar = a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space';
  3684. const isDelayedSpaceBar = FIX_SHORTCUTKEYS === 2 && isSpaceBar && !isSpaceKeyImmediate && (isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag());
  3685. // console.log(583, isDelayedSpaceBar)
  3686. if (isDelayedSpaceBar) return void 0; // accept delay spacebar under isSpeedMastSpacebarControlEnabled (no rejection)
  3687.  
  3688. const mediaPlayerElement = kRef(mediaPlayerElementWR);
  3689.  
  3690. let mediaWorking = false;
  3691. if (mediaPlayerElement && (mediaPlayerElement.readyState === 4 || mediaPlayerElement.readyState === 1) && mediaPlayerElement.networkState === 2 && mediaPlayerElement.duration > 0.01) {
  3692. mediaWorking = true;
  3693. } else if (mediaPlayerElement && !mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  3694. mediaWorking = true;
  3695. }
  3696. // console.log(182, mediaWorking, mediaPlayerElement.readyState , mediaPlayerElement.networkState)
  3697. mediaWorking && Promise.resolve().then(() => {
  3698. if (activeElement === document.activeElement) {
  3699. return activeElement.blur()
  3700. } else {
  3701. return false
  3702. }
  3703. }).then((r) => {
  3704. r !== false && mediaPlayerElement.focus();
  3705. });
  3706. }
  3707. },
  3708.  
  3709.  
  3710. handleGlobalKeyUp(a, b, c, d, e, f, h) {
  3711.  
  3712. if (BY_PASS_KEYBOARD_CONTROL) return this.handleGlobalKeyUp91(a, b, c, d, e, f, h);
  3713.  
  3714. const activeElement = document.activeElement;
  3715.  
  3716. const allow = typeof this.__handleGlobalKeyBefore__ === 'function' ? this.__handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) : void 0;
  3717. if (allow === false) return false;
  3718.  
  3719. const ret = this.handleGlobalKeyUp91(a, b, c, d, e, f, h);
  3720. // console.log('handleGlobalKeyUp',ret, a, b, c, d, e, f, h);
  3721.  
  3722. typeof this.__handleGlobalKeyAfter__ === 'function' && this.__handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret);
  3723.  
  3724. return ret;
  3725. },
  3726. handleGlobalKeyDown(a, b, c, d, e, f, h, l) {
  3727.  
  3728.  
  3729. if (BY_PASS_KEYBOARD_CONTROL) return this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  3730.  
  3731. const activeElement = document.activeElement;
  3732. // if (a === 32 && b === false && c === false && d === false && e === false && f === ' ' && h === 'Space' && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  3733. // return this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  3734. // }
  3735. const allow = typeof this.__handleGlobalKeyBefore__ === 'function' ? this.__handleGlobalKeyBefore__(a, b, c, d, e, f, h, activeElement) : void 0;
  3736. if (allow === false) return false;
  3737.  
  3738. const ret = this.handleGlobalKeyDown91(a, b, c, d, e, f, h, l);
  3739. // console.log('handleGlobalKeyDown',ret, a, b, c, d, e, f, h,l)
  3740.  
  3741. typeof this.__handleGlobalKeyAfter__ === 'function' && this.__handleGlobalKeyAfter__(a, b, c, d, e, f, h, activeElement, ret);
  3742.  
  3743. return ret;
  3744. }
  3745.  
  3746. };
  3747.  
  3748. // const p_a_jt = { // API
  3749.  
  3750. // playVideo(a) { // without spinner effect
  3751.  
  3752. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE) {
  3753.  
  3754. // const mediaPlayerElement = kRef(mediaPlayerElementWR);
  3755. // if (mediaPlayerElement && !mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  3756. // want_control_video = true;
  3757. // // Promise.resolve().then(()=> mediaPlayerElement.focus() );
  3758. // }
  3759.  
  3760. // }
  3761. // return this.playVideo91(a);
  3762.  
  3763. // },
  3764.  
  3765. // pauseVideo(a) { // without spinner effect
  3766.  
  3767. // if (CAN_TUNE_VOLUMN_AFTER_RESUME_OR_PAUSE) {
  3768.  
  3769. // const mediaPlayerElement = kRef(mediaPlayerElementWR);
  3770. // if (mediaPlayerElement && mediaPlayerElement.paused && !mediaPlayerElement.muted && mediaPlayerElement.duration > 0.01) {
  3771. // want_control_video = true;
  3772. // // Promise.resolve().then(()=> mediaPlayerElement.focus() );
  3773. // }
  3774.  
  3775. // }
  3776. // return this.pauseVideo91(a);
  3777.  
  3778. // }
  3779. // };
  3780.  
  3781. let flagSpeedMaster = null;
  3782. const getSpeedMasterControlFlag = () => {
  3783.  
  3784. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  3785. isSpeedMastSpacebarControlEnabled = false;
  3786. if (config && config.EXPERIMENT_FLAGS && config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control) {
  3787. isSpeedMastSpacebarControlEnabled = true;
  3788. }
  3789. if (config && config.EXPERIMENTS_FORCED_FLAGS && config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control) {
  3790. isSpeedMastSpacebarControlEnabled = true;
  3791. }
  3792.  
  3793. if (flagSpeedMaster === null) {
  3794. const p = (((config || 0).WEB_PLAYER_CONTEXT_CONFIGS || 0).WEB_PLAYER_CONTEXT_CONFIG_ID_KEVLAR_WATCH || 0).serializedExperimentFlags;
  3795. if (!p) {
  3796. flagSpeedMaster = false;
  3797. } else {
  3798.  
  3799. flagSpeedMaster = (p.includes('web_enable_speedmaster=true') && p.includes('web_speedmaster_spacebar_control=true') && p.includes('web_speedmaster_updated_edu=true'));
  3800.  
  3801. }
  3802.  
  3803. }
  3804. if (!flagSpeedMaster) isSpeedMastSpacebarControlEnabled = false;
  3805.  
  3806. return isSpeedMastSpacebarControlEnabled;
  3807. }
  3808.  
  3809.  
  3810. const getGlobalSpacebarControlFlag = () => {
  3811.  
  3812. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  3813. isGlobalSpaceControl = false;
  3814. if (config && config.EXPERIMENT_FLAGS && config.EXPERIMENT_FLAGS.global_spacebar_pause) {
  3815. isGlobalSpaceControl = true;
  3816. }
  3817. if (config && config.EXPERIMENTS_FORCED_FLAGS && config.EXPERIMENTS_FORCED_FLAGS.global_spacebar_pause) {
  3818. isGlobalSpaceControl = true;
  3819. }
  3820.  
  3821. return isGlobalSpaceControl;
  3822. }
  3823.  
  3824. const keyboardController = async (_yt_player) => {
  3825.  
  3826. const keyQT = getQT(_yt_player);
  3827. const keySV = getSV(_yt_player);
  3828. const keyDX = getDX(_yt_player);
  3829. console.log(`[QT,SV,DX]`, [keyQT, keySV, keyDX]);
  3830.  
  3831. if (!keyDX) return;
  3832. if (keyDX === keyQT || keyDX === keySV) return;
  3833.  
  3834. if (typeof keyDX !== 'string') return;
  3835.  
  3836. let lastAccessKey = '';
  3837. let lastAccessKeyConfirmed = '';
  3838. const mb = new Proxy({}, {
  3839. get(target, prop) {
  3840. if (prop === 'handleGlobalKeyUp') lastAccessKeyConfirmed = lastAccessKey;
  3841. throw 'mbGet'
  3842. },
  3843. set(target, prop, val) {
  3844. throw 'mbSet'
  3845. }
  3846. });
  3847. const ma = new Proxy({}, {
  3848. get(target, prop) {
  3849. lastAccessKey = prop;
  3850. return mb
  3851. },
  3852. set(target, prop, val) {
  3853. throw 'maSet'
  3854. }
  3855. });
  3856.  
  3857. let keyBw = '';
  3858. try {
  3859. _yt_player[keyDX].prototype.handleGlobalKeyUp.call(ma);
  3860. } catch (e) {
  3861. if (e === 'mbGet' && typeof lastAccessKeyConfirmed === 'string' && lastAccessKeyConfirmed.length > 0) {
  3862. keyBw = lastAccessKeyConfirmed;
  3863. }
  3864. }
  3865.  
  3866. if (!keyBw) return;
  3867.  
  3868. if (typeof _yt_player[keyDX].prototype.init !== 'function' || _yt_player[keyDX].prototype.init.length !== 0) return;
  3869.  
  3870. pm_p_a = new PromiseExternal();
  3871.  
  3872. _yt_player[keyDX].prototype.__cPzfo__ = keyBw;
  3873.  
  3874. _yt_player[keyDX].prototype.init91 = _yt_player[keyDX].prototype.init;
  3875.  
  3876. _yt_player[keyDX].prototype.init = p_a_init;
  3877.  
  3878. await pm_p_a.then();
  3879. const p_a_obj = kRef(p_a_objWR);
  3880.  
  3881. const isSpeedMastSpacebarControlEnabledA = getSpeedMasterControlFlag();
  3882.  
  3883.  
  3884. if (CHANGE_SPEEDMASTER_SPACEBAR_CONTROL > 0) {
  3885.  
  3886. isSpeedMastSpacebarControlEnabled = CHANGE_SPEEDMASTER_SPACEBAR_CONTROL == 1;
  3887.  
  3888. if (!isSpeedMastSpacebarControlEnabled) {
  3889.  
  3890. if (config && config.EXPERIMENT_FLAGS) {
  3891. config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control = false;
  3892. }
  3893. if (config && config.EXPERIMENTS_FORCED_FLAGS) {
  3894. config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control = false;
  3895. }
  3896.  
  3897. } else {
  3898.  
  3899. if (config && config.EXPERIMENT_FLAGS) {
  3900. config.EXPERIMENT_FLAGS.web_speedmaster_spacebar_control = true;
  3901. }
  3902. if (config && config.EXPERIMENTS_FORCED_FLAGS) {
  3903. config.EXPERIMENTS_FORCED_FLAGS.web_speedmaster_spacebar_control = true;
  3904. }
  3905.  
  3906. }
  3907.  
  3908. }
  3909.  
  3910. const isSpeedMastSpacebarControlEnabledB = getSpeedMasterControlFlag();
  3911.  
  3912.  
  3913.  
  3914.  
  3915. console.log('[yt-js-engine-tamer] speedmaster by space (yt setting)', isSpeedMastSpacebarControlEnabledA, isSpeedMastSpacebarControlEnabledB);
  3916.  
  3917. // console.log(p_a_obj.handleGlobalKeyUp)
  3918. console.log('[yt-js-engine-tamer] p_a', p_a_obj);
  3919.  
  3920. // console.log(p_a_obj.api)
  3921.  
  3922.  
  3923. // QT -> DX(SV) -> p_a
  3924.  
  3925.  
  3926. /*
  3927. *
  3928. *
  3929. g.k.handleGlobalKeyUp = function(a, b, c, d, e, f, h) {
  3930. b = void 0 === b ? !1 : b;
  3931. c = void 0 === c ? !1 : c;
  3932. d = void 0 === d ? !1 : d;
  3933. e = void 0 === e ? !1 : e;
  3934. var l = g.PT(this);
  3935. l && l.handleGlobalKeyUp(a, b, c, d, e, f, h)
  3936. }
  3937.  
  3938. */
  3939.  
  3940. /*
  3941. *
  3942. *
  3943. *
  3944. g.k.handleGlobalKeyUp = function(a, b, c, d, e, f, h) {
  3945. return this.Bw ? this.Bw.handleGlobalKeyUp(a, b, c, d, e, f, h) : !1
  3946. }
  3947.  
  3948. */
  3949.  
  3950.  
  3951. // if(!keyDX) return;
  3952.  
  3953. // console.log(4999, keyDX)
  3954.  
  3955. };
  3956.  
  3957.  
  3958. const ytResumeFn = function () { // ADVANCED_FIX_SHORTCUTKEYS
  3959.  
  3960. const p_a_obj = kRef(p_a_objWR);
  3961. // const api = p_a_obj.api;
  3962.  
  3963.  
  3964. // console.log(540);
  3965.  
  3966. let boolList = null;
  3967. let ret;
  3968. isSpaceKeyImmediate = true;
  3969. try {
  3970.  
  3971. ret = 0;
  3972. ret = ret | (p_a_obj.handleGlobalKeyDown(32, false, false, false, false, ' ', 'Space', false) ? 1 : 0);
  3973. let p_a_objT;
  3974. if (!spaceBarControl_keyG) { // just in case
  3975. boolList = new Set();
  3976. p_a_objT = new Proxy(p_a_obj, {
  3977. get(target, prop, handler) {
  3978. const val = target[prop];
  3979. if (typeof val !== 'boolean') return val;
  3980. boolList.add(prop);
  3981. // console.log(555, prop, val);
  3982. if (typeof prop === 'string' && prop.length <= 3 && val === true && boolList.length === 1) {
  3983. spaceBarControl_keyG = prop;
  3984. p_a_obj.__uZWaD__ = spaceBarControl_keyG;
  3985. val = false;
  3986. }
  3987. return val;
  3988. }
  3989. });
  3990.  
  3991.  
  3992. } else if (p_a_obj[spaceBarControl_keyG] === true) {
  3993. p_a_obj[spaceBarControl_keyG] = false;
  3994. p_a_objT = p_a_obj;
  3995. // console.log(p_a_obj, spaceBarControl_keyG, p_a_obj[spaceBarControl_keyG] )
  3996. } else {
  3997.  
  3998. p_a_objT = p_a_obj;
  3999. }
  4000.  
  4001. ret = ret | (p_a_objT.handleGlobalKeyUp(32, false, false, false, false, ' ', 'Space') ? 2 : 0);
  4002.  
  4003.  
  4004. } catch (e) {
  4005. console.log(e)
  4006. }
  4007. isSpaceKeyImmediate = false;
  4008.  
  4009. if (boolList && boolList.size === 1) {
  4010. const value = boolList.values().next().value;
  4011. spaceBarControl_keyG = value;
  4012. p_a_obj.__uZWaD__ = spaceBarControl_keyG;
  4013.  
  4014. }
  4015.  
  4016. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  4017.  
  4018. return ret;
  4019. }
  4020.  
  4021. const shortcutKeysFixer = () => {
  4022.  
  4023. let pausePromiseControlJ = 0;
  4024.  
  4025.  
  4026. const obtainCurrentControlPhase = (evt, mediaPlayerElement) => {
  4027.  
  4028. let controlPhase = 0;
  4029. const aElm = document.activeElement;
  4030.  
  4031. if (aElm) {
  4032.  
  4033. const controlPhaseCache = wmKeyControlPhase.get(aElm);
  4034.  
  4035. if (typeof controlPhaseCache === 'number') {
  4036.  
  4037. controlPhase = controlPhaseCache;
  4038. } else {
  4039.  
  4040. if (aElm instanceof HTMLInputElement) controlPhase = 1;
  4041. else if (aElm instanceof HTMLTextAreaElement) controlPhase = 1;
  4042. else if (aElm instanceof HTMLButtonElement) controlPhase = 2;
  4043. else if (aElm instanceof HTMLIFrameElement) controlPhase = 2;
  4044. else if (aElm instanceof HTMLImageElement) controlPhase = 2;
  4045. else if (aElm instanceof HTMLEmbedElement) controlPhase = 2;
  4046. else {
  4047. if (aElm instanceof HTMLElement_ && aElm.closest('[role]')) controlPhase = 5;
  4048. if (aElm instanceof HTMLDivElement) controlPhase = 2;
  4049. else if (aElm instanceof HTMLAnchorElement) controlPhase = 2;
  4050. else if (!(aElm instanceof HTMLElement_) && (aElm instanceof Element)) controlPhase = 2; // svg
  4051. }
  4052.  
  4053. if ((controlPhase === 2 || controlPhase === 5) && (aElm instanceof HTMLElement_) && aElm.contains(mediaPlayerElement)) {
  4054. controlPhase = 0;
  4055. }
  4056.  
  4057. if ((controlPhase === 2 || controlPhase === 5) && evt && evt.target && evt.target === aElm) {
  4058. if (aElm.closest('[contenteditable], input, textarea')) {
  4059. controlPhase = 5;
  4060. } else if (aElm.closest('button')) {
  4061. controlPhase = 4;
  4062. }
  4063. }
  4064.  
  4065. if (aElm.closest('#movie_player')) controlPhase = 6;
  4066.  
  4067. wmKeyControlPhase.set(aElm, controlPhase);
  4068.  
  4069. }
  4070. }
  4071.  
  4072. return controlPhase;
  4073.  
  4074. }
  4075.  
  4076. const isStateControllable = (api) => {
  4077. let appState = null;
  4078. let playerState = null;
  4079. let adState = null;
  4080. try {
  4081. appState = api.getAppState();
  4082. playerState = api.getPlayerState();
  4083. adState = api.getAdState();
  4084. } catch (e) { }
  4085. // ignore playerState -1
  4086. return appState === 5 && adState === -1 && (playerState === 1 || playerState === 2 || playerState === 3);
  4087. };
  4088.  
  4089.  
  4090. const keyEventListener = (evt) => {
  4091. if (BY_PASS_KEYBOARD_CONTROL) return;
  4092.  
  4093. if (evt.isTrusted && evt instanceof Event) lastUserAction = Date.now();
  4094. if (isSpaceKeyImmediate || !evt.isTrusted || !(evt instanceof KeyboardEvent)) return;
  4095. if (!ytPageReady) return;
  4096.  
  4097. if (evt.defaultPrevented === true) return;
  4098.  
  4099. const p_a_obj = kRef(p_a_objWR);
  4100.  
  4101. if (!p_a_obj) return;
  4102.  
  4103.  
  4104. const mediaPlayerElement = kRef(mediaPlayerElementWR);
  4105. if (!mediaPlayerElement) return;
  4106.  
  4107. // let focusBodyIfSuccess = false;
  4108.  
  4109. const controlPhase = obtainCurrentControlPhase(evt, mediaPlayerElement);
  4110.  
  4111. if (controlPhase === 6 && getCurrentSelectionText() !== "") void 0;
  4112. else if (controlPhase === 1 || controlPhase === 2 || controlPhase === 5) return;
  4113. else if ((controlPhase !== 6 || focusedElementAtSelection === document.activeElement) && getCurrentSelectionText() !== "") return;
  4114.  
  4115.  
  4116. if (evt.code === 'Space' && !getGlobalSpacebarControlFlag()) return;
  4117.  
  4118. // console.log(`${evt.type}::controlPhase`,controlPhase)
  4119.  
  4120. // if (controlPhase == 4) {
  4121. // focusBodyIfSuccess = true;
  4122. // }
  4123.  
  4124. spaceBarControl_keyG = spaceBarControl_keyG || p_a_obj.__uZWaD__ || ''
  4125. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  4126.  
  4127. if (FIX_SHORTCUTKEYS < 2) return;
  4128. if (!(!evt.shiftKey && !evt.ctrlKey && !evt.altKey && !evt.metaKey)) return; // ignore if modifier key is pressed -> let other event listener to handle first
  4129.  
  4130. let rr;
  4131. const isSpaceBar = evt.code === 'Space' && !evt.shiftKey && !evt.ctrlKey && !evt.altKey && !evt.metaKey;
  4132.  
  4133.  
  4134.  
  4135. let useImprovedPauseResume = false;
  4136.  
  4137. if (USE_IMPROVED_PAUSERESUME_UNDER_NO_SPEEDMASTER && isSpaceBar && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  4138.  
  4139. const api = p_a_obj.api;
  4140. const stateControllable = isStateControllable(api);
  4141. // console.log(2122, appState, playerState, adState)
  4142.  
  4143. if (stateControllable && isWatchPageURL() && mediaPlayerElement.duration > 0.01 && (mediaPlayerElement.readyState === 4 || mediaPlayerElement.readyState === 1) && mediaPlayerElement.networkState === 2) {
  4144.  
  4145. useImprovedPauseResume = true;
  4146.  
  4147. }
  4148.  
  4149.  
  4150. }
  4151.  
  4152.  
  4153. // force flag: CHANGE_SPEEDMASTER_SPACEBAR_CONTROL
  4154. if (evt.type === 'keydown') {
  4155.  
  4156. if (useImprovedPauseResume) {
  4157.  
  4158. const isPaused = mediaPlayerElement.paused;
  4159.  
  4160. const cj = ++pausePromiseControlJ;
  4161. Promise.resolve().then(() => {
  4162.  
  4163. if (cj !== pausePromiseControlJ) return;
  4164.  
  4165. if (mediaPlayerElement.paused !== isPaused) return;
  4166.  
  4167. const ret = ytResumeFn();
  4168. if (!ret) { // fallback
  4169. isPaused ? api.playVideo() : api.pauseVideo();
  4170. }
  4171.  
  4172. /*
  4173. let a = void 0;
  4174. console.log('Rb', api.Rb())
  4175. a = !window._yt_player.nL(api.Rb());
  4176. p_a_obj.Wd.kG(a)
  4177. a ? api.playVideo() : api.pauseVideo();
  4178.  
  4179. */
  4180.  
  4181.  
  4182. });
  4183. rr = true;
  4184. } else {
  4185.  
  4186. isSpaceKeyImmediate = true;
  4187. rr = p_a_obj.handleGlobalKeyDown(evt.keyCode, evt.shiftKey, evt.ctrlKey, evt.altKey, evt.metaKey, evt.key, evt.code, evt.repeat);
  4188. isSpaceKeyImmediate = false;
  4189. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  4190.  
  4191. }
  4192.  
  4193.  
  4194. } else if (evt.type === 'keyup') {
  4195.  
  4196. if (isSpaceBar && useImprovedPauseResume && !(isSpeedMastSpacebarControlEnabled = getSpeedMasterControlFlag())) {
  4197.  
  4198. rr = true;
  4199. } else {
  4200.  
  4201. isSpaceKeyImmediate = true;
  4202. rr = p_a_obj.handleGlobalKeyUp(evt.keyCode, evt.shiftKey, evt.ctrlKey, evt.altKey, evt.metaKey, evt.key, evt.code);
  4203. isSpaceKeyImmediate = false;
  4204. if (spaceBarControl_keyG && p_a_obj[spaceBarControl_keyG] === true) p_a_obj[spaceBarControl_keyG] = false;
  4205.  
  4206. }
  4207.  
  4208.  
  4209. /*
  4210.  
  4211. if (d)
  4212. switch (c) {
  4213. case 32:
  4214. case 13:
  4215. if ("BUTTON" === d.tagName || "A" === d.tagName || "INPUT" === d.tagName)
  4216. b = !0,
  4217. e = !1;
  4218. else if (e) {
  4219. var m = d.getAttribute("role");
  4220. !m || "option" !== m && "button" !== m && 0 !== m.indexOf("menuitem") || (b = !0,
  4221. d.click(),
  4222. f = !0)
  4223. }
  4224. break;
  4225. case 37:
  4226. case 39:
  4227. case 36:
  4228. case 35:
  4229. b = "slider" === d.getAttribute("role");
  4230. break;
  4231. case 38:
  4232. case 40:
  4233. m = d.getAttribute("role"),
  4234. d = 38 === c ? d.previousSibling : d.nextSibling,
  4235. "slider" === m ? b = !0 : e && ("option" === m ? (d && "option" === d.getAttribute("role") && d.focus(),
  4236. f = b = !0) : m && 0 === m.indexOf("menuitem") && (d && d.hasAttribute("role") && 0 === d.getAttribute("role").indexOf("menuitem") && d.focus(),
  4237. f = b = !0))
  4238. }
  4239. if (e && !f)
  4240. switch (c) {
  4241. case 38:
  4242. f = Math.min(this.api.getVolume() + 5, 100);
  4243. XV(this.Wd, f, !1);
  4244. this.api.setVolume(f);
  4245. h = f = !0;
  4246. break;
  4247. case 40:
  4248. f = Math.max(this.api.getVolume() - 5, 0);
  4249. XV(this.Wd, f, !0);
  4250. this.api.setVolume(f);
  4251. h = f = !0;
  4252. break;
  4253. case 36:
  4254. this.api.Yh() && (this.api.startSeekCsiAction(),
  4255. this.api.seekTo(0, void 0, void 0, void 0, 79),
  4256. h = f = !0);
  4257. break;
  4258. case 35:
  4259. this.api.Yh() && (this.api.startSeekCsiAction(),
  4260. this.api.seekTo(Infinity, void 0, void 0, void 0, 80),
  4261. h = f = !0)
  4262. }
  4263. */
  4264.  
  4265. }
  4266.  
  4267.  
  4268. if (rr) {
  4269.  
  4270. // focusBodyIfSuccess && Promise.resolve().then(() => {
  4271. // activeElement === document.activeElement && activeElement.blur();
  4272. // });
  4273.  
  4274. evt.preventDefault();
  4275. evt.stopImmediatePropagation();
  4276. evt.stopPropagation();
  4277.  
  4278. }
  4279.  
  4280. };
  4281.  
  4282. document.addEventListener('keydown', keyEventListener, { capture: true });
  4283.  
  4284.  
  4285. document.addEventListener('keyup', keyEventListener, { capture: true });
  4286.  
  4287. }
  4288.  
  4289. return { pageMediaWatcher, shortcutKeysFixer, keyboardController };
  4290.  
  4291. })();
  4292.  
  4293.  
  4294. pageMediaWatcher();
  4295. FIX_SHORTCUTKEYS > 0 && shortcutKeysFixer();
  4296.  
  4297.  
  4298. const check_for_set_key_order = (() => {
  4299.  
  4300. let mySet = new Set();
  4301.  
  4302. mySet.add("value1");
  4303. mySet.add("value2");
  4304. mySet.add("value3");
  4305.  
  4306. // Function to convert Set values to an array
  4307. function getSetValues(set) {
  4308. return Array.from(set.values());
  4309. }
  4310.  
  4311. // Function to test if the Set maintains insertion order
  4312. function testSetOrder(set, expectedOrder) {
  4313. let values = getSetValues(set);
  4314. return expectedOrder.join(',') === values.join(',');
  4315. }
  4316.  
  4317. // Test 1: Initial order
  4318. if (mySet.values().next().value !== "value1") return false;
  4319. if (!testSetOrder(mySet, ["value1", "value2", "value3"])) return false;
  4320.  
  4321. // Test 2: After deleting an element
  4322. mySet.delete("value2");
  4323. if (mySet.values().next().value !== "value1") return false;
  4324. if (!testSetOrder(mySet, ["value1", "value3"])) return false;
  4325.  
  4326. // Test 3: After re-adding a deleted element
  4327. mySet.add("value2");
  4328. if (mySet.values().next().value !== "value1") return false;
  4329. if (!testSetOrder(mySet, ["value1", "value3", "value2"])) return false;
  4330.  
  4331. // Test 4: After adding a new element
  4332. mySet.add("value4");
  4333. if (mySet.values().next().value !== "value1") return false;
  4334. if (!testSetOrder(mySet, ["value1", "value3", "value2", "value4"])) return false;
  4335.  
  4336. // Test 5: Delete+Add
  4337. mySet.delete("value1");
  4338. mySet.delete("value3");
  4339. mySet.add("value3");
  4340. mySet.add("value1");
  4341. if (mySet.values().next().value !== "value2") return false;
  4342. if (!testSetOrder(mySet, ["value2", "value4", "value3", "value1"])) return false;
  4343.  
  4344. return true;
  4345. })();
  4346.  
  4347.  
  4348. // const qm47 = Symbol();
  4349. const qm57 = Symbol();
  4350. const qm53 = Symbol();
  4351. const qn53 = Symbol();
  4352.  
  4353.  
  4354. const ump3 = new WeakMap();
  4355.  
  4356. const stp = document.createElement('noscript');
  4357. stp.id = 'weakref-placeholder';
  4358.  
  4359. PROP_OverReInclusion_AVOID && (() => {
  4360.  
  4361.  
  4362. if (typeof HTMLElement_.prototype.hasOwnProperty72 === 'function' || typeof HTMLElement_.prototype.hasOwnProperty !== 'function') return;
  4363. const f = HTMLElement_.prototype.hasOwnProperty72 = HTMLElement_.prototype.hasOwnProperty;
  4364. let byPassVal = null;
  4365. let byPassCount = 0;
  4366. let mmw = new Set();
  4367. HTMLElement_.prototype.hasOwnProperty = function (prop) {
  4368. if (arguments.length !== 1) return f.apply(this, arguments);
  4369. if (byPassVal !== null && typeof prop === 'string') {
  4370.  
  4371. if (PROP_OverReInclusion_LIST.has(prop)) {
  4372. byPassCount++;
  4373. return byPassVal;
  4374. }
  4375. PROP_OverReInclusion_DEBUGLOG && mmw.add(prop);
  4376.  
  4377. }
  4378. return this.hasOwnProperty72(prop);
  4379. };
  4380.  
  4381.  
  4382. /*
  4383.  
  4384.  
  4385. z.prototype.forwardDynamicProps = function() {
  4386. var B = m(this.inst);
  4387. B = h(B);
  4388. for (var F = B.next(); !F.done; F = B.next()) {
  4389. var H = h(F.value);
  4390. F = H.next().value;
  4391. H = H.next().value;
  4392. my(this, F, H);
  4393. r(b) && !ly(F) && Wua(this.inst, F)
  4394. }
  4395. }
  4396.  
  4397. */
  4398.  
  4399.  
  4400.  
  4401. let byPassZeroShowed = false;
  4402. const forwardDynamicPropsGeneral = function () {
  4403. byPassVal = true;
  4404. byPassCount = 0;
  4405. PROP_OverReInclusion_DEBUGLOG && mmw.clear();
  4406. const ret = this.forwardDynamicProps72();
  4407. byPassVal = null;
  4408. if (byPassCount === 0 && !byPassZeroShowed) {
  4409. byPassZeroShowed = true;
  4410. console.log('[yt-js-engine-tamer] byPassCount = 0 in forwardDynamicProps')
  4411. }
  4412. byPassCount = 0;
  4413. if (PROP_OverReInclusion_DEBUGLOG && mmw.size > 0) {
  4414. console.log(399, '[yt-js-engine-tamer]', [...mmw]);
  4415. mmw.clear();
  4416. }
  4417. return ret;
  4418. };
  4419.  
  4420. const propCheck = (proto) => {
  4421. if (typeof (proto || 0) == 'object' && typeof proto.forwardDynamicProps === 'function' && typeof proto.forwardDynamicProps72 !== 'function') {
  4422. proto.forwardDynamicProps72 = proto.forwardDynamicProps;
  4423. if (proto.forwardDynamicProps.length === 0) {
  4424. proto.forwardDynamicProps = forwardDynamicPropsGeneral;
  4425. }
  4426. }
  4427. };
  4428.  
  4429. const valMap = new WeakMap();
  4430. Object.defineProperty(HTMLElement_.prototype, 'didForwardDynamicProps', {
  4431. get() {
  4432. propCheck(this.constructor.prototype);
  4433. return valMap.get(this);
  4434. },
  4435. set(nv) {
  4436. propCheck(this.constructor.prototype);
  4437. valMap.set(this, nv);
  4438. return true;
  4439. },
  4440. enumerable: false,
  4441. configurable: true
  4442.  
  4443. });
  4444.  
  4445. promiseForCustomYtElementsReady.then(() => {
  4446. if (typeof customElements !== 'object' || typeof customElements.define72 === 'function' || typeof customElements.define !== 'function') return;
  4447. if (customElements.define.length !== 2) return;
  4448. customElements.define72 = customElements.define;
  4449. customElements.define = function (b, w) {
  4450. propCheck(w.prototype);
  4451. const ret = this.define72(b, w);
  4452. return ret;
  4453. }
  4454. });
  4455.  
  4456. })();
  4457.  
  4458.  
  4459. let marcoPr = new PromiseExternal();
  4460. const trackMarcoCm = document.createComment('1');
  4461. const trackMarcoCmObs = new MutationObserver(()=>{
  4462. marcoPr.resolve();
  4463. marcoPr = new PromiseExternal();
  4464. });
  4465. trackMarcoCmObs.observe(trackMarcoCm, {characterData: true});
  4466.  
  4467.  
  4468. // ----------------------------
  4469.  
  4470.  
  4471.  
  4472. const __refreshData938o__ = {};
  4473. const __refreshData938__ = function (prop, opt) {
  4474. const d = this[prop];
  4475. if (d) {
  4476. this._setPendingProperty(prop, __refreshData938o__, opt);
  4477. this._setPendingProperty(prop, d, opt);
  4478. this._invalidateProperties();
  4479. }
  4480. };
  4481.  
  4482. const __refreshData933__ = function (prop, opt) {
  4483. const d = this[prop];
  4484. if (d) {
  4485. this.signalProxy.setWithPath([prop], d);
  4486. }
  4487. }
  4488.  
  4489. const setupRefreshData930 = (cnt) => {
  4490. if (cnt.__refreshData930__ !== undefined) return;
  4491. const cProto = Reflect.getPrototypeOf(cnt);
  4492. let r = null;
  4493. let flag = 0;
  4494. if (typeof cnt._setPendingProperty === 'function' && typeof cnt._invalidateProperties === 'function' && cnt._setPendingProperty.length === 3 && cnt._invalidateProperties.length === 0) {
  4495. flag |= 1;
  4496. }
  4497. if (typeof cnt.signalProxy !== "undefined") {
  4498. flag |= 2;
  4499. }
  4500. if (typeof (cnt.signalProxy || 0).setWithPath === 'function' && cnt.signalProxy.setWithPath.length === 2) {
  4501. flag |= 4;
  4502. }
  4503. if (r === 1) r = __refreshData938__;
  4504. // else if (r === 6) r = __refreshData933__;
  4505. cProto.__refreshData930__ = r;
  4506. // ytd-comments-header-renderer : no _invalidateProperties (cnt.signalProxy.setWithPath)
  4507. }
  4508.  
  4509. // const pendingStampFlushs = [];
  4510.  
  4511. const nativeNow = performance.constructor.prototype.now.bind(performance);
  4512.  
  4513. const queueMicrotask_ = typeof queueMicrotask === 'function' ? queueMicrotask : (f) => (Promise.resolve().then(f), void 0);
  4514.  
  4515. const executeTaskBatch = function (taskArr, firstMarco = true) {
  4516. if (!(taskArr || 0).length) throw new TypeError(`Illegal invocation`);
  4517. return new Promise(resolveFinal => {
  4518. let resolveFn = null;
  4519. const len = taskArr.length;
  4520. const results = new Array(len);
  4521. const makePromise = () => new Promise(resolve => { resolveFn = resolve });
  4522. let firedCount = 0;
  4523. const executor = () => {
  4524. if (taskArr.length !== len) throw new TypeError(`Illegal invocation`);
  4525. const resolveFn_ = resolveFn;
  4526. let t0 = 0;
  4527. let next = 0;
  4528. taskArr.forEach((task, idx) => {
  4529. if (typeof (task || 0) !== 'object') throw new TypeError(`Illegal invocation`);
  4530. if (!task.fired) {
  4531. queueMicrotask_(() => {
  4532. if (next || task.fired) return;
  4533. task.fired = true;
  4534. const { fn } = task;
  4535. task.fn = null;
  4536. if (++firedCount === len) next |= 2;
  4537. if (!t0) t0 = nativeNow() + 10;
  4538. results[idx] = fn(task); // sync task only
  4539. if (nativeNow() > t0) next |= 1;
  4540. });
  4541. }
  4542. });
  4543. queueMicrotask_(() => resolveFn_(next))
  4544. }
  4545. const looper = (next) => {
  4546. if (!next) throw new TypeError(`Illegal invocation`);
  4547. if (next & 2) {
  4548. taskArr.length = 0;
  4549. if (next & 1) {
  4550. nextBrowserTick_(() => resolveFinal(results))
  4551. } else {
  4552. resolveFinal(results);
  4553. }
  4554. } else {
  4555. const p = makePromise();
  4556. nextBrowserTick_(executor);
  4557. p.then(looper);
  4558. }
  4559. }
  4560. const p = makePromise();
  4561. firstMarco ? nextBrowserTick_(executor) : executor();
  4562. p.then(looper);
  4563.  
  4564. })
  4565.  
  4566. }
  4567.  
  4568.  
  4569. FIX_ICON_RENDER && whenCEDefined('yt-icon').then(async () => {
  4570.  
  4571.  
  4572. // const globalPromiseStack = {};
  4573.  
  4574. // let dummy;
  4575. // while(!dummy){
  4576.  
  4577. // dummy = document.querySelector('yt-icon');
  4578. // await new Promise(r=>setTimeout(r,0));
  4579. // }
  4580.  
  4581. dummy = document.createElement('yt-icon');
  4582.  
  4583. let cProto;
  4584. if (!(dummy instanceof Element)) return;
  4585. cProto = insp(dummy).constructor.prototype;
  4586.  
  4587. cProto.handlePropertyChange671 = cProto.handlePropertyChange;
  4588. cProto.determineIconSet671 = cProto.determineIconSet;
  4589. cProto.switchToYtSysIconset671 = cProto.switchToYtSysIconset;
  4590. cProto.useYtSysIconsetForMissingIcons671 = cProto.useYtSysIconsetForMissingIcons;
  4591. cProto.getIconManager671 = cProto.getIconManager;
  4592. cProto.getIconShapeData671 = cProto.getIconShapeData;
  4593. cProto.renderIcon671 = cProto.renderIcon;
  4594.  
  4595. // cProto.attached488 = cProto.attached;
  4596. // cProto.attached = function(){
  4597. // console.log('attached')
  4598. // return this.attached488(...arguments);
  4599. // }
  4600. // cProto.detached488 = cProto.detached;
  4601. // cProto.detached = function(){
  4602. // console.log('detached')
  4603. // return this.detached488(...arguments);
  4604. // }
  4605.  
  4606. if(cProto.__renderIconFix__) return;
  4607. cProto.__renderIconFix__ = true;
  4608.  
  4609. let taskStack = [];
  4610. const cmObs = new MutationObserver(()=>{
  4611. const tasks = taskStack.slice();
  4612. taskStack.length = 0;
  4613. for(const task of tasks){
  4614. task();
  4615. }
  4616. })
  4617. const cm = document.createComment('1');
  4618. const stackTask = (f) => {
  4619. taskStack.push(f);
  4620. cm.data = `${(cm.data & 7) + 1}`;
  4621. }
  4622. cmObs.observe(cm, { characterData: true });
  4623.  
  4624. // let iconManagers = {}; // assume shared
  4625.  
  4626. // window.iconManagers = () => iconManagers;
  4627.  
  4628.  
  4629. const setupYtIcon = (inst) => {
  4630.  
  4631. if (inst.__ytIconSetup588__) return;
  4632. const cProto = Reflect.getPrototypeOf(inst);
  4633. cProto.__ytIconSetup588__ = true;
  4634.  
  4635.  
  4636. const config = (win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0;
  4637.  
  4638. config.EXPERIMENT_FLAGS.wil_icon_render_when_idle = false; // single rendering
  4639. config.EXPERIMENT_FLAGS.wil_icon_load_immediately = true; // single rendering
  4640. // config.EXPERIMENT_FLAGS.wil_icon_use_mask_rendering = false; // DON'T!
  4641. config.EXPERIMENT_FLAGS.wil_icon_network_first = true; // single rendering
  4642.  
  4643.  
  4644. // this.renderingMode = _.x("wil_icon_use_mask_rendering") ? 1 : 0;
  4645. // this.isNetworkFirstStrategy = _.x("wil_icon_network_first");
  4646. // this.renderWhenIdle = _.x("wil_icon_render_when_idle");
  4647. // this.waitForAnimationFrame = !_.x("wil_icon_load_immediately");
  4648.  
  4649.  
  4650.  
  4651. }
  4652.  
  4653. cProto.handlePropertyChange = function (...a) { // 10+
  4654.  
  4655. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4656. this.__resolved__ = {
  4657.  
  4658. };
  4659. const a01 = this.isAttached;
  4660. let a02, a03;
  4661.  
  4662.  
  4663. const t = this.__stackedKey3818__ = (this.__stackedKey3818__ & 1073741823) + 1;
  4664.  
  4665. const stackFn = () => {
  4666. if (t !== this.__stackedKey3818__) {
  4667. return;
  4668. }
  4669. a03 = this.isAttached;
  4670.  
  4671. if (a01 === false && a02 === false && a03 === false) return;
  4672.  
  4673. if (a01 === true && a02 === true && a03 === true) {
  4674.  
  4675. } else {
  4676. if (a01 === undefined && a02 === undefined && a03 === undefined && (this.hostElement || this).isConnected === false) {
  4677. // unknown yt-icon#label-icon
  4678. return;
  4679. } else {
  4680. console.log('[yt-icon] debug', a01, a02, a03, this)
  4681. }
  4682. }
  4683.  
  4684. this.handlePropertyChange671(...arguments);
  4685.  
  4686. };
  4687.  
  4688.  
  4689.  
  4690. Promise.resolve().then(() => {
  4691. a02 = this.isAttached;
  4692. stackTask(stackFn);
  4693. });
  4694.  
  4695.  
  4696. }
  4697.  
  4698. cProto.determineIconSet = function (a, b, c, d) { // 10-
  4699.  
  4700. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4701. // string bool? bool=false int=24
  4702. // NOTIFICATIONS_NONE OR LIKE
  4703. // console.log('yt-icon.determineIconSet', ...arguments);
  4704.  
  4705. const r = this.determineIconSet671(...arguments);
  4706. return r;
  4707. }
  4708.  
  4709. cProto.switchToYtSysIconset = function (a, b, c, d) { // 10-
  4710.  
  4711. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4712. // same as determineIconSet
  4713. // console.log('yt-icon.switchToYtSysIconset', ...arguments);
  4714. return this.switchToYtSysIconset671(...arguments);
  4715. }
  4716.  
  4717. cProto.useYtSysIconsetForMissingIcons = function (a, b, c, d) { // X
  4718.  
  4719. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4720. // console.log('yt-icon.useYtSysIconsetForMissingIcons', ...arguments);
  4721. return this.useYtSysIconsetForMissingIcons671(...arguments);
  4722. }
  4723.  
  4724. cProto.getIconManager = function () { // 10+
  4725.  
  4726. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4727. if (!this.__resolved__) this.__resolved__ = {};
  4728. if (!this.__resolved__.getIconManager) this.__resolved__.getIconManager = this.getIconManager671(...arguments);
  4729. const r = this.__resolved__.getIconManager;
  4730. return r;
  4731. }
  4732.  
  4733. cProto.getIconShapeData = function () { // 10+
  4734.  
  4735. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4736.  
  4737. // no argument
  4738. // console.log('yt-icon.getIconShapeData', ...arguments);
  4739. if (!this.__resolved__) this.__resolved__ = {};
  4740. if (!this.__resolved__.getIconShapeData) this.__resolved__.getIconShapeData = this.getIconShapeData671(...arguments);
  4741. const r = this.__resolved__.getIconShapeData;
  4742. return r
  4743. }
  4744.  
  4745. cProto.renderIcon = function (a, b) { // X
  4746.  
  4747. if (!this.__ytIconSetup588__) setupYtIcon(this);
  4748. // "" yt-icons:xxx
  4749. // console.log('yt-icon.renderIcon', ...arguments);
  4750. return this.renderIcon671(...arguments);
  4751. }
  4752.  
  4753. });
  4754.  
  4755.  
  4756.  
  4757. const createStampDomFnsB_ = ()=>{
  4758.  
  4759. const config = ((win.yt || 0).config_ || (win.ytcfg || 0).data_ || 0);
  4760.  
  4761. if (config.DEFERRED_DETACH === true) config.DEFERRED_DETACH = false;
  4762. if (config.REUSE_COMPONENTS === true) config.REUSE_COMPONENTS = false;
  4763.  
  4764. const rq0 = document.createElement('rp');
  4765. rq0.setAttribute('yt-element-placholder', '');
  4766.  
  4767. let activeStampContainerId = '';
  4768.  
  4769. const componentBasedTaskPool = new WeakMap();
  4770.  
  4771. const getStampContainer_ = function (containerId){
  4772.  
  4773. // if(this.__byPass828__) return this.getStampContainer7409_(containerId);
  4774.  
  4775. this.__activeContainerId929__ = containerId;
  4776.  
  4777. return this.getStampContainer7409_(containerId);
  4778.  
  4779. }
  4780.  
  4781.  
  4782. const it0 = Date.now() - 80000000000;
  4783. const genId = ()=>`${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}_${(Date.now()-it0).toString(36)}`;
  4784.  
  4785.  
  4786. const createComponent_ = function (componentConfig, data, canReuse) {
  4787.  
  4788. if(this.__byPass828__ || !this.__byPass348__) return this.createComponent7409_(componentConfig, data, canReuse);
  4789.  
  4790. const containerId = this.__activeContainerId929__;
  4791.  
  4792. // console.log(2883007, componentConfig, data, canReuse)
  4793.  
  4794. const r = rq0.cloneNode(false);
  4795.  
  4796. r.is = genId();
  4797.  
  4798. return r;
  4799.  
  4800. }
  4801.  
  4802. /*
  4803. const eTasks = [];
  4804.  
  4805. let executing = false;
  4806. const executeTasks = async () => {
  4807.  
  4808. if(!eTasks.length) return;
  4809. if (executing) return;
  4810. executing = true;
  4811.  
  4812. try {
  4813.  
  4814. let eTask;
  4815. let t0 = performance.now();
  4816. while (eTask = eTasks.shift()) {
  4817. eTask.fn(eTask);
  4818. const t1 = performance.now();
  4819. if (t1 - t0 > 10) {
  4820. await nextBrowserTick_();
  4821. t0 = t1;
  4822. } else {
  4823. await Promise.resolve();
  4824. }
  4825. }
  4826. } catch (e) {
  4827. console.warn(e);
  4828. }
  4829.  
  4830. executing = false;
  4831.  
  4832. }
  4833. */
  4834.  
  4835.  
  4836.  
  4837.  
  4838.  
  4839. let executing = false;
  4840. let eTasks = null;
  4841. let setRkT0;
  4842. let rkT0;
  4843.  
  4844. const rxProcessTask = () => {
  4845.  
  4846. if (setRkT0) {
  4847. rkT0 = performance.now();
  4848. setRkT0 = false;
  4849. }
  4850. const eTask = getETask();
  4851. if (!eTask) {
  4852. executing = false;
  4853. return;
  4854. }
  4855. try {
  4856. eTask.fn(eTask);
  4857. if (performance.now() - rkT0 > 10) {
  4858. setRkT0 = true;
  4859. nextBrowserTick_(rxProcessTask);
  4860. } else {
  4861. queueMicrotask_(rxProcessTask);
  4862. }
  4863. } catch (e) {
  4864. console.warn(e);
  4865. executing = false;
  4866. }
  4867. };
  4868.  
  4869. const getETask = ()=>{
  4870.  
  4871.  
  4872.  
  4873.  
  4874. const nodeTasks = [];
  4875.  
  4876.  
  4877. for (const nodeWr of pendingRxList) {
  4878. const node = kRef(nodeWr);
  4879. if (!node) continue;
  4880. let nodeLevel = levelStore.get(node);
  4881. if (!nodeLevel) debugger;
  4882. const pTask = componentBasedTaskPool.get(node);
  4883. if (!pTask) continue;
  4884. const processLevel = ['creation', 'flushStamper', 'flushStamperWait', 'idleContainer', 'waitContainersRenderFinish', 'idleProducer'].indexOf(pTask.step) + 1;
  4885. if (!processLevel) debugger;
  4886. nodeTasks.push({
  4887. nodeLevel: nodeLevel,
  4888. processLevel: processLevel,
  4889. nodeId: refIDs.get(nodeWr),
  4890. nodeWr
  4891. });
  4892. }
  4893.  
  4894. if(nodeTasks.length === 0) return null;
  4895.  
  4896. nodeTasks.sort((a, b) => {
  4897. let c;
  4898. c = a.nodeLevel - b.nodeLevel;
  4899. if (c) return c;
  4900. c = a.processLevel - b.processLevel;
  4901. if (c) return c;
  4902. return a.nodeId - b.nodeId;
  4903. });
  4904.  
  4905. // console.log(nodeTasks);
  4906.  
  4907.  
  4908. const eTasks = nodeTasks.map(e => ({
  4909. component: e.nodeWr,
  4910. fn: processTask
  4911. }));
  4912.  
  4913. const eTask = eTasks[0];
  4914. pendingRxList.delete(eTask.component);
  4915.  
  4916. console.log(388, eTask)
  4917.  
  4918. return eTask;
  4919.  
  4920. }
  4921.  
  4922. const executeTasks = () => {
  4923.  
  4924. // if (!eTasks.length) return;
  4925. if (executing) return;
  4926. executing = true;
  4927. setRkT0 = true;
  4928.  
  4929. rxProcessTask();
  4930. };
  4931.  
  4932. Node.prototype.checkFF = function(){
  4933. return componentBasedTaskPool.get(this)
  4934. }
  4935.  
  4936. const processTask = (mTask)=>{
  4937.  
  4938.  
  4939. let {component} = mTask;
  4940. component = kRef(component);
  4941. const pTask = component ? componentBasedTaskPool.get(component) : null;
  4942. if(!pTask) return;
  4943. let {step, producer, containerId, typeOrConfig, data, flushing, selfProducer} = pTask;
  4944. producer = kRef(producer);
  4945. selfProducer = kRef(selfProducer);
  4946. // console.log(2883034, 'pTask', component, {...pTask})
  4947.  
  4948. // console.log(18843992, component, {...pTask})
  4949.  
  4950. const resolveSelfAndCheckParent = ()=>{
  4951. const node = component;
  4952.  
  4953. const s = new Set();
  4954. node.removeAttribute('ytx-flushing');
  4955. const parentComponent = node.closest('[ytx-flushing]');
  4956. if(parentComponent && componentBasedTaskPool.has(parentComponent) && parentComponent[wk] && !parentComponent.querySelector('[ytx-flushing]') ){
  4957. if(!s.has(parentComponent[wk])){
  4958. s.add(parentComponent[wk])
  4959. pendingRxList.add_(parentComponent[wk]);
  4960. }
  4961. }
  4962.  
  4963. if(producer){
  4964.  
  4965. const parentComponent = producer.hostElement;
  4966. if(parentComponent && componentBasedTaskPool.has(parentComponent) && parentComponent[wk] && !parentComponent.querySelector('[ytx-flushing]') ){
  4967. if(!s.has(parentComponent[wk])){
  4968. s.add(parentComponent[wk])
  4969.  
  4970. pendingRxList.add_(parentComponent[wk]);
  4971. }
  4972. }
  4973.  
  4974. }
  4975.  
  4976. if(selfProducer){
  4977.  
  4978. const parentComponent = selfProducer.hostElement;
  4979. if (parentComponent && componentBasedTaskPool.has(parentComponent) && parentComponent[wk] && !parentComponent.querySelector('[ytx-flushing]')) {
  4980. if (!s.has(parentComponent[wk])) {
  4981. s.add(parentComponent[wk])
  4982. pendingRxList.add_(parentComponent[wk]);
  4983. }
  4984. }
  4985.  
  4986. }
  4987.  
  4988. s.clear();
  4989.  
  4990.  
  4991. }
  4992. if(pTask.step === 'creation'){
  4993.  
  4994. if (!producer) return;
  4995. if(component.parentNode && component.parentNode.id === containerId && component.parentNode === producer.getStampContainer7409_(containerId) ){
  4996. pTask.step = 'flushStamper';
  4997.  
  4998. const aNode = producer.createComponent7409_(typeOrConfig, data, false);
  4999. const qNode = component;
  5000.  
  5001. levelStore.set(aNode, levelStore.get(qNode));
  5002.  
  5003. aNode.setAttribute('ytx-stamp', 'flusher');
  5004. aNode.setAttribute('ytx-flushing', '2')
  5005. if(!aNode[wk]) aNode[wk] = mWeakRef(aNode);
  5006.  
  5007. const container = producer.getStampContainer7409_(containerId);
  5008. const containerApi = container.__domApi || container;
  5009.  
  5010. const frag = document.createDocumentFragment();
  5011. frag.appendChild(aNode);
  5012. containerApi.insertBefore(frag, qNode);
  5013. containerApi.removeChild(qNode);
  5014.  
  5015. componentBasedTaskPool.delete(qNode)
  5016. componentBasedTaskPool.set(aNode, pTask)
  5017.  
  5018. pendingRxList.add_(aNode[wk]);
  5019. return;
  5020.  
  5021.  
  5022. }
  5023. } else if(pTask.step === 'flushStamper'){
  5024.  
  5025. if (!producer) return;
  5026. pTask.step = 'flushStamperWait';
  5027. pTask.typeOrConfig = null;
  5028. pTask.data = null;
  5029.  
  5030. const node = component;
  5031. node.setAttribute('ytx-flushing', '3');
  5032. let taskB = { component: component, typeOrConfig: typeOrConfig, data: data };
  5033. // flushedObserver.observe(node, { subtree: true, childList: true });
  5034. producer.deferredBindingTasks_.push(taskB);
  5035. producer.flushRenderStamperComponentBindings7409_();
  5036.  
  5037. node.setAttribute('ytx-flushing', '4');
  5038.  
  5039.  
  5040. if(!node.querySelector('[ytx-flushing]')){
  5041. pendingRxList.add_(component[wk]);
  5042. return;
  5043. }
  5044.  
  5045.  
  5046.  
  5047. } else if (pTask.step === 'flushStamperWait'){
  5048. if (!producer) return;
  5049.  
  5050. // producer undetermined
  5051.  
  5052. const node = component;
  5053.  
  5054. if(!node.querySelector('[ytx-flushing]')){
  5055.  
  5056. pTask.step = 'idleContainer';
  5057.  
  5058. resolveSelfAndCheckParent();
  5059.  
  5060.  
  5061. }
  5062.  
  5063.  
  5064. } else if (pTask.step === 'waitContainersRenderFinish'){
  5065.  
  5066. const node = component;
  5067.  
  5068. if(!node.querySelector('[ytx-flushing]')){
  5069. pTask.step = 'idleProducer';
  5070. node.setAttribute('ytx-flushing', 's-2')
  5071. }
  5072. // const selfProducer = kRef(pTask.selfProducer);
  5073.  
  5074.  
  5075. }
  5076.  
  5077.  
  5078. if(selfProducer && flushing && flushing.length > 0){
  5079.  
  5080. const node = component;
  5081. if(!node.querySelector('[ytx-flushing]')){
  5082.  
  5083. // pTask.step = 'idleProducer';
  5084.  
  5085. // node.setAttribute('ytx-flushing', 's-2')
  5086.  
  5087. let shouldMarkDirty = false;
  5088.  
  5089. const m = new Set();
  5090.  
  5091.  
  5092. // console.log(644221399, node, [...flushing])
  5093.  
  5094. const producer = selfProducer;
  5095.  
  5096. for(const [containerId, bEvent, hasData] of flushing){
  5097. if(hasData){
  5098. shouldMarkDirty = true;
  5099. if(bEvent){
  5100. const container = producer.getStampContainer7409_(containerId);
  5101. // console.log(644221499, container)
  5102. m.add(container);
  5103. }
  5104. }
  5105. }
  5106. // flushing.clear();
  5107. flushing.length = 0;
  5108.  
  5109. if (shouldMarkDirty) {
  5110. producer.markDirty && producer.markDirty();
  5111. let q = true;
  5112. for (const container of m) {
  5113. if(!q) producer.markDirty && producer.markDirty();
  5114. q = false;
  5115. dispatchYtEvent(producer.hostElement, "yt-rendererstamper-finished", {
  5116. container
  5117. });
  5118. }
  5119. }
  5120.  
  5121. if(node.getAttribute('ytx-flushing') === 's-2') node.setAttribute('ytx-flushing', 's-3');
  5122.  
  5123.  
  5124. resolveSelfAndCheckParent();
  5125.  
  5126. //... event
  5127. }
  5128. }
  5129.  
  5130. // [...document.querySelectorAll('[ytx-flushing]')].filter(e=>!e.querySelector('[ytx-flushing]')).forEach((node)=>{
  5131. // if(node && node[wk] && componentBasedTaskPool.get(node)){
  5132.  
  5133. // eTasks.unshift({
  5134. // component: node[wk],
  5135. // fn: processTask
  5136. // });
  5137. // }
  5138.  
  5139.  
  5140. // })
  5141.  
  5142. }
  5143.  
  5144. const childrenObs = new MutationObserver((mutations) => {
  5145. const nodes = new Set();
  5146. for(const mutation of mutations){
  5147. if(mutation.addedNodes && mutation.addedNodes.length >= 1){
  5148. for(const addedNode of mutation.addedNodes){
  5149. nodes.add(addedNode);
  5150. }
  5151. }
  5152. if(mutation.removedNodes && mutation.removedNodes.length >= 1){
  5153. for(const removedNode of mutation.removedNodes){
  5154. nodes.add(removedNode);
  5155. }
  5156. }
  5157. nodes.add(mutation.target);
  5158. }
  5159. if (!nodes.size) return;
  5160. const flushDom = new Set();
  5161. for (let node of nodes) {
  5162. if (node.nodeType !== 1) {
  5163. node = node.parentNode;
  5164. }
  5165. if (node && node.nodeType === 1) {
  5166. flushDom.add(node.closest('[ytx-flushing]'));
  5167. }
  5168. }
  5169. for (const node of flushDom) {
  5170. if (node && node[wk] && componentBasedTaskPool.get(node)) {
  5171. pendingRxList.add_(node[wk]);
  5172. }
  5173. }
  5174. executeTasks();
  5175. });
  5176.  
  5177. // Element.prototype.ssk1 = function(){
  5178. // return componentBasedTaskPool.get(this)
  5179. // }
  5180. // Element.prototype.ssk2= function(){
  5181. // eTasks.push({
  5182. // component: this[wk],
  5183. // fn: processTask
  5184. // });
  5185. // executeTasks();
  5186. // }
  5187.  
  5188. // setInterval(()=>{
  5189.  
  5190. // if(!executing){
  5191.  
  5192. // for(const p of document.querySelectorAll('[ytx-flushing]')){
  5193. // eTasks.push({
  5194. // component: p[wk],
  5195. // fn: processTask
  5196. // });
  5197. // }
  5198.  
  5199. // executeTasks();
  5200. // }
  5201. // }, 500)
  5202.  
  5203. const levelStore = new WeakMap();
  5204. const pendingRxList = new Set();
  5205. const refIDs = new WeakMap();
  5206. let refIdCounter = 0;
  5207.  
  5208. pendingRxList.add = pendingRxList.addOriginal || pendingRxList.add;
  5209. pendingRxList.add_ = function(x){
  5210. this.add(x);
  5211. if(!refIDs.has(x)) refIDs.set(x, ++refIdCounter);
  5212. }
  5213.  
  5214.  
  5215. const deferRenderStamperBinding_ = function (component, typeOrConfig, data) {
  5216. if(this.__byPass828__ || !this.__byPass348__) return this.deferRenderStamperBinding7409_(component, typeOrConfig, data);
  5217.  
  5218. let producerLevel = levelStore.get(this.hostElement);
  5219. if(!producerLevel){
  5220. producerLevel = (levelStore.get(this.hostElement.closest('ytx-stamp')) || 0)+1
  5221. levelStore.set(this.hostElement, producerLevel );
  5222. }
  5223.  
  5224. const containerId = this.__activeContainerId929__;
  5225. if(!component[wk]) component[wk] = mWeakRef(component);
  5226. if(!this[wk]) this[wk] = mWeakRef(this);
  5227.  
  5228. const pTask = componentBasedTaskPool.get(component);
  5229.  
  5230. levelStore.set(component, producerLevel + 1 );
  5231.  
  5232. if(pTask && component.nodeName !== "RP"){
  5233.  
  5234. component.setAttribute('ytx-flushing', 'c-1');
  5235.  
  5236.  
  5237.  
  5238. for(const e of component.querySelectorAll('[ytx-flushing]')){
  5239. const pTask = componentBasedTaskPool.get(e);
  5240. if(pTask) {
  5241. pTask.step = 'abandon';
  5242. if(pTask.flushing) pTask.flushing.length = 0 ;
  5243. pTask.flushing = null;
  5244.  
  5245. pTask.typeOrConfig = null
  5246. pTask.data = null
  5247. // console.log(2377)
  5248. /*
  5249. pTask.producer = null
  5250. pTask.containerId = null
  5251. pTask.typeOrConfig = null
  5252. pTask.data = null
  5253. pTask.flushing = null;
  5254. */
  5255. componentBasedTaskPool.delete(e);
  5256. }
  5257. // e.removeAttribute('ytx-flushing')
  5258. }
  5259.  
  5260. if(pTask.flushing) pTask.flushing.length = 0;
  5261.  
  5262. // console.log(123, component.querySelectorAll('[ytx-flushing]'))
  5263.  
  5264.  
  5265. Object.assign(pTask, {
  5266. step: 'flushStamper',
  5267. producer: this[wk],
  5268. containerId: containerId,
  5269. typeOrConfig: typeOrConfig,
  5270. data: data
  5271. });
  5272.  
  5273. // let q = false;
  5274.  
  5275. // if(component.isConnected && !component.closest('[hidden]')){
  5276. // // const container = this.getStampContainer7409_(containerId);
  5277. // // if(container && container.isConnected){
  5278. // // // const containerApi = container.__domApi || container;
  5279. // // // let p = document.createElement('rp');
  5280. // // // containerApi.insertBefore(p, component).replaceWith(component);
  5281. // // // p.remove();
  5282. // // // q = true;
  5283. // // }
  5284.  
  5285. // // use direct dom interface.
  5286. // let p = document.createElement('rp');
  5287. // component.parentNode.insertBefore(p, component).replaceWith(component);
  5288. // p.remove();
  5289.  
  5290. // }
  5291.  
  5292. if (component.parentNode) {
  5293. let p = document.createComment('.');
  5294. component.parentNode.insertBefore(p, component).replaceWith(component);
  5295. p.remove();
  5296. }
  5297.  
  5298.  
  5299. // if(!q){
  5300. // processTask({
  5301. // component: component[wk],
  5302. // fn: processTask
  5303. // })
  5304. // }
  5305.  
  5306.  
  5307. // requestAnimationFrame(()=>{
  5308.  
  5309. // executeTasks();
  5310. // })
  5311.  
  5312.  
  5313.  
  5314. pendingRxList.add_(component[wk]);
  5315.  
  5316. }else{
  5317. component.setAttribute('ytx-flushing', '1');
  5318.  
  5319. component.setAttribute('ytx-stamp', 'flusher')
  5320.  
  5321. if(pTask){
  5322.  
  5323. Object.assign(pTask, {
  5324. step: 'creation',
  5325. producer: this[wk],
  5326. containerId: containerId,
  5327. typeOrConfig: typeOrConfig,
  5328. data: data
  5329. });
  5330. } else {
  5331.  
  5332. componentBasedTaskPool.set(component, {
  5333. step: 'creation',
  5334. producer: this[wk],
  5335. containerId: containerId,
  5336. typeOrConfig: typeOrConfig,
  5337. data: data
  5338. })
  5339. }
  5340.  
  5341. pendingRxList.add_(component[wk]);
  5342. }
  5343.  
  5344. const container = this.getStampContainer7409_(containerId);
  5345. if (container && !container.__rk75401__) {
  5346. container.__rk75401__ = true;
  5347. childrenObs.observe(container, { subtree: false, childList: true });
  5348. }
  5349.  
  5350. executeTasks();
  5351.  
  5352.  
  5353. }
  5354. flushRenderStamperComponentBindings_ = function (){
  5355. if(this.__byPass828__ || !this.__byPass348__) return this.flushRenderStamperComponentBindings7409_();
  5356. throw new Error('5ii48')
  5357. }
  5358.  
  5359. stampDomArray_ = function (dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList) {
  5360.  
  5361. if(!dataList || !dataList[0]) this.__byPass828__ = true;
  5362. // this.__byPass828__ = true;
  5363.  
  5364. // console.log(644221001)
  5365. bReuse = false;
  5366.  
  5367. // console.log(2883002, ...arguments, this.stampDomArray8581_)
  5368.  
  5369. // return this.stampDomArray8581_(...arguments);
  5370.  
  5371.  
  5372. let producerLevel = levelStore.get(this.hostElement);
  5373. if (!producerLevel) {
  5374. producerLevel = (levelStore.get(this.hostElement.closest('ytx-stamp')) || 0) + 1
  5375. levelStore.set(this.hostElement, producerLevel);
  5376. }
  5377.  
  5378. this.__activeContainerId929__ = containerId;
  5379.  
  5380. const producer = this;
  5381. const hostElement = producer.hostElement;
  5382. if(!hostElement[wk]) hostElement[wk] = mWeakRef(hostElement);
  5383. if(hostElement.getAttribute('ytx-stamp') === 'flusher'){
  5384.  
  5385. hostElement.setAttribute('ytx-stamp', 'flusher|producer');
  5386. }else if (!hostElement.hasAttribute('ytx-stamp')){
  5387.  
  5388. hostElement.setAttribute('ytx-stamp', 'producer');
  5389. }
  5390. const pTask = componentBasedTaskPool.get(hostElement) // can be flushStampWait -> waitContainersRenderFinish
  5391.  
  5392. const flushing = pTask? (pTask.flushing || []) : [];
  5393. // if(!flushing) debugger;
  5394. flushing.push([containerId, bEventCb, !!dataList]);
  5395.  
  5396. // console.log(644221299, containerId, bEventCb, !!dataList)
  5397.  
  5398. if(pTask){
  5399.  
  5400. // const pTaskProducer = pTask.producer;
  5401. // const parentProducer = pTaskProducer && pTaskProducer !== this[wk] ? pTaskProducer : null;
  5402. // const parentProducerContainerId = parentProducer ? pTask.containerId : null;
  5403.  
  5404. Object.assign(pTask, {
  5405. step: 'waitContainersRenderFinish',
  5406. selfProducer: this[wk],
  5407. flushing
  5408. });
  5409.  
  5410. // if(parentProducer && parentProducerContainerId){
  5411. // Object.assign(pTask, {
  5412. // parentProducer,
  5413. // parentProducerContainerId
  5414. // });
  5415. // }
  5416.  
  5417. } else {
  5418.  
  5419. componentBasedTaskPool.set(hostElement, {
  5420. step: 'waitContainersRenderFinish',
  5421. selfProducer: this[wk],
  5422. flushing
  5423.  
  5424. });
  5425. }
  5426.  
  5427. hostElement.setAttribute('ytx-flushing', 's-1');
  5428.  
  5429. hostElement.checkEE = ()=>{
  5430. console.log(componentBasedTaskPool.get(hostElement));
  5431. }
  5432.  
  5433. const container = this.getStampContainer7409_(containerId);
  5434. if (container && !container.__rk75401__) {
  5435. container.__rk75401__ = true;
  5436. childrenObs.observe(container, { subtree: false, childList: true });
  5437. }
  5438.  
  5439. // console.log(2883991);
  5440. let r, e_
  5441. try{
  5442. this.__byPass348__=true;
  5443. this.stampDomArray8581_(dataList, containerId, typeOrConfig, bReuse, bEventCb, bStableList);
  5444. }catch(e){
  5445. e_ = e;
  5446. }
  5447. this.__byPass348__=false;
  5448. // console.log(2883992);
  5449.  
  5450.  
  5451. // console.log()
  5452.  
  5453. pendingRxList.add_(hostElement[wk]);
  5454.  
  5455.  
  5456. if(!hostElement.querySelector('[ytx-flushing]')){
  5457. this.markDirty && this.markDirty();
  5458. dispatchYtEvent(hostElement, "yt-rendererstamper-finished", {
  5459. container
  5460. });
  5461. Promise.resolve().then(executeTasks);
  5462. return;
  5463. }
  5464.  
  5465.  
  5466. // if (hostElement && !hostElement.__rk75401__) {
  5467. // hostElement.__rk75401__ = true;
  5468. // childrenObs.observe(hostElement, { subtree: true, childList: true });
  5469. // }
  5470.  
  5471. // container.appendChild(document.createComment('.')).remove(); // trigger childrenObs for component reuse
  5472. // hostElement.appendChild(document.createComment('.')).remove(); // trigger childrenObs for component reuse
  5473.  
  5474. executeTasks();
  5475.  
  5476.  
  5477. if(e_ && e_.message !== '5ii48') throw e_;
  5478.  
  5479. }
  5480.  
  5481.  
  5482. return {getStampContainer_, createComponent_, deferRenderStamperBinding_, flushRenderStamperComponentBindings_, stampDomArray_};
  5483.  
  5484.  
  5485. }
  5486.  
  5487.  
  5488.  
  5489.  
  5490.  
  5491.  
  5492. const setupDiscreteTasks = (h, rb) => {
  5493.  
  5494.  
  5495.  
  5496. if (typeof h.onYtRendererstamperFinished === 'function' && !(h.onYtRendererstamperFinished.km34)) {
  5497. const f = h.onYtRendererstamperFinished;
  5498. const g = ump3.get(f) || function () {
  5499. if (this.updateChildVisibilityProperties && !this.markDirty) {
  5500. return f.apply(this, arguments);
  5501. }
  5502. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5503. }
  5504. ump3.set(f, g);
  5505. g.km34 = 1;
  5506. h.onYtRendererstamperFinished = g;
  5507.  
  5508. }
  5509.  
  5510. if (typeof h.onYtUpdateDescriptionAction === 'function' && !(h.onYtUpdateDescriptionAction.km34)) {
  5511. const f = h.onYtUpdateDescriptionAction;
  5512. const g = ump3.get(f) || function (a) {
  5513. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5514. }
  5515. ump3.set(f, g);
  5516. g.km34 = 1;
  5517. h.onYtUpdateDescriptionAction = g;
  5518.  
  5519. }
  5520.  
  5521. if (typeof h.handleUpdateDescriptionAction === 'function' && !(h.handleUpdateDescriptionAction.km34)) {
  5522. const f = h.handleUpdateDescriptionAction;
  5523. const g = ump3.get(f) || function (a) {
  5524. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5525. }
  5526. ump3.set(f, g);
  5527. g.km34 = 1;
  5528. h.handleUpdateDescriptionAction = g;
  5529.  
  5530. }
  5531.  
  5532. if (typeof h.handleUpdateLiveChatPollAction === 'function' && !(h.handleUpdateLiveChatPollAction.km34)) {
  5533. const f = h.handleUpdateLiveChatPollAction;
  5534. const g = ump3.get(f) || function (a) {
  5535. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5536. }
  5537. ump3.set(f, g);
  5538. g.km34 = 1;
  5539. h.handleUpdateLiveChatPollAction = g;
  5540.  
  5541. }
  5542.  
  5543. if (typeof h.onTextChanged === 'function' && !(h.onTextChanged.km34)) {
  5544. const f = h.onTextChanged;
  5545. const g = ump3.get(f) || function () {
  5546. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5547. }
  5548. ump3.set(f, g);
  5549. g.km34 = 1;
  5550. h.onTextChanged = g;
  5551.  
  5552. }
  5553.  
  5554. if (typeof h.onVideoDataChange === 'function' && !(h.onVideoDataChange.km34)) {
  5555. const f = h.onVideoDataChange;
  5556. const g = ump3.get(f) || function (a) {
  5557. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5558. }
  5559. ump3.set(f, g);
  5560. g.km34 = 1;
  5561. h.onVideoDataChange = g;
  5562.  
  5563. }
  5564.  
  5565. if (typeof h.onVideoDataChange_ === 'function' && !(h.onVideoDataChange_.km34)) {
  5566. const f = h.onVideoDataChange_;
  5567. const g = ump3.get(f) || function () {
  5568. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5569. }
  5570. ump3.set(f, g);
  5571. g.km34 = 1;
  5572. h.onVideoDataChange_ = g;
  5573.  
  5574. }
  5575.  
  5576. if (typeof h.addTooltips_ === 'function' && !(h.addTooltips_.km34)) {
  5577.  
  5578. const f = h.addTooltips_;
  5579. const g = ump3.get(f) || function () {
  5580. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5581. }
  5582. ump3.set(f, g);
  5583. g.km34 = 1;
  5584. h.addTooltips_ = g;
  5585.  
  5586. }
  5587.  
  5588. if (typeof h.updateRenderedElements === 'function' && !(h.updateRenderedElements.km34)) {
  5589.  
  5590. const f = h.updateRenderedElements;
  5591. const g = ump3.get(f) || function () {
  5592. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5593. }
  5594. ump3.set(f, g);
  5595. g.km34 = 1;
  5596. h.updateRenderedElements = g;
  5597.  
  5598. }
  5599.  
  5600. if ((WEAK_REF_BINDING_CONTROL & 2) && typeof h.loadPage_ === 'function' && !(h.loadPage_.km34)) {
  5601. const f = h.loadPage_;
  5602. const g = ump3.get(f) || function (a) {
  5603. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5604. }
  5605. ump3.set(f, g);
  5606. g.km34 = 1;
  5607. h.loadPage_ = g;
  5608.  
  5609. }
  5610. // updatePageData_ : possible conflict with Omit ShadyDOM
  5611. if ((WEAK_REF_BINDING_CONTROL & 2) && typeof h.updatePageData_ === 'function' && !(h.updatePageData_.km34)) {
  5612. const f = h.updatePageData_;
  5613. const g = ump3.get(f) || function (a) {
  5614. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5615. }
  5616. ump3.set(f, g);
  5617. g.km34 = 1;
  5618. h.updatePageData_ = g;
  5619.  
  5620. }
  5621.  
  5622.  
  5623. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onFocus_ === 'function' && !(h.onFocus_.km34)) {
  5624.  
  5625. const f = h.onFocus_;
  5626. const g = ump3.get(f) || function () {
  5627. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5628. }
  5629. ump3.set(f, g);
  5630. g.km34 = 1;
  5631. h.onFocus_ = g;
  5632.  
  5633. }
  5634.  
  5635. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onBlur_ === 'function' && !(h.onBlur_.km34)) {
  5636.  
  5637. const f = h.onBlur_;
  5638. const g = ump3.get(f) || function () {
  5639. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5640. }
  5641. ump3.set(f, g);
  5642. g.km34 = 1;
  5643. h.onBlur_ = g;
  5644.  
  5645. }
  5646.  
  5647.  
  5648. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.buttonClassChanged_ === 'function' && !(h.buttonClassChanged_.km34)) {
  5649.  
  5650. const f = h.buttonClassChanged_;
  5651. const g = ump3.get(f) || function (a, b) {
  5652. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5653. }
  5654. ump3.set(f, g);
  5655. g.km34 = 1;
  5656. h.buttonClassChanged_ = g;
  5657.  
  5658. }
  5659.  
  5660. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.buttonIconChanged_ === 'function' && !(h.buttonIconChanged_.km34)) {
  5661.  
  5662. const f = h.buttonIconChanged_;
  5663. const g = ump3.get(f) || function (a) {
  5664. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5665. }
  5666. ump3.set(f, g);
  5667. g.km34 = 1;
  5668. h.buttonIconChanged_ = g;
  5669.  
  5670. }
  5671.  
  5672. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.dataChangedInBehavior_ === 'function' && !(h.dataChangedInBehavior_.km34)) {
  5673.  
  5674. const f = h.dataChangedInBehavior_;
  5675. const g = ump3.get(f) || function () {
  5676. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5677. }
  5678. ump3.set(f, g);
  5679. g.km34 = 1;
  5680. h.dataChangedInBehavior_ = g;
  5681.  
  5682. }
  5683.  
  5684. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.continuationsChanged_ === 'function' && !(h.continuationsChanged_.km34)) {
  5685.  
  5686. const f = h.continuationsChanged_;
  5687. const g = ump3.get(f) || function () {
  5688. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5689. }
  5690. ump3.set(f, g);
  5691. g.km34 = 1;
  5692. h.continuationsChanged_ = g;
  5693.  
  5694. }
  5695.  
  5696.  
  5697. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.forceChatPoll_ === 'function' && !(h.forceChatPoll_.km34)) {
  5698.  
  5699. const f = h.forceChatPoll_;
  5700. const g = ump3.get(f) || function (a) {
  5701. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5702. }
  5703. ump3.set(f, g);
  5704. g.km34 = 1;
  5705. h.forceChatPoll_ = g;
  5706.  
  5707. }
  5708.  
  5709. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onEndpointClick_ === 'function' && !(h.onEndpointClick_.km34)) {
  5710.  
  5711. const f = h.onEndpointClick_;
  5712. const g = ump3.get(f) || function (a) {
  5713. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5714. }
  5715. ump3.set(f, g);
  5716. g.km34 = 1;
  5717. h.onEndpointClick_ = g;
  5718.  
  5719. }
  5720.  
  5721. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onEndpointTap_ === 'function' && !(h.onEndpointTap_.km34)) {
  5722.  
  5723. const f = h.onEndpointTap_;
  5724. const g = ump3.get(f) || function (a) {
  5725. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5726. }
  5727. ump3.set(f, g);
  5728. g.km34 = 1;
  5729. h.onEndpointTap_ = g;
  5730.  
  5731. }
  5732.  
  5733. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.handleClick_ === 'function' && !(h.handleClick_.km34)) {
  5734.  
  5735. const f = h.handleClick_;
  5736. const g = ump3.get(f) || function (a, b) {
  5737. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5738. }
  5739. ump3.set(f, g);
  5740. g.km34 = 1;
  5741. h.handleClick_ = g;
  5742.  
  5743. }
  5744.  
  5745. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onReadyStateChange_ === 'function' && !(h.onReadyStateChange_.km34)) {
  5746.  
  5747. const f = h.onReadyStateChange_;
  5748. const g = ump3.get(f) || function () {
  5749. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5750. }
  5751. ump3.set(f, g);
  5752. g.km34 = 1;
  5753. h.onReadyStateChange_ = g;
  5754.  
  5755. }
  5756.  
  5757. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onReadyStateChangeEntryPoint_ === 'function' && !(h.onReadyStateChangeEntryPoint_.km34)) {
  5758.  
  5759. const f = h.onReadyStateChangeEntryPoint_;
  5760. const g = ump3.get(f) || function () {
  5761. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5762. }
  5763. ump3.set(f, g);
  5764. g.km34 = 1;
  5765. h.onReadyStateChangeEntryPoint_ = g;
  5766.  
  5767. }
  5768.  
  5769. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.readyStateChangeHandler_ === 'function' && !(h.readyStateChangeHandler_.km34)) {
  5770.  
  5771. const f = h.readyStateChangeHandler_;
  5772. const g = ump3.get(f) || function (a) {
  5773. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5774. }
  5775. ump3.set(f, g);
  5776. g.km34 = 1;
  5777. h.readyStateChangeHandler_ = g;
  5778.  
  5779. }
  5780.  
  5781. if (typeof h.xmlHttpHandler_ === 'function' && !(h.xmlHttpHandler_.km34)) {
  5782.  
  5783. const f = h.xmlHttpHandler_;
  5784. const g = ump3.get(f) || function (a) {
  5785. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5786. }
  5787. ump3.set(f, g);
  5788. g.km34 = 1;
  5789. h.xmlHttpHandler_ = g;
  5790.  
  5791. }
  5792.  
  5793. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.executeCallbacks_ === 'function' && !(h.executeCallbacks_.km34)) {
  5794.  
  5795. const f = h.executeCallbacks_; // overloaded
  5796. const g = ump3.get(f) || function (a) {
  5797. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5798. }
  5799. ump3.set(f, g);
  5800. g.km34 = 1;
  5801. h.executeCallbacks_ = g;
  5802.  
  5803. }
  5804.  
  5805. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.handleInvalidationData_ === 'function' && !(h.handleInvalidationData_.km34)) {
  5806.  
  5807. const f = h.handleInvalidationData_;
  5808. const g = ump3.get(f) || function (a, b) {
  5809. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5810. }
  5811. ump3.set(f, g);
  5812. g.km34 = 1;
  5813. h.handleInvalidationData_ = g;
  5814.  
  5815. }
  5816.  
  5817. if (typeof h.onInput_ === 'function' && !(h.onInput_.km34)) {
  5818.  
  5819. const f = h.onInput_;
  5820. const g = ump3.get(f) || function () {
  5821. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5822. }
  5823. ump3.set(f, g);
  5824. g.km34 = 1;
  5825. h.onInput_ = g;
  5826.  
  5827. }
  5828. if (typeof h.trigger_ === 'function' && !(h.trigger_.km34)) {
  5829.  
  5830. const f = h.trigger_;
  5831. const g = ump3.get(f) || function (a) {
  5832. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5833. }
  5834. ump3.set(f, g);
  5835. g.km34 = 1;
  5836. h.trigger_ = g;
  5837.  
  5838. }
  5839.  
  5840. if (typeof h.requestData_ === 'function' && !(h.requestData_.km34)) {
  5841.  
  5842. const f = h.requestData_;
  5843. const g = ump3.get(f) || function (a) {
  5844. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5845. }
  5846. ump3.set(f, g);
  5847. g.km34 = 1;
  5848. h.requestData_ = g;
  5849.  
  5850. }
  5851.  
  5852. if (typeof h.onLoadReloadContinuation_ === 'function' && !(h.onLoadReloadContinuation_.km34)) {
  5853.  
  5854. const f = h.onLoadReloadContinuation_;
  5855. const g = ump3.get(f) || function (a, b) {
  5856. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5857. }
  5858. ump3.set(f, g);
  5859. g.km34 = 1;
  5860. h.onLoadReloadContinuation_ = g;
  5861.  
  5862. }
  5863.  
  5864. if (typeof h.onLoadIncrementalContinuation_ === 'function' && !(h.onLoadIncrementalContinuation_.km34)) {
  5865.  
  5866. const f = h.onLoadIncrementalContinuation_;
  5867. const g = ump3.get(f) || function (a, b) {
  5868. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5869. }
  5870. ump3.set(f, g);
  5871. g.km34 = 1;
  5872. h.onLoadIncrementalContinuation_ = g;
  5873.  
  5874. }
  5875.  
  5876. if (typeof h.onLoadSeekContinuation_ === 'function' && !(h.onLoadSeekContinuation_.km34)) {
  5877.  
  5878. const f = h.onLoadSeekContinuation_;
  5879. const g = ump3.get(f) || function (a, b) {
  5880. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5881. }
  5882. ump3.set(f, g);
  5883. g.km34 = 1;
  5884. h.onLoadSeekContinuation_ = g;
  5885.  
  5886. }
  5887. if (typeof h.onLoadReplayContinuation_ === 'function' && !(h.onLoadReplayContinuation_.km34)) {
  5888.  
  5889. const f = h.onLoadReplayContinuation_;
  5890. const g = ump3.get(f) || function (a, b) {
  5891. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5892. }
  5893. ump3.set(f, g);
  5894. g.km34 = 1;
  5895. h.onLoadReplayContinuation_ = g;
  5896.  
  5897. }
  5898. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.onNavigate_ === 'function' && !(h.onNavigate_.km34)) {
  5899.  
  5900. const f = h.onNavigate_;
  5901. const g = ump3.get(f) || function (a) {
  5902. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5903. }
  5904. ump3.set(f, g);
  5905. g.km34 = 1;
  5906. h.onNavigate_ = g;
  5907.  
  5908. }
  5909.  
  5910. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.ytRendererBehaviorDataObserver_ === 'function' && !(h.ytRendererBehaviorDataObserver_.km34)) {
  5911.  
  5912. const f = h.ytRendererBehaviorDataObserver_;
  5913. const g = ump3.get(f) || function () {
  5914. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5915. }
  5916. ump3.set(f, g);
  5917. g.km34 = 1;
  5918. h.ytRendererBehaviorDataObserver_ = g;
  5919.  
  5920. }
  5921.  
  5922. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.ytRendererBehaviorTargetIdObserver_ === 'function' && !(h.ytRendererBehaviorTargetIdObserver_.km34)) {
  5923.  
  5924. const f = h.ytRendererBehaviorTargetIdObserver_;
  5925. const g = ump3.get(f) || function () {
  5926. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5927. }
  5928. ump3.set(f, g);
  5929. g.km34 = 1;
  5930. h.ytRendererBehaviorTargetIdObserver_ = g;
  5931.  
  5932. }
  5933.  
  5934. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.unregisterRenderer_ === 'function' && !(h.unregisterRenderer_.km34)) {
  5935.  
  5936. const f = h.unregisterRenderer_;
  5937. const g = ump3.get(f) || function (a) {
  5938. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5939. }
  5940. ump3.set(f, g);
  5941. g.km34 = 1;
  5942. h.unregisterRenderer_ = g;
  5943.  
  5944. }
  5945.  
  5946. if ((WEAK_REF_BINDING_CONTROL & 1) && typeof h.textChanged_ === 'function' && !(h.textChanged_.km34)) {
  5947.  
  5948. const f = h.textChanged_;
  5949. const g = ump3.get(f) || function (a) {
  5950. if (void 0 !== this.isAttached) {
  5951. const hostElement = this.hostElement;
  5952. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  5953. return;
  5954. }
  5955. }
  5956. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5957. }
  5958. ump3.set(f, g);
  5959. g.km34 = 1;
  5960. h.textChanged_ = g;
  5961.  
  5962. }
  5963.  
  5964.  
  5965.  
  5966. /**
  5967. *
  5968. * Neglect following
  5969. *
  5970. * h.onYtAction_
  5971. * h.startLoadingWatch [ buggy for yt-player-updated ]
  5972. * h.deferRenderStamperBinding_
  5973. *
  5974. * h.stampDomArray_
  5975. * h.stampDomArraySplices_
  5976. *
  5977. */
  5978.  
  5979.  
  5980. // RP.prototype.searchChanged_ = RP.prototype.searchChanged_;
  5981. // RP.prototype.skinToneChanged_ = RP.prototype.skinToneChanged_;
  5982. // RP.prototype.onEmojiHover_ = RP.prototype.onEmojiHover_;
  5983. // RP.prototype.onSelectCategory_ = RP.prototype.onSelectCategory_;
  5984. // RP.prototype.onShowEmojiVariantSelector = RP.prototype.onShowEmojiVariantSelector;
  5985. // RP.prototype.updateCategoriesAndPlaceholder_ = RP.prototype.updateCategoriesAndPlaceholder_;
  5986.  
  5987. if (typeof h.searchChanged_ === 'function' && !(h.searchChanged_.km34)) {
  5988.  
  5989. const f = h.searchChanged_;
  5990. const g = ump3.get(f) || function () {
  5991. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  5992. }
  5993. ump3.set(f, g);
  5994. g.km34 = 1;
  5995. h.searchChanged_ = g;
  5996.  
  5997. }
  5998.  
  5999. if (typeof h.skinToneChanged_ === 'function' && !(h.skinToneChanged_.km34)) {
  6000.  
  6001. const f = h.skinToneChanged_;
  6002. const g = ump3.get(f) || function (a) {
  6003. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6004. }
  6005. ump3.set(f, g);
  6006. g.km34 = 1;
  6007. h.skinToneChanged_ = g;
  6008.  
  6009. }
  6010.  
  6011. if (typeof h.onEmojiHover_ === 'function' && !(h.onEmojiHover_.km34)) {
  6012.  
  6013. const f = h.onEmojiHover_;
  6014. const g = ump3.get(f) || function (a) {
  6015. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6016. }
  6017. ump3.set(f, g);
  6018. g.km34 = 1;
  6019. h.onEmojiHover_ = g;
  6020.  
  6021. }
  6022.  
  6023. if (typeof h.onSelectCategory_ === 'function' && !(h.onSelectCategory_.km34)) {
  6024.  
  6025. const f = h.onSelectCategory_;
  6026. const g = ump3.get(f) || function (a) {
  6027. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6028. }
  6029. ump3.set(f, g);
  6030. g.km34 = 1;
  6031. h.onSelectCategory_ = g;
  6032.  
  6033. }
  6034.  
  6035. if (typeof h.onShowEmojiVariantSelector === 'function' && !(h.onShowEmojiVariantSelector.km34)) {
  6036.  
  6037. const f = h.onShowEmojiVariantSelector;
  6038. const g = ump3.get(f) || function (a) {
  6039. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6040. }
  6041. ump3.set(f, g);
  6042. g.km34 = 1;
  6043. h.onShowEmojiVariantSelector = g;
  6044.  
  6045. }
  6046.  
  6047. if (typeof h.updateCategoriesAndPlaceholder_ === 'function' && !(h.updateCategoriesAndPlaceholder_.km34)) {
  6048.  
  6049. const f = h.updateCategoriesAndPlaceholder_;
  6050. const g = ump3.get(f) || function () {
  6051. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6052. }
  6053. ump3.set(f, g);
  6054. g.km34 = 1;
  6055. h.updateCategoriesAndPlaceholder_ = g;
  6056.  
  6057. }
  6058.  
  6059. if (typeof h.watchPageActiveChanged_ === 'function' && !(h.watchPageActiveChanged_.km34)) {
  6060.  
  6061. const f = h.watchPageActiveChanged_;
  6062. const g = ump3.get(f) || function () {
  6063. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6064. }
  6065. ump3.set(f, g);
  6066. g.km34 = 1;
  6067. h.watchPageActiveChanged_ = g;
  6068.  
  6069. }
  6070.  
  6071. if (typeof h.activate_ === 'function' && !(h.activate_.km34)) {
  6072.  
  6073. const f = h.activate_;
  6074. const g = ump3.get(f) || function () {
  6075. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6076. }
  6077. ump3.set(f, g);
  6078. g.km34 = 1;
  6079. h.activate_ = g;
  6080.  
  6081. }
  6082. if (typeof h.onYtPlaylistDataUpdated_ === 'function' && !(h.onYtPlaylistDataUpdated_.km34)) {
  6083.  
  6084. const f = h.onYtPlaylistDataUpdated_;
  6085. const g = ump3.get(f) || function () {
  6086. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6087. }
  6088. ump3.set(f, g);
  6089. g.km34 = 1;
  6090. h.onYtPlaylistDataUpdated_ = g;
  6091.  
  6092. }
  6093.  
  6094.  
  6095.  
  6096. /**
  6097. *
  6098. * Neglect following
  6099. *
  6100. * h.rendererStamperObserver_
  6101. * h.rendererStamperApplyChangeRecord_
  6102. * h.flushRenderStamperComponentBindings_
  6103. * h.forwardRendererStamperChanges_
  6104. *
  6105. */
  6106.  
  6107. if (typeof h.tryRenderChunk_ === 'function' && !(h.tryRenderChunk_.km34)) {
  6108.  
  6109. const f = h.tryRenderChunk_;
  6110. const g = ump3.get(f) || function () {
  6111. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6112. }
  6113. ump3.set(f, g);
  6114. g.km34 = 1;
  6115. h.tryRenderChunk_ = g;
  6116.  
  6117. }
  6118.  
  6119.  
  6120. if (typeof h.renderChunk_ === 'function' && !(h.renderChunk_.km34)) {
  6121.  
  6122. const f = h.renderChunk_;
  6123. const g = ump3.get(f) || function () {
  6124. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6125. }
  6126. ump3.set(f, g);
  6127. g.km34 = 1;
  6128. h.renderChunk_ = g;
  6129.  
  6130. }
  6131.  
  6132. if (typeof h.deepLazyListObserver_ === 'function' && !(h.deepLazyListObserver_.km34)) {
  6133.  
  6134. const f = h.deepLazyListObserver_;
  6135. const g = ump3.get(f) || function () {
  6136. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6137. }
  6138. ump3.set(f, g);
  6139. g.km34 = 1;
  6140. h.deepLazyListObserver_ = g;
  6141.  
  6142. }
  6143.  
  6144. if (typeof h.onItemsUpdated_ === 'function' && !(h.onItemsUpdated_.km34)) {
  6145.  
  6146. const f = h.onItemsUpdated_;
  6147. const g = ump3.get(f) || function () {
  6148. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6149. }
  6150. ump3.set(f, g);
  6151. g.km34 = 1;
  6152. h.onItemsUpdated_ = g;
  6153.  
  6154. }
  6155.  
  6156. if (typeof h.requestRenderChunk_ === 'function' && !(h.requestRenderChunk_.km34)) {
  6157.  
  6158. const f = h.requestRenderChunk_;
  6159. const g = ump3.get(f) || function () {
  6160. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  6161. }
  6162. ump3.set(f, g);
  6163. g.km34 = 1;
  6164. h.requestRenderChunk_ = g;
  6165.  
  6166. }
  6167.  
  6168. /**
  6169. *
  6170. * Neglect following
  6171. *
  6172. * h.dataChanged_ [ buggy for page swtiching ]
  6173. *
  6174. * h.updateChangeRecord_ [ see https://github.com/cyfung1031/userscript-supports/issues/20 ]
  6175. *
  6176. * h.cancelPendingTasks_
  6177. * h.fillRange_
  6178. * h.addTextNodes_
  6179. * h.updateText_
  6180. * h.stampTypeChanged_
  6181. *
  6182. */
  6183.  
  6184.  
  6185. }
  6186.  
  6187. const keyStConnectedCallback = Symbol(); // avoid copying the value
  6188.  
  6189. const dmf = new WeakMap();
  6190.  
  6191.  
  6192. let nativeHTMLElement = Reflect.getPrototypeOf(HTMLFontElement);
  6193.  
  6194. try {
  6195.  
  6196. const q = document.createElement('template');
  6197. q.innerHTML = '<ytz-null361></ytz-null361>';
  6198. nativeHTMLElement = q.content.firstChild.constructor
  6199.  
  6200. } catch (e) { }
  6201.  
  6202. if (!nativeHTMLElement.prototype.connectedCallback) {
  6203. nativeHTMLElement.prototype.connectedCallback79 = nativeHTMLElement.prototype.connectedCallback;
  6204. nativeHTMLElement.prototype.connectedCallback = function () {
  6205. let r;
  6206. if (this.connectedCallback79) r = this.connectedCallback79.apply(this, arguments);
  6207. return r;
  6208. }
  6209. }
  6210. const pvr = Symbol()
  6211.  
  6212. let stampDomArrayFnStore = null;
  6213. const setupMap = new WeakSet();
  6214. const setupYtComponent = (cnt) => {
  6215. const cProto = Reflect.getPrototypeOf(cnt || 0) || 0;
  6216. if (!cProto || setupMap.has(cProto)) return;
  6217. setupMap.add(cProto);
  6218. if (FIX_stampDomArray && !(cProto[pvr] & 1) && 'stampDomArray_' in cProto) {
  6219. cProto[pvr] |= 1;
  6220.  
  6221.  
  6222.  
  6223. if (FIX_stampDomArray && !location.pathname.startsWith('/live_chat') && cProto.stampDomArray_) {
  6224. const b = cProto.stampDomArray_.length === 6
  6225. && cProto.getStampContainer_ && cProto.getStampContainer_.length === 1
  6226. && cProto.createComponent_ && cProto.createComponent_.length === 3
  6227. && cProto.deferRenderStamperBinding_ && cProto.deferRenderStamperBinding_.length === 3
  6228. && cProto.flushRenderStamperComponentBindings_ && cProto.flushRenderStamperComponentBindings_.length === 0
  6229. && cProto.deferRenderStamperBinding_ === cnt.deferRenderStamperBinding_
  6230. if (!b) {
  6231. console.warn("YouTube Coding Changed. createStampDomFns_() is not applied")
  6232. } else if(!cProto.createComponent7409_ && !cProto.deferRenderStamperBinding7409_ && !cProto.flushRenderStamperComponentBindings7409_) {
  6233. if(!stampDomArrayFnStore) stampDomArrayFnStore = createStampDomFnsB_();
  6234. const {getStampContainer_, createComponent_, deferRenderStamperBinding_, flushRenderStamperComponentBindings_, stampDomArray_} = stampDomArrayFnStore;
  6235.  
  6236. cProto.getStampContainer7409_ = cProto.getStampContainer_;
  6237. cProto.createComponent7409_ = cProto.createComponent_;
  6238. cProto.deferRenderStamperBinding7409_ = cProto.deferRenderStamperBinding_;
  6239. cProto.flushRenderStamperComponentBindings7409_ = cProto.flushRenderStamperComponentBindings_;
  6240. cProto.stampDomArray7409_ = cProto.stampDomArray8581_ = cProto.stampDomArray_;
  6241.  
  6242. cProto.getStampContainer_ = getStampContainer_;
  6243. cProto.createComponent_ = createComponent_;
  6244. cProto.deferRenderStamperBinding_ = deferRenderStamperBinding_;
  6245. cProto.flushRenderStamperComponentBindings_ = flushRenderStamperComponentBindings_;
  6246. cProto.stampDomArray_ = stampDomArray_;
  6247.  
  6248. }
  6249. }
  6250.  
  6251.  
  6252.  
  6253.  
  6254. if(cProto._runEffectsForTemplate && !cProto._runEffectsForTemplate6344) {
  6255. cProto._runEffectsForTemplate6344 = cProto._runEffectsForTemplate;
  6256.  
  6257. if(cProto._runEffectsForTemplate6344.length === 4){
  6258.  
  6259. cProto._runEffectsForTemplate = function (c, d, e, g) {
  6260. const cnt = this;
  6261. const { propertyEffects, nodeList, firstChild } = c;
  6262. cnt._runEffectsForTemplate6344({ propertyEffects, nodeList, firstChild }, d, e, g);
  6263.  
  6264. }
  6265.  
  6266. }
  6267.  
  6268. }
  6269.  
  6270. }
  6271. if (ENABLE_discreteTasking && !(cProto[pvr] & 2) && (typeof (cProto.is || 0) === 'string' || ('attached' in cProto) || ('isAttached' in cProto))) {
  6272. cProto[pvr] |= 2;
  6273. setupDiscreteTasks(cProto);
  6274. }
  6275. };
  6276.  
  6277. (ENABLE_discreteTasking || FIX_stampDomArray) && Object.defineProperty(Object.prototype, 'connectedCallback', {
  6278. get() {
  6279. const f = this[keyStConnectedCallback];
  6280. if (this.is) {
  6281. setupYtComponent(this);
  6282. }
  6283. return f;
  6284. },
  6285. set(nv) {
  6286. let gv = nv;
  6287. this[keyStConnectedCallback] = gv; // proto or object
  6288. return true;
  6289. },
  6290. enumerable: false,
  6291. configurable: true
  6292.  
  6293. });
  6294.  
  6295. const pLoad = new Promise(resolve => {
  6296. if (document.readyState !== 'loading') {
  6297. resolve();
  6298. } else {
  6299. window.addEventListener("DOMContentLoaded", resolve, false);
  6300. }
  6301. });
  6302.  
  6303. if (FIX_fix_requestIdleCallback_timing && !window.requestIdleCallback471 && typeof window.requestIdleCallback === 'function') {
  6304. window.requestIdleCallback471 = window.requestIdleCallback;
  6305. window.requestIdleCallback = function (f, ...args) {
  6306. return (this || window).requestIdleCallback471(async function () {
  6307. await pLoad.then();
  6308. // await new Promise(nextBrowserTick_);
  6309. f.call(this, ...arguments)
  6310. }, ...args);
  6311. }
  6312. }
  6313.  
  6314. pLoad.then(() => {
  6315.  
  6316. let nonce = document.querySelector('style[nonce]');
  6317. nonce = nonce ? nonce.getAttribute('nonce') : null;
  6318. const st = document.createElement('style');
  6319. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  6320. st.textContent = "none-element-k47{order:0}";
  6321. st.addEventListener('load', () => {
  6322. pf31.resolve();
  6323. p59 = 1;
  6324. }, false);
  6325. (document.body || document.head || document.documentElement).appendChild(st);
  6326.  
  6327. });
  6328.  
  6329. const prepareLogs = [];
  6330.  
  6331. const skipAdsDetection = new Set(['/robots.txt', '/live_chat', '/live_chat_replay']);
  6332.  
  6333. let winError00 = window.onerror;
  6334.  
  6335. let fix_error_many_stack_state = !FIX_error_many_stack ? 0 : skipAdsDetection.has(location.pathname) ? 2 : 1;
  6336.  
  6337. if (!JSON || !('parse' in JSON)) fix_error_many_stack_state = 0;
  6338.  
  6339. ; FIX_Iframe_NULL_SRC && !isChatRoomURL && typeof kagi === 'undefined' && (() => {
  6340.  
  6341. const emptyBlobUrl = URL.createObjectURL(new Blob([], { type: 'text/html' }));
  6342. const lcOpt = { sensitivity: 'base' };
  6343. document.createElement24 = document.createElement;
  6344. document.createElement = function (t) {
  6345. if (typeof t === 'string' && t.length === 6) {
  6346. if (t.localeCompare('iframe', undefined, lcOpt) === 0) {
  6347. const p = this.createElement24(t);
  6348. try {
  6349. const stack = new Error().stack;
  6350. const isSearchbox = stack.includes('initializeSearchbox'); // see https://gf.qytechs.cn/scripts/473972-youtube-js-engine-tamer/discussions/217084
  6351. if (!isSearchbox) {
  6352. p.src = emptyBlobUrl; // avoid iframe is appended to DOM without any url
  6353. }
  6354. } catch (e) { }
  6355. return p;
  6356. }
  6357. }
  6358. return this.createElement24.apply(this, arguments);
  6359. };
  6360.  
  6361. })();
  6362.  
  6363. ; fix_error_many_stack_state === 1 && (() => {
  6364.  
  6365.  
  6366. let p1 = winError00;
  6367.  
  6368. let stackNeedleDetails = null;
  6369.  
  6370. Object.defineProperty(Object.prototype, 'matchAll', {
  6371. get() {
  6372. stackNeedleDetails = this;
  6373. return true;
  6374. },
  6375. enumerable: true,
  6376. configurable: true
  6377. });
  6378.  
  6379. try {
  6380. JSON.parse("{}");
  6381. } catch (e) {
  6382. console.warn(e)
  6383. fix_error_many_stack_state = 0;
  6384. }
  6385.  
  6386. delete Object.prototype['matchAll'];
  6387.  
  6388. let p2 = window.onerror;
  6389.  
  6390. window.onerror = p1;
  6391.  
  6392. if (fix_error_many_stack_state === 0) return;
  6393.  
  6394. if (stackNeedleDetails) {
  6395. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  6396. stackNeedleDetails.matchAll = true;
  6397. }
  6398.  
  6399. if (p1 === p2) return (fix_error_many_stack_state = 0);
  6400.  
  6401. // p1!==p2
  6402. fix_error_many_stack_state = !stackNeedleDetails ? 4 : 3;
  6403.  
  6404. })();
  6405.  
  6406. ; fix_error_many_stack_state === 2 && (() => {
  6407.  
  6408.  
  6409. let p1 = winError00;
  6410.  
  6411. let objectPrune = null;
  6412. let stackNeedleDetails = null;
  6413.  
  6414. Object.defineProperty(Function.prototype, 'findOwner', {
  6415. get() {
  6416. objectPrune = this;
  6417. return this._findOwner;
  6418. },
  6419. set(nv) {
  6420. this._findOwner = nv;
  6421. return true;
  6422. },
  6423. enumerable: true,
  6424. configurable: true
  6425. });
  6426.  
  6427. Object.defineProperty(Object.prototype, 'matchAll', {
  6428. get() {
  6429. stackNeedleDetails = this;
  6430. return true;
  6431. },
  6432. enumerable: true,
  6433. configurable: true
  6434. });
  6435.  
  6436. try {
  6437. JSON.parse("{}");
  6438. } catch (e) {
  6439. console.warn(e)
  6440. fix_error_many_stack_state = 0;
  6441. }
  6442.  
  6443. delete Function.prototype['findOwner'];
  6444. delete Object.prototype['matchAll'];
  6445.  
  6446. let p2 = window.onerror;
  6447.  
  6448. if (p1 !== p2) return (fix_error_many_stack_state = 4); // p1 != p2
  6449.  
  6450. if (fix_error_many_stack_state == 0) return;
  6451.  
  6452. // the following will only execute when Brave's scriptlets.js is executed.
  6453.  
  6454. prepareLogs.push("fix_error_many_stack_state NB")
  6455.  
  6456. if (stackNeedleDetails) {
  6457. stackNeedleDetails.pattern = null;
  6458. stackNeedleDetails.re = null;
  6459. stackNeedleDetails.expect = null;
  6460. stackNeedleDetails.matchAll = true;
  6461. }
  6462.  
  6463. if (objectPrune) {
  6464. objectPrune.findOwner = objectPrune.mustProcess = objectPrune.logJson = () => { }
  6465. delete objectPrune._findOwner;
  6466. }
  6467.  
  6468. fix_error_many_stack_state = 3;
  6469. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  6470. JSON.parse.objectPrune = objectPrune;
  6471.  
  6472. })();
  6473.  
  6474. ; fix_error_many_stack_state === 3 && (() => {
  6475.  
  6476.  
  6477. let p1 = winError00;
  6478.  
  6479. try {
  6480. JSON.parse("{}");
  6481. } catch (e) {
  6482. console.warn(e)
  6483. fix_error_many_stack_state = 0;
  6484. }
  6485.  
  6486. let p2 = window.onerror;
  6487.  
  6488. if (p1 === p2) return;
  6489.  
  6490. window.onerror = p1;
  6491.  
  6492. if (fix_error_many_stack_state === 0) return;
  6493.  
  6494. fix_error_many_stack_state = 4; // p1 != p2
  6495.  
  6496.  
  6497. })();
  6498.  
  6499. fix_error_many_stack_state === 4 && (() => {
  6500.  
  6501. // the following will only execute when Brave's scriptlets.js is executed.
  6502.  
  6503. prepareLogs.push("fix_error_many_stack_state AB")
  6504.  
  6505. JSON.parseProxy = JSON.parse;
  6506.  
  6507. JSON.parse = ((parse) => {
  6508.  
  6509. parse = parse.bind(JSON); // get a new instance of the current JSON.parse
  6510. return function (text, reviver) {
  6511. const onerror = window.onerror;
  6512. window.onerror = null;
  6513. let r;
  6514. try {
  6515. r = parse(...arguments);
  6516. } catch (e) {
  6517. r = e;
  6518. }
  6519. window.onerror = onerror;
  6520. if (r instanceof Error) {
  6521. throw r;
  6522. }
  6523. return r;
  6524. }
  6525.  
  6526. })(JSON.parse);
  6527.  
  6528.  
  6529. })();
  6530.  
  6531.  
  6532. // << if FIX_yt_player >>
  6533.  
  6534. // credit to @nopeless (https://gf.qytechs.cn/scripts/471489-youtube-player-perf/)
  6535. const PERF_471489_ = true;
  6536. // PERF_471489_ is not exactly the same to Youtube Player perf v0.7
  6537. // This script uses a much gentle way to tamer the JS engine instead.
  6538.  
  6539. // << end >>
  6540.  
  6541. const steppingScaleN = 200; // transform: scaleX(k/N); 0<k<N
  6542.  
  6543.  
  6544.  
  6545. const nilFn = () => { };
  6546.  
  6547. let isMainWindow = false;
  6548. try {
  6549. isMainWindow = window.document === window.top.document
  6550. } catch (e) { }
  6551.  
  6552. let NO_PRELOAD_GENERATE_204_BYPASS = NO_PRELOAD_GENERATE_204 ? false : true;
  6553. let headLinkCollection = null;
  6554.  
  6555.  
  6556. // const assertor = (f) => f() || console.assert(false, `${f}`);
  6557.  
  6558. const fnIntegrity = (f, d) => {
  6559. if (!f || typeof f !== 'function') {
  6560. console.warn('f is not a function', f);
  6561. return;
  6562. }
  6563. let p = `${f}`, s = 0, j = -1, w = 0;
  6564. for (let i = 0, l = p.length; i < l; i++) {
  6565. const t = p[i];
  6566. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  6567. if (j < i - 1) w++;
  6568. j = i;
  6569. } else {
  6570. s++;
  6571. }
  6572. }
  6573. let itz = `${f.length}.${s}.${w}`;
  6574. if (!d) {
  6575. return itz;
  6576. } else {
  6577. return itz === d;
  6578. }
  6579. };
  6580.  
  6581. const getZqOu = (_yt_player) => {
  6582.  
  6583. const w = 'ZqOu';
  6584.  
  6585. let arr = [];
  6586.  
  6587. for (const [k, v] of Object.entries(_yt_player)) {
  6588.  
  6589. const p = typeof v === 'function' ? v.prototype : 0;
  6590. if (p
  6591. && typeof p.start === 'function' && p.start.length === 0 // Ou
  6592. && typeof p.isActive === 'function' && p.isActive.length === 0
  6593. && typeof p.stop === 'function' && p.stop.length === 0
  6594. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  6595. && !p.send && !p.abort
  6596. && !p.sample && !p.initialize && !p.fail && !p.getName
  6597. // && !p.dispose && !p.isDisposed
  6598.  
  6599. ) {
  6600. arr = addProtoToArr(_yt_player, k, arr) || arr;
  6601.  
  6602.  
  6603. }
  6604.  
  6605. }
  6606.  
  6607. if (arr.length === 0) {
  6608.  
  6609. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6610. } else {
  6611.  
  6612. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6613. return arr[0];
  6614. }
  6615.  
  6616. }
  6617.  
  6618. const getZqQu = (_yt_player) => {
  6619.  
  6620. const w = 'ZqQu';
  6621.  
  6622. let arr = [];
  6623.  
  6624.  
  6625. for (const [k, v] of Object.entries(_yt_player)) {
  6626.  
  6627. const p = typeof v === 'function' ? v.prototype : 0;
  6628. if (p
  6629. && typeof p.start === 'function' && p.start.length === 1 // Qu
  6630. && typeof p.isActive === 'function' && p.isActive.length === 0
  6631. && typeof p.stop === 'function' && p.stop.length === 0
  6632. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  6633. && !p.send && !p.abort
  6634. && !p.sample && !p.initialize && !p.fail && !p.getName
  6635. // && !p.dispose && !p.isDisposed
  6636.  
  6637. ) {
  6638. arr = addProtoToArr(_yt_player, k, arr) || arr;
  6639.  
  6640.  
  6641. }
  6642.  
  6643. }
  6644.  
  6645. if (arr.length === 0) {
  6646.  
  6647. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6648. } else {
  6649.  
  6650. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6651. return arr[0];
  6652. }
  6653.  
  6654. }
  6655.  
  6656.  
  6657. const getVG = (_yt_player) => {
  6658. const w = 'VG';
  6659.  
  6660. let arr = [];
  6661.  
  6662. for (const [k, v] of Object.entries(_yt_player)) {
  6663.  
  6664. const p = typeof v === 'function' ? v.prototype : 0;
  6665. if (p
  6666. && typeof p.show === 'function' && p.show.length === 1
  6667. && typeof p.hide === 'function' && p.hide.length === 0
  6668. && typeof p.stop === 'function' && p.stop.length === 0) {
  6669.  
  6670. arr = addProtoToArr(_yt_player, k, arr) || arr;
  6671.  
  6672. }
  6673.  
  6674. }
  6675.  
  6676.  
  6677. if (arr.length === 0) {
  6678.  
  6679. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6680. } else {
  6681.  
  6682. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6683. return arr[0];
  6684. }
  6685.  
  6686.  
  6687.  
  6688. }
  6689.  
  6690.  
  6691. const getzo = (_yt_player) => {
  6692. const w = 'zo';
  6693.  
  6694. let arr = [];
  6695.  
  6696. for (const [k, v] of Object.entries(_yt_player)) {
  6697.  
  6698. if (
  6699. typeof v === 'function' && v.length === 3 && k.length < 3
  6700. ) {
  6701. const vt = `${v}`;
  6702. if (vt.length >= 21 && vt.includes(".style[")) {
  6703. if (/\((\w{1,3}),(\w{1,3}),(\w{1,3})\)\{[\s\S]*\1\.style\[\2\]=\3\W/.test(vt)) {
  6704. arr.push(k);
  6705. } else {
  6706. console.warn('[yt-js-engine-tamer] unexpected zo::vt', vt);
  6707. }
  6708. }
  6709. }
  6710.  
  6711. }
  6712.  
  6713. if (arr.length === 0) {
  6714.  
  6715. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6716. } else {
  6717.  
  6718. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6719. return arr[0];
  6720. }
  6721.  
  6722. }
  6723.  
  6724. const addProtoToArr = (parent, key, arr) => {
  6725.  
  6726.  
  6727. let isChildProto = false;
  6728. for (const sr of arr) {
  6729. if (parent[key].prototype instanceof parent[sr]) {
  6730. isChildProto = true;
  6731. break;
  6732. }
  6733. }
  6734.  
  6735. if (isChildProto) return;
  6736.  
  6737. arr = arr.filter(sr => {
  6738. if (parent[sr].prototype instanceof parent[key]) {
  6739. return false;
  6740. }
  6741. return true;
  6742. });
  6743.  
  6744. arr.push(key);
  6745.  
  6746. return arr;
  6747.  
  6748.  
  6749. }
  6750.  
  6751. const getuG = (_yt_player) => {
  6752.  
  6753. const w = 'uG';
  6754.  
  6755. let arr = [];
  6756.  
  6757. for (const [k, v] of Object.entries(_yt_player)) {
  6758.  
  6759.  
  6760. const p = typeof v === 'function' ? v.prototype : 0;
  6761.  
  6762. if (p
  6763. && typeof p.createElement === 'function' && p.createElement.length === 2
  6764. && typeof p.detach === 'function' && p.detach.length === 0
  6765. && typeof p.update === 'function' && p.update.length === 1
  6766. && typeof p.updateValue === 'function' && p.updateValue.length === 2
  6767. ) {
  6768.  
  6769. arr = addProtoToArr(_yt_player, k, arr) || arr;
  6770.  
  6771. }
  6772.  
  6773. }
  6774.  
  6775.  
  6776.  
  6777.  
  6778.  
  6779. if (arr.length === 0) {
  6780.  
  6781. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6782. } else {
  6783.  
  6784. console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6785. return arr[0];
  6786. }
  6787.  
  6788. }
  6789.  
  6790.  
  6791. const getQT = (_yt_player) => {
  6792. const w = 'QT';
  6793.  
  6794. let arr = [];
  6795. let brr = new Map();
  6796.  
  6797. for (const [k, v] of Object.entries(_yt_player)) {
  6798.  
  6799. const p = typeof v === 'function' ? v.prototype : 0;
  6800. if (p) {
  6801. let q = 0;
  6802. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  6803. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  6804. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  6805.  
  6806. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q -= 600; // avoid SV
  6807.  
  6808. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  6809.  
  6810. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  6811. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  6812. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  6813. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  6814.  
  6815.  
  6816. // differentiate QT and DX
  6817.  
  6818. q += 280;
  6819. if (typeof p.cueVideoByPlayerVars === 'function') q += 4;
  6820. if (typeof p.loadVideoByPlayerVars === 'function') q += 4;
  6821. if (typeof p.preloadVideoByPlayerVars === 'function') q += 4;
  6822. if (typeof p.seekBy === 'function') q += 4;
  6823. if (typeof p.seekTo === 'function') q += 4;
  6824. if (typeof p.getStoryboardFormat === 'function') q += 4;
  6825. if (typeof p.getDuration === 'function') q += 4;
  6826. if (typeof p.loadModule === 'function') q += 4;
  6827. if (typeof p.unloadModule === 'function') q += 4;
  6828. if (typeof p.getOption === 'function') q += 4;
  6829. if (typeof p.getOptions === 'function') q += 4;
  6830. if (typeof p.setOption === 'function') q += 4;
  6831. if (typeof p.addCueRange === 'function') q += 4;
  6832. if (typeof p.getDebugText === 'function') q += 4;
  6833. if (typeof p.getCurrentBroadcastId === 'function') q += 4;
  6834. if (typeof p.setSizeStyle === 'function') q += 4;
  6835. if (typeof p.showControls === 'function') q += 4;
  6836. if (typeof p.hideControls === 'function') q += 4;
  6837. if (typeof p.getVideoContentRect === 'function') q += 4;
  6838. if (typeof p.toggleFullscreen === 'function') q += 4;
  6839. if (typeof p.isFullscreen === 'function') q += 4;
  6840. if (typeof p.cancelPlayback === 'function') q += 4;
  6841. if (typeof p.getProgressState === 'function') q += 4;
  6842. if (typeof p.isInline === 'function') q += 4;
  6843. if (typeof p.setInline === 'function') q += 4;
  6844. if (typeof p.toggleSubtitles === 'function') q += 4;
  6845. if (typeof p.getPlayerSize === 'function') q += 4;
  6846. if (typeof p.wakeUpControls === 'function') q += 4;
  6847. if (typeof p.setCenterCrop === 'function') q += 4;
  6848. if (typeof p.getLoopVideo === 'function') q += 4;
  6849. if (typeof p.setLoopVideo === 'function') q += 4;
  6850.  
  6851.  
  6852. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  6853.  
  6854. if (q > 0) brr.set(k, q);
  6855.  
  6856. }
  6857.  
  6858. }
  6859.  
  6860. if (arr.length === 0) {
  6861.  
  6862. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6863. } else {
  6864.  
  6865. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  6866.  
  6867. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  6868.  
  6869. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6870. return arr[0][0];
  6871. }
  6872.  
  6873.  
  6874.  
  6875. }
  6876.  
  6877.  
  6878.  
  6879. const getSV = (_yt_player) => {
  6880. const w = 'SV';
  6881.  
  6882. let arr = [];
  6883. let brr = new Map();
  6884.  
  6885. for (const [k, v] of Object.entries(_yt_player)) {
  6886.  
  6887. const p = typeof v === 'function' ? v.prototype : 0;
  6888. if (p) {
  6889. let q = 0;
  6890. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  6891. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  6892. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  6893.  
  6894. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q += 600; // SV
  6895.  
  6896. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  6897.  
  6898. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  6899. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  6900. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  6901. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  6902.  
  6903.  
  6904. // differentiate QT and DX
  6905.  
  6906.  
  6907. q += 280;
  6908.  
  6909. if (typeof p.cueVideoByPlayerVars === 'function') q -= 4;
  6910. if (typeof p.loadVideoByPlayerVars === 'function') q -= 4;
  6911. if (typeof p.preloadVideoByPlayerVars === 'function') q -= 4;
  6912. if (typeof p.seekBy === 'function') q -= 4;
  6913. if (typeof p.seekTo === 'function') q -= 4;
  6914. if (typeof p.getStoryboardFormat === 'function') q -= 4;
  6915. if (typeof p.getDuration === 'function') q -= 4;
  6916. if (typeof p.loadModule === 'function') q -= 4;
  6917. if (typeof p.unloadModule === 'function') q -= 4;
  6918. if (typeof p.getOption === 'function') q -= 4;
  6919. if (typeof p.getOptions === 'function') q -= 4;
  6920. if (typeof p.setOption === 'function') q -= 4;
  6921. if (typeof p.addCueRange === 'function') q -= 4;
  6922. if (typeof p.getDebugText === 'function') q -= 4;
  6923. if (typeof p.getCurrentBroadcastId === 'function') q -= 4;
  6924. if (typeof p.setSizeStyle === 'function') q -= 4;
  6925. if (typeof p.showControls === 'function') q -= 4;
  6926. if (typeof p.hideControls === 'function') q -= 4;
  6927. if (typeof p.getVideoContentRect === 'function') q -= 4;
  6928. if (typeof p.toggleFullscreen === 'function') q -= 4;
  6929. if (typeof p.isFullscreen === 'function') q -= 4;
  6930. if (typeof p.cancelPlayback === 'function') q -= 4;
  6931. if (typeof p.getProgressState === 'function') q -= 4;
  6932. if (typeof p.isInline === 'function') q -= 4;
  6933. if (typeof p.setInline === 'function') q -= 4;
  6934. if (typeof p.toggleSubtitles === 'function') q -= 4;
  6935. if (typeof p.getPlayerSize === 'function') q -= 4;
  6936. if (typeof p.wakeUpControls === 'function') q -= 4;
  6937. if (typeof p.setCenterCrop === 'function') q -= 4;
  6938. if (typeof p.getLoopVideo === 'function') q -= 4;
  6939. if (typeof p.setLoopVideo === 'function') q -= 4;
  6940.  
  6941.  
  6942. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  6943.  
  6944. if (q > 0) brr.set(k, q);
  6945.  
  6946. }
  6947.  
  6948. }
  6949.  
  6950. if (arr.length === 0) {
  6951.  
  6952. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  6953. } else {
  6954.  
  6955. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  6956.  
  6957. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  6958.  
  6959. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  6960. return arr[0][0];
  6961. }
  6962.  
  6963.  
  6964.  
  6965. }
  6966.  
  6967.  
  6968.  
  6969.  
  6970. const getDX = (_yt_player) => {
  6971. const w = 'DX';
  6972.  
  6973. let arr = [];
  6974. let brr = new Map();
  6975.  
  6976. for (const [k, v] of Object.entries(_yt_player)) {
  6977.  
  6978. const p = typeof v === 'function' ? v.prototype : 0;
  6979. if (p) {
  6980. let q = 0;
  6981. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 7) q += 400;
  6982. else if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 8) q += 300;
  6983. else if (typeof p.handleGlobalKeyUp === 'function') q += 200;
  6984.  
  6985. if (typeof p.handleGlobalKeyUp === 'function' && p.handleGlobalKeyUp.length === 0) q -= 600; // avoid SV
  6986.  
  6987.  
  6988. if (!(typeof p.init === 'function' && p.init.length === 0)) q -= 300; // init is required
  6989.  
  6990. if (q < 200) continue; // p.handleGlobalKeyUp must be available
  6991.  
  6992. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 8) q += 80;
  6993. if (typeof p.handleGlobalKeyDown === 'function' && p.handleGlobalKeyDown.length === 7) q += 30;
  6994. if (typeof p.step === 'function' && p.step.length === 1) q += 10;
  6995. if (typeof p.step === 'function' && p.step.length !== 1) q += 5;
  6996.  
  6997.  
  6998. // differentiate QT and DX
  6999.  
  7000.  
  7001. q += 280;
  7002.  
  7003. if (typeof p.cueVideoByPlayerVars === 'function') q -= 4;
  7004. if (typeof p.loadVideoByPlayerVars === 'function') q -= 4;
  7005. if (typeof p.preloadVideoByPlayerVars === 'function') q -= 4;
  7006. if (typeof p.seekBy === 'function') q -= 4;
  7007. if (typeof p.seekTo === 'function') q -= 4;
  7008. if (typeof p.getStoryboardFormat === 'function') q -= 4;
  7009. if (typeof p.getDuration === 'function') q -= 4;
  7010. if (typeof p.loadModule === 'function') q -= 4;
  7011. if (typeof p.unloadModule === 'function') q -= 4;
  7012. if (typeof p.getOption === 'function') q -= 4;
  7013. if (typeof p.getOptions === 'function') q -= 4;
  7014. if (typeof p.setOption === 'function') q -= 4;
  7015. if (typeof p.addCueRange === 'function') q -= 4;
  7016. if (typeof p.getDebugText === 'function') q -= 4;
  7017. if (typeof p.getCurrentBroadcastId === 'function') q -= 4;
  7018. if (typeof p.setSizeStyle === 'function') q -= 4;
  7019. if (typeof p.showControls === 'function') q -= 4;
  7020. if (typeof p.hideControls === 'function') q -= 4;
  7021. if (typeof p.getVideoContentRect === 'function') q -= 4;
  7022. if (typeof p.toggleFullscreen === 'function') q -= 4;
  7023. if (typeof p.isFullscreen === 'function') q -= 4;
  7024. if (typeof p.cancelPlayback === 'function') q -= 4;
  7025. if (typeof p.getProgressState === 'function') q -= 4;
  7026. if (typeof p.isInline === 'function') q -= 4;
  7027. if (typeof p.setInline === 'function') q -= 4;
  7028. if (typeof p.toggleSubtitles === 'function') q -= 4;
  7029. if (typeof p.getPlayerSize === 'function') q -= 4;
  7030. if (typeof p.wakeUpControls === 'function') q -= 4;
  7031. if (typeof p.setCenterCrop === 'function') q -= 4;
  7032. if (typeof p.getLoopVideo === 'function') q -= 4;
  7033. if (typeof p.setLoopVideo === 'function') q -= 4;
  7034.  
  7035.  
  7036. if (q > 0) arr = addProtoToArr(_yt_player, k, arr) || arr;
  7037.  
  7038. if (q > 0) brr.set(k, q);
  7039.  
  7040. }
  7041.  
  7042. }
  7043.  
  7044. if (arr.length === 0) {
  7045.  
  7046. console.warn(`[yt-js-engine-tamer] (key-extraction) Key does not exist. [${w}]`);
  7047. } else {
  7048.  
  7049. arr = arr.map(key => [key, (brr.get(key) || 0)]);
  7050.  
  7051. if (arr.length > 1) arr.sort((a, b) => b[1] - a[1]);
  7052.  
  7053. if (arr.length > 2) console.log(`[yt-js-engine-tamer] (key-extraction) [${w}]`, arr);
  7054. return arr[0][0];
  7055. }
  7056.  
  7057.  
  7058.  
  7059. }
  7060.  
  7061.  
  7062.  
  7063. const isPrepareCachedV = (FIX_avoid_incorrect_video_meta ? true : false) && (window === top);
  7064.  
  7065. let pageSetupVideoId = null; // set at finish; '' for indeterminate state
  7066. let pageSetupState = 0;
  7067.  
  7068. isPrepareCachedV && (() => {
  7069.  
  7070. pageSetupVideoId = '';
  7071. const clearCachedV = () => {
  7072. pageSetupVideoId = '';
  7073. pageSetupState = 0;
  7074. }
  7075. document.addEventListener('yt-navigate-start', clearCachedV, false); // user action
  7076. document.addEventListener('yt-navigate-cache', clearCachedV, false); // pop state
  7077. document.addEventListener('yt-page-data-fetched', clearCachedV, false); // still consider invalid until url is ready in yt-navigate-finish
  7078. document.addEventListener('yt-navigate-finish', () => {
  7079. pageSetupState = 1;
  7080. try {
  7081. const url = new URL(location.href);
  7082. if (!url || !isWatchPageURL(url)) {
  7083. pageSetupVideoId = '';
  7084. } else {
  7085. pageSetupVideoId = url.searchParams.get('v') || '';
  7086. }
  7087. } catch (e) {
  7088. pageSetupVideoId = '';
  7089. }
  7090. }, false);
  7091.  
  7092. })();
  7093.  
  7094. let videoPlayingY = null;
  7095.  
  7096. isPrepareCachedV && (() => {
  7097.  
  7098. let getNext = true;
  7099. let videoPlayingX = {
  7100. get videoId() {
  7101. if (getNext) {
  7102. getNext = false;
  7103.  
  7104. let elements = document.querySelectorAll('ytd-watch-flexy[video-id]');
  7105. const arr = [];
  7106. for (const element of elements) {
  7107. if (!element.closest('[hidden]')) arr.push(element);
  7108. }
  7109. if (arr.length !== 1) this.__videoId__ = '';
  7110. else {
  7111. this.__videoId__ = arr[0].getAttribute('video-id');
  7112. }
  7113.  
  7114. }
  7115. return this.__videoId__ || '';
  7116. }
  7117. }
  7118.  
  7119. videoPlayingY = videoPlayingX;
  7120. const handler = (evt) => {
  7121. const target = (evt || 0).target;
  7122. if (target instanceof HTMLVideoElement) {
  7123. getNext = true;
  7124. }
  7125. }
  7126. document.addEventListener('loadedmetadata', handler, true);
  7127. document.addEventListener('durationchange', handler, true);
  7128.  
  7129. })();
  7130.  
  7131.  
  7132.  
  7133. const cleanContext = async (win) => {
  7134. const waitFn = requestAnimationFrame; // shall have been binded to window
  7135. try {
  7136. let mx = 16; // MAX TRIAL
  7137. const frameId = 'vanillajs-iframe-v1';
  7138. /** @type {HTMLIFrameElement | null} */
  7139. let frame = document.getElementById(frameId);
  7140. let removeIframeFn = null;
  7141. if (!frame) {
  7142. frame = document.createElement('iframe');
  7143. frame.id = frameId;
  7144. const blobURL = typeof webkitCancelAnimationFrame === 'function' && typeof kagi === 'undefined' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  7145. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  7146. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  7147. n.appendChild(frame);
  7148. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  7149. const root = document.documentElement;
  7150. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  7151. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  7152.  
  7153. removeIframeFn = (setTimeout) => {
  7154. const removeIframeOnDocumentReady = (e) => {
  7155. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  7156. e = n;
  7157. n = win = removeIframeFn = 0;
  7158. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  7159. }
  7160. if (!setTimeout || document.readyState !== 'loading') {
  7161. removeIframeOnDocumentReady();
  7162. } else {
  7163. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  7164. }
  7165. }
  7166. }
  7167. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  7168. const fc = frame.contentWindow;
  7169. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  7170. try {
  7171. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle } = fc;
  7172. const res = { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle };
  7173. for (let k in res) res[k] = res[k].bind(win); // necessary
  7174. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  7175. res.animate = fc.HTMLElement.prototype.animate;
  7176. res.perfNow = fc.performance.now;
  7177. return res;
  7178. } catch (e) {
  7179. if (removeIframeFn) removeIframeFn();
  7180. return null;
  7181. }
  7182. } catch (e) {
  7183. console.warn(e);
  7184. return null;
  7185. }
  7186. };
  7187.  
  7188. const promiseForYtActionCalled = new Promise(resolve => {
  7189.  
  7190. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-app';
  7191. if (typeof AbortSignal !== 'undefined') {
  7192. let hn = () => {
  7193. if (!hn) return;
  7194. hn = null;
  7195. resolve(document.querySelector(appTag));
  7196. };
  7197. document.addEventListener('yt-action', hn, { capture: true, passive: true, once: true });
  7198. } else {
  7199. let hn = () => {
  7200. if (!hn) return;
  7201. document.removeEventListener('yt-action', hn, true);
  7202. hn = null;
  7203. resolve(document.querySelector(appTag));
  7204. };
  7205. document.addEventListener('yt-action', hn, true);
  7206. }
  7207. });
  7208.  
  7209. cleanContext(window).then(__CONTEXT__ => {
  7210. if (!__CONTEXT__) return null;
  7211.  
  7212. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, requestIdleCallback, getComputedStyle, perfNow } = __CONTEXT__;
  7213.  
  7214.  
  7215. performance.now17 = perfNow.bind(performance);
  7216.  
  7217.  
  7218.  
  7219. __requestAnimationFrame__ = requestAnimationFrame;
  7220.  
  7221.  
  7222. const isGPUAccelerationAvailable = (() => {
  7223. // https://gist.github.com/cvan/042b2448fcecefafbb6a91469484cdf8
  7224. try {
  7225. const canvas = document.createElement('canvas');
  7226. return !!(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
  7227. } catch (e) {
  7228. return false;
  7229. }
  7230. })();
  7231.  
  7232. const foregroundPromiseFn_noGPU = (() => {
  7233.  
  7234. if (isGPUAccelerationAvailable) return null;
  7235.  
  7236. const pd = Object.getOwnPropertyDescriptor(Document.prototype, 'visibilityState');
  7237. if (!pd || typeof pd.get !== 'function') return null;
  7238. const pdGet = pd.get;
  7239.  
  7240. let pr = null;
  7241.  
  7242. let hState = pdGet.call(document) === 'hidden';
  7243. // let cid = 0;
  7244. pureAddEventListener.call(document, 'visibilitychange', (evt) => {
  7245. const newHState = pdGet.call(document) === 'hidden';
  7246. if (hState !== newHState) {
  7247. // if (cid > 0) cid = clearInterval(cid);
  7248. hState = newHState;
  7249. if (!hState && pr) pr = pr.resolve();
  7250. }
  7251. });
  7252.  
  7253. // cid = setInterval(() => {
  7254. // const newHState = document.visibilityState === 'hidden';
  7255. // if (hState !== newHState) {
  7256. // hState = newHState;
  7257. // if (!hState && pr) pr = pr.resolve();
  7258. // }
  7259. // }, 100);
  7260.  
  7261.  
  7262. return (() => {
  7263. if (pr) return pr;
  7264. const w = ((!hState && setTimeout(() => {
  7265. if (!hState && pr === w) pr = pr.resolve();
  7266. })), (pr = new PromiseExternal()));
  7267. return w;
  7268. });
  7269.  
  7270. })();
  7271.  
  7272.  
  7273. let rafPromise = null;
  7274. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  7275. requestAnimationFrame(hRes => {
  7276. rafPromise = null;
  7277. resolve(hRes);
  7278. });
  7279. }));
  7280.  
  7281. const foregroundPromiseFn = foregroundPromiseFn_noGPU || getRafPromise;
  7282.  
  7283.  
  7284. const wmComputedStyle = new WeakMap();
  7285.  
  7286. if (!window.__native__getComputedStyle__ && !window.__jst__getComputedStyle__ && typeof window.getComputedStyle === 'function' && window.getComputedStyle.length === 1) {
  7287. window.__native__getComputedStyle__ = getComputedStyle;
  7288. if (ENABLE_COMPUTEDSTYLE_CACHE) {
  7289. window.__original__getComputedStyle__ = window.getComputedStyle;
  7290. window.getComputedStyle = function (elem) {
  7291. if (!(elem instanceof Element) || (arguments.length === 2 && arguments[1]) || (arguments.length > 2)) {
  7292. return window.__original__getComputedStyle__(...arguments);
  7293. }
  7294. let cs = wmComputedStyle.get(elem);
  7295. if (!cs) {
  7296. cs = window.__native__getComputedStyle__(elem);
  7297. wmComputedStyle.set(elem, cs);
  7298. }
  7299. return cs;
  7300. };
  7301. } else {
  7302. window.__original__getComputedStyle__ = null;
  7303. }
  7304. window.__jst__getComputedStyle__ = window.getComputedStyle;
  7305. }
  7306.  
  7307. NO_SCHEDULING_DUE_TO_COMPUTEDSTYLE && promiseForYtActionCalled.then(() => {
  7308. if (typeof window.__jst__getComputedStyle__ === 'function' && window.__jst__getComputedStyle__.length === 1 && window.__jst__getComputedStyle__ !== window.getComputedStyle) {
  7309. window.getComputedStyle = window.__jst__getComputedStyle__;
  7310. }
  7311. });
  7312.  
  7313. const isUrlInEmbed = location.href.includes('.youtube.com/embed/');
  7314. const isAbortSignalSupported = typeof AbortSignal !== "undefined";
  7315.  
  7316. const promiseForTamerTimeout = new Promise(resolve => {
  7317. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  7318. setTimeout(resolve, 480);
  7319. }, { capture: true, passive: true, once: true });
  7320. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  7321. setTimeout(resolve, 1200);
  7322. });
  7323. setTimeout(resolve, 3000);
  7324. });
  7325.  
  7326. const promiseForPageInitied = new Promise(resolve => {
  7327. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  7328. setTimeout(resolve, 450);
  7329. }, { capture: true, passive: true, once: true });
  7330. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  7331. setTimeout(resolve, 900);
  7332. });
  7333. setTimeout(resolve, 1800);
  7334. });
  7335.  
  7336. NO_PRELOAD_GENERATE_204_BYPASS || promiseForPageInitied.then(() => {
  7337. NO_PRELOAD_GENERATE_204_BYPASS = true;
  7338. headLinkCollection = null;
  7339. });
  7340.  
  7341.  
  7342. NATIVE_CANVAS_ANIMATION && (() => {
  7343.  
  7344. observablePromise(() => {
  7345. HTMLCanvasElement.prototype.animate = animate;
  7346. }, promiseForTamerTimeout).obtain();
  7347.  
  7348. })();
  7349.  
  7350.  
  7351.  
  7352.  
  7353. FIX_ytAction_ && (async () => {
  7354.  
  7355. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-app';
  7356.  
  7357. const ytdApp = await new Promise(resolve => {
  7358.  
  7359. whenCEDefined(appTag).then(() => {
  7360. const ytdApp = document.querySelector(appTag);
  7361. if (ytdApp) {
  7362. resolve(ytdApp);
  7363. return;
  7364. }
  7365. let mo = new MutationObserver(() => {
  7366. const ytdApp = document.querySelector(appTag);
  7367. if (!ytdApp) return;
  7368. if (mo) {
  7369. mo.disconnect();
  7370. mo.takeRecords();
  7371. mo = null;
  7372. }
  7373. resolve(ytdApp);
  7374. });
  7375. mo.observe(document, { subtree: true, childList: true });
  7376. });
  7377.  
  7378. });
  7379.  
  7380. if (!ytdApp) return;
  7381. const cProto = insp(ytdApp).constructor.prototype;
  7382.  
  7383. if (!cProto) return;
  7384. let mbd = 0;
  7385.  
  7386. const fixer = (_ytdApp) => {
  7387. const ytdApp = insp(_ytdApp);
  7388. if (ytdApp && typeof ytdApp.onYtActionBoundListener_ === 'function' && !ytdApp.onYtActionBoundListener57_) {
  7389. ytdApp.onYtActionBoundListener57_ = ytdApp.onYtActionBoundListener_;
  7390. ytdApp.onYtActionBoundListener_ = ytdApp.onYtAction_.bind(ytdApp);
  7391. mbd++;
  7392. }
  7393. }
  7394.  
  7395. observablePromise(() => {
  7396.  
  7397. if (typeof cProto.created === 'function' && !cProto.created56) {
  7398. cProto.created56 = cProto.created;
  7399. cProto.created = function (...args) {
  7400. const r = this.created56(...args);
  7401. fixer(this);
  7402. return r;
  7403. };
  7404. mbd++;
  7405. }
  7406.  
  7407. if (typeof cProto.onYtAction_ === 'function' && !cProto.onYtAction57_) {
  7408. cProto.onYtAction57_ = cProto.onYtAction_;
  7409. cProto.onYtAction_ = function (...args) {
  7410. Promise.resolve().then(() => this.onYtAction57_(...args));
  7411. };
  7412. mbd++;
  7413. }
  7414.  
  7415. if (ytdApp) fixer(ytdApp);
  7416.  
  7417. /*
  7418. const actionRouter_ = ytdApp ? ytdApp.actionRouter_ : null;
  7419. if (actionRouter_ && typeof actionRouter_.handleAction === 'function' && !actionRouter_.handleAction57) {
  7420. actionRouter_.handleAction57 = actionRouter_.handleAction;
  7421. actionRouter_.handleAction = function (...args) {
  7422. Promise.resolve().then(() => this.handleAction57(...args));
  7423. }
  7424. mbd++;
  7425. }
  7426. */
  7427.  
  7428. // if(mbd === 3) return 1;
  7429. if (mbd >= 3) return 1;
  7430.  
  7431. }, new Promise(r => setTimeout(r, 1000))).obtain();
  7432.  
  7433. })();
  7434.  
  7435.  
  7436. FORCE_NO_REUSEABLE_ELEMENT_POOL && promiseForYtActionCalled.then(async () => {
  7437.  
  7438. const appTag = isChatRoomURL ? 'yt-live-chat-app' : 'ytd-watch-flexy';
  7439.  
  7440. const app = await observablePromise(() => {
  7441.  
  7442. return document.querySelector(appTag);
  7443.  
  7444. }).obtain();
  7445.  
  7446. if (!app) return;
  7447.  
  7448. const appCnt = insp(app);
  7449. FORCE_NO_REUSEABLE_ELEMENT_POOL_fn(appCnt);
  7450.  
  7451.  
  7452.  
  7453.  
  7454. });
  7455.  
  7456. const observablePromise = (proc, timeoutPromise) => {
  7457. let promise = null;
  7458. return {
  7459. obtain() {
  7460. if (!promise) {
  7461. promise = new Promise(resolve => {
  7462. let mo = null;
  7463. const f = () => {
  7464. let t = proc();
  7465. if (t) {
  7466. mo.disconnect();
  7467. mo.takeRecords();
  7468. mo = null;
  7469. resolve(t);
  7470. }
  7471. }
  7472. mo = new MutationObserver(f);
  7473. mo.observe(document, { subtree: true, childList: true })
  7474. f();
  7475. timeoutPromise && timeoutPromise.then(() => {
  7476. resolve(null)
  7477. });
  7478. });
  7479. }
  7480. return promise
  7481. }
  7482. }
  7483. }
  7484.  
  7485. // let _yt_player_promise = null;
  7486. /*
  7487. const getYtPlayerPromise = () => {
  7488. if (!_yt_player_promise) {
  7489. _yt_player_promise = new Promise(resolve => {
  7490. let cid = setInterval(() => {
  7491. let t = (((window || 0)._yt_player || 0) || 0);
  7492. if (t) {
  7493. clearInterval(cid);
  7494. resolve(t);
  7495. }
  7496. }, 1);
  7497. promiseForTamerTimeout.then(() => {
  7498. resolve(null)
  7499. });
  7500. });
  7501. }
  7502. return _yt_player_promise;
  7503. }
  7504. */
  7505. const _yt_player_observable = observablePromise(() => {
  7506. const _yt_player = (((window || 0)._yt_player || 0) || 0);
  7507. if (_yt_player) {
  7508. _yt_player[`__is_yt_player__${Date.now()}`] = 1;
  7509. return _yt_player;
  7510. }
  7511. }, promiseForTamerTimeout);
  7512.  
  7513. const polymerObservable = observablePromise(() => {
  7514. const Polymer = window.Polymer;
  7515. if (typeof Polymer !== 'function') return;
  7516. if (!(Polymer.Base || 0).connectedCallback || !(Polymer.Base || 0).disconnectedCallback) return;
  7517. return Polymer;
  7518. }, promiseForTamerTimeout);
  7519.  
  7520. const schedulerInstanceObservable = observablePromise(() => {
  7521. return (((window || 0).ytglobal || 0).schedulerInstanceInstance_ || 0);
  7522. }, promiseForTamerTimeout);
  7523.  
  7524. const timelineObservable = observablePromise(() => {
  7525. let t = (((document || 0).timeline || 0) || 0);
  7526. if (t && typeof t._play === 'function') {
  7527. return t;
  7528. }
  7529. }, promiseForTamerTimeout);
  7530. const animationObservable = observablePromise(() => {
  7531. let t = (((window || 0).Animation || 0) || 0);
  7532. if (t && typeof t === 'function' && t.length === 2 && typeof t.prototype._updatePromises === 'function') {
  7533. return t;
  7534. }
  7535. }, promiseForTamerTimeout);
  7536.  
  7537.  
  7538. const getScreenInfo = {
  7539. screenWidth: 0,
  7540. screenHeight: 0,
  7541. valueReady: false,
  7542. onResize: () => {
  7543. getScreenInfo.valueReady = false;
  7544. },
  7545. sizeProvided: () => {
  7546. if (getScreenInfo.valueReady) return true;
  7547. getScreenInfo.screenWidth = screen.width;
  7548. getScreenInfo.screenHeight = screen.height;
  7549. if (getScreenInfo.screenWidth * getScreenInfo.screenHeight > 1) {
  7550. getScreenInfo.valueReady = true;
  7551. return true;
  7552. }
  7553. return false;
  7554. }
  7555. };
  7556.  
  7557. window.addEventListener('resize', getScreenInfo.onResize, true);
  7558.  
  7559.  
  7560. // const hookLeftPending = new WeakMap();
  7561.  
  7562. const isNaNx = Number.isNaN;
  7563.  
  7564. const hookLeftPD = {
  7565. get() {
  7566. const p = 'left';
  7567. // const o = hookLeftPending.get(this);
  7568. // if (o && o.key) {
  7569. // this.setProperty(p, o.value);
  7570. // o.key = null
  7571. // }
  7572. return this.getPropertyValue(p);
  7573. },
  7574. set(v) {
  7575.  
  7576. const p = 'left';
  7577. const cv = this.getPropertyValue(p);
  7578. const sv = v;
  7579.  
  7580. // const did = Math.floor(Math.random() * 314159265359 + 314159265359).toString(36);
  7581.  
  7582. // console.log(8380,did, cv, sv)
  7583. if (!cv && !sv) return true;
  7584. if (cv === sv) return true;
  7585.  
  7586. // skip 0~9px => L>=4
  7587.  
  7588. const qsv = `${sv}`.length >= 4 && `${sv}`.endsWith('px') ? +sv.slice(0, -2) : NaN;
  7589.  
  7590. if (!isNaNx(qsv)) {
  7591. const qcv = `${cv}`.length >= 4 && `${cv}`.endsWith('px') ? +cv.slice(0, -2) : NaN;
  7592.  
  7593. if (!isNaNx(qcv) && getScreenInfo.sizeProvided()) {
  7594. const { screenWidth, screenHeight } = getScreenInfo;
  7595. let pWidth = screenWidth + 1024;
  7596. let pHeight = screenHeight + 768;
  7597. const minRatio = 0.003;
  7598. const dw = pWidth * 0.0003; // min dw = 0.3072
  7599. const dh = pHeight * 0.0003; // min dh = 0.2304
  7600. // console.log(8381,did, Math.abs(qcv - qsv) < dw)
  7601. if (Math.abs(qcv - qsv) < dw) return true;
  7602. }
  7603.  
  7604. v = `${qsv > -1e-5 && qsv < 1e-5 ? 0 : qsv.toFixed(4)}px`;
  7605. if (`${v}`.length > `${sv}`.length) v = sv;
  7606. // console.log(8382, did, sv, nv, cv, this)
  7607. }
  7608.  
  7609. // Promise.resolve().then(() => {
  7610. // const o = hookLeftPending.get(this);
  7611. // if (o && o.key === did) {
  7612. // this.setProperty(p, o.value);
  7613. // o.key = null;
  7614. // }
  7615. // });
  7616. // hookLeftPending.set(this, {
  7617. // key: did,
  7618. // value: nv
  7619. // });
  7620.  
  7621. // if (nv != v) {
  7622. // console.log(8387, v, nv);
  7623. // }
  7624.  
  7625. this.setProperty(p, v);
  7626. // console.log(8383, did, this.getPropertyValue(p))
  7627. return true;
  7628. },
  7629. enumerable: true,
  7630. configurable: true
  7631. };
  7632.  
  7633.  
  7634. if (HOOK_CSSPD_LEFT) {
  7635.  
  7636.  
  7637. Object.defineProperty(CSSStyleDeclaration.prototype, 'left', hookLeftPD);
  7638.  
  7639. }
  7640.  
  7641.  
  7642.  
  7643.  
  7644.  
  7645. const generalEvtHandler = async (_evKey, _fvKey, _debug) => {
  7646.  
  7647. const evKey = `${_evKey}`;
  7648. const fvKey = `${_fvKey}`;
  7649. const debug = !!_debug;
  7650.  
  7651. const _yt_player = await _yt_player_observable.obtain();
  7652.  
  7653.  
  7654. if (!_yt_player || typeof _yt_player !== 'object') return;
  7655.  
  7656.  
  7657. const getArr = (_yt_player) => {
  7658.  
  7659. let arr = [];
  7660.  
  7661. for (const [k, v] of Object.entries(_yt_player)) {
  7662.  
  7663. const p = typeof v === 'function' ? v.prototype : 0;
  7664. if (p
  7665. && typeof p[evKey] === 'function' && p[evKey].length >= 0 && !p[fvKey]
  7666.  
  7667. ) {
  7668. arr = addProtoToArr(_yt_player, k, arr) || arr;
  7669.  
  7670. }
  7671.  
  7672. }
  7673.  
  7674. if (arr.length === 0) {
  7675.  
  7676. console.warn(`Key prop [${evKey}] does not exist.`);
  7677. } else {
  7678.  
  7679. return arr;
  7680. }
  7681.  
  7682. };
  7683.  
  7684. const arr = getArr(_yt_player);
  7685.  
  7686.  
  7687. if (!arr) return;
  7688.  
  7689. debug && console.log(`FIX_${evKey}`, arr);
  7690.  
  7691. const f = function (...args) {
  7692. Promise.resolve().then(() => this[fvKey](...args));
  7693. };
  7694.  
  7695.  
  7696. for (const k of arr) {
  7697.  
  7698. const g = _yt_player;
  7699. const gk = g[k];
  7700. const gkp = gk.prototype;
  7701.  
  7702. debug && console.log(237, k, gkp)
  7703.  
  7704. if (typeof gkp[evKey] == 'function' && !gkp[fvKey]) {
  7705. gkp[fvKey] = gkp[evKey];
  7706. gkp[evKey] = f;
  7707. }
  7708. }
  7709.  
  7710.  
  7711.  
  7712.  
  7713. }
  7714.  
  7715. if (!isChatRoomURL) {
  7716.  
  7717. FIX_onVideoDataChange && generalEvtHandler('onVideoDataChange', 'onVideoDataChange57');
  7718. // FIX_onClick && generalEvtHandler('onClick', 'onClick57');
  7719. FIX_onStateChange && generalEvtHandler('onStateChange', 'onStateChange57');
  7720. FIX_onLoopRangeChange && generalEvtHandler('onLoopRangeChange', 'onLoopRangeChange57');
  7721. if (FIX_VideoEVENTS_v2) {
  7722. const FIX_VideoEVENTS_DEBUG = 0;
  7723. generalEvtHandler('onVideoProgress', 'onVideoProgress57', FIX_VideoEVENTS_DEBUG); // --
  7724. // generalEvtHandler('onAutoplayBlocked', 'onAutoplayBlocked57', FIX_VideoEVENTS_DEBUG);
  7725. // generalEvtHandler('onLoadProgress', 'onLoadProgress57', FIX_VideoEVENTS_DEBUG); // << CAUSE ISSUE >>
  7726. generalEvtHandler('onFullscreenChange', 'onFullscreenChange57', FIX_VideoEVENTS_DEBUG); // --
  7727. // generalEvtHandler('onLoadedMetadata', 'onLoadedMetadata57', FIX_VideoEVENTS_DEBUG);
  7728. // generalEvtHandler('onDrmOutputRestricted', 'onDrmOutputRestricted57', FIX_VideoEVENTS_DEBUG);
  7729. // generalEvtHandler('onAirPlayActiveChange', 'onAirPlayActiveChange57', FIX_VideoEVENTS_DEBUG);
  7730. // generalEvtHandler('onAirPlayAvailabilityChange', 'onAirPlayAvailabilityChange57', FIX_VideoEVENTS_DEBUG);
  7731. // generalEvtHandler('onApiChange', 'onApiChange57', FIX_VideoEVENTS_DEBUG);
  7732.  
  7733. }
  7734. // onMutedAutoplayChange
  7735. // onVolumeChange
  7736. // onPlaybackRateChange
  7737.  
  7738. // onAirPlayActiveChange
  7739. // onAirPlayAvailabilityChange
  7740. // onApiChange
  7741. // onAutoplayBlocked
  7742. // onDrmOutputRestricted
  7743. // onFullscreenChange
  7744. // onLoadProgress
  7745. // onLoadedMetadata
  7746. // onVideoDataChange
  7747. // onVideoProgress
  7748.  
  7749. }
  7750.  
  7751.  
  7752. let isAmended_Polymer_RenderStatus = false;
  7753.  
  7754. (ENABLE_discreteTasking || FIX_Polymer_dom || FIX_Polymer_AF || FIX_stampDomArray) && (async () => {
  7755.  
  7756. const Polymer = await polymerObservable.obtain();
  7757. if (!Polymer) return;
  7758.  
  7759. if (FIX_Polymer_AF && Polymer && Polymer.RenderStatus && !isAmended_Polymer_RenderStatus) {
  7760. isAmended_Polymer_RenderStatus = true;
  7761.  
  7762. if (typeof Polymer.RenderStatus.beforeNextRender === 'function' && typeof Polymer.RenderStatus.afterNextRender === 'function' && Polymer.RenderStatus.beforeNextRender.length === 3 && Polymer.RenderStatus.afterNextRender.length === 3) {
  7763. let arrBefore = null, arrAfter = null;
  7764. const push = Array.prototype.push;
  7765. let arr = null;
  7766. Array.prototype.push = function () {
  7767. arr = this;
  7768. }
  7769. Polymer.RenderStatus.beforeNextRender({}, {}, {});
  7770. if (arr) arrBefore = arr;
  7771. arr = null;
  7772. Polymer.RenderStatus.afterNextRender({}, {}, {});
  7773. if (arr) arrAfter = arr;
  7774. arr = null;
  7775. Array.prototype.push = push;
  7776. Polymer.RenderStatus.arrBefore = arrBefore;
  7777. Polymer.RenderStatus.arrAfter = arrAfter;
  7778.  
  7779. if (arrBefore && arrAfter) {
  7780.  
  7781. Function.prototype.call7900 = Function.prototype.call;
  7782. Function.prototype.apply7900 = Function.prototype.apply;
  7783. Function.prototype.apply7948 = function (obj, args) {
  7784. const f = this;
  7785. let m = kRef(obj);
  7786. if (!m) return;
  7787. if (m.is && !m.nodeName) {
  7788. if (!m.isAttached || !m.hostElement) {
  7789. return;
  7790. }
  7791. }
  7792. try {
  7793. return !args ? f.call7900(m) : f.apply7900(m, args);
  7794. } catch (e) {
  7795. console.warn(e);
  7796. }
  7797. return null;
  7798. }
  7799.  
  7800. arrBefore.push = arrAfter.push = function (a) {
  7801. if (arguments.length !== 1 || !a || a.length === 0 || !a[0]) return push.apply(this, arguments);
  7802. if (a[0].deref) a[0] = kRef(a[0]);
  7803. const f = a[1]
  7804. const obj = a[0]
  7805. const args = a[2];
  7806. f.apply = f.apply7948;
  7807. if (!obj[wk]) obj[wk] = mWeakRef(obj);
  7808. a[0] = obj[wk]
  7809. // console.log(4992, a)
  7810. return push.call(this, a);
  7811. }
  7812.  
  7813. }
  7814.  
  7815.  
  7816. }
  7817. // Polymer.RenderStatus.beforeNextRender
  7818. }
  7819.  
  7820. if (FIX_Polymer_dom) {
  7821.  
  7822. const checkPDFuncValue = (pd) => {
  7823. return pd && pd.writable && pd.enumerable && pd.configurable && typeof pd.value == 'function'
  7824. }
  7825. const checkPDFuncValue2 = (pd) => {
  7826. return pd && typeof pd.value == 'function'
  7827. }
  7828.  
  7829. const checkPDFuncGet = (pd) => {
  7830. return pd && typeof pd.get == 'function'
  7831. }
  7832.  
  7833. const domX = Polymer.dom(document.createElement('null'));
  7834. const domXP = (((domX || 0).constructor || 0).prototype || 0);
  7835. const pd1 = Object.getOwnPropertyDescriptor(domXP, 'getOwnerRoot');
  7836. const pd2 = Object.getOwnPropertyDescriptor(Node.prototype, 'parentElement');
  7837. const pd3 = Object.getOwnPropertyDescriptor(domXP, 'querySelector'); // undefined
  7838. const pd4 = Object.getOwnPropertyDescriptor(Element.prototype, 'querySelector');
  7839. const pd4b = Object.getOwnPropertyDescriptor(Document.prototype, 'querySelector');
  7840. const pd5 = Object.getOwnPropertyDescriptor(domXP, 'querySelectorAll'); // undefined
  7841. const pd6 = Object.getOwnPropertyDescriptor(Element.prototype, 'querySelectorAll');
  7842. const pd6b = Object.getOwnPropertyDescriptor(Document.prototype, 'querySelectorAll');
  7843.  
  7844.  
  7845. // getOwnerRoot - to be reviewed
  7846. if (0 && checkPDFuncValue(pd1) && checkPDFuncGet(pd2) && !domXP.getOwnerRoot15 && typeof domXP.getOwnerRoot === 'function') {
  7847.  
  7848. domXP.getOwnerRoot15 = domXP.getOwnerRoot;
  7849. domXP.getOwnerRoot = function () {
  7850. try {
  7851. const p = this.node;
  7852.  
  7853. if (p instanceof HTMLElement_) {
  7854. const pp = pd2.get.call(p);
  7855. if (pp instanceof HTMLElement_ && pp.isConnected === true) {
  7856. return pp.getRootNode();
  7857. }
  7858.  
  7859. }
  7860. } catch (e) { }
  7861. return this.getOwnerRoot15();
  7862. }
  7863.  
  7864. Polymer.__fixedGetOwnerRoot__ = 1;
  7865. }
  7866.  
  7867.  
  7868.  
  7869.  
  7870. if ((!pd3 || checkPDFuncValue(pd3)) && checkPDFuncValue2(pd4) && checkPDFuncValue2(pd4b) && !('querySelector15' in domXP)) {
  7871.  
  7872. domXP.querySelector15 = domXP.querySelector;
  7873.  
  7874. const querySelectorFn = function (query) {
  7875. try {
  7876. const p = this.node;
  7877.  
  7878. if (p instanceof Document && p.isConnected === true) {
  7879. return pd4b.value.call(p, query);
  7880. }
  7881.  
  7882. } catch (e) { }
  7883. return this.querySelector15(query);
  7884. }
  7885.  
  7886. Object.defineProperty(domXP, 'querySelector', {
  7887. get() {
  7888. return querySelectorFn;
  7889. },
  7890. set(nv) {
  7891. if (nv === querySelectorFn) return true;
  7892. this.querySelector15 = nv;
  7893. return true;
  7894. },
  7895.  
  7896. enumerable: false,
  7897. configurable: true
  7898. });
  7899.  
  7900. Polymer.__fixedQuerySelector__ = 1;
  7901. }
  7902.  
  7903. if ((!pd5 || checkPDFuncValue(pd5)) && checkPDFuncValue2(pd6) && checkPDFuncValue2(pd6b) && !('querySelectorAll15' in domXP)) {
  7904.  
  7905. domXP.querySelectorAll15 = domXP.querySelectorAll;
  7906.  
  7907. const querySelectorAllFn = function (query) {
  7908.  
  7909. try {
  7910.  
  7911. const p = this.node;
  7912.  
  7913. if (p instanceof Document && p.isConnected === true) {
  7914. return pd6b.value.call(p, query);
  7915. }
  7916.  
  7917. } catch (e) {
  7918.  
  7919. }
  7920. return this.querySelectorAll15(query);
  7921. }
  7922.  
  7923. Object.defineProperty(domXP, 'querySelectorAll', {
  7924. get() {
  7925. return querySelectorAllFn;
  7926. },
  7927. set(nv) {
  7928. if (nv === querySelectorAllFn) return true;
  7929. this.querySelectorAll15 = nv;
  7930. return true;
  7931. },
  7932.  
  7933. enumerable: false,
  7934. configurable: true
  7935. });
  7936.  
  7937. Polymer.__fixedQuerySelectorAll__ = 1;
  7938. }
  7939. }
  7940.  
  7941.  
  7942. if (ENABLE_discreteTasking || FIX_stampDomArray) {
  7943.  
  7944. Polymer.Base.__connInit__ = function () {
  7945. setupYtComponent(this);
  7946. }
  7947.  
  7948.  
  7949. /** @type {Function} */
  7950. const connectedCallbackK = function (...args) {
  7951. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  7952. const r = this[qm53](...args);
  7953. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  7954. this.mh35 = 1;
  7955. return r;
  7956. };
  7957.  
  7958. connectedCallbackK.m353 = 1;
  7959.  
  7960.  
  7961. const qt53 = Polymer.Base.connectedCallback;
  7962. Polymer.Base[qm53] = dmf.get(qt53) || qt53;
  7963.  
  7964. Polymer.Base.connectedCallback = connectedCallbackK;
  7965.  
  7966.  
  7967. /** @type {Function} */
  7968. const createdK = function (...args) {
  7969. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  7970. const r = this[qn53](...args);
  7971. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  7972. this.mh36 = 1;
  7973. return r;
  7974. };
  7975.  
  7976.  
  7977. createdK.m353 = 1;
  7978. Polymer.Base[qn53] = Polymer.Base.created;
  7979. Polymer.Base.created = createdK;
  7980.  
  7981.  
  7982.  
  7983.  
  7984.  
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.  
  7991. }
  7992.  
  7993. })();
  7994.  
  7995.  
  7996. /*
  7997.  
  7998. e.nativeAppendChild = d.prototype.appendChild,
  7999. d.prototype.appendChild = function(h) {
  8000. return function(l) {
  8001. if (l instanceof DocumentFragment) {
  8002. var m = Array.from(l.children);
  8003. l = h.nativeAppendChild.call(this, l);
  8004. if (this.isConnected) {
  8005. m = g(m);
  8006. for (var p = m.next(); !p.done; p = m.next())
  8007. YD(p.value)
  8008. }
  8009. return l
  8010. }
  8011. m = l instanceof Element && l.isConnected;
  8012. p = h.nativeAppendChild.call(this, l);
  8013. m && ZD(l);
  8014. this.isConnected && YD(l);
  8015. return p
  8016. }
  8017. }(e),
  8018.  
  8019. */
  8020.  
  8021. CHANGE_appendChild && !Node.prototype.appendChild73 && Node.prototype.appendChild && (() => {
  8022.  
  8023. const f = Node.prototype.appendChild73 = Node.prototype.appendChild;
  8024. if (f) Node.prototype.appendChild = function (a) {
  8025. if (this instanceof Element) { // exclude DocumentFragment
  8026. try {
  8027. let checkFragmentA = (a instanceof DocumentFragment);
  8028. if (!NO_PRELOAD_GENERATE_204_BYPASS && document.head === this) {
  8029. if (headLinkCollection === null) headLinkCollection = document.head.getElementsByTagName('LINK');
  8030. for (const node of headLinkCollection) {
  8031. if (node.rel === 'preload' && node.as === 'fetch') {
  8032. node.rel = 'prefetch'; // see https://github.com/GoogleChromeLabs/quicklink
  8033. }
  8034. }
  8035. } else if (checkFragmentA && this.nodeName.startsWith('YT-')) { // yt-animated-rolling-number, yt-attributed-string
  8036. checkFragmentA = false;
  8037. }
  8038. if (checkFragmentA && a.firstElementChild === null) {
  8039. // no element in fragmentA
  8040. let doNormal = false;
  8041. for (let child = a.firstChild; child instanceof Node; child = child.nextSibling) {
  8042. if (child.nodeType === 3) { doNormal = true; break; }
  8043. }
  8044. if (!doNormal) return a;
  8045. }
  8046. } catch (e) {
  8047. console.log(e);
  8048. }
  8049. }
  8050. return arguments.length === 1 ? f.call(this, a) : f.apply(this, arguments);
  8051. }
  8052.  
  8053. })();
  8054.  
  8055. if (FIX_Shady) {
  8056.  
  8057. observablePromise(() => {
  8058. const { ShadyDOM, ShadyCSS } = window;
  8059. if (ShadyDOM) {
  8060. ShadyDOM.handlesDynamicScoping = false; // 9 of 10
  8061. ShadyDOM.noPatch = true; // 1 of 10
  8062. ShadyDOM.patchOnDemand = false; // 1 of 10
  8063. ShadyDOM.preferPerformance = true; // 1 of 10
  8064. ShadyDOM.querySelectorImplementation = undefined; // 1 of 10
  8065. }
  8066. if (ShadyCSS) {
  8067. ShadyCSS.nativeCss = true; // 1 of 10
  8068. ShadyCSS.nativeShadow = true; // 6 of 10
  8069. ShadyCSS.cssBuild = undefined; // 1 of 10
  8070. ShadyCSS.disableRuntime = true; // 1 of 10
  8071. }
  8072. if (ShadyDOM && ShadyCSS) return 1;
  8073. }, promiseForTamerTimeout).obtain(); // clear until 1 is return
  8074.  
  8075. }
  8076.  
  8077.  
  8078. // let schedulerInstancePropOfTimerType = '';
  8079. // let schedulerInstancePropOfTimerId = '';
  8080. (FIX_schedulerInstanceInstance & 2) && (async () => {
  8081.  
  8082. const schedulerInstanceInstance_ = await schedulerInstanceObservable.obtain();
  8083.  
  8084. if (!schedulerInstanceInstance_) return;
  8085.  
  8086. const checkOK = typeof schedulerInstanceInstance_.start === 'function' && !schedulerInstanceInstance_.start993 && !schedulerInstanceInstance_.stop && !schedulerInstanceInstance_.cancel && !schedulerInstanceInstance_.terminate && !schedulerInstanceInstance_.interupt;
  8087. if (checkOK) {
  8088.  
  8089. schedulerInstanceInstance_.start993 = schedulerInstanceInstance_.start;
  8090.  
  8091. let requestingFn = null;
  8092. let requestingArgs = null;
  8093.  
  8094. const f = function () {
  8095. requestingFn = this.fn;
  8096. requestingArgs = [...arguments];
  8097. return 12373;
  8098. };
  8099.  
  8100. const fakeFns = [
  8101. f.bind({ fn: requestAnimationFrame }),
  8102. f.bind({ fn: setInterval }),
  8103. f.bind({ fn: setTimeout }),
  8104. f.bind({ fn: requestIdleCallback })
  8105. ];
  8106.  
  8107. let mzt = 0;
  8108.  
  8109. let _fnSelectorProp = null;
  8110. const mkFns = new Array(4);
  8111.  
  8112. /*
  8113. case 1:
  8114. var a = this.K;
  8115. this.g = this.I ? window.requestIdleCallback(a, {
  8116. timeout: 3E3
  8117. }) : window.setTimeout(a, ma);
  8118. break;
  8119. case 2:
  8120. this.g = window.setTimeout(this.M, this.N);
  8121. break;
  8122. case 3:
  8123. this.g = window.requestAnimationFrame(this.L);
  8124. break;
  8125. case 4:
  8126. this.g = window.setTimeout(this.J, 0)
  8127. }
  8128.  
  8129. */
  8130. const startFnHandler = {
  8131. get(target, prop, receiver) {
  8132. if (prop === '$$12377$$') return true;
  8133. if (prop === '$$12378$$') return target;
  8134.  
  8135. // console.log('get',prop)
  8136. return target[prop]
  8137. },
  8138. set(target, prop, value, receiver) {
  8139. // console.log('set', prop, value)
  8140.  
  8141. if (value >= 1 && value <= 4) _fnSelectorProp = prop;
  8142. if (value === 12373 && _fnSelectorProp) {
  8143.  
  8144. const schedulerTypeSelection = target[_fnSelectorProp];
  8145. const timerIdProp = prop;
  8146.  
  8147. // if (schedulerTypeSelection && schedulerTypeSelection >= 1 && schedulerTypeSelection <= 4 && timerIdProp) {
  8148. // schedulerInstancePropOfTimerType = _fnSelectorProp || '';
  8149. // schedulerInstancePropOfTimerId = timerIdProp || '';
  8150. // }
  8151.  
  8152. if (schedulerTypeSelection === 3 && requestingFn === requestAnimationFrame) { // rAF(fn)
  8153. target[timerIdProp] = baseRAF.apply(window, requestingArgs);
  8154. } else if (schedulerTypeSelection === 2 && requestingFn === setTimeout) { // setTimeout(fn, delay)
  8155. // rare
  8156. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  8157. } else if (schedulerTypeSelection === 4 && requestingFn === setTimeout && !requestingArgs[1]) { // setTimeout(fn, 0)
  8158. // often
  8159. if ((FIX_schedulerInstanceInstance & 4)) {
  8160. const f = requestingArgs[0];
  8161. const tir = ++mzt;
  8162. nextBrowserTick_(() => {
  8163. if (target[timerIdProp] === -tir) f();
  8164. });
  8165. target[_fnSelectorProp] = 940;
  8166. target[timerIdProp] = -tir;
  8167. } else {
  8168. const f = requestingArgs[0];
  8169. const tir = ++mzt;
  8170. Promise.resolve().then(() => {
  8171. if (target[timerIdProp] === -tir) f();
  8172. });
  8173. target[_fnSelectorProp] = 930;
  8174. target[timerIdProp] = -tir;
  8175. }
  8176. } else if (schedulerTypeSelection === 1 && (requestingFn === requestIdleCallback || requestingFn === setTimeout)) { // setTimeout(requestIdleCallback)
  8177. // often
  8178. if (requestingFn === requestIdleCallback) {
  8179. target[timerIdProp] = requestIdleCallback.apply(window, requestingArgs);
  8180. } else {
  8181. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  8182. }
  8183. } else {
  8184. target[_fnSelectorProp] = 0;
  8185. target[timerIdProp] = 0;
  8186. }
  8187. } else {
  8188. target[prop] = value;
  8189. }
  8190. return true;
  8191. }
  8192. };
  8193.  
  8194. let startBusy = false;
  8195. schedulerInstanceInstance_.start = function () {
  8196. if (startBusy) return;
  8197. startBusy = true;
  8198. try {
  8199. mkFns[0] = window.requestAnimationFrame;
  8200. mkFns[1] = window.setInterval;
  8201. mkFns[2] = window.setTimeout;
  8202. mkFns[3] = window.requestIdleCallback;
  8203. const tThis = this['$$12378$$'] || this;
  8204. window.requestAnimationFrame = fakeFns[0]
  8205. window.setInterval = fakeFns[1]
  8206. window.setTimeout = fakeFns[2]
  8207. window.requestIdleCallback = fakeFns[3]
  8208. _fnSelectorProp = null;
  8209. tThis.start993.call(new Proxy(tThis, startFnHandler));
  8210. _fnSelectorProp = null;
  8211. window.requestAnimationFrame = mkFns[0];
  8212. window.setInterval = mkFns[1];
  8213. window.setTimeout = mkFns[2];
  8214. window.requestIdleCallback = mkFns[3];
  8215. } catch (e) {
  8216. console.warn(e);
  8217. }
  8218. startBusy = false;
  8219. }
  8220.  
  8221. schedulerInstanceInstance_.start.toString = schedulerInstanceInstance_.start993.toString.bind(schedulerInstanceInstance_.start993);
  8222.  
  8223. }
  8224. })();
  8225.  
  8226. FIX_yt_player && !isChatRoomURL && (async () => {
  8227.  
  8228. const fOption = 1 | 2 | 4;
  8229.  
  8230. const _yt_player = await _yt_player_observable.obtain();
  8231.  
  8232. if (!_yt_player || typeof _yt_player !== 'object') return;
  8233.  
  8234. const g = _yt_player;
  8235. let k;
  8236.  
  8237. if (fOption & 1) {
  8238.  
  8239. // rAf scheduling
  8240.  
  8241. const keyZqOu = getZqOu(_yt_player);
  8242. if (!keyZqOu) {
  8243. console.warn('[yt-js-engine-tamer] FIX_yt_player::keyZqOu error');
  8244. return;
  8245. }
  8246. k = keyZqOu
  8247.  
  8248. const gk = g[k];
  8249. if (typeof gk !== 'function') {
  8250. console.warn('[yt-js-engine-tamer] FIX_yt_player::g[keyZqOu] error');
  8251. return;
  8252. }
  8253. const gkp = gk.prototype;
  8254.  
  8255. const dummyObject = new gk;
  8256. const nilFunc = () => { };
  8257.  
  8258. const nilObj = {};
  8259.  
  8260. // console.log(1111111111)
  8261.  
  8262. let keyBoolD = '';
  8263. let keyWindow = '';
  8264. let keyFuncC = '';
  8265. let keyCidj = '';
  8266.  
  8267. for (const [t, y] of Object.entries(dummyObject)) {
  8268. if (y instanceof Window) keyWindow = t;
  8269. }
  8270.  
  8271. const dummyObjectProxyHandler = {
  8272. get(target, prop) {
  8273. let v = target[prop]
  8274. if (v instanceof Window && !keyWindow) {
  8275. keyWindow = t;
  8276. }
  8277. let y = typeof v === 'function' ? nilFunc : typeof v === 'object' ? nilObj : v;
  8278. if (prop === keyWindow) y = {
  8279. requestAnimationFrame(f) {
  8280. return 3;
  8281. },
  8282. cancelAnimationFrame() {
  8283.  
  8284. }
  8285. }
  8286. if (!keyFuncC && typeof v === 'function' && !(prop in target.constructor.prototype)) {
  8287. keyFuncC = prop;
  8288. }
  8289. // console.log('[get]', prop, typeof target[prop])
  8290.  
  8291.  
  8292. return y;
  8293. },
  8294. set(target, prop, value) {
  8295.  
  8296. if (typeof value === 'boolean' && !keyBoolD) {
  8297. keyBoolD = prop;
  8298. }
  8299. if (typeof value === 'number' && !keyCidj && value >= 2) {
  8300. keyCidj = prop;
  8301. }
  8302.  
  8303. // console.log('[set]', prop, value)
  8304. target[prop] = value;
  8305.  
  8306. return true;
  8307. }
  8308. };
  8309.  
  8310. dummyObject.start.call(new Proxy(dummyObject, dummyObjectProxyHandler));
  8311.  
  8312. // console.log('gkp.start',gkp.start);
  8313. // console.log('gkp.stop',gkp.stop);
  8314. gkp._activation = false;
  8315.  
  8316. gkp.start = function () {
  8317. // p59 || console.log(12100)
  8318. if (!this._activation) {
  8319. this._activation = true;
  8320. foregroundPromiseFn().then(() => {
  8321. this._activation = false;
  8322. if (this[keyCidj]) {
  8323. Promise.resolve().then(this[keyFuncC]);
  8324. }
  8325. });
  8326. }
  8327. this[keyCidj] = 1;
  8328. this[keyBoolD] = true;
  8329. };
  8330.  
  8331. gkp.stop = function () {
  8332. this[keyCidj] = null;
  8333. };
  8334.  
  8335.  
  8336. /*
  8337. g[k].start = function() {
  8338. this.stop();
  8339. this.D = true;
  8340. var a = requestAnimationFrame
  8341. , b = cancelAnimationFrame;
  8342. this.j = a.call(this.B, this.C)
  8343. }
  8344. ;
  8345. g[k].stop = function() {
  8346. if (this.isActive()) {
  8347. var a = requestAnimationFrame
  8348. , b = cancelAnimationFrame;
  8349. b.call(this.B, this.j)
  8350. }
  8351. this.j = null
  8352. }
  8353. */
  8354. }
  8355.  
  8356. if (fOption & 2) {
  8357. const keyzo = PERF_471489_ ? getzo(_yt_player) : null;
  8358.  
  8359. if (keyzo) {
  8360.  
  8361. k = keyzo;
  8362.  
  8363. const attrUpdateFn = g[k];
  8364. // console.log(5992, attrUpdateFn)
  8365. g['$$original$$' + k] = attrUpdateFn;
  8366. const zoTransform = async (a, c) => {
  8367.  
  8368. let transformType = '';
  8369. let transformValue = 0;
  8370. let transformUnit = '';
  8371. let transformTypeI = 0;
  8372.  
  8373. const aStyle = a.style;
  8374.  
  8375. let cType = 0;
  8376.  
  8377. const cl = c.length;
  8378.  
  8379. if (cl >= 8) {
  8380. // scale(1)
  8381. if (c.startsWith('scale') && c.charCodeAt(6) === 40 && c.charCodeAt(cl - 1) === 41) {
  8382. cType = 1;
  8383. let t = c.charCodeAt(5);
  8384. if (t === 88 || t === 120) cType = 1 | 4;
  8385. if (t === 89 || t === 121) cType = 1 | 8;
  8386. } else if (c.startsWith('translate') && c.charCodeAt(10) === 40 && c.charCodeAt(cl - 1) === 41) {
  8387. cType = 2;
  8388. let t = c.charCodeAt(9);
  8389. if (t === 88 || t === 120) cType = 2 | 4;
  8390. if (t === 89 || t === 121) cType = 2 | 8;
  8391. }
  8392. let w = 0;
  8393. if (w = (cType === 5) ? 1 : (cType === 9) ? 2 : 0) {
  8394. let p = c.substring(7, cl - 1);
  8395. let q = p.length >= 1 ? parseFloat(p) : NaN;
  8396. if (typeof q === 'number' && !isNaNx(q)) {
  8397. transformType = w === 1 ? 'scaleX' : 'scaleY';
  8398. transformValue = q;
  8399. transformUnit = '';
  8400. transformTypeI = 1;
  8401. } else {
  8402. cType = 256;
  8403. }
  8404. } else if (w = (cType === 6) ? 1 : (cType === 10) ? 2 : 0) {
  8405. if (c.endsWith('px)')) {
  8406. let p = c.substring(11, cl - 3);
  8407. let q = p.length >= 1 ? parseFloat(p) : NaN;
  8408. if (typeof q === 'number' && !isNaNx(q)) {
  8409. transformType = w === 1 ? 'translateX' : 'translateY';
  8410. transformValue = q;
  8411. transformUnit = 'px';
  8412. transformTypeI = 2;
  8413. } else if (p === 'NaN') {
  8414. return;
  8415. }
  8416. } else {
  8417. cType = 256;
  8418. }
  8419. } else if (cType > 0) {
  8420. cType = 256;
  8421. }
  8422. }
  8423.  
  8424.  
  8425. if (cType === 256) {
  8426. console.log('[yt-js-engine-tamer] zoTransform undefined', c);
  8427. }
  8428.  
  8429. if (transformTypeI === 1) {
  8430. const q = Math.round(transformValue * steppingScaleN) / steppingScaleN;
  8431. const vz = toFixed2(q, 3);
  8432. c = `${transformType}(${vz})`;
  8433. const cv = aStyle.transform;
  8434. if (c === cv) return;
  8435. aStyle.transform = c;
  8436. } else if (transformTypeI === 2) {
  8437. const q = transformValue;
  8438. const vz = toFixed2(q, 1);
  8439. c = `${transformType}(${vz}${transformUnit})`;
  8440. const cv = aStyle.transform;
  8441. if (c === cv) return;
  8442. aStyle.transform = c;
  8443. } else { // eg empty
  8444. const cv = aStyle.transform;
  8445. if (!c && !cv) return;
  8446. else if (c === cv) return;
  8447. aStyle.transform = c;
  8448. }
  8449.  
  8450. };
  8451.  
  8452. const elmTransformTemp = new WeakMap();
  8453. const elmPropTemps = {
  8454. 'display': new WeakMap(),
  8455. 'width': new WeakMap(),
  8456. 'height': new WeakMap(),
  8457. 'outlineWidth': new WeakMap(),
  8458. 'position': new WeakMap(),
  8459. 'padding': new WeakMap(),
  8460. "cssText": new WeakMap(),
  8461. "right": new WeakMap(),
  8462. "left": new WeakMap(),
  8463. "top": new WeakMap(),
  8464. "bottom": new WeakMap(),
  8465. "transitionDelay": new WeakMap(),
  8466. "marginLeft": new WeakMap(),
  8467. "marginTop": new WeakMap(),
  8468. "marginRight": new WeakMap(),
  8469. "marginBottom": new WeakMap(),
  8470. }
  8471.  
  8472. const ns5 = Symbol();
  8473. const nextModify = (a, c, m, f, immediate) => {
  8474. const a_ = a;
  8475. const m_ = m;
  8476. const noKey = !m_.has(a_);
  8477. if (immediate || noKey) {
  8478. m_.set(a_, ns5);
  8479. f(a_, c);
  8480. noKey && nextBrowserTick_(() => {
  8481. const d = m_.get(a_);
  8482. if (d === undefined) return;
  8483. m_.delete(a_);
  8484. if (d !== ns5) f(a_, d);
  8485. });
  8486. } else {
  8487. m_.set(a_, c);
  8488. }
  8489. };
  8490.  
  8491. const set66 = new Set();
  8492. const log77 = new Map();
  8493. // const set77 = new Set(['top', 'left', 'bottom', 'right']); // caption positioning - immediate change
  8494.  
  8495. const modifiedFn = function (a, b, c, immediateChange = false) { // arrow function does not have function.prototype
  8496.  
  8497. // console.log(140000, a, b, c);
  8498. if (typeof c === 'number' && typeof b === 'string' && a instanceof HTMLElement_) {
  8499. const num = c;
  8500. c = `${num}`;
  8501. if (c.length > 5) c = (num < 10 && num > -10) ? toFixed2(num, 3) : toFixed2(num, 1);
  8502. }
  8503.  
  8504. if (typeof b === 'string' && typeof c === 'string' && a instanceof HTMLElement_) {
  8505.  
  8506. let elmPropTemp = null;
  8507.  
  8508. if (b === "transform") {
  8509. // div.ytp-hover-progress.ytp-hover-progress-light
  8510. // div.ytp-play-progress.ytp-swatch-background-color
  8511.  
  8512. nextModify(a, c, elmTransformTemp, zoTransform, immediateChange);
  8513. return;
  8514.  
  8515. } else if (elmPropTemp = elmPropTemps[b]) {
  8516.  
  8517. // if (c.length > 5 && c.includes('.')) {
  8518. // console.log(123213, c)
  8519. // }
  8520.  
  8521. const b_ = b;
  8522. nextModify(a, c, elmPropTemp, (a, c) => {
  8523. const style = a.style;
  8524. const cv = style[b_];
  8525. if (!cv && !c) return;
  8526. if (cv === c) return;
  8527. style[b_] = c;
  8528. }, immediateChange);
  8529. return;
  8530.  
  8531. } else if (b === "outline-width") {
  8532.  
  8533. const b_ = 'outlineWidth';
  8534. elmPropTemp = elmPropTemps[b_];
  8535. nextModify(a, c, elmPropTemp, (a, c) => {
  8536. const style = a.style;
  8537. const cv = style[b_];
  8538. if (!cv && !c) return;
  8539. if (cv === c) return;
  8540. style[b_] = c;
  8541. }, immediateChange);
  8542. return;
  8543.  
  8544. } else if (b === 'maxWidth' || b === 'maxHeight') {
  8545. // I think these can be directly assigned.
  8546.  
  8547. const b_ = b;
  8548. const style = a.style;
  8549. const cv = style[b_];
  8550. if (!cv && !c) return;
  8551. if (cv === c) return;
  8552. style[b_] = c;
  8553. return;
  8554.  
  8555. } else {
  8556. // if(immediate && elmPropTemps[b]){
  8557. // console.log(5191, b)
  8558. // }
  8559. // caption-window
  8560. // margin-left max-height max-width font-family fill color font-size background white-space margin
  8561. // text-align background-color
  8562. // console.log(27304, a, b, c)
  8563. if (!set66.has(b)) {
  8564. set66.add(b);
  8565. nextBrowserTick_(() => {
  8566. if (!a.classList.contains('caption-window') && !a.classList.contains('ytp-caption-segment')) {
  8567. console.log(27304, a, b, c)
  8568. }
  8569. })
  8570. }
  8571. }
  8572.  
  8573. attrUpdateFn.call(this, a, b, c);
  8574. return;
  8575. } else if (typeof (b || 0) === 'object') {
  8576.  
  8577. // this is to fix caption positioning
  8578. // const immediate = (a.id || 0).length > 14 && (('top' in b) || ('left' in b) || ('right' in b) || ('bottom' in b));
  8579. const immediate = (a.id || 0).length > 14;
  8580. for (const [k, v] of Object.entries(b)) {
  8581. modifiedFn.call(this, a, k, v, immediate);
  8582. }
  8583.  
  8584. } else {
  8585.  
  8586. // a = circle, b = stroke-dasharray, c= "1.8422857142857143 32"
  8587. // ytp-ad-timed-pie-countdown-inner
  8588.  
  8589. if (typeof b === 'string') {
  8590.  
  8591. let m = log77.get(b);
  8592. if (!m) {
  8593. m = [];
  8594. console.log('attrUpdateFn.debug.27304', m);
  8595. log77.set(b, m);
  8596. }
  8597. m.push([a, b, c]);
  8598.  
  8599. } else {
  8600. console.log('attrUpdateFn.debug.27306', a, b, c);
  8601. }
  8602.  
  8603. attrUpdateFn.call(this, a, b, c);
  8604. return;
  8605. }
  8606.  
  8607. // console.log(130000, a, b, c);
  8608.  
  8609. };
  8610. g[k] = modifiedFn;
  8611.  
  8612.  
  8613. /*
  8614.  
  8615. g.zo = function(a, b, c) {
  8616. if ("string" === typeof b)
  8617. (b = yo(a, b)) && (a.style[b] = c);
  8618. else
  8619. for (var d in b) {
  8620. c = a;
  8621. var e = b[d]
  8622. , f = yo(c, d);
  8623. f && (c.style[f] = e)
  8624. }
  8625. }
  8626.  
  8627.  
  8628. */
  8629.  
  8630.  
  8631. }
  8632. }
  8633.  
  8634. if (fOption & 4) {
  8635. const keyuG = PERF_471489_ ? getuG(_yt_player) : null;
  8636.  
  8637. if (keyuG) {
  8638.  
  8639. k = keyuG;
  8640.  
  8641. const gk = g[k];
  8642. const gkp = gk.prototype;
  8643.  
  8644.  
  8645. /** @type { Map<string, WeakMap<any, any>> } */
  8646. const ntLogs = new Map();
  8647.  
  8648. if (typeof gkp.updateValue === 'function' && gkp.updateValue.length === 2 && !gkp.updateValue31) {
  8649.  
  8650. gkp.updateValue31 = gkp.updateValue;
  8651. gkp.updateValue = function (a, b) {
  8652. if (typeof a !== 'string') return this.updateValue31(a, b);
  8653.  
  8654. const element = this.element;
  8655. if (!(element instanceof HTMLElement_)) return this.updateValue31(a, b);
  8656.  
  8657. let ntLog = ntLogs.get(a);
  8658. if (!ntLog) ntLogs.set(a, (ntLog = new WeakMap()));
  8659.  
  8660. let cache = ntLog.get(element);
  8661. if (cache && cache.value === b) {
  8662. return;
  8663. }
  8664. if (!cache) {
  8665. this.__oldValueByUpdateValue__ = null;
  8666. ntLog.set(element, cache = { value: b });
  8667. } else {
  8668. this.__oldValueByUpdateValue__ = cache.value;
  8669. cache.value = b;
  8670. }
  8671.  
  8672. return this.updateValue31(a, b);
  8673. }
  8674.  
  8675. /*
  8676. g.k.update = function(a) {
  8677. for (var b = g.u(Object.keys(a)), c = b.next(); !c.done; c = b.next())
  8678. c = c.value,
  8679. this.updateValue(c, a[c])
  8680. }
  8681. ;
  8682. g.k.updateValue = function(a, b) {
  8683. (a = this.Td["{{" + a + "}}"]) && wG(this, a[0], a[1], b)
  8684. }
  8685. */
  8686.  
  8687. }
  8688.  
  8689.  
  8690. }
  8691. }
  8692.  
  8693.  
  8694.  
  8695. })();
  8696.  
  8697.  
  8698. FIX_yt_player && !isChatRoomURL && FIX_SHORTCUTKEYS > 0 && (async () => {
  8699. // keyboard shortcut keys controller
  8700.  
  8701. const _yt_player = await _yt_player_observable.obtain();
  8702.  
  8703. if (!_yt_player || typeof _yt_player !== 'object') return;
  8704.  
  8705. keyboardController(_yt_player);
  8706.  
  8707. })();
  8708.  
  8709. FIX_yt_player && !isChatRoomURL && (async () => {
  8710. // timer scheduling
  8711.  
  8712. const _yt_player = await _yt_player_observable.obtain();
  8713.  
  8714. if (!_yt_player || typeof _yt_player !== 'object') return;
  8715.  
  8716. let keyZqQu = getZqQu(_yt_player);
  8717.  
  8718. if (!keyZqQu) return;
  8719.  
  8720. const g = _yt_player
  8721. let k = keyZqQu
  8722.  
  8723. const gk = g[k];
  8724. if (typeof gk !== 'function') return;
  8725. const gkp = gk.prototype;
  8726.  
  8727. const extractKeysZqQu = () => {
  8728.  
  8729.  
  8730. let _keyeC = '';
  8731. try {
  8732. gkp.stop.call(new Proxy({
  8733. isActive: () => { }
  8734. }, {
  8735. set(target, prop, value) {
  8736. if (value === 0) _keyeC = prop;
  8737. return true;
  8738. }
  8739. }));
  8740. } catch (e) { }
  8741. if (!_keyeC) return;
  8742. const keyeC = _keyeC;
  8743.  
  8744. let keyC = ''; // this.C = this.ST.bind(this)
  8745. let keyhj = ''; // 1000ms
  8746. try {
  8747. gkp.start.call(new Proxy({
  8748. stop: () => { },
  8749. [keyeC]: 0,
  8750. }, {
  8751. get(target, prop) {
  8752. if (prop in target) return target[prop];
  8753. if (!keyC) {
  8754. keyC = prop;
  8755. return null; // throw error
  8756. }
  8757. else if (!keyhj) {
  8758. keyhj = prop;
  8759. }
  8760.  
  8761. }
  8762. }));
  8763. } catch (e) {
  8764. if (!keyC || !keyhj) {
  8765. console.log(e)
  8766. }
  8767. }
  8768.  
  8769. if (!keyC || !keyhj) return;
  8770. let keyST = '';
  8771. let keyj = '';
  8772. let keyB = '';
  8773. let keyxa = '';
  8774.  
  8775. const possibleKs = new Set();
  8776.  
  8777. for (const [k, v] of Object.entries(gkp)) {
  8778. if (k === 'stop' || k === 'start' || k === 'isActive' || k === 'constructor' || k === keyeC || k === keyC || k === keyhj) {
  8779. continue;
  8780. }
  8781. if (typeof v === 'function') {
  8782. const m = /this\.(\w+)\.call\(this\.(\w+)\)/.exec(v + '');
  8783. if (m) {
  8784. keyST = k;
  8785. keyj = m[1];
  8786. keyB = m[2];
  8787. } else {
  8788. possibleKs.add(k);
  8789. }
  8790. }
  8791. }
  8792.  
  8793. if (!keyST || !keyj || !keyB) return;
  8794.  
  8795. for (const k of possibleKs) {
  8796. if (k === keyST || k === keyj || k === keyB) {
  8797. continue;
  8798. }
  8799. const v = gkp[k];
  8800. if (typeof v === 'function' && (v + '').includes(`this.stop();delete this.${keyj};delete this.${keyB}`)) {
  8801. keyxa = k;
  8802. }
  8803. }
  8804.  
  8805. return [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa];
  8806.  
  8807. }
  8808.  
  8809. const keys = extractKeysZqQu();
  8810. if (!keys || !keys.length) return;
  8811. const [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa] = keys; // [timerId, binded executorFn, 1000ms, executorFn, dataJ, objectB, disposeFn]
  8812.  
  8813. if (!keyeC || !keyC || !keyhj || !keyST || !keyj || !keyB || !keyxa) return;
  8814.  
  8815. let disposeKeys = null;
  8816.  
  8817. gkp[keyxa] = function () {
  8818. // dispose
  8819. if (!disposeKeys) {
  8820. disposeKeys = Object.getOwnPropertyNames(this).filter(key => {
  8821. if (key != keyeC && key != keyC && key != keyhj && key != keyST && key != keyj && key != keyB && key != keyxa) {
  8822. const t = typeof this[key];
  8823. return t === 'undefined' || t === 'object'
  8824. }
  8825. return false;
  8826. });
  8827. }
  8828. for (const key of disposeKeys) {
  8829. const v = this[key];
  8830. if ((v || 0).length >= 1) v.length = 0; // function (){if(this.fn)for(;this.fn.length;)this.fn.shift()()}
  8831. }
  8832. if (this[keyeC] > 0) this.stop();
  8833. this[keyj] = null;
  8834. this[keyB] = null;
  8835. };
  8836.  
  8837. gkp.start = function (a) {
  8838. if (this[keyeC] > 0) this.stop();
  8839. const delay = void 0 !== a ? a : this[keyhj];
  8840. this[keyeC] = window.setTimeout(this[keyC], delay);
  8841. };
  8842. gkp.stop = function () {
  8843. if (this[keyeC] > 0) {
  8844. window.clearTimeout(this[keyeC]);
  8845. this[keyeC] = 0;
  8846. }
  8847. };
  8848.  
  8849. gkp.isActive = function () {
  8850. return this[keyeC] > 0;
  8851. };
  8852.  
  8853. gkp[keyST] = function () {
  8854. this.stop(); // this[keyeC] = 0;
  8855. const fn = this[keyj];
  8856. const obj = this[keyB];
  8857. let skip = false;
  8858. if (!fn) skip = true;
  8859. else if (IGNORE_bufferhealth_CHECK && obj) {
  8860. let m;
  8861. if ((m = obj[keyC]) instanceof Map || (m = obj[keyj]) instanceof Map) {
  8862. if (m.has("bufferhealth")) skip = true;
  8863. }
  8864. }
  8865. if (!skip) {
  8866. fn.call(obj);
  8867. }
  8868. };
  8869.  
  8870.  
  8871.  
  8872.  
  8873. /*
  8874.  
  8875. g.k.eC = 0;
  8876. g.k.xa = function() {
  8877. g.Qu.Vf.xa.call(this);
  8878. this.stop();
  8879. delete this.j;
  8880. delete this.B
  8881. }
  8882. ;
  8883. g.k.start = function(a) {
  8884. this.stop();
  8885. this.eC = g.gg(this.C, void 0 !== a ? a : this.hj)
  8886. }
  8887. ;
  8888. g.k.stop = function() {
  8889. this.isActive() && g.Sa.clearTimeout(this.eC);
  8890. this.eC = 0
  8891. }
  8892. ;
  8893. g.k.isActive = function() {
  8894. return 0 != this.eC
  8895. }
  8896. ;
  8897. g.k.ST = function() {
  8898. this.eC = 0;
  8899. this.j && this.j.call(this.B)
  8900. }
  8901. ;
  8902. */
  8903.  
  8904.  
  8905.  
  8906.  
  8907. })();
  8908.  
  8909. FIX_Animation_n_timeline && (async () => {
  8910.  
  8911. const [timeline, Animation] = await Promise.all([timelineObservable.obtain(), animationObservable.obtain()]);
  8912.  
  8913. if (!timeline || !Animation) return;
  8914.  
  8915. const aniProto = Animation.prototype;
  8916. // aniProto.sequenceNumber = 0; // native YouTube engine bug - sequenceNumber is not set
  8917.  
  8918. const getXroto = (x) => {
  8919. try {
  8920. return x.__proto__;
  8921. } catch (e) { }
  8922. return null;
  8923. }
  8924. const timProto = getXroto(timeline);
  8925. if (!timProto) return;
  8926. if (
  8927. (
  8928. typeof timProto.getAnimations === 'function' && typeof timProto.play === 'function' &&
  8929. typeof timProto._discardAnimations === 'function' && typeof timProto._play === 'function' &&
  8930. typeof timProto._updateAnimationsPromises === 'function' && !timProto.nofCQ &&
  8931. typeof aniProto._updatePromises === 'function' && !aniProto.nofYH
  8932. )
  8933.  
  8934. ) {
  8935.  
  8936. timProto.nofCQ = 1;
  8937. aniProto.nofYH = 1;
  8938.  
  8939. const originalAnimationsWithPromises = ((_updateAnimationsPromises) => {
  8940.  
  8941.  
  8942. /*
  8943. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  8944. return c._updatePromises();
  8945. });
  8946. */
  8947.  
  8948. const p = Array.prototype.filter;
  8949.  
  8950. let res = null;
  8951. Array.prototype.filter = function () {
  8952.  
  8953. res = this;
  8954. return this;
  8955.  
  8956. };
  8957.  
  8958. _updateAnimationsPromises.call({});
  8959.  
  8960. Array.prototype.filter = p;
  8961.  
  8962. if (res && typeof res.length === 'number') {
  8963. /** @type {any[]} */
  8964. const _res = res;
  8965. return _res;
  8966. }
  8967.  
  8968.  
  8969. return null;
  8970.  
  8971.  
  8972.  
  8973.  
  8974. })(timProto._updateAnimationsPromises);
  8975.  
  8976. if (!originalAnimationsWithPromises || typeof originalAnimationsWithPromises.length !== 'number') return;
  8977.  
  8978. // console.log('originalAnimationsWithPromises', originalAnimationsWithPromises)
  8979.  
  8980. aniProto._updatePromises31 = aniProto._updatePromises;
  8981.  
  8982. /*
  8983. aniProto._updatePromises = function(){
  8984. console.log('eff',this._oldPlayState, this.playState)
  8985. return this._updatePromises31.apply(this, arguments)
  8986. }
  8987. */
  8988.  
  8989. aniProto._updatePromises = function () {
  8990. var oldPlayState = this._oldPlayState;
  8991. var newPlayState = this.playState;
  8992. // console.log('ett', oldPlayState, newPlayState)
  8993. if (newPlayState !== oldPlayState) {
  8994. this._oldPlayState = newPlayState;
  8995. if (this._readyPromise) {
  8996. if ("idle" == newPlayState) {
  8997. this._rejectReadyPromise();
  8998. this._readyPromise = void 0;
  8999. } else if ("pending" == oldPlayState) {
  9000. this._resolveReadyPromise();
  9001. } else if ("pending" == newPlayState) {
  9002. this._readyPromise = void 0;
  9003. }
  9004. }
  9005. if (this._finishedPromise) {
  9006. if ("idle" == newPlayState) {
  9007. this._rejectFinishedPromise();
  9008. this._finishedPromise = void 0;
  9009. } else if ("finished" == newPlayState) {
  9010. this._resolveFinishedPromise();
  9011. } else if ("finished" == oldPlayState) {
  9012. this._finishedPromise = void 0;
  9013. }
  9014. }
  9015. }
  9016. return this._readyPromise || this._finishedPromise;
  9017. };
  9018.  
  9019.  
  9020. let restartWebAnimationsNextTickFlag = false;
  9021.  
  9022. const looperMethodT = () => {
  9023.  
  9024. const runnerFn = (hRes) => {
  9025. var b = timeline;
  9026. b.currentTime = hRes;
  9027. b._discardAnimations();
  9028. if (0 == b._animations.length) {
  9029. restartWebAnimationsNextTickFlag = false;
  9030. } else {
  9031. getRafPromise().then(runnerFn);
  9032. }
  9033. }
  9034.  
  9035. const restartWebAnimationsNextTick = () => {
  9036. if (!restartWebAnimationsNextTickFlag) {
  9037. restartWebAnimationsNextTickFlag = true;
  9038. getRafPromise().then(runnerFn);
  9039. }
  9040. }
  9041.  
  9042. return { restartWebAnimationsNextTick }
  9043. };
  9044.  
  9045.  
  9046. const looperMethodN = () => {
  9047.  
  9048. const acs = document.createElement('a-f');
  9049. acs.id = 'a-f';
  9050.  
  9051. if (!document.getElementById('afscript')) {
  9052. const style = document.createElement('style');
  9053. style.id = 'afscript';
  9054. style.textContent = `
  9055. @keyFrames aF1 {
  9056. 0% {
  9057. order: 0;
  9058. }
  9059. 100% {
  9060. order: 1;
  9061. }
  9062. }
  9063. #a-f[id] {
  9064. visibility: collapse !important;
  9065. position: fixed !important;
  9066. display: block !important;
  9067. top: -100px !important;
  9068. left: -100px !important;
  9069. margin:0 !important;
  9070. padding:0 !important;
  9071. outline:0 !important;
  9072. border:0 !important;
  9073. z-index:-1 !important;
  9074. width: 0px !important;
  9075. height: 0px !important;
  9076. contain: strict !important;
  9077. pointer-events: none !important;
  9078. animation: 1ms steps(2, jump-none) 0ms infinite alternate forwards running aF1 !important;
  9079. }
  9080. `;
  9081. (document.head || document.documentElement).appendChild(style);
  9082. }
  9083.  
  9084. document.documentElement.insertBefore(acs, document.documentElement.firstChild);
  9085.  
  9086. const _onanimationiteration = function (evt) {
  9087. const hRes = evt.timeStamp;
  9088. var b = timeline;
  9089. b.currentTime = hRes;
  9090. b._discardAnimations();
  9091. if (0 == b._animations.length) {
  9092. restartWebAnimationsNextTickFlag = false;
  9093. acs.onanimationiteration = null;
  9094. } else {
  9095. acs.onanimationiteration = _onanimationiteration;
  9096. }
  9097.  
  9098. }
  9099.  
  9100.  
  9101.  
  9102. const restartWebAnimationsNextTick = () => {
  9103. if (!restartWebAnimationsNextTickFlag) {
  9104. restartWebAnimationsNextTickFlag = true;
  9105. acs.onanimationiteration = _onanimationiteration;
  9106.  
  9107. }
  9108. }
  9109.  
  9110. return { restartWebAnimationsNextTick }
  9111. };
  9112.  
  9113.  
  9114.  
  9115. const { restartWebAnimationsNextTick } = ('onanimationiteration' in document.documentElement) ? looperMethodN() : looperMethodT();
  9116.  
  9117.  
  9118. // console.log(571, timProto);
  9119. timProto._play = function (c) {
  9120. c = new Animation(c, this);
  9121. this._animations.push(c);
  9122. restartWebAnimationsNextTick();
  9123. c._updatePromises();
  9124. c._animation.play();
  9125. c._updatePromises();
  9126. return c
  9127. }
  9128.  
  9129. const animationsWithPromisesMap = new Set(originalAnimationsWithPromises);
  9130. originalAnimationsWithPromises.length = 0;
  9131. originalAnimationsWithPromises.push = null;
  9132. originalAnimationsWithPromises.splice = null;
  9133. originalAnimationsWithPromises.slice = null;
  9134. originalAnimationsWithPromises.indexOf = null;
  9135. originalAnimationsWithPromises.unshift = null;
  9136. originalAnimationsWithPromises.shift = null;
  9137. originalAnimationsWithPromises.pop = null;
  9138. originalAnimationsWithPromises.filter = null;
  9139. originalAnimationsWithPromises.forEach = null;
  9140. originalAnimationsWithPromises.map = null;
  9141.  
  9142.  
  9143. const _updateAnimationsPromises = () => {
  9144. animationsWithPromisesMap.forEach(c => {
  9145. if (!c._updatePromises()) animationsWithPromisesMap.delete(c);
  9146. });
  9147. /*
  9148. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  9149. return c._updatePromises();
  9150. });
  9151. */
  9152. }
  9153.  
  9154. timProto._updateAnimationsPromises31 = timProto._updateAnimationsPromises;
  9155.  
  9156. timProto._updateAnimationsPromises = _updateAnimationsPromises;
  9157.  
  9158. delete timProto._updateAnimationsPromises;
  9159. Object.defineProperty(timProto, '_updateAnimationsPromises', {
  9160. get() {
  9161. if (animationsWithPromisesMap.size === 0) return nilFn;
  9162. return _updateAnimationsPromises;
  9163. },
  9164. set(nv) {
  9165. delete this._updateAnimationsPromises;
  9166. this._updateAnimationsPromises = nv;
  9167. },
  9168. enumerable: true,
  9169. configurable: true,
  9170. });
  9171.  
  9172.  
  9173. let pdFinished = Object.getOwnPropertyDescriptor(aniProto, 'finished');
  9174. aniProto.__finished_native_get__ = pdFinished.get;
  9175. if (typeof pdFinished.get === 'function' && !pdFinished.set && pdFinished.configurable === true && pdFinished.enumerable === true) {
  9176.  
  9177.  
  9178. Object.defineProperty(aniProto, 'finished', {
  9179. get() {
  9180. this._finishedPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  9181. this._finishedPromise = new Promise((resolve, reject) => {
  9182. this._resolveFinishedPromise = function () {
  9183. resolve(this)
  9184. };
  9185. this._rejectFinishedPromise = function () {
  9186. reject({
  9187. type: DOMException.ABORT_ERR,
  9188. name: "AbortError"
  9189. })
  9190. };
  9191. }),
  9192. "finished" == this.playState && this._resolveFinishedPromise());
  9193. return this._finishedPromise
  9194. },
  9195. set: undefined,
  9196. enumerable: true,
  9197. configurable: true
  9198. });
  9199.  
  9200. }
  9201.  
  9202.  
  9203.  
  9204. let pdReady = Object.getOwnPropertyDescriptor(aniProto, 'ready');
  9205. aniProto.__ready_native_get__ = pdReady.get;
  9206. if (typeof pdReady.get === 'function' && !pdReady.set && pdReady.configurable === true && pdReady.enumerable === true) {
  9207.  
  9208. Object.defineProperty(aniProto, 'ready', {
  9209. get() {
  9210. this._readyPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  9211. this._readyPromise = new Promise((resolve, reject) => {
  9212. this._resolveReadyPromise = function () {
  9213. resolve(this)
  9214. };
  9215. this._rejectReadyPromise = function () {
  9216. reject({
  9217. type: DOMException.ABORT_ERR,
  9218. name: "AbortError"
  9219. })
  9220. };
  9221. }),
  9222. "pending" !== this.playState && this._resolveReadyPromise());
  9223. return this._readyPromise
  9224. },
  9225. set: undefined,
  9226. enumerable: true,
  9227. configurable: true
  9228. });
  9229.  
  9230. }
  9231.  
  9232.  
  9233. if (IGNORE_bindAnimationForCustomEffect && typeof aniProto._rebuildUnderlyingAnimation === 'function' && !aniProto._rebuildUnderlyingAnimation21 && aniProto._rebuildUnderlyingAnimation.length === 0) {
  9234.  
  9235. aniProto._rebuildUnderlyingAnimation21 = aniProto._rebuildUnderlyingAnimation;
  9236. const _rebuildUnderlyingAnimation = function () {
  9237. // if (isNaN(this._sequenceNumber)) return; // do not rebuild underlying animation if native animation is used.
  9238. this.effect && this.effect._onsample && (this.effect._onsample = null);
  9239. return this._rebuildUnderlyingAnimation21();
  9240. }
  9241. aniProto._rebuildUnderlyingAnimation = _rebuildUnderlyingAnimation;
  9242. // delete aniProto._rebuildUnderlyingAnimation;
  9243. // Object.defineProperty(aniProto, '_rebuildUnderlyingAnimation', {
  9244. // get() {
  9245. // if (isNaN(this._sequenceNumber)) return nilFn;
  9246. // return this._rebuildUnderlyingAnimation21;
  9247. // },
  9248. // set(nv) {
  9249. // delete this._rebuildUnderlyingAnimation;
  9250. // this._rebuildUnderlyingAnimation = nv;
  9251. // },
  9252. // enumerable: true,
  9253. // configurable: true
  9254. // });
  9255. }
  9256.  
  9257.  
  9258. /*
  9259.  
  9260.  
  9261. function f(c) {
  9262. var b = v.timeline;
  9263. b.currentTime = c;
  9264. b._discardAnimations();
  9265. 0 == b._animations.length ? d = !1 : requestAnimationFrame(f)
  9266. }
  9267. var h = window.requestAnimationFrame;
  9268. window.requestAnimationFrame = function(c) {
  9269. return h(function(b) {
  9270. v.timeline._updateAnimationsPromises();
  9271. c(b);
  9272. v.timeline._updateAnimationsPromises()
  9273. })
  9274. }
  9275. ;
  9276. v.AnimationTimeline = function() {
  9277. this._animations = [];
  9278. this.currentTime = void 0
  9279. }
  9280. ;
  9281. v.AnimationTimeline.prototype = {
  9282. getAnimations: function() {
  9283. this._discardAnimations();
  9284. return this._animations.slice()
  9285. },
  9286. _updateAnimationsPromises: function() {
  9287. v.animationsWithPromises = v.animationsWithPromises.filter(function(c) {
  9288. return c._updatePromises()
  9289. })
  9290. },
  9291. _discardAnimations: function() {
  9292. this._updateAnimationsPromises();
  9293. this._animations = this._animations.filter(function(c) {
  9294. return "finished" != c.playState && "idle" != c.playState
  9295. })
  9296. },
  9297. _play: function(c) {
  9298. c = new v.Animation(c,this);
  9299. this._animations.push(c);
  9300. v.restartWebAnimationsNextTick();
  9301. c._updatePromises();
  9302. c._animation.play();
  9303. c._updatePromises();
  9304. return c
  9305. },
  9306. play: function(c) {
  9307. c && c.remove();
  9308. return this._play(c)
  9309. }
  9310. };
  9311. var d = !1;
  9312. v.restartWebAnimationsNextTick = function() {
  9313. d || (d = !0,
  9314. requestAnimationFrame(f))
  9315. }
  9316. ;
  9317. var a = new v.AnimationTimeline;
  9318. v.timeline = a;
  9319. try {
  9320. Object.defineProperty(window.document, "timeline", {
  9321. configurable: !0,
  9322. get: function() {
  9323. return a
  9324. }
  9325. })
  9326. } catch (c) {}
  9327. try {
  9328. window.document.timeline = a
  9329. } catch (c) {}
  9330.  
  9331. */
  9332.  
  9333.  
  9334.  
  9335. /*
  9336.  
  9337. var g = window.getComputedStyle;
  9338. Object.defineProperty(window, "getComputedStyle", {
  9339. configurable: !0,
  9340. enumerable: !0,
  9341. value: function() {
  9342. v.timeline._updateAnimationsPromises();
  9343. var e = g.apply(this, arguments);
  9344. h() && (e = g.apply(this, arguments));
  9345. v.timeline._updateAnimationsPromises();
  9346. return e
  9347. }
  9348. });
  9349.  
  9350. */
  9351.  
  9352.  
  9353.  
  9354.  
  9355. }
  9356.  
  9357.  
  9358.  
  9359.  
  9360. })();
  9361.  
  9362. !isUrlInEmbed && Promise.resolve().then(() => {
  9363.  
  9364. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  9365.  
  9366.  
  9367.  
  9368. class LimitedSizeSet extends Set {
  9369. constructor(n) {
  9370. super();
  9371. this.limit = n;
  9372. }
  9373.  
  9374. add(key) {
  9375. if (!super.has(key)) {
  9376. super.add(key);
  9377. let n = super.size - this.limit;
  9378. if (n > 0) {
  9379. const iterator = super.values();
  9380. do {
  9381. const firstKey = iterator.next().value; // Get the first (oldest) key
  9382. super.delete(firstKey); // Delete the oldest key
  9383. } while (--n > 0)
  9384. }
  9385. }
  9386. }
  9387.  
  9388. removeAdd(key) {
  9389. super.delete(key);
  9390. this.add(key);
  9391. }
  9392.  
  9393. }
  9394.  
  9395. // const wk3 = new WeakMap();
  9396.  
  9397. // let mtxVideoId = '';
  9398. // let aje3 = [];
  9399. const mfvContinuationRecorded = new LimitedSizeSet(8); // record all success continuation keys
  9400. const mfyContinuationIgnored = new LimitedSizeSet(8); // ignore continuation keys by copying the keys in the past
  9401. let mtzlastAllowedContinuation = ''; // the key stored at the last success; clear when scheduling changes
  9402. let mtzCount = 0; // the key keeps unchanged
  9403. // let mjtNextMainKey = '';
  9404. let mjtRecordedPrevKey = ''; // the key stored at the last success (no clear)
  9405. let mjtLockPreviousKey = ''; // the key before fetch() should be discarded. (uncertain continuation)
  9406. let mbCId322 = 0; // cid for delay fetchUpdatedMetadata
  9407. // let allowNoDelay322=false;
  9408. let mbDelayBelowNCalls = 0; // after N calls, by pass delay; reset when scheduling changes
  9409.  
  9410. let mpKey22 = ''; // last success continutation key & url pair
  9411. let mpUrl22 = ''; // last success continutation key & url pair
  9412. let mpKey21 = ''; // latest requested continutation key & url pair
  9413. let mpUrl21 = ''; // latest requested continutation key & url pair
  9414.  
  9415.  
  9416. async function sha1Hex(message) {
  9417. const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
  9418. const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8); // hash the message
  9419. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  9420. const hashHex = hashArray
  9421. .map((b) => b.toString(16).padStart(2, "0"))
  9422. .join(""); // convert bytes to hex string
  9423. return hashHex;
  9424. }
  9425.  
  9426. async function continuationLog(a, ...args) {
  9427. let b = a;
  9428. try {
  9429. if (advanceLogging) b = await sha1Hex(a);
  9430. let c = args.map(e => {
  9431. return e === a ? b : e
  9432. });
  9433. console.log(...c)
  9434. } catch (e) { console.warn(e) }
  9435. }
  9436.  
  9437. function copyPreviousContiuationToIgnored374(toClearRecorded) {
  9438.  
  9439.  
  9440. if (mfvContinuationRecorded.length > 0) {
  9441. for (const [e, d] of mfvContinuationRecorded) {
  9442. mfyContinuationIgnored.removeAdd(e);
  9443. }
  9444. toClearRecorded && mfvContinuationRecorded.clear();
  9445. }
  9446.  
  9447. }
  9448.  
  9449. function setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr) {
  9450.  
  9451. const tmProto = taskMgr.constructor.prototype;
  9452. if (tmProto && typeof tmProto.addJob === 'function' && tmProto.addJob.length === 3 && typeof tmProto.cancelJob === 'function' && tmProto.cancelJob.length === 1) {
  9453.  
  9454. if (!tmProto.addJob714) {
  9455.  
  9456. tmProto.addJob714 = tmProto.addJob;
  9457.  
  9458. tmProto.addJob = function (a, b, c) {
  9459. const jobId = this.addJob714(a, b, c);
  9460. if (jobId > 0) {
  9461. // const ez = wk3.get(this);
  9462. // const dz = ez ? ez.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint : null;
  9463. // aje3.push({mtx, jobId, a,b,c, element: this, dz, data: (ez?.data || null) })
  9464.  
  9465. this.__lastJobId863__ = jobId;
  9466. }
  9467. return jobId;
  9468. }
  9469.  
  9470. }
  9471.  
  9472. if (!tmProto.cancelJob714) {
  9473.  
  9474. tmProto.cancelJob714 = tmProto.cancelJob;
  9475.  
  9476. tmProto.cancelJob = function (a) {
  9477. const res = this.cancelJob714(a);
  9478. // if (a > 0) {
  9479. // for (const e of aje3) {
  9480. // if (e.jobId === a) e.cancelled = true;
  9481. // }
  9482. // }
  9483. return res;
  9484. }
  9485.  
  9486. }
  9487.  
  9488. }
  9489. }
  9490.  
  9491.  
  9492. const FIX_avoid_incorrect_video_meta_bool = FIX_avoid_incorrect_video_meta && isPrepareCachedV && check_for_set_key_order && !isChatRoomURL;
  9493.  
  9494.  
  9495. FIX_avoid_incorrect_video_meta_bool && whenCEDefined('ytd-video-primary-info-renderer').then(() => {
  9496. let dummy;
  9497. let cProto;
  9498. // let mc = 4;
  9499. // dummy = await observablePromise(() => {
  9500. // const r = document.querySelector('ytd-video-primary-info-renderer');
  9501. // if (!r) return;
  9502. // let cProto = insp(r).constructor.prototype;
  9503. // if (cProto.fetchUpdatedMetadata) return r;
  9504. // if (--mc < 0) return -1;
  9505. // return null;
  9506. // }).obtain();
  9507. dummy = document.createElement('ytd-video-primary-info-renderer');
  9508. if (!(dummy instanceof Element)) return;
  9509. // console.log(5022, dummy)
  9510. cProto = insp(dummy).constructor.prototype;
  9511.  
  9512. cProto.__getEmittorTaskMgr859__ = function () {
  9513. let taskMgr_ = null;
  9514. try {
  9515. taskMgr_ = (this.ytTaskEmitterBehavior || 0).getTaskManager() || null;
  9516. } catch (e) { }
  9517. return taskMgr_;
  9518. }
  9519. if (typeof cProto.fetchUpdatedMetadata === 'function' && cProto.fetchUpdatedMetadata.length === 1 && !cProto.fetchUpdatedMetadata717) {
  9520. // console.log(1234, cProto, cProto.is)
  9521. cProto.fetchUpdatedMetadata717 = cProto.fetchUpdatedMetadata;
  9522.  
  9523. let c_;
  9524. cProto.fetchUpdatedMetadata718 = function (a) {
  9525. // delay or immediate call the actual fetchUpdatedMetadata
  9526.  
  9527. let doImmediately = false;
  9528. if (a && typeof a === 'string' && mjtRecordedPrevKey && mjtRecordedPrevKey === mpKey22 && a === mpKey22 && (!pageSetupVideoId || pageSetupVideoId !== mpUrl22)) {
  9529.  
  9530. if (!pageSetupVideoId && videoPlayingY.videoId === mpUrl22) doImmediately = true;
  9531.  
  9532. } else if (typeof a !== 'string' || mbDelayBelowNCalls > 3 || !mpKey22 || (mpKey22 === a && mpKey22 !== mjtLockPreviousKey) || (mjtLockPreviousKey && mjtLockPreviousKey !== a)) {
  9533.  
  9534. doImmediately = true;
  9535.  
  9536. }
  9537.  
  9538. if (mbCId322) {
  9539. clearTimeout(mbCId322);
  9540. mbCId322 = 0;
  9541. }
  9542.  
  9543. if (doImmediately) return this.fetchUpdatedMetadata717(a);
  9544.  
  9545. let delay = mjtLockPreviousKey === a ? 8000 : 800;
  9546.  
  9547. mbCId322 = setTimeout(() => {
  9548. this.fetchUpdatedMetadata717(a);
  9549. }, delay);
  9550.  
  9551. console.log('[yt-js-engine-tamer]', '5190 delayed fetchUpdatedMetadata', delay);
  9552.  
  9553. }
  9554.  
  9555. cProto.fetchUpdatedMetadata = function (a) {
  9556.  
  9557. if (!pageSetupState) {
  9558. if (c_) clearTimeout(c_);
  9559. c_ = setTimeout(() => {
  9560. this.fetchUpdatedMetadata718(a);
  9561. }, 300);
  9562. return;
  9563. }
  9564.  
  9565. // pageSetupState == 0
  9566.  
  9567. try {
  9568.  
  9569. mbDelayBelowNCalls++;
  9570.  
  9571. if (arguments.length > 1 || !(a === undefined || (typeof a === 'string' && a))) {
  9572. console.warn("CAUTION: fetchUpdatedMetadata coding might have to be updated.");
  9573. }
  9574.  
  9575. // console.log('fum377', a)
  9576. if (typeof a === 'string' && mfyContinuationIgnored.has(a)) {
  9577. console.log('[yt-js-engine-tamer]', '5040 skip fetchUpdatedMetadata', a);
  9578. return;
  9579. }
  9580.  
  9581. if (!a && (this.data || 0).updatedMetadataEndpoint) {
  9582. if (mjtRecordedPrevKey && mjtLockPreviousKey !== mjtRecordedPrevKey) {
  9583. mjtLockPreviousKey = mjtRecordedPrevKey;
  9584. LOG_FETCHMETA_UPDATE && continuationLog(mjtLockPreviousKey, '5150 Lock Key', mjtLockPreviousKey);
  9585. }
  9586. // mjtNextMainKey = true;
  9587. mtzlastAllowedContinuation = '';
  9588. mtzCount = 0;
  9589. // allowNoDelay322 = false;
  9590. // fetch new metadata, cancel all previous continuations
  9591. copyPreviousContiuationToIgnored374(true);
  9592. } else if (typeof a === 'string') {
  9593. const videoPlayingId = videoPlayingY.videoId;
  9594.  
  9595. // if(mjtNextMainKey === true) mjtNextMainKey = a;
  9596.  
  9597. let update21 = !!pageSetupVideoId;
  9598. if (mpKey22 === a && mpUrl22 === videoPlayingId && mpUrl22 && videoPlayingId && (!pageSetupVideoId || pageSetupVideoId === videoPlayingId)) {
  9599. update21 = true;
  9600. } else if (mpKey22 === a && mpUrl22 !== pageSetupVideoId) {
  9601. LOG_FETCHMETA_UPDATE && continuationLog(mpKey22, '5060 mpUrl22 mismatched', mpKey22, mpUrl22, pageSetupVideoId || '(null)', videoPlayingId || '(null)');
  9602. return;
  9603. }
  9604. if (update21) {
  9605. mpKey21 = a;
  9606. mpUrl21 = pageSetupVideoId || videoPlayingId;
  9607. }
  9608.  
  9609. if (!mfvContinuationRecorded.has(a)) mfvContinuationRecorded.add(a);
  9610. }
  9611. LOG_FETCHMETA_UPDATE && continuationLog(a, '5180 fetchUpdatedMetadata\t', a, pageSetupVideoId || '(null)', videoPlayingY.videoId || '(null)');
  9612. // if (!pageSetupVideoId && typeof a === 'string' && a.length > 40) return; // ignore incorrect continuation
  9613. // if(a === mjtNextMainKey) allowNoDelay322 = false;
  9614. return this.fetchUpdatedMetadata718(a);
  9615.  
  9616. } catch (e) {
  9617. console.log('Code Error in fetchUpdatedMetadata', e);
  9618. }
  9619. return this.fetchUpdatedMetadata717(a)
  9620. }
  9621. }
  9622.  
  9623.  
  9624. if (typeof cProto.scheduleInitialUpdatedMetadataRequest === 'function' && cProto.scheduleInitialUpdatedMetadataRequest.length === 0 && !cProto.scheduleInitialUpdatedMetadataRequest717) {
  9625. // console.log(1234, cProto, cProto.is)
  9626. cProto.scheduleInitialUpdatedMetadataRequest717 = cProto.scheduleInitialUpdatedMetadataRequest;
  9627. let mJob = null;
  9628.  
  9629. cProto.scheduleInitialUpdatedMetadataRequest = function () {
  9630.  
  9631. try {
  9632.  
  9633. if (arguments.length > 0) {
  9634. console.warn("CAUTION: scheduleInitialUpdatedMetadataRequest coding might have to be updated.");
  9635. }
  9636. // mfy = mfv;
  9637.  
  9638. // mjtNextMainKey = '';
  9639. mtzlastAllowedContinuation = '';
  9640. mtzCount = 0;
  9641. if (mbCId322) {
  9642. clearTimeout(mbCId322);
  9643. mbCId322 = 0;
  9644. }
  9645. mbDelayBelowNCalls = 0;
  9646. // allowNoDelay322 = false;
  9647. copyPreviousContiuationToIgnored374(true);
  9648.  
  9649. const taskMgr = this.__getEmittorTaskMgr859__();
  9650. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714 && taskMgr.addJob && taskMgr.cancelJob) setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr);
  9651. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714) {
  9652. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 507');
  9653. }
  9654.  
  9655. // prevent depulicated schedule job by clearing previous JobId
  9656. if (taskMgr && typeof taskMgr.addLowPriorityJob === 'function' && taskMgr.addLowPriorityJob.length === 2 && typeof taskMgr.cancelJob === 'function' && taskMgr.cancelJob.length === 1) {
  9657.  
  9658. let res;
  9659.  
  9660. if (mJob) {
  9661. const job = mJob;
  9662. mJob = null;
  9663. console.log('cancelJob', job)
  9664. taskMgr.cancelJob(job); // clear previous [Interval Meta Update] job
  9665. // p.cancelJob(a,b);
  9666. }
  9667.  
  9668. // const updatedMetadataEndpoint = this.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint
  9669.  
  9670. let pza = taskMgr.__lastJobId863__;
  9671. try { res = this.scheduleInitialUpdatedMetadataRequest717(); } catch (e) { }
  9672. let pzb = taskMgr.__lastJobId863__
  9673. if (pza !== pzb) {
  9674. mJob = pzb; // set [Interval Meta Update] jobId
  9675. }
  9676.  
  9677. // if (updatedMetadataEndpoint && updatedMetadataEndpoint.videoId) {
  9678. // mtxVideoId = updatedMetadataEndpoint.videoId || ''; // set the current target VideoId
  9679. // } else {
  9680. // mtxVideoId = ''; // sometimes updatedMetadataEndpoint is not ready
  9681. // }
  9682.  
  9683. return res;
  9684.  
  9685. } else {
  9686. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 601');
  9687. }
  9688.  
  9689. } catch (e) {
  9690. console.log('Code Error in scheduleInitialUpdatedMetadataRequest', e);
  9691. }
  9692.  
  9693.  
  9694. return this.scheduleInitialUpdatedMetadataRequest717();
  9695. }
  9696. }
  9697.  
  9698.  
  9699. });
  9700.  
  9701. FIX_avoid_incorrect_video_meta_bool && promiseForYtActionCalled.then((ytAppDom) => {
  9702. let dummy;
  9703. let cProto;
  9704. dummy = ytAppDom;
  9705. if (!(dummy instanceof Element)) return;
  9706. cProto = insp(dummy).constructor.prototype;
  9707. if (typeof cProto.sendServiceAjax_ === 'function' && cProto.sendServiceAjax_.length === 4 && !cProto.sendServiceAjax717_) {
  9708. // console.log(1234, cProto, cProto.is);
  9709. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  9710. // cProto.handleServiceRequest_ = function (a, b, c, d) {
  9711. // console.log(123401, arguments);
  9712. // return this.handleServiceRequest717_(a, b, c, d);
  9713. // }
  9714.  
  9715. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  9716.  
  9717. // cProto.handleServiceRequest_ = function(a,b,c,d){
  9718. // console.log(59901, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  9719. // if(a?.is === 'ytd-video-primary-info-renderer' && b?.updatedMetadataEndpoint?.videoId && c?.continuation && typeof c?.continuation ==='string'){
  9720. // console.log('mfv', c.continuation);
  9721. // mfv.add( c.continuation);
  9722. // }
  9723. // return this.handleServiceRequest717_(a,b,c,d);
  9724. // }
  9725.  
  9726. function extraArguments322(a, b, c) {
  9727. let is = (a || 0).is;
  9728. let videoId = ((b || 0).updatedMetadataEndpoint || 0).videoId;
  9729. let continuation = (c || 0).continuation;
  9730. if (typeof is !== 'string') is = null;
  9731. if (typeof videoId !== 'string') videoId = null;
  9732. if (typeof continuation !== 'string') continuation = null;
  9733. return { is, videoId, continuation };
  9734. }
  9735.  
  9736. cProto.sendServiceAjax717_ = cProto.sendServiceAjax_;
  9737. cProto.sendServiceAjax_ = function (a, b, c, d) {
  9738.  
  9739. // console.log(8001)
  9740. try {
  9741.  
  9742. const { is, videoId, continuation } = extraArguments322(a, b, c);
  9743.  
  9744. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  9745. console.warn("CAUTION: sendServiceAjax_ coding might have to be updated.");
  9746. }
  9747.  
  9748. if (pageSetupVideoId && videoId && continuation) {
  9749. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  9750. mfyContinuationIgnored.removeAdd(continuation);
  9751. mfvContinuationRecorded.delete(continuation);
  9752. return;
  9753. }
  9754. }
  9755.  
  9756. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  9757. copyPreviousContiuationToIgnored374(false);
  9758. mfyContinuationIgnored.delete(continuation);
  9759. mfvContinuationRecorded.removeAdd(continuation);
  9760. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  9761. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  9762. mjtLockPreviousKey = '';
  9763. }
  9764. // if (mjtNextMainKey === continuation) {
  9765. // copyPreviousContiuationToIgnored(false);
  9766. // mfyContinuationIgnored.delete(continuation);
  9767. // mfvContinuationRecorded.add(continuation);
  9768. // }
  9769.  
  9770.  
  9771. if (mfyContinuationIgnored && continuation) {
  9772. if (mfyContinuationIgnored.has(continuation)) {
  9773. LOG_FETCHMETA_UPDATE && continuationLog(continuation, '5260 matched01', continuation)
  9774. return;
  9775. }
  9776. }
  9777.  
  9778. // console.log(59902, a?.is, b,c,d)
  9779. // console.log(59903, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  9780. if (is === 'ytd-video-primary-info-renderer' && videoId && continuation && !mfvContinuationRecorded.has(continuation)) {
  9781. // console.log('mfv377', continuation);
  9782. mfvContinuationRecorded.add(continuation);
  9783. }
  9784.  
  9785. // if (videoId) {
  9786. // if (!pageSetupVideoId) return; // ignore page not ready
  9787. // // if (mtxVideoId && b.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  9788. // if (videoId !== pageSetupVideoId) {
  9789. // return;
  9790. // }
  9791. // }
  9792.  
  9793. } catch (e) {
  9794. console.log('Coding Error in sendServiceAjax_', e)
  9795. }
  9796. // console.log(8002)
  9797. // console.log(123402, arguments);
  9798. // console.log(5162, 'a',a?.is,'b',b,'c',c,'d',d);
  9799.  
  9800. // console.log(5211, b?.updatedMetadataEndpoint?.kdkw33);
  9801. // if(b &&b.updatedMetadataEndpoint && !b.updatedMetadataEndpoint.kdkw33){
  9802. // b.updatedMetadataEndpoint = new Proxy(b.updatedMetadataEndpoint, {
  9803. // get(target, prop, receiver){
  9804. // console.log('xxs99', target.videoId, mtx)
  9805. // if(prop ==='kdkw33') return 1;
  9806. // console.log(3322, prop, target)
  9807. // if(prop === 'initialDelayMs') {
  9808. // throw new Error("ABCC");
  9809. // }
  9810. // return target[prop];
  9811. // },
  9812. // set(target, prop, value, receiver){
  9813.  
  9814. // if(prop ==='kdkw33') return true;
  9815. // target[prop]=value;
  9816. // return true;
  9817. // }
  9818. // });
  9819. // }
  9820. // console.log(5533, b?.updatedMetadataEndpoint?.kdkw33)
  9821. return this.sendServiceAjax717_(a, b, c, d);
  9822. }
  9823. }
  9824.  
  9825. function delayClearOtherKeys(lztContinuation) {
  9826. // // schedule delayed removal if mfyContinuationIgnored is not empty
  9827. // getRafPromise().then(() => {
  9828. // // assume the repeat continuation could be only for popstate which is triggered by user interaction
  9829. // // foreground page only
  9830.  
  9831. // });
  9832.  
  9833.  
  9834. if (lztContinuation !== mtzlastAllowedContinuation) return;
  9835. if (lztContinuation !== mpKey21 || lztContinuation !== mpKey22) return;
  9836. if (!mfyContinuationIgnored.size) return;
  9837. if (mfyContinuationIgnored.size > 1) {
  9838. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, 'delayClearOtherKeys, current = ', lztContinuation);
  9839. }
  9840. mfyContinuationIgnored.forEach((value, key) => {
  9841. if (key !== lztContinuation) {
  9842. mfyContinuationIgnored.delete(key);
  9843. LOG_FETCHMETA_UPDATE && continuationLog(key, 'previous continuation removed from ignored store', key);
  9844. }
  9845. });
  9846.  
  9847. }
  9848. if (typeof cProto.getCancellableNetworkPromise_ === 'function' && cProto.getCancellableNetworkPromise_.length === 5 && !cProto.getCancellableNetworkPromise717_) {
  9849. cProto.getCancellableNetworkPromise717_ = cProto.getCancellableNetworkPromise_;
  9850. cProto.getCancellableNetworkPromise_ = function (a, b, c, d, e) {
  9851.  
  9852. // console.log(8003)
  9853. try {
  9854.  
  9855.  
  9856. const { is, videoId, continuation } = extraArguments322(b, c, d);
  9857.  
  9858. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  9859. console.warn("CAUTION: getCancellableNetworkPromise_ coding might have to be updated.");
  9860. }
  9861.  
  9862. if (pageSetupVideoId && videoId && continuation) {
  9863. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  9864. mfyContinuationIgnored.removeAdd(continuation);
  9865. mfvContinuationRecorded.delete(continuation);
  9866. return;
  9867. }
  9868. }
  9869.  
  9870. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  9871. copyPreviousContiuationToIgnored374(false);
  9872. mfyContinuationIgnored.delete(continuation);
  9873. mfvContinuationRecorded.removeAdd(continuation);
  9874. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  9875. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  9876. mjtLockPreviousKey = '';
  9877. }
  9878.  
  9879. // if (mjtNextMainKey === continuation) {
  9880. // copyPreviousContiuationToIgnored(false);
  9881. // mfyContinuationIgnored.delete(continuation);
  9882. // mfvContinuationRecorded.add(continuation);
  9883. // }
  9884.  
  9885. const lztContinuation = continuation;
  9886.  
  9887. if (mfyContinuationIgnored && lztContinuation && typeof lztContinuation === 'string') {
  9888. if (mfyContinuationIgnored.has(lztContinuation)) {
  9889. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5360 matched02', lztContinuation)
  9890. return;
  9891. }
  9892. }
  9893.  
  9894. // if (videoId) {
  9895. // if (!pageSetupVideoId) return; // ignore page not ready
  9896. // // if (mtxVideoId && c.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  9897. // if (videoId !== pageSetupVideoId) {
  9898. // return;
  9899. // }
  9900. // }
  9901.  
  9902. if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation !== lztContinuation) {
  9903. mtzlastAllowedContinuation = lztContinuation;
  9904. // console.log(70401, lztContinuation, mfyContinuationIgnored.size)
  9905.  
  9906. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5382 Continuation sets to\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  9907. mjtRecordedPrevKey = lztContinuation;
  9908. if (mjtLockPreviousKey === lztContinuation) mjtLockPreviousKey = '';
  9909. // if (mfyContinuationIgnored.size > 0) {
  9910. // delayClearOtherKeys(lztContinuation);
  9911. // }
  9912. mtzCount = 0;
  9913. // allowNoDelay322 = false;
  9914. } else if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation && mtzlastAllowedContinuation === lztContinuation) {
  9915. // repeated
  9916. if (++mtzCount > 1e9) mtzCount = 1e4;
  9917. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5386 Same Continuation\t\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  9918.  
  9919. // if (mtzCount >= 3) allowNoDelay322 = true;
  9920. if (mtzCount >= 3 && mfyContinuationIgnored.size > 0) {
  9921. Promise.resolve(lztContinuation).then(delayClearOtherKeys).catch(console.warn);
  9922. }
  9923. if (mtzCount === 5) {
  9924. mfvContinuationRecorded.clear();
  9925. mfvContinuationRecorded.add(lztContinuation);
  9926. }
  9927.  
  9928. }
  9929.  
  9930. if (typeof lztContinuation === 'string' && lztContinuation && (pageSetupVideoId || videoPlayingY.videoId)) {
  9931. mpKey22 = lztContinuation;
  9932. mpUrl22 = pageSetupVideoId || videoPlayingY.videoId;
  9933. }
  9934.  
  9935. if (mbCId322) {
  9936. clearTimeout(mbCId322);
  9937. mbCId322 = 0;
  9938. }
  9939. } catch (e) {
  9940. console.log('Coding Error in getCancellableNetworkPromise_', e)
  9941. }
  9942.  
  9943. // console.log(8004)
  9944. // console.log(123403, arguments);
  9945. // if(c.updatedMetadataEndpoint) console.log(123404, pageSetupVideoId, JSON.stringify(c.updatedMetadataEndpoint))
  9946.  
  9947. // console.log(5163, a?.is,b,c,d,e);
  9948. return this.getCancellableNetworkPromise717_(a, b, c, d, e);
  9949. }
  9950. }
  9951. });
  9952.  
  9953. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  9954.  
  9955.  
  9956. FIX_ytdExpander_childrenChanged && !isChatRoomURL && whenCEDefined('ytd-expander').then(() => {
  9957.  
  9958. let dummy;
  9959. let cProto;
  9960.  
  9961. dummy = document.createElement('ytd-expander');
  9962. cProto = insp(dummy).constructor.prototype;
  9963.  
  9964. if (fnIntegrity(cProto.initChildrenObserver, '0.48.21') && fnIntegrity(cProto.childrenChanged, '0.40.22')) {
  9965.  
  9966. cProto.initChildrenObserver14 = cProto.initChildrenObserver;
  9967. cProto.childrenChanged14 = cProto.childrenChanged;
  9968.  
  9969. cProto.initChildrenObserver = function () {
  9970. var a = this;
  9971. this.observer = new MutationObserver(function () {
  9972. a.childrenChanged()
  9973. }
  9974. );
  9975. this.observer.observe(this.content, {
  9976. subtree: !0,
  9977. childList: !0,
  9978. attributes: !0,
  9979. characterData: !0
  9980. });
  9981. this.childrenChanged()
  9982. }
  9983. ;
  9984. cProto.childrenChanged = function () {
  9985. if (this.alwaysToggleable) {
  9986. this.canToggle = this.alwaysToggleable;
  9987. } else if (!this.canToggleJobId) {
  9988. this.canToggleJobId = 1;
  9989. foregroundPromiseFn().then(() => {
  9990. this.canToggleJobId = 0;
  9991. this.calculateCanCollapse()
  9992. })
  9993. }
  9994. }
  9995.  
  9996. // console.log(cProto.initChildrenObserver)
  9997. console.debug('ytd-expander-fix-childrenChanged');
  9998.  
  9999. }
  10000.  
  10001. });
  10002.  
  10003.  
  10004. FIX_paper_ripple_animate && whenCEDefined('paper-ripple').then(() => {
  10005.  
  10006. let dummy;
  10007. let cProto;
  10008. dummy = document.createElement('paper-ripple');
  10009. cProto = insp(dummy).constructor.prototype;
  10010.  
  10011. if (fnIntegrity(cProto.animate, '0.74.5')) {
  10012.  
  10013.  
  10014. cProto.animate34 = cProto.animate;
  10015. cProto.animate = function () {
  10016. if (this._animating) {
  10017. var a;
  10018. const ripples = this.ripples;
  10019. for (a = 0; a < ripples.length; ++a) {
  10020. var b = ripples[a];
  10021. b.draw();
  10022. this.$.background.style.opacity = b.outerOpacity;
  10023. b.isOpacityFullyDecayed && !b.isRestingAtMaxRadius && this.removeRipple(b)
  10024. }
  10025. if ((this.shouldKeepAnimating || 0) !== ripples.length) {
  10026. if (!this._boundAnimate38) this._boundAnimate38 = this.animate.bind(this);
  10027. foregroundPromiseFn().then(this._boundAnimate38);
  10028. } else {
  10029. this.onAnimationComplete();
  10030. }
  10031. }
  10032. }
  10033.  
  10034. console.debug('FIX_paper_ripple_animate')
  10035.  
  10036. // console.log(cProto.animate)
  10037.  
  10038. }
  10039.  
  10040. });
  10041.  
  10042. if (FIX_doIdomRender) {
  10043.  
  10044. const xsetTimeout = function (f, d) {
  10045. if (xsetTimeout.m511 === 1 && !d) {
  10046. xsetTimeout.m511 = 2;
  10047. xsetTimeout.m568 = f;
  10048. } else {
  10049. return setTimeout.apply(window, arguments)
  10050. }
  10051.  
  10052. }
  10053.  
  10054. /**
  10055. *
  10056. IGb = function(a) {
  10057. var b, c = null == (b = a.requestAninmationFrameResolver) ? void 0 : b.promise;
  10058. c || (a.requestAninmationFrameResolver = new Vi,
  10059. c = a.requestAninmationFrameResolver.promise,
  10060. Da.requestAnimationFrame(function() {
  10061. var d;
  10062. null == (d = a.requestAninmationFrameResolver) || d.resolve();
  10063. a.requestAninmationFrameResolver = null
  10064. }));
  10065. return c
  10066. }
  10067.  
  10068.  
  10069. */
  10070.  
  10071. const xrequestAnimationFrame = function (f) {
  10072. const h = `${f}`;
  10073. if (h.startsWith("function(){setTimeout(function(){") && h.endsWith("})}")) {
  10074. let t = null;
  10075. xsetTimeout.m511 = 1;
  10076. f();
  10077. if (xsetTimeout.m511 === 2) {
  10078. t = xsetTimeout.m568;
  10079. xsetTimeout.m568 = null;
  10080. }
  10081. xsetTimeout.m511 = 0;
  10082. if (typeof t === 'function') {
  10083. foregroundPromiseFn().then(t);
  10084. }
  10085. } else if (h.includes("requestAninmationFrameResolver")) {
  10086. foregroundPromiseFn().then(f);
  10087. } else {
  10088. return requestAnimationFrame.apply(window, arguments);
  10089. }
  10090. }
  10091.  
  10092. let busy = false;
  10093. const doIdomRender = function () {
  10094.  
  10095. if (!this) return;
  10096. if (busy) {
  10097. return this.doIdomRender13(...arguments);
  10098. }
  10099. busy = true;
  10100. const { requestAnimationFrame, setTimeout } = window;
  10101. window.requestAnimationFrame = xrequestAnimationFrame;
  10102. window.setTimeout = xsetTimeout;
  10103. let r = this.doIdomRender13(...arguments);
  10104. window.requestAnimationFrame = requestAnimationFrame;
  10105. window.setTimeout = setTimeout;
  10106. busy = false;
  10107. return r;
  10108. };
  10109. 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']) {
  10110.  
  10111.  
  10112. whenCEDefined(ytTag).then(() => {
  10113.  
  10114. let dummy;
  10115. let cProto;
  10116. dummy = document.createElement(ytTag);
  10117. cProto = insp(dummy).constructor.prototype;
  10118.  
  10119. cProto.doIdomRender13 = cProto.doIdomRender;
  10120. cProto.doIdomRender = doIdomRender;
  10121.  
  10122. if (cProto.doIdomRender13 === cProto.templatingFn) cProto.templatingFn = doIdomRender;
  10123.  
  10124. console.debug('[yt-js-engine-tamer] FIX_doIdomRender', ytTag)
  10125.  
  10126.  
  10127.  
  10128. });
  10129.  
  10130. }
  10131.  
  10132. }
  10133.  
  10134.  
  10135.  
  10136.  
  10137. FIX_POPUP_UNIQUE_ID && whenCEDefined('ytd-popup-container').then(async () => {
  10138.  
  10139. const sMap = new Map();
  10140.  
  10141. const ZTa = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
  10142. const ZT = function () {
  10143. for (var a = Array(36), b = 0, c, d = 0; d < 36; d++)
  10144. d == 8 || d == 13 || d == 18 || d == 23 ? a[d] = "-" : d == 14 ? a[d] = "4" : (b <= 2 && (b = 33554432 + Math.random() * 16777216 | 0),
  10145. c = b & 15,
  10146. b >>= 4,
  10147. a[d] = ZTa[d == 19 ? c & 3 | 8 : c]);
  10148. return a.join("")
  10149. };
  10150.  
  10151.  
  10152. const popupContainerCollection = document.getElementsByTagName('ytd-popup-container');
  10153.  
  10154. const popupContainer = await observablePromise(() => {
  10155. return popupContainerCollection[0];
  10156. }).obtain();
  10157.  
  10158.  
  10159. let cProto;
  10160. cProto = insp(popupContainer).constructor.prototype;
  10161.  
  10162.  
  10163. if (!cProto || typeof cProto.handleOpenPopupAction !== 'function' || cProto.handleOpenPopupAction3868 || cProto.handleOpenPopupAction.length !== 2) {
  10164. console.log('FIX_POPUP_UNIQUE_ID NG')
  10165. return;
  10166. }
  10167. cProto.handleOpenPopupAction3868 = cProto.handleOpenPopupAction;
  10168.  
  10169. cProto.handleOpenPopupAction = function (a, b) {
  10170.  
  10171. if (typeof (a || 0) === 'object' && !a.__jOdQA__) {
  10172.  
  10173. a.__jOdQA__ = true;
  10174.  
  10175. try {
  10176.  
  10177. const h = this.hostElement;
  10178.  
  10179. if (h instanceof HTMLElement_) {
  10180.  
  10181. const map = h.__skme44__ = h.__skme44__ || new Map();
  10182.  
  10183. let mKey = '';
  10184. const wKey = firstObjectKey(a);
  10185. const wObj = wKey ? a[wKey] : null;
  10186. if (wKey && wObj && typeof (wObj.popup || 0) === 'object') {
  10187. const pKey = firstObjectKey(wObj.popup)
  10188. const pObj = pKey ? wObj.popup[pKey] : null;
  10189. let contentKey = '';
  10190. let headerKey = '';
  10191.  
  10192. if (pObj && pObj.identifier && pObj.content && pObj.header) {
  10193. contentKey = firstObjectKey(pObj.content)
  10194. headerKey = firstObjectKey(pObj.header)
  10195. }
  10196. if (contentKey && headerKey) {
  10197.  
  10198. mKey = `${wKey}(popupType:${wObj.popupType},popup(${pKey}(content(${contentKey}:...),header(${headerKey}:...),identifer(surface:${pObj.identifier.surface}))))`
  10199.  
  10200. if (mKey) {
  10201.  
  10202. if (!wObj.uniqueId) {
  10203. for (let i = 0; i < 8; i++) {
  10204. wObj.uniqueId = ZT();
  10205. if (!sMap.has(wObj.uniqueId)) break;
  10206. }
  10207. }
  10208. const oId = wObj.uniqueId
  10209.  
  10210. let nId_ = map.get(mKey);
  10211. if (!nId_) {
  10212. map.set(mKey, nId_ = oId);
  10213. }
  10214.  
  10215. wObj.uniqueId = nId_ || wObj.uniqueId;
  10216.  
  10217. const nId = wObj.uniqueId
  10218.  
  10219. sMap.set(oId, nId);
  10220. sMap.set(nId, nId);
  10221.  
  10222. wObj.uniqueId = nId;
  10223. pObj.targetId = nId;
  10224. pObj.identifier.tag = nId;
  10225.  
  10226. if (oId !== nId) {
  10227. console.log('FIX_POPUP_UNIQUE_ID', oId, nId);
  10228. }
  10229.  
  10230. }
  10231.  
  10232. }
  10233. }
  10234.  
  10235. // console.log(12213, mKey, a, b, h)
  10236.  
  10237. }
  10238.  
  10239. } catch (e) {
  10240. console.warn(e)
  10241. }
  10242.  
  10243. try {
  10244.  
  10245. const results = searchNestedObject(a, (x) => {
  10246. if (typeof x === 'string' && x.length === 36) {
  10247. 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;
  10248. }
  10249. return false;
  10250. });
  10251. for (const [obj, key] of results) {
  10252. const oId = obj[key];
  10253. const nId = sMap.get(oId);
  10254. if (nId) obj[key] = nId;
  10255. }
  10256. } catch (e) {
  10257. console.warn(e)
  10258. }
  10259.  
  10260.  
  10261. }
  10262.  
  10263. return this.handleOpenPopupAction3868(...arguments)
  10264. }
  10265.  
  10266. console.log('FIX_POPUP_UNIQUE_ID OK')
  10267.  
  10268.  
  10269. });
  10270.  
  10271.  
  10272. FIX_TRANSCRIPT_SEGMENTS && !isChatRoomURL && whenCEDefined('yt-formatted-string').then(async () => {
  10273.  
  10274. let dummy;
  10275. let cProto;
  10276. dummy = document.createElement('yt-formatted-string');
  10277. cProto = insp(dummy).constructor.prototype;
  10278.  
  10279. if (!cProto || typeof cProto.setNodeStyle_ !== 'function' || cProto.setNodeStyle17_ || cProto.setNodeStyle_.length !== 2) {
  10280. console.log('FIX_TRANSCRIPT_SEGMENTS(2) NG');
  10281. return;
  10282. }
  10283.  
  10284. cProto.setNodeStyle17_ = cProto.setNodeStyle_;
  10285. cProto.setNodeStyle_ = function (a, b) {
  10286. if (b instanceof HTMLElement_ && typeof (a || 0) === 'object') b.classList.toggle('yt-formatted-string-block-line', !!a.blockLine);
  10287. return this.setNodeStyle17_(a, b);
  10288. }
  10289.  
  10290. console.log('FIX_TRANSCRIPT_SEGMENTS(2) OK');
  10291. });
  10292.  
  10293. });
  10294.  
  10295. });
  10296.  
  10297.  
  10298.  
  10299.  
  10300. if (isMainWindow) {
  10301.  
  10302. console.groupCollapsed(
  10303. "%cYouTube JS Engine Tamer",
  10304. "background-color: #EDE43B ; color: #000 ; font-weight: bold ; padding: 4px ;"
  10305. );
  10306.  
  10307.  
  10308.  
  10309. console.log("Script is loaded.");
  10310. console.log("This script changes the core mechanisms of the YouTube JS engine.");
  10311.  
  10312. console.log("This script is experimental and subject to further changes.");
  10313.  
  10314. console.log("This might boost your YouTube performance.");
  10315.  
  10316. console.log("CAUTION: This might break your YouTube.");
  10317.  
  10318.  
  10319. if (prepareLogs.length >= 1) {
  10320. console.log(" =========================================================================== ");
  10321.  
  10322. for (const msg of prepareLogs) {
  10323. console.log(msg)
  10324. }
  10325.  
  10326. console.log(" =========================================================================== ");
  10327. }
  10328.  
  10329. console.groupEnd();
  10330.  
  10331. }
  10332.  
  10333.  
  10334.  
  10335. })();

QingJ © 2025

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