YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

当前为 2024-01-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube JS Engine Tamer
  3. // @namespace UserScripts
  4. // @match https://www.youtube.com/*
  5. // @version 0.9.0
  6. // @license MIT
  7. // @author CY Fung
  8. // @icon https://github.com/cyfung1031/userscript-supports/raw/main/icons/yt-engine.png
  9. // @description To enhance YouTube performance by modifying YouTube JS Engine
  10. // @grant none
  11. // @require https://cdn.jsdelivr.net/gh/cyfung1031/userscript-supports@4871cab1b40a53521e6578f92ca10fc03b4ce823/library/nextBrowserTick.min.js
  12. // @run-at document-start
  13. // @unwrap
  14. // @inject-into page
  15. // @allFrames true
  16. // ==/UserScript==
  17.  
  18. (() => {
  19.  
  20. const NATIVE_CANVAS_ANIMATION = false; // for #cinematics
  21. const FIX_schedulerInstanceInstance_V1 = false;
  22. const FIX_schedulerInstanceInstance_V2 = true;
  23. const FIX_yt_player = true;
  24. const FIX_Animation_n_timeline = true;
  25. const NO_PRELOAD_GENERATE_204 = false;
  26. const CHANGE_appendChild = true;
  27.  
  28. const FIX_error_many_stack = true; // should be a bug caused by uBlock Origin
  29. // const FIX_error_many_stack_keepAliveDuration = 200; // ms
  30. // const FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than = 8;
  31.  
  32. const FIX_Iframe_NULL_SRC = true;
  33.  
  34. const IGNORE_bindAnimationForCustomEffect = true; // prevent `v.bindAnimationForCustomEffect(this);` being executed
  35.  
  36. const FIX_stampDomArray_stableList = true;
  37. const FIX_ytdExpander_childrenChanged = true;
  38. const FIX_paper_ripple_animate = true;
  39. const FIX_avoid_incorrect_video_meta = true; // omit the incorrect yt-animated-rolling-number
  40. const FIX_avoid_incorrect_video_meta_emitterBehavior = true;
  41.  
  42. const FIX_doIdomRender = true;
  43.  
  44. const FIX_Shady = true;
  45.  
  46. const FIX_ytAction_ = true; // ytd-app
  47. const FIX_onVideoDataChange = false;
  48. // const FIX_onClick = true;
  49. const FIX_onStateChange = true;
  50. const FIX_onLoopRangeChange = true;
  51. const FIX_maybeUpdateFlexibleMenu = true; // ytd-menu-renderer
  52. const FIX_VideoEVENTS_v2 = true; // true might cause bug in switching page
  53.  
  54. const ENABLE_discreteTasking = true;
  55. // << if ENABLE_discreteTasking >>
  56. const ENABLE_weakenStampReferences = true;
  57. // << end >>
  58.  
  59. const FIX_perfNow = true;
  60. const ENABLE_ASYNC_DISPATCHEVENT = true;
  61.  
  62. const UNLOAD_DETACHED_POLYMER = false; // unstable
  63.  
  64. const WEAK_REF_BINDING = true; // false if your browser is slow
  65. // << if WEAK_REF_BINDING >>
  66. const WEAK_REF_PROXY_DOLLAR = true; // false if your browser is slow
  67. // << end >>
  68.  
  69.  
  70.  
  71. /*
  72. window.addEventListener('edm',()=>{
  73. let p = [...this.onerror.errorTokens][0].token; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  74. });
  75.  
  76. window.addEventListener('edn',()=>{
  77. let p = [...this.onerror.errorTokens][0].token+"X"; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  78. });
  79. window.addEventListener('edr',()=>{
  80. let p = '123'; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  81. });
  82. */
  83.  
  84. // only for macOS with Chrome/Firefox 100+
  85. const advanceLogging = typeof AbortSignal !== 'undefined' && typeof (AbortSignal || 0).timeout === 'function' && typeof navigator !== 'undefined' && /\b(Macintosh|Mac\s*OS)\b/i.test((navigator || 0).userAgent || '');
  86.  
  87. const win = this instanceof Window ? this : window;
  88.  
  89. // Create a unique key for the script and check if it is already running
  90. const hkey_script = 'jswylcojvzts';
  91. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  92. win[hkey_script] = true;
  93.  
  94.  
  95. // const setImmediate = ((self || 0).jmt || 0).setImmediate;
  96. const nextBrowserTick = (self || 0).nextBrowserTick || 0;
  97.  
  98. let p59 = 0;
  99.  
  100. const Promise = (async () => { })().constructor;
  101.  
  102. const PromiseExternal = ((resolve_, reject_) => {
  103. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  104. return class PromiseExternal extends Promise {
  105. constructor(cb = h) {
  106. super(cb);
  107. if (cb === h) {
  108. /** @type {(value: any) => void} */
  109. this.resolve = resolve_;
  110. /** @type {(reason?: any) => void} */
  111. this.reject = reject_;
  112. }
  113. }
  114. };
  115. })();
  116.  
  117.  
  118. let pf31 = new PromiseExternal();
  119.  
  120. // native RAF
  121. let __requestAnimationFrame__ = typeof webkitRequestAnimationFrame === 'function' ? window.webkitRequestAnimationFrame.bind(window) : window.requestAnimationFrame.bind(window);
  122.  
  123. // 1st wrapped RAF
  124. const baseRAF = (callback) => {
  125. return p59 ? __requestAnimationFrame__(callback) : __requestAnimationFrame__((hRes) => {
  126. pf31.then(() => {
  127. callback(hRes);
  128. });
  129. });
  130. };
  131.  
  132. // 2nd wrapped RAF
  133. window.requestAnimationFrame = baseRAF;
  134.  
  135. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  136. const indr = o => insp(o).$ || o.$ || 0;
  137.  
  138. /** @type {(o: Object | null) => WeakRef | null} */
  139. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  140.  
  141. /** @type {(wr: Object | null) => Object | null} */
  142. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  143.  
  144. FIX_perfNow && (() => {
  145. let nowh = -1;
  146. const dtl = new DocumentTimeline();
  147. performance.now = performance.now16 = function () {
  148.  
  149. /**
  150. * Bug 1842437 - When attempting to go back on youtube.com, the content remains the same
  151. *
  152. * If consecutive session history entries had history.state.entryTime set to same value,
  153. * back button doesn't work as expected. The entryTime value is coming from performance.now()
  154. * and modifying its return value slightly to make sure two close consecutive calls don't
  155. * get the same result helped with resolving the issue.
  156. */
  157.  
  158. let t = nowh;
  159. let c = dtl.currentTime;
  160. return (nowh = (t + 1e-7 > c ? t + 1e-5 : c));
  161. }
  162. if (performance.now !== performance.now16) { // might not able to set in Firefox
  163. if (performance.now() === performance.now()) console.warn('performance.now() is not mono increasing.');
  164. }
  165. })();
  166.  
  167. if (ENABLE_ASYNC_DISPATCHEVENT && nextBrowserTick) {
  168. const filter = new Set([
  169. 'yt-action',
  170. // 'iframe-src-replaced',
  171. 'shown-items-changed',
  172. 'can-show-more-changed', 'collapsed-changed',
  173.  
  174. 'yt-navigate', 'yt-navigate-start', 'yt-navigate-cache',
  175. 'yt-player-updated', 'yt-page-data-fetched', 'yt-page-type-changed', 'yt-page-data-updated',
  176. 'yt-navigate-finish',
  177.  
  178. // 'data-changed','yt-watch-comments-ready'
  179. ])
  180. EventTarget.prototype.dispatchEvent938 = EventTarget.prototype.dispatchEvent;
  181. EventTarget.prototype.dispatchEvent = function (event) {
  182. const type = (event || 0).type;
  183. if (typeof type === 'string' && event.isTrusted === false && (event instanceof CustomEvent) && event.cancelable === false) {
  184. if (!filter.has(type) && !type.endsWith('-changed')) {
  185. if (this instanceof Node || this instanceof Window) {
  186. nextBrowserTick(() => this.dispatchEvent938(event));
  187. return true;
  188. }
  189. }
  190. }
  191. return this.dispatchEvent938(event);
  192. }
  193. }
  194.  
  195.  
  196.  
  197. const check_for_set_key_order = (() => {
  198.  
  199. let mySet = new Set();
  200.  
  201. mySet.add("value1");
  202. mySet.add("value2");
  203. mySet.add("value3");
  204.  
  205. // Function to convert Set values to an array
  206. function getSetValues(set) {
  207. return Array.from(set.values());
  208. }
  209.  
  210. // Function to test if the Set maintains insertion order
  211. function testSetOrder(set, expectedOrder) {
  212. let values = getSetValues(set);
  213. return expectedOrder.join(',') === values.join(',');
  214. }
  215.  
  216. // Test 1: Initial order
  217. if (mySet.values().next().value !== "value1") return false;
  218. if (!testSetOrder(mySet, ["value1", "value2", "value3"])) return false;
  219.  
  220. // Test 2: After deleting an element
  221. mySet.delete("value2");
  222. if (mySet.values().next().value !== "value1") return false;
  223. if (!testSetOrder(mySet, ["value1", "value3"])) return false;
  224.  
  225. // Test 3: After re-adding a deleted element
  226. mySet.add("value2");
  227. if (mySet.values().next().value !== "value1") return false;
  228. if (!testSetOrder(mySet, ["value1", "value3", "value2"])) return false;
  229.  
  230. // Test 4: After adding a new element
  231. mySet.add("value4");
  232. if (mySet.values().next().value !== "value1") return false;
  233. if (!testSetOrder(mySet, ["value1", "value3", "value2", "value4"])) return false;
  234.  
  235. // Test 5: Delete+Add
  236. mySet.delete("value1");
  237. mySet.delete("value3");
  238. mySet.add("value3");
  239. mySet.add("value1");
  240. if (mySet.values().next().value !== "value2") return false;
  241. if (!testSetOrder(mySet, ["value2", "value4", "value3", "value1"])) return false;
  242.  
  243. return true;
  244. })();
  245.  
  246.  
  247.  
  248. // const qm47 = Symbol();
  249. const qm57 = Symbol();
  250. const qm53 = Symbol();
  251. const qn53 = Symbol();
  252.  
  253.  
  254. const ump3 = new WeakMap();
  255.  
  256. const stp = document.createElement('noscript');
  257. stp.id = 'weakref-placeholder'
  258.  
  259.  
  260. const setupD = typeof WeakRef !== 'undefined' ? (elm, s, usePlaceholder) => {
  261.  
  262. const z = `${s}72`;
  263.  
  264. if (s in elm) {
  265. // console.log(1162, elm[s], elm)
  266.  
  267. const p = elm[s];
  268.  
  269. delete elm[s];
  270.  
  271. Object.defineProperty(elm, s, {
  272. get() {
  273. const elm = this;
  274. const wr = elm[z];
  275. if (!wr) return null;
  276. const m = kRef(wr);
  277. if (!m && usePlaceholder) {
  278. if (typeof usePlaceholder === 'function') usePlaceholder(elm);
  279. return stp;
  280. }
  281. return m;
  282. },
  283. set(nv) {
  284. const elm = this;
  285. elm[z] = nv ? mWeakRef(nv) : null;
  286. return true;
  287. },
  288. configurable: true,
  289. enumerable: true
  290.  
  291. });
  292.  
  293. elm[s] = p;
  294. elm = null;
  295.  
  296.  
  297. }
  298. } : null;
  299.  
  300. const mxMap = new WeakMap();
  301.  
  302. const myMap = new WeakSet();
  303.  
  304. const setup$ = typeof WeakRef !== 'undefined' ? function (dh) {
  305.  
  306. const $ = dh.$;
  307. // const elements_ = dh.elements_;
  308.  
  309. // setupD(dh, '$');
  310.  
  311.  
  312. if (WEAK_REF_PROXY_DOLLAR && $ && typeof $ === 'object' && !dh.$ky37) {
  313.  
  314. dh.$ky37 = 1;
  315.  
  316. if (!myMap.has($)) {
  317.  
  318.  
  319.  
  320.  
  321. for (const k of Object.keys($)) {
  322.  
  323. const v = $[k];
  324. if ($[k] instanceof Node) {
  325.  
  326. $[k] = mWeakRef($[k]);
  327.  
  328. }
  329.  
  330. }
  331.  
  332.  
  333.  
  334. dh.$ = mxMap.get($) || new Proxy($, {
  335. get(obj, prop) {
  336. const val = obj[prop];
  337. if (typeof (val || 0).deref === 'function') {
  338. return val.deref();
  339. }
  340. return val;
  341. },
  342. set(obj, prop, val) {
  343. if (val instanceof Node) {
  344. obj[prop] = mWeakRef(val);
  345. } else {
  346. obj[prop] = val;
  347. }
  348. return true;
  349. }
  350. });
  351.  
  352. mxMap.set($, dh.$);
  353. myMap.add(dh.$);
  354.  
  355. }
  356.  
  357.  
  358.  
  359.  
  360. }
  361.  
  362.  
  363.  
  364.  
  365. // if (WEAK_REF_PROXY_DOLLAR && elements_ && typeof elements_ === 'object' && !dh.$ky38) {
  366.  
  367. // dh.$ky38 = 1;
  368.  
  369. // if (!myMap.has(elements_)) {
  370.  
  371.  
  372.  
  373.  
  374. // for (const k of Object.keys(elements_)) {
  375.  
  376. // const v = elements_[k];
  377. // if (elements_[k] instanceof Node) {
  378.  
  379. // elements_[k] = new WeakRef(elements_[k]);
  380.  
  381. // }
  382.  
  383. // }
  384.  
  385. // /*
  386.  
  387.  
  388.  
  389. // dh.elements_ = mxMap.get(elements_) || new Proxy(elements_, {
  390. // get(obj, prop) {
  391. // const val = obj[prop];
  392. // if (typeof (val || 0).deref === 'function') {
  393. // return val.deref();
  394. // }
  395. // return val;
  396. // },
  397. // set(obj, prop, val) {
  398. // if (val instanceof Node) {
  399. // obj[prop] = new WeakRef(val);
  400. // } else {
  401. // obj[prop] = val;
  402. // }
  403. // return true;
  404. // }
  405. // });
  406.  
  407. // console.log(dh, dh.elements_, elements_)
  408.  
  409. // mxMap.set(elements_, dh.elements_);
  410. // myMap.add(dh.elements_);
  411.  
  412. // */
  413. // }
  414.  
  415.  
  416.  
  417.  
  418. // }
  419.  
  420.  
  421.  
  422.  
  423.  
  424. } : null;
  425.  
  426.  
  427. const configureVisibilityObserverT_ = function () {
  428. const hostElement = this.hostElement;
  429. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  430. this.unobserve_();
  431. } else {
  432. return this.configureVisibilityObserver27_();
  433. }
  434. };
  435. const getParentRendererT = function () {
  436. const hostElement = this.hostElement;
  437. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  438. return null;
  439. } else {
  440. return this.getParentRenderer27();
  441. }
  442. }
  443. const readyT = function () {
  444. const hostElement = this.hostElement;
  445. let b = false;
  446. if (this.enableContentEditableChanged_) {
  447. b = true;
  448. } else if (this.is && this.is.length > 15 && this.is.length < 20) {
  449.  
  450. } else {
  451. b = true;
  452. }
  453. if (b) {
  454. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  455. return void 0;
  456. }
  457. }
  458. return this.ready27.apply(this, arguments);
  459. }
  460. const _enablePropertiesT = function () {
  461. const hostElement = this.hostElement;
  462. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  463. return void 0;
  464. }
  465. return this._enableProperties27();
  466. }
  467.  
  468. const attachedT = function () {
  469. const hostElement = this.hostElement;
  470. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  471. if (this.isAttached === true) this.isAttached = false;
  472. return void 0;
  473. } else {
  474. return this.attached27();
  475. }
  476. }
  477.  
  478. const hostElementCleanUp = (dh) => {
  479. if (typeof dh.dispose === 'function') {
  480. try {
  481. if (dh.visibilityMonitor || dh.visibilityObserver) {
  482. dh.dispose();
  483. dh.visibilityMonitor = null;
  484. dh.visibilityObserver = null;
  485. }
  486. } catch (e) { }
  487. }
  488. if (typeof dh.detached === 'function') {
  489. try {
  490. if (dh.visibilityObserverForChild_ || dh.localVisibilityObserver_) {
  491. dh.detached();
  492. dh.visibilityObserverForChild_ = null;
  493. dh.localVisibilityObserver_ = null;
  494. }
  495. } catch (e) { }
  496. }
  497. // if (dh.__dataEnabled === true) {
  498. // dh.__dataEnabled = false;
  499. // }
  500. };
  501. const setupDataHost = setupD && setup$ ? function (dh, opt) {
  502.  
  503. if (dh && typeof dh === 'object') {
  504.  
  505. if (typeof dh.configureVisibilityObserver_ === 'function' && !dh.configureVisibilityObserver27_) {
  506. dh.configureVisibilityObserver27_ = dh.configureVisibilityObserver_;
  507. dh.configureVisibilityObserver_ = configureVisibilityObserverT_;
  508. }
  509.  
  510. if (typeof dh.getParentRenderer === 'function' && !dh.getParentRenderer27) {
  511. dh.getParentRenderer27 = dh.getParentRenderer;
  512. dh.getParentRenderer = getParentRendererT;
  513. }
  514.  
  515. // if (!opt) {
  516.  
  517. // if (typeof dh.ready === 'function' && !dh.ready27) {
  518. // dh.ready27 = dh.ready;
  519. // dh.ready = readyT;
  520. // }
  521.  
  522. // }
  523.  
  524. // if (typeof dh._enableProperties === 'function' && !dh._enableProperties27) {
  525. // dh._enableProperties27 = dh._enableProperties;
  526. // dh._enableProperties = _enablePropertiesT;
  527. // }
  528.  
  529. if (typeof dh.attached === 'function' && !dh.attached27) {
  530. dh.attached27 = dh.attached;
  531. dh.attached = attachedT;
  532. }
  533.  
  534. setupD(dh, 'hostElement', hostElementCleanUp);
  535. setupD(dh, 'parentComponent');
  536. setupD(dh, 'localVisibilityObserver_');
  537. setupD(dh, 'cachedProviderNode_');
  538.  
  539.  
  540. setupD(dh, '__template');
  541. setupD(dh, '__templatizeOwner');
  542. setupD(dh, '__templateInfo');
  543.  
  544. // setupD(dh, 'root', 1);
  545.  
  546. const elements_ = dh.elements_;
  547. if (elements_ && typeof elements_ === 'object' && Object.keys(elements_).length > 0) setupD(dh, 'elements_');
  548.  
  549.  
  550.  
  551. setup$(dh);
  552. }
  553.  
  554.  
  555.  
  556.  
  557. } : null;
  558.  
  559.  
  560. let delay300 = null;
  561.  
  562. if (UNLOAD_DETACHED_POLYMER || WEAK_REF_BINDING) {
  563. delay300 = new PromiseExternal();
  564. setInterval(() => {
  565. delay300.resolve();
  566. delay300 = new PromiseExternal();
  567. }, 300);
  568. }
  569.  
  570. const aDelay = async function () {
  571. await delay300.then();
  572. await delay300.then();
  573. }
  574.  
  575. const convertionFuncMap = new WeakMap();
  576. let val_kevlar_should_maintain_stable_list = null;
  577.  
  578. const createStampDomArrayFn_ = (fn) => {
  579. if (val_kevlar_should_maintain_stable_list === null) {
  580. const config_ = ((window.yt || 0).config_ || 0);
  581. val_kevlar_should_maintain_stable_list = ((config_ || 0).EXPERIMENT_FLAGS || 0).kevlar_should_maintain_stable_list === true
  582. }
  583. const gn = function (a, b, c, d, e, h) {
  584. const isNonEmptyArray = (a || 0).length >= 1
  585. if (!isNonEmptyArray) {
  586. return fn.call(this, undefined, b, undefined, d);
  587. } else if (h === undefined && typeof b === 'string' && c && typeof c === 'object' && this.is && val_kevlar_should_maintain_stable_list) {
  588. if (c.clientSideToggleMenuItemRenderer) {
  589. h = false;
  590. } else {
  591. h = true;
  592. }
  593. }
  594. return fn.call(this, a, b, c, d, e, h)
  595. }
  596. gn.originalFn = fn;
  597. convertionFuncMap.set(fn, gn);
  598. return gn;
  599. }
  600.  
  601. const fixStampDomArrayStableList = (h) => {
  602. if (!h.stampDomArray_) return;
  603. const proto = h.__proto__;
  604. const f = proto.stampDomArray_;
  605. if (!proto.stampDomArrayF001_ && typeof f === 'function' && f.length === 6) {
  606. proto.stampDomArrayF001_ = 1;
  607. proto.stampDomArray_ = convertionFuncMap.get(f) || createStampDomArrayFn_(f);
  608. }
  609. }
  610.  
  611. const weakenStampReferences = (() => {
  612.  
  613. const DEBUG_STAMP = false;
  614.  
  615. const s1 = Symbol();
  616. const handler1 = {
  617. get(target, prop, receiver) {
  618. if (prop === 'object') {
  619. return kRef(target[s1]); // avoid memory leakage
  620. }
  621. if (prop === '__proxy312__') return 1;
  622. return target[prop];
  623. }
  624. };
  625. const handler2 = {
  626. get(target, prop, receiver) {
  627. if (prop === 'indexSplices') {
  628. return kRef(target[s1]); // avoid memory leakage
  629. }
  630. if (prop === '__proxy312__') return 1;
  631. return target[prop];
  632. }
  633. }
  634. const handler3 = {
  635. get(target, prop, receiver) {
  636. if (prop === '__proxy312__') return 1;
  637. let w = target[prop]
  638. if (w && typeof w === 'object' && typeof w.deref === 'function') {
  639. return w.deref();
  640. }
  641. return w;
  642. }
  643. }
  644. return (h) => {
  645.  
  646. if (h.rendererStamperApplyChangeRecord_ || h.stampDomArraySplices_) {
  647. const proto = h.__proto__;
  648. if (!proto.yzxer && (proto.rendererStamperApplyChangeRecord_ || proto.stampDomArraySplices_)) {
  649. proto.yzxer = 1;
  650.  
  651. const list = [
  652. // "rendererStamperObserver_", // 3 ==> rendererStamperApplyChangeRecord_
  653. "rendererStamperApplyChangeRecord_", // 3
  654. "forwardRendererStamperChanges_", // 3
  655. "stampDomArraySplices_", // 3
  656. "stampDomArray_", // 6
  657. "deferRenderStamperBinding_", // 3
  658. ];
  659. for (const key of list) {
  660. const pey = `${key}$wq0iw_`
  661. if (typeof proto[key] !== 'function') continue;
  662. // console.log( proto.isRenderer_, 'ms_'+key, proto[key].length, h.is)
  663. if (proto[pey] || proto[key].length === 0) continue;
  664.  
  665. // proto[pey] = proto[key];
  666. // proto[key] = function () {
  667. // console.log(key, arguments.length, [...arguments]);
  668.  
  669. // return proto[pey].apply(this, arguments);
  670. // }
  671.  
  672.  
  673. if (key === 'stampDomArraySplices_' && proto[key].length === 3) {
  674. proto[pey] = proto[key];
  675. proto[key] = function (a, b, c) {
  676.  
  677. if (typeof a === 'string' && typeof b === 'string' && typeof c === 'object' && c && c.indexSplices && c.indexSplices.length >= 1 && !c.indexSplices.rzgjr) {
  678.  
  679. c.indexSplices = c.indexSplices.map(e => {
  680. if (e.__proxy312__) return e;
  681. e[s1] = mWeakRef(e.object);
  682. e.object = null;
  683. return new Proxy(e, handler1);
  684. });
  685. c.indexSplices.rzgjr = 1;
  686.  
  687. c[s1] = mWeakRef(c.indexSplices);
  688. c.indexSplices = null;
  689. c = new Proxy(c, handler2)
  690. arguments[2] = c;
  691.  
  692. }
  693. // console.log(key, arguments.length, [...arguments]);
  694. return proto[pey].call(this, a, b, c);
  695. }
  696.  
  697. } else if (key === 'rendererStamperApplyChangeRecord_' && proto[key].length === 3) {
  698.  
  699.  
  700. // proto[pey] = proto[key];
  701. // proto[key] = function (a, b, c) {
  702.  
  703. // if (typeof a === 'string' && typeof b === 'string' && typeof c === 'object' && c && c.value && c.base) {
  704.  
  705. // if(c.value.length >=1){
  706.  
  707.  
  708. // c.value = c.value.map(e=>{
  709.  
  710. // if(!e.__proxy312__){
  711.  
  712. // for (const k of Object.keys(e)) {
  713. // const v = e[k];
  714. // if(typeof v ==='object' && v && typeof v.length ==='undefined' && !v.deref) e[k] = mWeakRef(v)
  715.  
  716. // }
  717. // return new Proxy(e, handler3);
  718.  
  719. // }
  720.  
  721. // })
  722.  
  723.  
  724. // window.se3=c.value;
  725.  
  726. // }
  727.  
  728. // if(c.base.length >=1){
  729.  
  730. // c.base = c.base.map(e=>{
  731.  
  732. // if(!e.__proxy312__){
  733.  
  734.  
  735. // for (const k of Object.keys(e)) {
  736. // const v = e[k];
  737. // if(typeof v ==='object' && v && typeof v.length ==='undefined' && !v.deref) e[k] = mWeakRef(v)
  738. // }
  739. // return new Proxy(e, handler3);
  740. // }
  741.  
  742.  
  743. // })
  744.  
  745. // console.log(c.base);
  746.  
  747.  
  748. // window.se4=c.base;
  749.  
  750. // }
  751.  
  752.  
  753. // }
  754. // // console.log(key, arguments.length, [...arguments]);
  755. // return proto[pey].call(this, a, b, c);
  756. // }
  757.  
  758. } else if (DEBUG_STAMP) {
  759.  
  760. console.log(proto.isRenderer_, 'ms_' + key, proto[key].length, h.is)
  761. proto[pey] = proto[key];
  762. proto[key] = function () {
  763. if (key === 'rendererStamperApplyChangeRecord_' && typeof arguments[3] === 'object') {
  764. console.log(key, arguments.length, { value: arguments[3].value, base: arguments[3].base, })
  765. }
  766. console.log(key, arguments.length, [...arguments]);
  767. return proto[pey].apply(this, arguments);
  768. }
  769.  
  770. }
  771.  
  772. }
  773.  
  774.  
  775. // const m = (Object.mkss = Object.mkss || new Set());
  776. // Object.keys(h.__proto__).filter(e => e.toLowerCase().includes('stamp') && typeof h[e] === 'function').forEach(e => m.add(e))
  777. // console.log([...m])
  778. }
  779. }
  780.  
  781. }
  782. })();
  783.  
  784. const setupDiscreteTasks = (h, rb) => {
  785.  
  786. if (rb) {
  787. if (h.ky36) return;
  788. }
  789.  
  790.  
  791. if (typeof h.onYtRendererstamperFinished === 'function' && !(h.onYtRendererstamperFinished.km34)) {
  792. const f = h.onYtRendererstamperFinished;
  793. const g = ump3.get(f) || function () {
  794. if (this.updateChildVisibilityProperties && !this.markDirty) {
  795. return f.apply(this, arguments);
  796. }
  797. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  798. }
  799. ump3.set(f, g);
  800. g.km34 = 1;
  801. h.onYtRendererstamperFinished = g;
  802.  
  803. }
  804.  
  805.  
  806.  
  807.  
  808. if (typeof h.onYtUpdateDescriptionAction === 'function' && !(h.onYtUpdateDescriptionAction.km34)) {
  809. const f = h.onYtUpdateDescriptionAction;
  810. const g = ump3.get(f) || function (a) {
  811. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  812. }
  813. ump3.set(f, g);
  814. g.km34 = 1;
  815. h.onYtUpdateDescriptionAction = g;
  816.  
  817. }
  818.  
  819.  
  820.  
  821. if (typeof h.handleUpdateDescriptionAction === 'function' && !(h.handleUpdateDescriptionAction.km34)) {
  822. const f = h.handleUpdateDescriptionAction;
  823. const g = ump3.get(f) || function (a) {
  824. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  825. }
  826. ump3.set(f, g);
  827. g.km34 = 1;
  828. h.handleUpdateDescriptionAction = g;
  829.  
  830. }
  831.  
  832. if (typeof h.handleUpdateLiveChatPollAction === 'function' && !(h.handleUpdateLiveChatPollAction.km34)) {
  833. const f = h.handleUpdateLiveChatPollAction;
  834. const g = ump3.get(f) || function (a) {
  835. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  836. }
  837. ump3.set(f, g);
  838. g.km34 = 1;
  839. h.handleUpdateLiveChatPollAction = g;
  840.  
  841. }
  842.  
  843.  
  844.  
  845. /*
  846.  
  847.  
  848. if (typeof h.onYtAction_ === 'function' && !(h.onYtAction_.km34)) {
  849. const f = h.onYtAction_;
  850. const g = ump3.get(f) || function (a) {
  851. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  852. }
  853. ump3.set(f, g);
  854. g.km34 = 1;
  855. h.onYtAction_ = g;
  856.  
  857. }
  858.  
  859. */
  860.  
  861.  
  862.  
  863. if (typeof h.onTextChanged === 'function' && !(h.onTextChanged.km34)) {
  864. const f = h.onTextChanged;
  865. const g = ump3.get(f) || function () {
  866. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  867. }
  868. ump3.set(f, g);
  869. g.km34 = 1;
  870. h.onTextChanged = g;
  871.  
  872. }
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879. if (typeof h.onVideoDataChange === 'function' && !(h.onVideoDataChange.km34)) {
  880. const f = h.onVideoDataChange;
  881. const g = ump3.get(f) || function (a) {
  882. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  883. }
  884. ump3.set(f, g);
  885. g.km34 = 1;
  886. h.onVideoDataChange = g;
  887.  
  888. }
  889.  
  890.  
  891.  
  892.  
  893.  
  894. if (typeof h.onVideoDataChange_ === 'function' && !(h.onVideoDataChange_.km34)) {
  895. const f = h.onVideoDataChange_;
  896. const g = ump3.get(f) || function () {
  897. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  898. }
  899. ump3.set(f, g);
  900. g.km34 = 1;
  901. h.onVideoDataChange_ = g;
  902.  
  903. }
  904.  
  905.  
  906.  
  907.  
  908. if (typeof h.addTooltips === 'function' && !(h.addTooltips.km34)) {
  909.  
  910. const f = h.addTooltips;
  911. const g = ump3.get(f) || function () {
  912. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  913. }
  914. ump3.set(f, g);
  915. g.km34 = 1;
  916. h.addTooltips = g;
  917.  
  918. }
  919.  
  920.  
  921.  
  922.  
  923. if (typeof h.addTooltips_ === 'function' && !(h.addTooltips_.km34)) {
  924.  
  925. const f = h.addTooltips_;
  926. const g = ump3.get(f) || function () {
  927. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  928. }
  929. ump3.set(f, g);
  930. g.km34 = 1;
  931. h.addTooltips_ = g;
  932.  
  933. }
  934.  
  935.  
  936.  
  937. if (typeof h.updateRenderedElements === 'function' && !(h.updateRenderedElements.km34)) {
  938.  
  939. const f = h.updateRenderedElements;
  940. const g = ump3.get(f) || function () {
  941. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  942. }
  943. ump3.set(f, g);
  944. g.km34 = 1;
  945. h.updateRenderedElements = g;
  946.  
  947. }
  948.  
  949.  
  950.  
  951.  
  952. /*
  953. // buggy for yt-player-updated
  954. if (typeof h.startLoadingWatch === 'function' && !(h.startLoadingWatch.km34)) {
  955.  
  956. const f = h.startLoadingWatch;
  957. const g = ump3.get(f) || function () {
  958. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  959. }
  960. ump3.set(f, g);
  961. g.km34 = 1;
  962. h.startLoadingWatch = g;
  963.  
  964. }
  965. */
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979. if (typeof h.loadPage_ === 'function' && !(h.loadPage_.km34)) {
  980. const f = h.loadPage_;
  981. const g = ump3.get(f) || function (a) {
  982. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  983. }
  984. ump3.set(f, g);
  985. g.km34 = 1;
  986. h.loadPage_ = g;
  987.  
  988. }
  989. if (typeof h.updatePageData_ === 'function' && !(h.updatePageData_.km34)) {
  990. const f = h.updatePageData_;
  991. const g = ump3.get(f) || function (a) {
  992. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  993. }
  994. ump3.set(f, g);
  995. g.km34 = 1;
  996. h.updatePageData_ = g;
  997.  
  998. }
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008. if (typeof h.onFocus_ === 'function' && !(h.onFocus_.km34)) {
  1009.  
  1010. const f = h.onFocus_;
  1011. const g = ump3.get(f) || function () {
  1012. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1013. }
  1014. ump3.set(f, g);
  1015. g.km34 = 1;
  1016. h.onFocus_ = g;
  1017.  
  1018. }
  1019.  
  1020. if (typeof h.onBlur_ === 'function' && !(h.onBlur_.km34)) {
  1021.  
  1022. const f = h.onBlur_;
  1023. const g = ump3.get(f) || function () {
  1024. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1025. }
  1026. ump3.set(f, g);
  1027. g.km34 = 1;
  1028. h.onBlur_ = g;
  1029.  
  1030. }
  1031.  
  1032.  
  1033. if (typeof h.buttonClassChanged_ === 'function' && !(h.buttonClassChanged_.km34)) {
  1034.  
  1035. const f = h.buttonClassChanged_;
  1036. const g = ump3.get(f) || function (a, b) {
  1037. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1038. }
  1039. ump3.set(f, g);
  1040. g.km34 = 1;
  1041. h.buttonClassChanged_ = g;
  1042.  
  1043. }
  1044.  
  1045.  
  1046. if (typeof h.buttonIconChanged_ === 'function' && !(h.buttonIconChanged_.km34)) {
  1047.  
  1048. const f = h.buttonIconChanged_;
  1049. const g = ump3.get(f) || function (a) {
  1050. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1051. }
  1052. ump3.set(f, g);
  1053. g.km34 = 1;
  1054. h.buttonIconChanged_ = g;
  1055.  
  1056. }
  1057.  
  1058.  
  1059. if (typeof h.dataChangedInBehavior_ === 'function' && !(h.dataChangedInBehavior_.km34)) {
  1060.  
  1061. const f = h.dataChangedInBehavior_;
  1062. const g = ump3.get(f) || function () {
  1063. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1064. }
  1065. ump3.set(f, g);
  1066. g.km34 = 1;
  1067. h.dataChangedInBehavior_ = g;
  1068.  
  1069. }
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075. if (typeof h.continuationsChanged_ === 'function' && !(h.continuationsChanged_.km34)) {
  1076.  
  1077. const f = h.continuationsChanged_;
  1078. const g = ump3.get(f) || function () {
  1079. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1080. }
  1081. ump3.set(f, g);
  1082. g.km34 = 1;
  1083. h.continuationsChanged_ = g;
  1084.  
  1085. }
  1086.  
  1087.  
  1088. if (typeof h.forceChatPoll_ === 'function' && !(h.forceChatPoll_.km34)) {
  1089.  
  1090. const f = h.forceChatPoll_;
  1091. const g = ump3.get(f) || function (a) {
  1092. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1093. }
  1094. ump3.set(f, g);
  1095. g.km34 = 1;
  1096. h.forceChatPoll_ = g;
  1097.  
  1098. }
  1099.  
  1100.  
  1101.  
  1102. if (typeof h.onEndpointClick_ === 'function' && !(h.onEndpointClick_.km34)) {
  1103.  
  1104. const f = h.onEndpointClick_;
  1105. const g = ump3.get(f) || function (a) {
  1106. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1107. }
  1108. ump3.set(f, g);
  1109. g.km34 = 1;
  1110. h.onEndpointClick_ = g;
  1111.  
  1112. }
  1113.  
  1114.  
  1115. if (typeof h.onEndpointTap_ === 'function' && !(h.onEndpointTap_.km34)) {
  1116.  
  1117. const f = h.onEndpointTap_;
  1118. const g = ump3.get(f) || function (a) {
  1119. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1120. }
  1121. ump3.set(f, g);
  1122. g.km34 = 1;
  1123. h.onEndpointTap_ = g;
  1124.  
  1125. }
  1126.  
  1127.  
  1128. if (typeof h.handleClick_ === 'function' && !(h.handleClick_.km34)) {
  1129.  
  1130. const f = h.handleClick_;
  1131. const g = ump3.get(f) || function (a, b) {
  1132. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1133. }
  1134. ump3.set(f, g);
  1135. g.km34 = 1;
  1136. h.handleClick_ = g;
  1137.  
  1138. }
  1139.  
  1140.  
  1141.  
  1142. // return;
  1143.  
  1144.  
  1145.  
  1146. if (typeof h.onReadyStateChange_ === 'function' && !(h.onReadyStateChange_.km34)) {
  1147.  
  1148. const f = h.onReadyStateChange_;
  1149. const g = ump3.get(f) || function () {
  1150. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1151. }
  1152. ump3.set(f, g);
  1153. g.km34 = 1;
  1154. h.onReadyStateChange_ = g;
  1155.  
  1156. }
  1157.  
  1158. if (typeof h.onReadyStateChangeEntryPoint_ === 'function' && !(h.onReadyStateChangeEntryPoint_.km34)) {
  1159.  
  1160. const f = h.onReadyStateChangeEntryPoint_;
  1161. const g = ump3.get(f) || function () {
  1162. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1163. }
  1164. ump3.set(f, g);
  1165. g.km34 = 1;
  1166. h.onReadyStateChangeEntryPoint_ = g;
  1167.  
  1168. }
  1169.  
  1170.  
  1171. if (typeof h.readyStateChangeHandler_ === 'function' && !(h.readyStateChangeHandler_.km34)) {
  1172.  
  1173. const f = h.readyStateChangeHandler_;
  1174. const g = ump3.get(f) || function (a) {
  1175. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1176. }
  1177. ump3.set(f, g);
  1178. g.km34 = 1;
  1179. h.readyStateChangeHandler_ = g;
  1180.  
  1181. }
  1182.  
  1183.  
  1184.  
  1185.  
  1186. if (typeof h.xmlHttpHandler_ === 'function' && !(h.xmlHttpHandler_.km34)) {
  1187.  
  1188. const f = h.xmlHttpHandler_;
  1189. const g = ump3.get(f) || function (a) {
  1190. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1191. }
  1192. ump3.set(f, g);
  1193. g.km34 = 1;
  1194. h.xmlHttpHandler_ = g;
  1195.  
  1196. }
  1197.  
  1198.  
  1199. if (typeof h.executeCallbacks_ === 'function' && !(h.executeCallbacks_.km34)) {
  1200.  
  1201. const f = h.executeCallbacks_; // overloaded
  1202. const g = ump3.get(f) || function (a) {
  1203. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1204. }
  1205. ump3.set(f, g);
  1206. g.km34 = 1;
  1207. h.executeCallbacks_ = g;
  1208.  
  1209. }
  1210.  
  1211.  
  1212.  
  1213. if (typeof h.handleInvalidationData_ === 'function' && !(h.handleInvalidationData_.km34)) {
  1214.  
  1215. const f = h.handleInvalidationData_;
  1216. const g = ump3.get(f) || function (a, b) {
  1217. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1218. }
  1219. ump3.set(f, g);
  1220. g.km34 = 1;
  1221. h.handleInvalidationData_ = g;
  1222.  
  1223. }
  1224.  
  1225. if (typeof h.onInput_ === 'function' && !(h.onInput_.km34)) {
  1226.  
  1227. const f = h.onInput_;
  1228. const g = ump3.get(f) || function () {
  1229. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1230. }
  1231. ump3.set(f, g);
  1232. g.km34 = 1;
  1233. h.onInput_ = g;
  1234.  
  1235. }
  1236.  
  1237.  
  1238. if (typeof h.trigger_ === 'function' && !(h.trigger_.km34)) {
  1239.  
  1240. const f = h.trigger_;
  1241. const g = ump3.get(f) || function (a) {
  1242. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1243. }
  1244. ump3.set(f, g);
  1245. g.km34 = 1;
  1246. h.trigger_ = g;
  1247.  
  1248. }
  1249.  
  1250.  
  1251. if (typeof h.requestData_ === 'function' && !(h.requestData_.km34)) {
  1252.  
  1253. const f = h.requestData_;
  1254. const g = ump3.get(f) || function (a) {
  1255. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1256. }
  1257. ump3.set(f, g);
  1258. g.km34 = 1;
  1259. h.requestData_ = g;
  1260.  
  1261. }
  1262.  
  1263. if (typeof h.onLoadReloadContinuation_ === 'function' && !(h.onLoadReloadContinuation_.km34)) {
  1264.  
  1265. const f = h.onLoadReloadContinuation_;
  1266. const g = ump3.get(f) || function (a, b) {
  1267. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1268. }
  1269. ump3.set(f, g);
  1270. g.km34 = 1;
  1271. h.onLoadReloadContinuation_ = g;
  1272.  
  1273. }
  1274.  
  1275.  
  1276.  
  1277. if (typeof h.onLoadIncrementalContinuation_ === 'function' && !(h.onLoadIncrementalContinuation_.km34)) {
  1278.  
  1279. const f = h.onLoadIncrementalContinuation_;
  1280. const g = ump3.get(f) || function (a, b) {
  1281. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1282. }
  1283. ump3.set(f, g);
  1284. g.km34 = 1;
  1285. h.onLoadIncrementalContinuation_ = g;
  1286.  
  1287. }
  1288.  
  1289. if (typeof h.onLoadSeekContinuation_ === 'function' && !(h.onLoadSeekContinuation_.km34)) {
  1290.  
  1291. const f = h.onLoadSeekContinuation_;
  1292. const g = ump3.get(f) || function (a, b) {
  1293. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1294. }
  1295. ump3.set(f, g);
  1296. g.km34 = 1;
  1297. h.onLoadSeekContinuation_ = g;
  1298.  
  1299. }
  1300. if (typeof h.onLoadReplayContinuation_ === 'function' && !(h.onLoadReplayContinuation_.km34)) {
  1301.  
  1302. const f = h.onLoadReplayContinuation_;
  1303. const g = ump3.get(f) || function (a, b) {
  1304. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1305. }
  1306. ump3.set(f, g);
  1307. g.km34 = 1;
  1308. h.onLoadReplayContinuation_ = g;
  1309.  
  1310. }
  1311. if (typeof h.onNavigate_ === 'function' && !(h.onNavigate_.km34)) {
  1312.  
  1313. const f = h.onNavigate_;
  1314. const g = ump3.get(f) || function (a) {
  1315. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1316. }
  1317. ump3.set(f, g);
  1318. g.km34 = 1;
  1319. h.onNavigate_ = g;
  1320.  
  1321. }
  1322.  
  1323. /*
  1324. if(typeof h.deferRenderStamperBinding_ ==='function' && !(h.deferRenderStamperBinding_.km34)){
  1325.  
  1326. const f = h.deferRenderStamperBinding_;
  1327. const g = function(){
  1328. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1329. }
  1330. g.km34 = 1;
  1331. h.deferRenderStamperBinding_ = g;
  1332.  
  1333. }
  1334. */
  1335.  
  1336.  
  1337.  
  1338. if (typeof h.ytRendererBehaviorDataObserver_ === 'function' && !(h.ytRendererBehaviorDataObserver_.km34)) {
  1339.  
  1340. const f = h.ytRendererBehaviorDataObserver_;
  1341. const g = ump3.get(f) || function () {
  1342. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1343. }
  1344. ump3.set(f, g);
  1345. g.km34 = 1;
  1346. h.ytRendererBehaviorDataObserver_ = g;
  1347.  
  1348. }
  1349.  
  1350. if (typeof h.ytRendererBehaviorTargetIdObserver_ === 'function' && !(h.ytRendererBehaviorTargetIdObserver_.km34)) {
  1351.  
  1352. const f = h.ytRendererBehaviorTargetIdObserver_;
  1353. const g = ump3.get(f) || function () {
  1354. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1355. }
  1356. ump3.set(f, g);
  1357. g.km34 = 1;
  1358. h.ytRendererBehaviorTargetIdObserver_ = g;
  1359.  
  1360. }
  1361.  
  1362. if (typeof h.unregisterRenderer_ === 'function' && !(h.unregisterRenderer_.km34)) {
  1363.  
  1364. const f = h.unregisterRenderer_;
  1365. const g = ump3.get(f) || function (a) {
  1366. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1367. }
  1368. ump3.set(f, g);
  1369. g.km34 = 1;
  1370. h.unregisterRenderer_ = g;
  1371.  
  1372. }
  1373.  
  1374.  
  1375.  
  1376. if (typeof h.textChanged_ === 'function' && !(h.textChanged_.km34)) {
  1377.  
  1378. const f = h.textChanged_;
  1379. const g = ump3.get(f) || function (a) {
  1380. if (void 0 !== this.isAttached) {
  1381. const hostElement = this.hostElement;
  1382. if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  1383. return;
  1384. }
  1385. }
  1386. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1387. }
  1388. ump3.set(f, g);
  1389. g.km34 = 1;
  1390. h.textChanged_ = g;
  1391.  
  1392. }
  1393.  
  1394.  
  1395.  
  1396.  
  1397. /*
  1398. if(typeof h.stampDomArray_ ==='function' && !(h.stampDomArray_.km34)){
  1399.  
  1400. if( h.stampDomArray_.length === 6){
  1401.  
  1402. const f = h.stampDomArray_;
  1403. const g = function(a,b,c,d,e,h){
  1404. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1405. }
  1406. g.km34 = 1;
  1407. h.stampDomArray_ = g;
  1408.  
  1409. }else{
  1410.  
  1411.  
  1412.  
  1413. const f = h.stampDomArray_;
  1414. const g = function(){
  1415. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1416. }
  1417. g.km34 = 1;
  1418. h.stampDomArray_ = g;
  1419. }
  1420.  
  1421.  
  1422. }
  1423. */
  1424.  
  1425. /*
  1426. if(typeof h.stampDomArraySplices_ ==='function' && !(h.stampDomArraySplices_.km34)){
  1427.  
  1428. if(h.stampDomArraySplices_.length === 3){
  1429.  
  1430.  
  1431.  
  1432. const f = h.stampDomArraySplices_;
  1433. const g = function(a,b,c){
  1434. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1435. }
  1436. g.km34 = 1;
  1437. h.stampDomArraySplices_ = g;
  1438.  
  1439.  
  1440. }else{
  1441.  
  1442.  
  1443.  
  1444. const f = h.stampDomArraySplices_;
  1445. const g = function(){
  1446. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1447. }
  1448. g.km34 = 1;
  1449. h.stampDomArraySplices_ = g;
  1450.  
  1451.  
  1452. }
  1453.  
  1454. }
  1455. */
  1456.  
  1457.  
  1458.  
  1459.  
  1460. // RP.prototype.searchChanged_ = RP.prototype.searchChanged_;
  1461. // RP.prototype.skinToneChanged_ = RP.prototype.skinToneChanged_;
  1462. // RP.prototype.onEmojiHover_ = RP.prototype.onEmojiHover_;
  1463. // RP.prototype.onSelectCategory_ = RP.prototype.onSelectCategory_;
  1464. // RP.prototype.onShowEmojiVariantSelector = RP.prototype.onShowEmojiVariantSelector;
  1465. // RP.prototype.updateCategoriesAndPlaceholder_ = RP.prototype.updateCategoriesAndPlaceholder_;
  1466.  
  1467.  
  1468.  
  1469. if (typeof h.searchChanged_ === 'function' && !(h.searchChanged_.km34)) {
  1470.  
  1471. const f = h.searchChanged_;
  1472. const g = ump3.get(f) || function () {
  1473. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1474. }
  1475. ump3.set(f, g);
  1476. g.km34 = 1;
  1477. h.searchChanged_ = g;
  1478.  
  1479. }
  1480.  
  1481. if (typeof h.skinToneChanged_ === 'function' && !(h.skinToneChanged_.km34)) {
  1482.  
  1483. const f = h.skinToneChanged_;
  1484. const g = ump3.get(f) || function (a) {
  1485. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1486. }
  1487. ump3.set(f, g);
  1488. g.km34 = 1;
  1489. h.skinToneChanged_ = g;
  1490.  
  1491. }
  1492.  
  1493. if (typeof h.onEmojiHover_ === 'function' && !(h.onEmojiHover_.km34)) {
  1494.  
  1495. const f = h.onEmojiHover_;
  1496. const g = ump3.get(f) || function (a) {
  1497. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1498. }
  1499. ump3.set(f, g);
  1500. g.km34 = 1;
  1501. h.onEmojiHover_ = g;
  1502.  
  1503. }
  1504.  
  1505. if (typeof h.onSelectCategory_ === 'function' && !(h.onSelectCategory_.km34)) {
  1506.  
  1507. const f = h.onSelectCategory_;
  1508. const g = ump3.get(f) || function (a) {
  1509. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1510. }
  1511. ump3.set(f, g);
  1512. g.km34 = 1;
  1513. h.onSelectCategory_ = g;
  1514.  
  1515. }
  1516.  
  1517. if (typeof h.onShowEmojiVariantSelector === 'function' && !(h.onShowEmojiVariantSelector.km34)) {
  1518.  
  1519. const f = h.onShowEmojiVariantSelector;
  1520. const g = ump3.get(f) || function (a) {
  1521. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1522. }
  1523. ump3.set(f, g);
  1524. g.km34 = 1;
  1525. h.onShowEmojiVariantSelector = g;
  1526.  
  1527. }
  1528.  
  1529. if (typeof h.updateCategoriesAndPlaceholder_ === 'function' && !(h.updateCategoriesAndPlaceholder_.km34)) {
  1530.  
  1531. const f = h.updateCategoriesAndPlaceholder_;
  1532. const g = ump3.get(f) || function () {
  1533. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1534. }
  1535. ump3.set(f, g);
  1536. g.km34 = 1;
  1537. h.updateCategoriesAndPlaceholder_ = g;
  1538.  
  1539. }
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545. if (typeof h.watchPageActiveChanged_ === 'function' && !(h.watchPageActiveChanged_.km34)) {
  1546.  
  1547. const f = h.watchPageActiveChanged_;
  1548. const g = ump3.get(f) || function () {
  1549. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1550. }
  1551. ump3.set(f, g);
  1552. g.km34 = 1;
  1553. h.watchPageActiveChanged_ = g;
  1554.  
  1555. }
  1556.  
  1557.  
  1558. if (typeof h.activate_ === 'function' && !(h.activate_.km34)) {
  1559.  
  1560. const f = h.activate_;
  1561. const g = ump3.get(f) || function () {
  1562. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1563. }
  1564. ump3.set(f, g);
  1565. g.km34 = 1;
  1566. h.activate_ = g;
  1567.  
  1568. }
  1569. if (typeof h.onYtPlaylistDataUpdated_ === 'function' && !(h.onYtPlaylistDataUpdated_.km34)) {
  1570.  
  1571. const f = h.onYtPlaylistDataUpdated_;
  1572. const g = ump3.get(f) || function () {
  1573. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1574. }
  1575. ump3.set(f, g);
  1576. g.km34 = 1;
  1577. h.onYtPlaylistDataUpdated_ = g;
  1578.  
  1579. }
  1580.  
  1581. FIX_stampDomArray_stableList && fixStampDomArrayStableList(h);
  1582. ENABLE_weakenStampReferences && weakenStampReferences(h);
  1583.  
  1584.  
  1585.  
  1586. /// -----------------------
  1587.  
  1588.  
  1589. // const isMainRenderer = (h) => {
  1590. // if (h.is && h.$ && h.__dataEnabled && h.__dataReady && h.__shady && h.__templateInfo && h.root && h.hostElement) {
  1591. // const q = (h.parentComponent ? 1 : 0) | (h.ytComponentBehavior ? 2 : 0);
  1592. // if (q === 3) {
  1593. // // chat renderer
  1594. // if (h.is.endsWith('-renderer')) {
  1595. // return true;
  1596. // }
  1597. // } else if (q === 0) {
  1598. // // custom lyrics engagement panel
  1599. // if (h.is.endsWith('-renderer')) {
  1600. // return true;
  1601. // }
  1602. // } else if (q === 1) {
  1603. // // input renderer
  1604. // if (h.is.endsWith('-renderer')) {
  1605. // return true;
  1606. // }
  1607. // }
  1608. // }
  1609. // return false;
  1610. // }
  1611.  
  1612. // const skipRenderer = (h) => {
  1613. // return (h.is === 'yt-live-chat-renderer') ||
  1614. // (h.is === 'yt-live-chat-item-list-renderer') ||
  1615. // (h.is === 'yt-live-chat-text-input-field-renderer') ||
  1616. // (h.is === 'yt-live-chat-message-buy-flow-renderer') ||
  1617. // false;
  1618. // }
  1619.  
  1620.  
  1621. /*
  1622. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km31) && h.rendererStamperApplyChangeRecord_.length === 3) {
  1623.  
  1624. const f = h.rendererStamperApplyChangeRecord_;
  1625. h.rendererStamperApplyChangeRecord31_ = f;
  1626. const g = ump3.get(f) || function (a, b, c) {
  1627. if (isMainRenderer(this) || (this.updateChildVisibilityProperties && !this.markDirty)) {
  1628. let y = false;
  1629. if (!this.markDirty) {
  1630. // yt-live-chat-dialog-renderer
  1631. // ytd-engagement-panel-section-list-renderer
  1632. y = true;
  1633. } else if (!this.visibilityObserverForChild_ && !!this.getVisibilityObserverForChild) {
  1634. const lobs = this.localVisibilityObserver_;
  1635. if (this.isRenderer_ === true) {
  1636. if (lobs) {
  1637. if (lobs.observer && lobs.isConnected === true) {
  1638. // if (lobs.observer && lobs.isConnected === true && lobs.pauseObservingUntilReconnect === false && lobs.handlers && lobs.handlers.size > 0) {
  1639. // if ((this.__data || 0).isEmpty === false) {
  1640. // // by pass
  1641. // } else if (this.is === 'yt-live-chat-renderer') {
  1642. // y = true;
  1643. // }
  1644. if (this.is === 'yt-live-chat-renderer') {
  1645. y = true;
  1646. }
  1647. } else {
  1648. y = true;
  1649. }
  1650. } else if (lobs === null) {
  1651. y = true;
  1652. } else {
  1653. console.log('renderer-check-failure 01', this.is)
  1654. }
  1655. } else {
  1656. console.log('renderer-check-failure 02', this.is)
  1657. }
  1658. }
  1659. if (y) {
  1660. return f.apply(this, arguments);
  1661. }
  1662. }
  1663. let c2 = c;
  1664. if (c && typeof c === 'object') {
  1665. c2 = {};
  1666. for (const entry of Object.entries(c)) {
  1667. const [key, value] = entry;
  1668. let choice = 0;
  1669. if (value && typeof value === 'object') {
  1670. if (key === 'base' && value.length >= 1) choice = 1;
  1671. else if (key === 'value' && value.indexSplices && value.indexSplices.length >= 1) choice = 2;
  1672. }
  1673. if (choice === 1) c2[key] = value.slice(0);
  1674. else if (choice === 2) c2[key] = Object.assign({}, value, { indexSplices: value.indexSplices.map(splice=>{
  1675.  
  1676. if (!splice || typeof splice !== 'object') return splice;
  1677. if (splice.removed && splice.removed.length >= 1) splice.removed = splice.removed.slice(0);
  1678. if (splice.object && splice.object.length >= 1) splice.object = splice.object.slice(0);
  1679.  
  1680. return splice;
  1681.  
  1682. }) });
  1683. else c2[key] = value;
  1684. }
  1685. }
  1686. const acceptable = () => {
  1687. return this.isAttached && this.data && this.__dataEnabled
  1688. }
  1689. // sequence on the same proto
  1690. this[qm47] = (this[qm47] || Promise.resolve()).then(() => acceptable() && this.rendererStamperApplyChangeRecord31_(a, b, c2)).catch(console.log);
  1691. }
  1692. ump3.set(f, g);
  1693. g.km31 = 1;
  1694. h.rendererStamperApplyChangeRecord_ = g;
  1695.  
  1696.  
  1697. }
  1698. */
  1699.  
  1700.  
  1701.  
  1702.  
  1703. /*
  1704. if (typeof h.rendererStamperObserver_ === 'function' && !(h.rendererStamperObserver_.km34)) {
  1705.  
  1706. const f = h.rendererStamperObserver_;
  1707. const g = ump3.get(f) || function (a, b, c) {
  1708. if (isMainRenderer(this)) {
  1709. return f.apply(this, arguments);
  1710. }
  1711. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1712. }
  1713. ump3.set(f, g);
  1714. g.km34 = 1;
  1715. h.rendererStamperObserver_ = g;
  1716.  
  1717. }
  1718.  
  1719.  
  1720. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km34)) {
  1721.  
  1722. const f = h.rendererStamperApplyChangeRecord_;
  1723. const g = ump3.get(f) || function () {
  1724. if (isMainRenderer(this)) {
  1725. return f.apply(this, arguments);
  1726. }
  1727. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1728. }
  1729. ump3.set(f, g);
  1730. g.km34 = 1;
  1731. h.rendererStamperApplyChangeRecord_ = g;
  1732.  
  1733. }
  1734.  
  1735.  
  1736.  
  1737. if (typeof h.flushRenderStamperComponentBindings_ === 'function' && !(h.flushRenderStamperComponentBindings_.km34)) {
  1738.  
  1739. const f = h.flushRenderStamperComponentBindings_;
  1740. const g = ump3.get(f) || function () {
  1741. if (isMainRenderer(this)) {
  1742. return f.apply(this, arguments);
  1743. }
  1744. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1745. }
  1746. ump3.set(f, g);
  1747. g.km34 = 1;
  1748. h.flushRenderStamperComponentBindings_ = g;
  1749.  
  1750. }
  1751.  
  1752.  
  1753. if (typeof h.forwardRendererStamperChanges_ === 'function' && !(h.forwardRendererStamperChanges_.km34)) {
  1754.  
  1755. const f = h.forwardRendererStamperChanges_;
  1756. const g = ump3.get(f) || function () {
  1757. if (isMainRenderer(this)) {
  1758. return f.apply(this, arguments);
  1759. }
  1760. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1761. }
  1762. ump3.set(f, g);
  1763. g.km34 = 1;
  1764. h.forwardRendererStamperChanges_ = g;
  1765.  
  1766. }
  1767. */
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773. // console.log(123)
  1774.  
  1775. // return;
  1776.  
  1777.  
  1778. /*
  1779.  
  1780. // buggy for page swtiching
  1781.  
  1782. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km31)) {
  1783.  
  1784.  
  1785.  
  1786.  
  1787. const f = h.dataChanged_;
  1788. h.dataChanged31_ = f;
  1789. const g = ump3.get(f) || function (...args) {
  1790.  
  1791. if (isMainRenderer(this)) {
  1792. return f.apply(this, arguments);
  1793. }
  1794.  
  1795. // sequence on the same proto
  1796. this[qm47] = (this[qm47] || Promise.resolve()).then(() => this.dataChanged31_(...args)).catch(console.log);
  1797. }
  1798. ump3.set(f, g);
  1799. g.km31 = 1;
  1800. h.dataChanged_ = g;
  1801.  
  1802.  
  1803. }
  1804. */
  1805.  
  1806.  
  1807. /*
  1808.  
  1809. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km34)) {
  1810.  
  1811. const f = h.dataChanged_;
  1812. const g = ump3.get(f) || function () {
  1813. if (isMainRenderer(this)) {
  1814. return f.apply(this, arguments);
  1815. }
  1816. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1817. }
  1818. ump3.set(f, g);
  1819. g.km34 = 1;
  1820. h.dataChanged_ = g;
  1821.  
  1822. }
  1823. */
  1824.  
  1825.  
  1826.  
  1827. if (typeof h.tryRenderChunk_ === 'function' && !(h.tryRenderChunk_.km34)) {
  1828.  
  1829. const f = h.tryRenderChunk_;
  1830. const g = ump3.get(f) || function () {
  1831. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1832. }
  1833. ump3.set(f, g);
  1834. g.km34 = 1;
  1835. h.tryRenderChunk_ = g;
  1836.  
  1837. }
  1838.  
  1839.  
  1840. if (typeof h.renderChunk_ === 'function' && !(h.renderChunk_.km34)) {
  1841.  
  1842. const f = h.renderChunk_;
  1843. const g = ump3.get(f) || function () {
  1844. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1845. }
  1846. ump3.set(f, g);
  1847. g.km34 = 1;
  1848. h.renderChunk_ = g;
  1849.  
  1850. }
  1851.  
  1852. if (typeof h.deepLazyListObserver_ === 'function' && !(h.deepLazyListObserver_.km34)) {
  1853.  
  1854. const f = h.deepLazyListObserver_;
  1855. const g = ump3.get(f) || function () {
  1856. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1857. }
  1858. ump3.set(f, g);
  1859. g.km34 = 1;
  1860. h.deepLazyListObserver_ = g;
  1861.  
  1862. }
  1863.  
  1864.  
  1865. if (typeof h.onItemsUpdated_ === 'function' && !(h.onItemsUpdated_.km34)) {
  1866.  
  1867. const f = h.onItemsUpdated_;
  1868. const g = ump3.get(f) || function () {
  1869. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1870. }
  1871. ump3.set(f, g);
  1872. g.km34 = 1;
  1873. h.onItemsUpdated_ = g;
  1874.  
  1875. }
  1876.  
  1877. /*
  1878. // see https://github.com/cyfung1031/userscript-supports/issues/20
  1879. if (typeof h.updateChangeRecord_ === 'function' && !(h.updateChangeRecord_.km34)) {
  1880.  
  1881. const f = h.updateChangeRecord_;
  1882. const g = ump3.get(f) || function () {
  1883. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1884. }
  1885. ump3.set(f, g);
  1886. g.km34 = 1;
  1887. h.updateChangeRecord_ = g;
  1888.  
  1889. }
  1890. */
  1891.  
  1892.  
  1893. if (typeof h.requestRenderChunk_ === 'function' && !(h.requestRenderChunk_.km34)) {
  1894.  
  1895. const f = h.requestRenderChunk_;
  1896. const g = ump3.get(f) || function () {
  1897. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1898. }
  1899. ump3.set(f, g);
  1900. g.km34 = 1;
  1901. h.requestRenderChunk_ = g;
  1902.  
  1903. }
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909. return;
  1910.  
  1911.  
  1912.  
  1913. /*
  1914. if (typeof h.cancelPendingTasks_ === 'function' && !(h.cancelPendingTasks_.km34)) {
  1915.  
  1916. const f = h.cancelPendingTasks_;
  1917. const g = ump3.get(f) || function () {
  1918. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1919. }
  1920. ump3.set(f, g);
  1921. g.km34 = 1;
  1922. h.cancelPendingTasks_ = g;
  1923.  
  1924. }
  1925.  
  1926.  
  1927. if (typeof h.fillRange_ === 'function' && !(h.fillRange_.km34)) {
  1928.  
  1929. const f = h.fillRange_;
  1930. const g = ump3.get(f) || function () {
  1931. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1932. }
  1933. ump3.set(f, g);
  1934. g.km34 = 1;
  1935. h.fillRange_ = g;
  1936.  
  1937. }
  1938. */
  1939.  
  1940.  
  1941.  
  1942.  
  1943. if (typeof h.addTextNodes_ === 'function' && !(h.addTextNodes_.km34)) {
  1944.  
  1945. const f = h.addTextNodes_;
  1946. const g = function () {
  1947. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1948. }
  1949. g.km34 = 1;
  1950. h.addTextNodes_ = g;
  1951.  
  1952. }
  1953.  
  1954.  
  1955.  
  1956.  
  1957. if (typeof h.updateText_ === 'function' && !(h.updateText_.km34)) {
  1958.  
  1959. const f = h.updateText_;
  1960. const g = function () {
  1961. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1962. }
  1963. g.km34 = 1;
  1964. h.updateText_ = g;
  1965.  
  1966. }
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972. if (typeof h.stampTypeChanged_ === 'function' && !(h.stampTypeChanged_.km34)) {
  1973.  
  1974. const f = h.stampTypeChanged_;
  1975. const g = function () {
  1976. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1977. }
  1978. g.km34 = 1;
  1979. h.stampTypeChanged_ = g;
  1980.  
  1981. }
  1982.  
  1983.  
  1984.  
  1985.  
  1986. // console.log(166)
  1987.  
  1988.  
  1989.  
  1990.  
  1991. }
  1992.  
  1993. const keyStConnectedCallback = Symbol(); // avoid copying the value
  1994.  
  1995. const keyStDisconnectedCallback = Symbol(); // avoid copying the value
  1996. const cmf = new WeakMap();
  1997. const dmf = new WeakMap();
  1998.  
  1999. const gvGenerator = (nv) => {
  2000. return function () {
  2001. const cnt = insp(this);
  2002. const hostElement = cnt.hostElement || 0;
  2003. const dollar = hostElement ? (this.$ || indr(this)) : 0;
  2004. let p = (hostElement instanceof HTMLElement) && (dollar || !this.is);
  2005. if (p && (!dollar && !this.is)) {
  2006. const nodeName = hostElement.nodeName;
  2007. if (typeof nodeName !== 'string') {
  2008. // just in case
  2009. } else if (nodeName.startsWith("DOM-")) {
  2010. // dom-if, dom-repeat, etc
  2011. } else {
  2012. // yt element - new model, yt-xxxx, anixxxxxx
  2013. p = false;
  2014. }
  2015. }
  2016. if (p) {
  2017. if (typeof cnt.markDirty === 'function') {
  2018. // the yt element might call markDirty (occasionally)
  2019. p = false;
  2020. } else if (this.is === 'ytd-engagement-panel-section-list-renderer') {
  2021. // see https://github.com/cyfung1031/userscript-supports/issues/20
  2022. p = false;
  2023. }
  2024. }
  2025. if (p) {
  2026.  
  2027. // << dom-repeat & dom-if >>
  2028.  
  2029. // sequence on the same instance
  2030. this[qm57] = (this[qm57] || Promise.resolve()).then(() => nv.apply(this, arguments)).catch(console.log);
  2031. } else {
  2032. nv.apply(this, arguments);
  2033. }
  2034. };
  2035. }
  2036.  
  2037. const setupWeakRef = (h) => {
  2038.  
  2039.  
  2040. if (WEAK_REF_BINDING && !h.kz62 && setup$ && setupD && setupDataHost && (h.is || h.__dataHost)) {
  2041.  
  2042. let skip = false;
  2043. // if (h.is && typeof h.is === 'string' && h.is.length > 15 && h.is.length < 30) {
  2044. // if (h.is.includes('yt-') && !h.$ && h.is.length !== 20 && h.is.length !== 21 && h.is.length !== 22) {
  2045. // skip = true;
  2046. // // return;
  2047. // }
  2048. // }
  2049.  
  2050. h.kz62 = 1;
  2051.  
  2052. //
  2053.  
  2054. setup$(h);
  2055. const hostElement = h.hostElement;
  2056.  
  2057. if (hostElement !== h) {
  2058.  
  2059. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  2060. setupD(h, s);
  2061.  
  2062. }
  2063.  
  2064. const dh = h.__dataHost;
  2065.  
  2066. setupDataHost(dh, skip)
  2067. }
  2068.  
  2069.  
  2070.  
  2071.  
  2072. if (hostElement) {
  2073.  
  2074. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  2075. setupD(hostElement, s);
  2076.  
  2077. }
  2078.  
  2079. const dh = hostElement.__dataHost;
  2080.  
  2081. setupDataHost(dh, skip)
  2082.  
  2083.  
  2084.  
  2085.  
  2086. aDelay().then(() => {
  2087. setupD(hostElement, '__CE_shadowRoot');
  2088. });
  2089.  
  2090.  
  2091. }
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097. }
  2098.  
  2099. }
  2100.  
  2101.  
  2102. let nativeHTMLElement = window.HTMLElement;
  2103.  
  2104. try {
  2105.  
  2106. const q = document.createElement('template');
  2107. q.innerHTML = '<ytz-null361></ytz-null361>';
  2108. nativeHTMLElement = q.content.firstChild.constructor
  2109.  
  2110. } catch (e) { }
  2111.  
  2112. if (!nativeHTMLElement.prototype.connectedCallback) {
  2113. nativeHTMLElement.prototype.connectedCallback79 = nativeHTMLElement.prototype.connectedCallback;
  2114. nativeHTMLElement.prototype.connectedCallback = function () {
  2115. let r;
  2116. if (this.connectedCallback79) r = this.connectedCallback79.apply(this, arguments);
  2117.  
  2118. if (WEAK_REF_BINDING && (this instanceof Node) && (this.is || this.__dataHost)) {
  2119. setupWeakRef(this)
  2120. // setupWeakRef(this.__dataHost)
  2121. }
  2122. return r;
  2123. }
  2124. }
  2125.  
  2126. ENABLE_discreteTasking && Object.defineProperty(Object.prototype, 'connectedCallback', {
  2127. get() {
  2128. const f = this[keyStConnectedCallback];
  2129. if (this.is) {
  2130. setupDiscreteTasks(this, true);
  2131. if (f) this.ky36 = 1;
  2132. }
  2133. if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  2134. setupWeakRef(this)
  2135. }
  2136. return f;
  2137. },
  2138. set(nv) {
  2139. let gv;
  2140. if (typeof nv === 'function') {
  2141.  
  2142. gv = cmf.get(nv) || gvGenerator(nv);
  2143. if (gv !== nv) {
  2144. cmf.set(nv, gv);
  2145. cmf.set(gv, gv);
  2146. dmf.set(gv, nv);
  2147. }
  2148.  
  2149. } else {
  2150. gv = nv;
  2151. }
  2152. this[keyStConnectedCallback] = gv; // proto or object
  2153. if (this.is) {
  2154. setupDiscreteTasks(this);
  2155. }
  2156. if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  2157. setupWeakRef(this)
  2158. }
  2159. return true;
  2160. },
  2161. enumerable: false,
  2162. configurable: true
  2163.  
  2164. });
  2165.  
  2166. const pLoad = new Promise(resolve => {
  2167. if (document.readyState !== 'loading') {
  2168. resolve();
  2169. } else {
  2170. window.addEventListener("DOMContentLoaded", resolve, false);
  2171. }
  2172. });
  2173. pLoad.then(() => {
  2174.  
  2175. let nonce = document.querySelector('style[nonce]');
  2176. nonce = nonce ? nonce.getAttribute('nonce') : null;
  2177. const st = document.createElement('style');
  2178. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  2179. st.textContent = "none-element-k47{order:0}";
  2180. st.addEventListener('load', () => {
  2181. pf31.resolve();
  2182. p59 = 1;
  2183. }, false);
  2184. document.body.appendChild(st);
  2185.  
  2186.  
  2187. // console.debug('90002', location.pathname)
  2188. // console.log(90000, location.pathname)
  2189.  
  2190. });
  2191.  
  2192. const prepareLogs = [];
  2193.  
  2194. const skipAdsDetection = new Set(['/robots.txt', '/live_chat', '/live_chat_replay']);
  2195.  
  2196. let winError00 = window.onerror;
  2197.  
  2198. let fix_error_many_stack_state = !FIX_error_many_stack ? 0 : skipAdsDetection.has(location.pathname) ? 2 : 1;
  2199.  
  2200. if (!JSON || !('parse' in JSON)) fix_error_many_stack_state = 0;
  2201.  
  2202. ; FIX_Iframe_NULL_SRC && (() => {
  2203.  
  2204. const emptyBlobUrl = URL.createObjectURL(new Blob([], { type: 'text/html' }));
  2205. const lcOpt = { sensitivity: 'base' };
  2206. document.createElement24 = document.createElement;
  2207. document.createElement = function (t) {
  2208. if (typeof t === 'string' && t.length === 6) {
  2209. if (t.localeCompare('iframe', undefined, lcOpt) === 0) {
  2210. const p = this.createElement24(t);
  2211. try {
  2212. const stack = new Error().stack;
  2213. const isSearchbox = stack.includes('initializeSearchbox'); // see https://greasyfork.org/scripts/473972-youtube-js-engine-tamer/discussions/217084
  2214. if (!isSearchbox) {
  2215. p.src = emptyBlobUrl; // avoid iframe is appended to DOM without any url
  2216. }
  2217. } catch (e) { }
  2218. return p;
  2219. }
  2220. }
  2221. return this.createElement24.apply(this, arguments);
  2222. };
  2223.  
  2224. })();
  2225.  
  2226. ; fix_error_many_stack_state === 1 && (() => {
  2227.  
  2228.  
  2229. let p1 = winError00;
  2230.  
  2231. let stackNeedleDetails = null;
  2232.  
  2233. Object.defineProperty(Object.prototype, 'matchAll', {
  2234. get() {
  2235. stackNeedleDetails = this;
  2236. return true;
  2237. },
  2238. enumerable: true,
  2239. configurable: true
  2240. });
  2241.  
  2242. try {
  2243. JSON.parse("{}");
  2244. } catch (e) {
  2245. console.warn(e)
  2246. fix_error_many_stack_state = 0;
  2247. }
  2248.  
  2249. delete Object.prototype['matchAll'];
  2250.  
  2251. let p2 = window.onerror;
  2252.  
  2253. window.onerror = p1;
  2254.  
  2255. if (fix_error_many_stack_state === 0) return;
  2256.  
  2257. if (stackNeedleDetails) {
  2258. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  2259. stackNeedleDetails.matchAll = true;
  2260. }
  2261.  
  2262. if (p1 === p2) return (fix_error_many_stack_state = 0);
  2263.  
  2264. // p1!==p2
  2265. fix_error_many_stack_state = !stackNeedleDetails ? 4 : 3;
  2266.  
  2267. })();
  2268.  
  2269. ; fix_error_many_stack_state === 2 && (() => {
  2270.  
  2271.  
  2272. let p1 = winError00;
  2273.  
  2274. let objectPrune = null;
  2275. let stackNeedleDetails = null;
  2276.  
  2277. Object.defineProperty(Function.prototype, 'findOwner', {
  2278. get() {
  2279. objectPrune = this;
  2280. return this._findOwner;
  2281. },
  2282. set(nv) {
  2283. this._findOwner = nv;
  2284. return true;
  2285. },
  2286. enumerable: true,
  2287. configurable: true
  2288. });
  2289.  
  2290. Object.defineProperty(Object.prototype, 'matchAll', {
  2291. get() {
  2292. stackNeedleDetails = this;
  2293. return true;
  2294. },
  2295. enumerable: true,
  2296. configurable: true
  2297. });
  2298.  
  2299. try {
  2300. JSON.parse("{}");
  2301. } catch (e) {
  2302. console.warn(e)
  2303. fix_error_many_stack_state = 0;
  2304. }
  2305.  
  2306. delete Function.prototype['findOwner'];
  2307. delete Object.prototype['matchAll'];
  2308.  
  2309. let p2 = window.onerror;
  2310.  
  2311. if (p1 !== p2) return (fix_error_many_stack_state = 4); // p1 != p2
  2312.  
  2313. if (fix_error_many_stack_state == 0) return;
  2314.  
  2315. // the following will only execute when Brave's scriptlets.js is executed.
  2316.  
  2317. prepareLogs.push("fix_error_many_stack_state NB")
  2318.  
  2319. if (stackNeedleDetails) {
  2320. stackNeedleDetails.pattern = null;
  2321. stackNeedleDetails.re = null;
  2322. stackNeedleDetails.expect = null;
  2323. stackNeedleDetails.matchAll = true;
  2324. }
  2325.  
  2326. if (objectPrune) {
  2327. objectPrune.findOwner = objectPrune.mustProcess = objectPrune.logJson = () => { }
  2328. delete objectPrune._findOwner;
  2329. }
  2330.  
  2331. fix_error_many_stack_state = 3;
  2332. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  2333. JSON.parse.objectPrune = objectPrune;
  2334.  
  2335. })();
  2336.  
  2337. ; fix_error_many_stack_state === 3 && (() => {
  2338.  
  2339.  
  2340. let p1 = winError00;
  2341.  
  2342. try {
  2343. JSON.parse("{}");
  2344. } catch (e) {
  2345. console.warn(e)
  2346. fix_error_many_stack_state = 0;
  2347. }
  2348.  
  2349. let p2 = window.onerror;
  2350.  
  2351. if (p1 === p2) return;
  2352.  
  2353. window.onerror = p1;
  2354.  
  2355. if (fix_error_many_stack_state === 0) return;
  2356.  
  2357. fix_error_many_stack_state = 4; // p1 != p2
  2358.  
  2359.  
  2360. })();
  2361.  
  2362. fix_error_many_stack_state === 4 && (() => {
  2363.  
  2364. // the following will only execute when Brave's scriptlets.js is executed.
  2365.  
  2366. prepareLogs.push("fix_error_many_stack_state AB")
  2367.  
  2368. JSON.parseProxy = JSON.parse;
  2369.  
  2370. JSON.parse = ((parse) => {
  2371.  
  2372. parse = parse.bind(JSON); // get a new instance of the current JSON.parse
  2373. return function (text, reviver) {
  2374. const onerror = window.onerror;
  2375. window.onerror = null;
  2376. let r;
  2377. try {
  2378. r = parse(...arguments);
  2379. } catch (e) {
  2380. r = e;
  2381. }
  2382. window.onerror = onerror;
  2383. if (r instanceof Error) {
  2384. throw r;
  2385. }
  2386. return r;
  2387. }
  2388.  
  2389. })(JSON.parse);
  2390.  
  2391.  
  2392. })();
  2393.  
  2394.  
  2395.  
  2396. // ================================================ 0.4.5 ================================================
  2397.  
  2398.  
  2399. // ; (() => {
  2400.  
  2401. // if (FIX_error_many_stack && self instanceof Window) {
  2402. // // infinite stack due to matchesStackTrace inside objectPrune of AdsBlock
  2403.  
  2404. // const pdK = Object.getOwnPropertyDescriptor(window, 'onerror');
  2405. // if (!pdK || (pdK.get && pdK.configurable)) {
  2406.  
  2407. // } else {
  2408. // return;
  2409. // }
  2410.  
  2411. // let unsupportErrorFix = false;
  2412.  
  2413. // let firstHook = true;
  2414. // let busy33 = false;
  2415.  
  2416. // let state = 0;
  2417.  
  2418. // if (pdK) {
  2419. // delete window['onerror'];
  2420. // }
  2421.  
  2422. // const pd = {
  2423. // get() {
  2424. // const stack = (new Error()).stack;
  2425. // // targetStack = stack;
  2426. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  2427. // state = isGetExceptionToken ? 1 : 0;
  2428. // delete Window.prototype['onerror'];
  2429. // let r = pdK ? pdK.get.call(this) : this.onerror;
  2430. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2431. // // console.log('onerror get', r)
  2432. // return r;
  2433. // },
  2434. // set(nv) {
  2435. // const stack = (new Error()).stack;
  2436. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  2437. // state = state === 1 && isGetExceptionToken ? 2 : 0;
  2438. // /** @type {string?} */
  2439. // let sToken = null;
  2440. // if (unsupportErrorFix || busy33) {
  2441.  
  2442. // } else if (typeof nv === 'function' && state === 2) {
  2443. // if (firstHook) {
  2444. // firstHook = false;
  2445. // console.groupCollapsed('Infinite onerror Bug Found');
  2446. // console.log(location.href);
  2447. // console.log(stack);
  2448. // console.log(nv);
  2449. // console.groupEnd();
  2450. // }
  2451. // let _token = null;
  2452. // busy33 = true;
  2453. // String.prototype.includes76 = String.prototype.includes;
  2454. // String.prototype.includes = function (token) {
  2455. // _token = token;
  2456. // return true;
  2457. // }
  2458. // nv('token');
  2459. // String.prototype.includes = String.prototype.includes76;
  2460. // sToken = _token;
  2461. // busy33 = false;
  2462. // if (typeof sToken !== 'string') {
  2463. // unsupportErrorFix = true;
  2464. // }
  2465. // }
  2466. // delete Window.prototype['onerror'];
  2467. // if (typeof sToken === 'string' && sToken.length > 1) {
  2468. // /** @type {string} */
  2469. // const token = sToken;
  2470. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>?} } */
  2471. // const currentOnerror = pdK ? pdK.get.call(this) : this.onerror;
  2472.  
  2473. // const now = Date.now();
  2474. // const tokenEntry = {
  2475. // token,
  2476. // expired: now + FIX_error_many_stack_keepAliveDuration
  2477. // }
  2478. // /** @typedef {typeof tokenEntry} TokenEntry */
  2479.  
  2480. // /** @type {Set<TokenEntry>} */
  2481. // const errorTokens = currentOnerror.errorTokens;
  2482.  
  2483. // if (errorTokens) {
  2484. // if (errorTokens.size > FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than) {
  2485. // for (const entry of errorTokens) {
  2486. // if (entry.expired < now) {
  2487. // errorTokens.delete(entry);
  2488. // }
  2489. // }
  2490. // }
  2491. // errorTokens.add(tokenEntry)
  2492. // } else {
  2493. // /** @type {Set<TokenEntry>} */
  2494. // const errorTokens = new Set([tokenEntry]);
  2495. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>} } */
  2496. // const newOnerror = ((oe) => {
  2497. // const r = function (msg, ...args) {
  2498. // if (typeof msg === 'string' && errorTokens.size > 0) {
  2499. // for (const entry of errorTokens) {
  2500. // if (msg.includes(entry.token)) return true;
  2501. // }
  2502. // }
  2503. // if (typeof oe === 'function') {
  2504. // return oe.apply(this, arguments);
  2505. // }
  2506. // };
  2507. // r.errorTokens = errorTokens;
  2508. // return r;
  2509. // })(currentOnerror);
  2510.  
  2511. // if (pdK && pdK.set) pdK.set.call(this, newOnerror);
  2512. // else this.onerror = newOnerror;
  2513. // }
  2514. // } else {
  2515. // if (pdK && pdK.set) pdK.set.call(this, nv);
  2516. // else this.onerror = nv;
  2517. // }
  2518. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2519.  
  2520. // // console.log('onerror set', nv)
  2521. // return true;
  2522. // },
  2523. // enumerable: true,
  2524. // configurable: true
  2525. // }
  2526.  
  2527. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2528.  
  2529.  
  2530. // }
  2531.  
  2532.  
  2533. // })();
  2534.  
  2535.  
  2536.  
  2537. // ================================================ 0.4.5 ================================================
  2538.  
  2539.  
  2540. // << if FIX_yt_player >>
  2541.  
  2542. // credit to @nopeless (https://greasyfork.org/scripts/471489-youtube-player-perf/)
  2543. const PERF_471489_ = true;
  2544. // PERF_471489_ is not exactly the same to Youtube Player perf v0.7
  2545. // This script uses a much gentle way to tamer the JS engine instead.
  2546.  
  2547. // << end >>
  2548.  
  2549. const steppingScaleN = 200; // transform: scaleX(k/N); 0<k<N
  2550.  
  2551.  
  2552.  
  2553. const nilFn = () => { };
  2554.  
  2555. let isMainWindow = false;
  2556. try {
  2557. isMainWindow = window.document === window.top.document
  2558. } catch (e) { }
  2559.  
  2560. let NO_PRELOAD_GENERATE_204_BYPASS = NO_PRELOAD_GENERATE_204 ? false : true;
  2561.  
  2562. const onRegistryReady = (callback) => {
  2563. if (typeof customElements === 'undefined') {
  2564. if (!('__CE_registry' in document)) {
  2565. // https://github.com/webcomponents/polyfills/
  2566. Object.defineProperty(document, '__CE_registry', {
  2567. get() {
  2568. // return undefined
  2569. },
  2570. set(nv) {
  2571. if (typeof nv == 'object') {
  2572. delete this.__CE_registry;
  2573. this.__CE_registry = nv;
  2574. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  2575. }
  2576. return true;
  2577. },
  2578. enumerable: false,
  2579. configurable: true
  2580. })
  2581. }
  2582. let eventHandler = (evt) => {
  2583. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  2584. const f = callback;
  2585. callback = null;
  2586. eventHandler = null;
  2587. f();
  2588. };
  2589. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  2590. } else {
  2591. callback();
  2592. }
  2593. };
  2594.  
  2595.  
  2596. const assertor = (f) => f() || console.assert(false, f + "");
  2597.  
  2598. const fnIntegrity = (f, d) => {
  2599. if (!f || typeof f !== 'function') {
  2600. console.warn('f is not a function', f);
  2601. return;
  2602. }
  2603. let p = f + "", s = 0, j = -1, w = 0;
  2604. for (let i = 0, l = p.length; i < l; i++) {
  2605. const t = p[i];
  2606. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  2607. if (j < i - 1) w++;
  2608. j = i;
  2609. } else {
  2610. s++;
  2611. }
  2612. }
  2613. let itz = `${f.length}.${s}.${w}`;
  2614. if (!d) {
  2615. return itz;
  2616. } else {
  2617. return itz === d;
  2618. }
  2619. };
  2620.  
  2621. const getZq = (_yt_player) => {
  2622.  
  2623. const w = 'Zq';
  2624.  
  2625. let arr = [];
  2626.  
  2627. for (const [k, v] of Object.entries(_yt_player)) {
  2628.  
  2629. const p = typeof v === 'function' ? v.prototype : 0;
  2630. if (p
  2631. && typeof p.start === 'function' && p.start.length === 0
  2632. && typeof p.isActive === 'function' && p.isActive.length === 0
  2633. && typeof p.stop === 'function' && p.stop.length === 0
  2634. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  2635. && !p.send && !p.abort
  2636. && !p.sample && !p.initialize && !p.fail && !p.getName
  2637. // && !p.dispose && !p.isDisposed
  2638.  
  2639. ) {
  2640. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2641.  
  2642.  
  2643. }
  2644.  
  2645. }
  2646.  
  2647. if (arr.length === 0) {
  2648.  
  2649. console.warn(`Key does not exist. [${w}]`);
  2650. } else {
  2651.  
  2652. console.log(`[${w}]`, arr);
  2653. return arr[0];
  2654. }
  2655.  
  2656.  
  2657.  
  2658.  
  2659. }
  2660.  
  2661.  
  2662. const getVG = (_yt_player) => {
  2663. const w = 'VG';
  2664.  
  2665. let arr = [];
  2666.  
  2667. for (const [k, v] of Object.entries(_yt_player)) {
  2668.  
  2669. const p = typeof v === 'function' ? v.prototype : 0;
  2670. if (p
  2671. && typeof p.show === 'function' && p.show.length === 1
  2672. && typeof p.hide === 'function' && p.hide.length === 0
  2673. && typeof p.stop === 'function' && p.stop.length === 0) {
  2674.  
  2675. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2676.  
  2677. }
  2678.  
  2679. }
  2680.  
  2681.  
  2682. if (arr.length === 0) {
  2683.  
  2684. console.warn(`Key does not exist. [${w}]`);
  2685. } else {
  2686.  
  2687. console.log(`[${w}]`, arr);
  2688. return arr[0];
  2689. }
  2690.  
  2691.  
  2692.  
  2693. }
  2694.  
  2695.  
  2696. const getzo = (_yt_player) => {
  2697. const w = 'zo';
  2698.  
  2699. let arr = [];
  2700.  
  2701. for (const [k, v] of Object.entries(_yt_player)) {
  2702.  
  2703. if (
  2704. typeof v === 'function' && v.length === 3 && k.length < 3
  2705. && (v + "").includes("a.style[b]=c")
  2706. ) {
  2707.  
  2708. arr.push(k);
  2709.  
  2710. }
  2711.  
  2712. }
  2713.  
  2714.  
  2715. if (arr.length === 0) {
  2716.  
  2717. console.warn(`Key does not exist. [${w}]`);
  2718. } else {
  2719.  
  2720. console.log(`[${w}]`, arr);
  2721. return arr[0];
  2722. }
  2723.  
  2724. }
  2725.  
  2726. const addProtoToArr = (parent, key, arr) => {
  2727.  
  2728.  
  2729. let isChildProto = false;
  2730. for (const sr of arr) {
  2731. if (parent[key].prototype instanceof parent[sr]) {
  2732. isChildProto = true;
  2733. break;
  2734. }
  2735. }
  2736.  
  2737. if (isChildProto) return;
  2738.  
  2739. arr = arr.filter(sr => {
  2740. if (parent[sr].prototype instanceof parent[key]) {
  2741. return false;
  2742. }
  2743. return true;
  2744. });
  2745.  
  2746. arr.push(key);
  2747.  
  2748. return arr;
  2749.  
  2750.  
  2751. }
  2752.  
  2753. const getuG = (_yt_player) => {
  2754.  
  2755. const w = 'uG';
  2756.  
  2757. let arr = [];
  2758.  
  2759. for (const [k, v] of Object.entries(_yt_player)) {
  2760.  
  2761.  
  2762. const p = typeof v === 'function' ? v.prototype : 0;
  2763.  
  2764. if (p
  2765. && typeof p.createElement === 'function' && p.createElement.length === 2
  2766. && typeof p.detach === 'function' && p.detach.length === 0
  2767. && typeof p.update === 'function' && p.update.length === 1
  2768. && typeof p.updateValue === 'function' && p.updateValue.length === 2
  2769. ) {
  2770.  
  2771. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2772.  
  2773. }
  2774.  
  2775. }
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781. if (arr.length === 0) {
  2782.  
  2783. console.warn(`Key does not exist. [${w}]`);
  2784. } else {
  2785.  
  2786. console.log(`[${w}]`, arr);
  2787. return arr[0];
  2788. }
  2789.  
  2790. }
  2791.  
  2792.  
  2793.  
  2794. // << if FIX_schedulerInstanceInstance_ >>
  2795.  
  2796. let idleFrom = Date.now() + 2700;
  2797. let slowMode = false;
  2798.  
  2799. let ytEvented = false;
  2800.  
  2801.  
  2802. const setupEvents = FIX_schedulerInstanceInstance_V1 && !FIX_schedulerInstanceInstance_V2 ? () => {
  2803.  
  2804. document.addEventListener('yt-navigate', () => {
  2805.  
  2806. ytEvented = true;
  2807. slowMode = false;
  2808. idleFrom = Date.now() + 2700;
  2809.  
  2810. });
  2811. document.addEventListener('yt-navigate-start', () => {
  2812.  
  2813. ytEvented = true;
  2814. slowMode = false;
  2815. idleFrom = Date.now() + 2700;
  2816.  
  2817. });
  2818.  
  2819. document.addEventListener('yt-page-type-changed', () => {
  2820.  
  2821. ytEvented = true;
  2822. slowMode = false;
  2823. idleFrom = Date.now() + 1700;
  2824.  
  2825. });
  2826.  
  2827.  
  2828. document.addEventListener('yt-player-updated', () => {
  2829.  
  2830. ytEvented = true;
  2831. slowMode = false;
  2832. idleFrom = Date.now() + 1700;
  2833.  
  2834. });
  2835.  
  2836.  
  2837. document.addEventListener('yt-page-data-fetched', () => {
  2838.  
  2839. ytEvented = true;
  2840. slowMode = false;
  2841. idleFrom = Date.now() + 1700;
  2842.  
  2843. });
  2844.  
  2845. document.addEventListener('yt-navigate-finish', () => {
  2846.  
  2847. ytEvented = true;
  2848. slowMode = false;
  2849. let t = Date.now() + 700;
  2850. if (t > idleFrom) idleFrom = t;
  2851.  
  2852. });
  2853.  
  2854. document.addEventListener('yt-page-data-updated', () => {
  2855.  
  2856. ytEvented = true;
  2857. slowMode = false;
  2858. let t = Date.now() + 700;
  2859. if (t > idleFrom) idleFrom = t;
  2860.  
  2861. });
  2862.  
  2863. document.addEventListener('yt-watch-comments-ready', () => {
  2864.  
  2865. ytEvented = true;
  2866. slowMode = false;
  2867. let t = Date.now() + 700;
  2868. if (t > idleFrom) idleFrom = t;
  2869.  
  2870. });
  2871. } : () => { };
  2872.  
  2873.  
  2874. // << end >>
  2875.  
  2876. const isPrepareCachedV = (FIX_avoid_incorrect_video_meta ? true : false) && (window === top);
  2877.  
  2878. let pageSetupVideoId = null; // set at finish; '' for indeterminate state
  2879. let pageSetupState = 0;
  2880.  
  2881. isPrepareCachedV && (() => {
  2882.  
  2883. pageSetupVideoId = '';
  2884. const clearCachedV = () => {
  2885. pageSetupVideoId = '';
  2886. pageSetupState = 0;
  2887. }
  2888. document.addEventListener('yt-navigate-start', clearCachedV, false); // user action
  2889. document.addEventListener('yt-navigate-cache', clearCachedV, false); // pop state
  2890. document.addEventListener('yt-page-data-fetched', clearCachedV, false); // still consider invalid until url is ready in yt-navigate-finish
  2891. document.addEventListener('yt-navigate-finish', () => {
  2892. pageSetupState = 1;
  2893. try {
  2894. const url = new URL(location.href);
  2895. if (!url || url.pathname !== '/watch') {
  2896. pageSetupVideoId = '';
  2897. } else {
  2898. pageSetupVideoId = url.searchParams.get('v') || '';
  2899. }
  2900. } catch (e) {
  2901. pageSetupVideoId = '';
  2902. }
  2903. }, false);
  2904.  
  2905. })();
  2906.  
  2907. let videoPlayingY = null;
  2908.  
  2909. isPrepareCachedV && (() => {
  2910.  
  2911. let getNext = true;
  2912. let videoPlayingX = {
  2913. get videoId(){
  2914. if(getNext){
  2915. getNext = false;
  2916.  
  2917. let elements = document.querySelectorAll('ytd-watch-flexy[video-id]');
  2918. const arr = [];
  2919. for (const element of elements) {
  2920. if (!element.closest('[hidden]')) arr.push(element);
  2921. }
  2922. if (arr.length !== 1) this.__videoId__ = '';
  2923. else {
  2924. this.__videoId__ = arr[0].getAttribute('video-id');
  2925. }
  2926. }
  2927. return this.__videoId__ || '';
  2928. }
  2929. }
  2930.  
  2931. videoPlayingY = videoPlayingX;
  2932. const handler = (evt) => {
  2933. const target = (evt || 0).target;
  2934. if (target instanceof HTMLVideoElement) {
  2935. getNext = true;
  2936. }
  2937. }
  2938. document.addEventListener('loadedmetadata', handler, true);
  2939. document.addEventListener('durationchange', handler, true);
  2940.  
  2941. })();
  2942.  
  2943.  
  2944.  
  2945. const cleanContext = async (win) => {
  2946. const waitFn = requestAnimationFrame; // shall have been binded to window
  2947. try {
  2948. let mx = 16; // MAX TRIAL
  2949. const frameId = 'vanillajs-iframe-v1';
  2950. /** @type {HTMLIFrameElement | null} */
  2951. let frame = document.getElementById(frameId);
  2952. let removeIframeFn = null;
  2953. if (!frame) {
  2954. frame = document.createElement('iframe');
  2955. frame.id = frameId;
  2956. const blobURL = typeof webkitCancelAnimationFrame === 'function' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  2957. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  2958. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  2959. n.appendChild(frame);
  2960. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  2961. const root = document.documentElement;
  2962. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  2963. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  2964.  
  2965. removeIframeFn = (setTimeout) => {
  2966. const removeIframeOnDocumentReady = (e) => {
  2967. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2968. e = n;
  2969. n = win = removeIframeFn = 0;
  2970. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  2971. }
  2972. if (!setTimeout || document.readyState !== 'loading') {
  2973. removeIframeOnDocumentReady();
  2974. } else {
  2975. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2976. }
  2977. }
  2978. }
  2979. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  2980. const fc = frame.contentWindow;
  2981. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  2982. try {
  2983. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle } = fc;
  2984. const res = { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle };
  2985. for (let k in res) res[k] = res[k].bind(win); // necessary
  2986. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  2987. res.animate = fc.HTMLElement.prototype.animate;
  2988. res.perfNow = fc.performance.now;
  2989. return res;
  2990. } catch (e) {
  2991. if (removeIframeFn) removeIframeFn();
  2992. return null;
  2993. }
  2994. } catch (e) {
  2995. console.warn(e);
  2996. return null;
  2997. }
  2998. };
  2999.  
  3000. const promiseForYtActionCalled = new Promise(resolve => {
  3001. let hn = () => {
  3002. if (!hn) return;
  3003. document.removeEventListener('yt-action', hn, true);
  3004. hn = null;
  3005. resolve(document.querySelector('ytd-app'));
  3006. };
  3007. document.addEventListener('yt-action', hn, true);
  3008. });
  3009.  
  3010.  
  3011.  
  3012. const promiseForCustomYtElementsReady = new Promise(onRegistryReady);
  3013.  
  3014. cleanContext(window).then(__CONTEXT__ => {
  3015. if (!__CONTEXT__) return null;
  3016.  
  3017. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, requestIdleCallback, getComputedStyle, perfNow } = __CONTEXT__;
  3018.  
  3019.  
  3020. performance.now17 = perfNow.bind(performance);
  3021. // performance.now = performance.now16;
  3022. /*
  3023. let nowh = -1;
  3024. performance.now = function () {
  3025. let t = nowh;
  3026. let c = this.now17();
  3027. return (nowh = (t + 1e-7 > c ? t + 0.1 : c));
  3028. }
  3029. */
  3030.  
  3031. // console.log(performance.now())
  3032. // console.log(performance.now())
  3033. // console.log(performance.now())
  3034. // console.log(performance.now())
  3035.  
  3036.  
  3037.  
  3038. __requestAnimationFrame__ = requestAnimationFrame;
  3039.  
  3040. let rafPromise = null;
  3041.  
  3042. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  3043. requestAnimationFrame(hRes => {
  3044. rafPromise = null;
  3045. resolve(hRes);
  3046. });
  3047. }));
  3048.  
  3049. const getForegroundPromise = () => {
  3050. if (document.visibilityState === 'visible') {
  3051. return Promise.resolve();
  3052. } else {
  3053. return getRafPromise();
  3054. }
  3055. };
  3056.  
  3057. NO_PRELOAD_GENERATE_204_BYPASS || promiseForCustomYtElementsReady.then(() => {
  3058. setTimeout(() => {
  3059. NO_PRELOAD_GENERATE_204_BYPASS = true;
  3060. }, 1270);
  3061. });
  3062.  
  3063. const promiseForTamerTimeout = new Promise(resolve => {
  3064. promiseForCustomYtElementsReady.then(() => {
  3065. customElements.whenDefined('ytd-app').then(() => {
  3066. setTimeout(resolve, 1200);
  3067. });
  3068. });
  3069. setTimeout(resolve, 3000);
  3070. });
  3071.  
  3072.  
  3073. class RAFHub {
  3074. constructor() {
  3075. /** @type {number} */
  3076. this.startAt = 8170;
  3077. /** @type {number} */
  3078. this.counter = 0;
  3079. /** @type {number} */
  3080. this.rid = 0;
  3081. /** @type {Map<number, FrameRequestCallback>} */
  3082. this.funcs = new Map();
  3083. const funcs = this.funcs;
  3084. /** @type {FrameRequestCallback} */
  3085. this.bCallback = this.mCallback.bind(this);
  3086. this.pClear = () => funcs.clear();
  3087. }
  3088. /** @param {DOMHighResTimeStamp} highResTime */
  3089. mCallback(highResTime) {
  3090. this.rid = 0;
  3091. Promise.resolve().then(this.pClear);
  3092. this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  3093. }
  3094. /** @param {FrameRequestCallback} f */
  3095. request(f) {
  3096. if (this.counter > 1e9) this.counter = 9;
  3097. let cid = this.startAt + (++this.counter);
  3098. this.funcs.set(cid, f);
  3099. if (this.rid === 0) {
  3100. console.log(2455)
  3101. this.rid = requestAnimationFrame(this.bCallback);
  3102. }
  3103. return cid;
  3104. }
  3105. /** @param {number} cid */
  3106. cancel(cid) {
  3107. cid = +cid;
  3108. if (cid > 0) {
  3109. if (cid <= this.startAt) {
  3110. return cancelAnimationFrame(cid);
  3111. }
  3112. if (this.rid > 0) {
  3113. this.funcs.delete(cid);
  3114. if (this.funcs.size === 0) {
  3115. cancelAnimationFrame(this.rid);
  3116. this.rid = 0;
  3117. }
  3118. }
  3119. }
  3120. }
  3121. /** @param {number} cid */
  3122. /** @param {FrameRequestCallback} f */
  3123. replaceFunc(cid, f) {
  3124. if (typeof this.funcs.get(cid) === 'function') {
  3125. this.funcs.set(cid, f);
  3126. return cid;
  3127. } else {
  3128. let r = this.request(f);
  3129. this.cancel(cid);
  3130. return r;
  3131. }
  3132. }
  3133. }
  3134.  
  3135.  
  3136. // WEAK_REF_BINDING && (async () => {
  3137.  
  3138. // ['tp-yt-paper-menu-button'].forEach(async tag => {
  3139.  
  3140. // const dummy = await new Promise(resolve => {
  3141. // promiseForCustomYtElementsReady.then(() => {
  3142. // customElements.whenDefined(tag).then(() => {
  3143. // resolve(document.createElement(tag));
  3144. // });
  3145. // });
  3146.  
  3147. // });
  3148.  
  3149. // if (!dummy || dummy.is !== tag) return;
  3150.  
  3151. // const cProto = insp(dummy).constructor.prototype;
  3152.  
  3153. // if (typeof cProto.close === 'function' && !cProto.close58) {
  3154. // cProto.close58 = cProto.close;
  3155. // console.log(cProto.close58)
  3156. // cProto.close = function () {
  3157. // // const dropdown = (this.$ || 0).dropdown || 0;
  3158. // // if (!dropdown) return;
  3159. // try{
  3160. // return this.close58.apply(this, arguments);
  3161. // }catch(e){
  3162.  
  3163. // }
  3164.  
  3165. // }
  3166. // }
  3167.  
  3168.  
  3169. // });
  3170.  
  3171. // })();
  3172.  
  3173. NATIVE_CANVAS_ANIMATION && (() => {
  3174.  
  3175. observablePromise(() => {
  3176. HTMLCanvasElement.prototype.animate = animate;
  3177. }, promiseForTamerTimeout).obtain();
  3178.  
  3179. })();
  3180.  
  3181. FIX_ytAction_ && (async () => {
  3182.  
  3183. const ytdApp = await new Promise(resolve => {
  3184.  
  3185. promiseForCustomYtElementsReady.then(() => {
  3186. customElements.whenDefined('ytd-app').then(() => {
  3187. const ytdApp = document.querySelector('ytd-app');
  3188. if (ytdApp) {
  3189. resolve(ytdApp);
  3190. return;
  3191. }
  3192. let mo = new MutationObserver(() => {
  3193. const ytdApp = document.querySelector('ytd-app');
  3194. if (!ytdApp) return;
  3195. if (mo) {
  3196. mo.disconnect();
  3197. mo.takeRecords();
  3198. mo = null;
  3199. }
  3200. resolve(ytdApp);
  3201. });
  3202. mo.observe(document, { subtree: true, childList: true });
  3203. });
  3204. });
  3205.  
  3206. });
  3207.  
  3208. if (!ytdApp) return;
  3209. const cProto = insp(ytdApp).constructor.prototype;
  3210.  
  3211. if (!cProto) return;
  3212. let mbd = 0;
  3213.  
  3214. const fixer = (_ytdApp) => {
  3215. const ytdApp = insp(_ytdApp);
  3216. if (ytdApp && typeof ytdApp.onYtActionBoundListener_ === 'function' && !ytdApp.onYtActionBoundListener57_) {
  3217. ytdApp.onYtActionBoundListener57_ = ytdApp.onYtActionBoundListener_;
  3218. ytdApp.onYtActionBoundListener_ = ytdApp.onYtAction_.bind(ytdApp);
  3219. mbd++;
  3220. }
  3221. }
  3222.  
  3223. observablePromise(() => {
  3224.  
  3225. if (typeof cProto.created === 'function' && !cProto.created56) {
  3226. cProto.created56 = cProto.created;
  3227. cProto.created = function (...args) {
  3228. const r = this.created56(...args);
  3229. fixer(this);
  3230. return r;
  3231. };
  3232. mbd++;
  3233. }
  3234.  
  3235. if (typeof cProto.onYtAction_ === 'function' && !cProto.onYtAction57_) {
  3236. cProto.onYtAction57_ = cProto.onYtAction_;
  3237. cProto.onYtAction_ = function (...args) {
  3238. Promise.resolve().then(() => this.onYtAction57_(...args));
  3239. };
  3240. mbd++;
  3241. }
  3242.  
  3243. if (ytdApp) fixer(ytdApp);
  3244.  
  3245. /*
  3246. const actionRouter_ = ytdApp ? ytdApp.actionRouter_ : null;
  3247. if (actionRouter_ && typeof actionRouter_.handleAction === 'function' && !actionRouter_.handleAction57) {
  3248. actionRouter_.handleAction57 = actionRouter_.handleAction;
  3249. actionRouter_.handleAction = function (...args) {
  3250. Promise.resolve().then(() => this.handleAction57(...args));
  3251. }
  3252. mbd++;
  3253. }
  3254. */
  3255.  
  3256. // if(mbd === 3) return 1;
  3257. if (mbd >= 3) return 1;
  3258.  
  3259. }, new Promise(r => setTimeout(r, 1000))).obtain();
  3260.  
  3261. })();
  3262.  
  3263. const observablePromise = (proc, timeoutPromise) => {
  3264. let promise = null;
  3265. return {
  3266. obtain() {
  3267. if (!promise) {
  3268. promise = new Promise(resolve => {
  3269. let mo = null;
  3270. const f = () => {
  3271. let t = proc();
  3272. if (t) {
  3273. mo.disconnect();
  3274. mo.takeRecords();
  3275. mo = null;
  3276. resolve(t);
  3277. }
  3278. }
  3279. mo = new MutationObserver(f);
  3280. mo.observe(document, { subtree: true, childList: true })
  3281. f();
  3282. timeoutPromise && timeoutPromise.then(() => {
  3283. resolve(null)
  3284. });
  3285. });
  3286. }
  3287. return promise
  3288. }
  3289. }
  3290. }
  3291.  
  3292. // let _yt_player_promise = null;
  3293. /*
  3294. const getYtPlayerPromise = () => {
  3295. if (!_yt_player_promise) {
  3296. _yt_player_promise = new Promise(resolve => {
  3297. let cid = setInterval(() => {
  3298. let t = (((window || 0)._yt_player || 0) || 0);
  3299. if (t) {
  3300. clearInterval(cid);
  3301. resolve(t);
  3302. }
  3303. }, 1);
  3304. promiseForTamerTimeout.then(() => {
  3305. resolve(null)
  3306. });
  3307. });
  3308. }
  3309. return _yt_player_promise;
  3310. }
  3311. */
  3312. const _yt_player_observable = observablePromise(() => {
  3313. return (((window || 0)._yt_player || 0) || 0);
  3314. }, promiseForTamerTimeout);
  3315.  
  3316. const polymerObservable = observablePromise(() => {
  3317. const Polymer = window.Polymer;
  3318. if (typeof Polymer !== 'function') return;
  3319. if (!(Polymer.Base || 0).connectedCallback || !(Polymer.Base || 0).disconnectedCallback) return;
  3320. return Polymer;
  3321. }, promiseForTamerTimeout);
  3322.  
  3323. const schedulerInstanceObservable = observablePromise(() => {
  3324. return (((window || 0).ytglobal || 0).schedulerInstanceInstance_ || 0);
  3325. }, promiseForTamerTimeout);
  3326.  
  3327. const timelineObservable = observablePromise(() => {
  3328. let t = (((document || 0).timeline || 0) || 0);
  3329. if (t && typeof t._play === 'function') {
  3330. return t;
  3331. }
  3332. }, promiseForTamerTimeout);
  3333. const animationObservable = observablePromise(() => {
  3334. let t = (((window || 0).Animation || 0) || 0);
  3335. if (t && typeof t === 'function' && t.length === 2 && typeof t.prototype._updatePromises === 'function') {
  3336. return t;
  3337. }
  3338. }, promiseForTamerTimeout);
  3339.  
  3340.  
  3341.  
  3342.  
  3343. const generalEvtHandler = async (_evKey, _fvKey, _debug) => {
  3344.  
  3345. const evKey = `${_evKey}`;
  3346. const fvKey = `${_fvKey}`;
  3347. const debug = !!_debug;
  3348.  
  3349.  
  3350. // const rafHub = new RAFHub();
  3351.  
  3352.  
  3353. const _yt_player = await _yt_player_observable.obtain();
  3354.  
  3355.  
  3356. if (!_yt_player || typeof _yt_player !== 'object') return;
  3357.  
  3358.  
  3359. const getArr = (_yt_player) => {
  3360.  
  3361. let arr = [];
  3362.  
  3363. for (const [k, v] of Object.entries(_yt_player)) {
  3364.  
  3365. const p = typeof v === 'function' ? v.prototype : 0;
  3366. if (p
  3367. && typeof p[evKey] === 'function' && p[evKey].length >= 0 && !p[fvKey]
  3368.  
  3369. ) {
  3370. arr = addProtoToArr(_yt_player, k, arr) || arr;
  3371.  
  3372. }
  3373.  
  3374. }
  3375.  
  3376. if (arr.length === 0) {
  3377.  
  3378. console.warn(`Key prop [${evKey}] does not exist.`);
  3379. } else {
  3380.  
  3381. return arr;
  3382. }
  3383.  
  3384. };
  3385.  
  3386. const arr = getArr(_yt_player);
  3387.  
  3388.  
  3389. if (!arr) return;
  3390.  
  3391. debug && console.log(`FIX_${evKey}`, arr);
  3392.  
  3393. const f = function (...args) {
  3394. Promise.resolve().then(() => this[fvKey](...args));
  3395. };
  3396.  
  3397.  
  3398. for (const k of arr) {
  3399.  
  3400. const g = _yt_player;
  3401. const gk = g[k];
  3402. const gkp = gk.prototype;
  3403.  
  3404. debug && console.log(237, k, gkp)
  3405.  
  3406. if (typeof gkp[evKey] == 'function' && !gkp[fvKey]) {
  3407. gkp[fvKey] = gkp[evKey];
  3408. gkp[evKey] = f;
  3409. }
  3410. }
  3411.  
  3412.  
  3413.  
  3414.  
  3415. }
  3416.  
  3417. FIX_onVideoDataChange && generalEvtHandler('onVideoDataChange', 'onVideoDataChange57');
  3418. // FIX_onClick && generalEvtHandler('onClick', 'onClick57');
  3419. FIX_onStateChange && generalEvtHandler('onStateChange', 'onStateChange57');
  3420. FIX_onLoopRangeChange && generalEvtHandler('onLoopRangeChange', 'onLoopRangeChange57');
  3421. if (FIX_VideoEVENTS_v2) {
  3422. const FIX_VideoEVENTS_DEBUG = 0;
  3423. generalEvtHandler('onVideoProgress', 'onVideoProgress57', FIX_VideoEVENTS_DEBUG); // --
  3424. // generalEvtHandler('onAutoplayBlocked', 'onAutoplayBlocked57', FIX_VideoEVENTS_DEBUG);
  3425. // generalEvtHandler('onLoadProgress', 'onLoadProgress57', FIX_VideoEVENTS_DEBUG); // << CAUSE ISSUE >>
  3426. generalEvtHandler('onFullscreenChange', 'onFullscreenChange57', FIX_VideoEVENTS_DEBUG); // --
  3427. // generalEvtHandler('onLoadedMetadata', 'onLoadedMetadata57', FIX_VideoEVENTS_DEBUG);
  3428. // generalEvtHandler('onDrmOutputRestricted', 'onDrmOutputRestricted57', FIX_VideoEVENTS_DEBUG);
  3429. // generalEvtHandler('onAirPlayActiveChange', 'onAirPlayActiveChange57', FIX_VideoEVENTS_DEBUG);
  3430. // generalEvtHandler('onAirPlayAvailabilityChange', 'onAirPlayAvailabilityChange57', FIX_VideoEVENTS_DEBUG);
  3431. // generalEvtHandler('onApiChange', 'onApiChange57', FIX_VideoEVENTS_DEBUG);
  3432.  
  3433. }
  3434. // onMutedAutoplayChange
  3435. // onVolumeChange
  3436. // onPlaybackRateChange
  3437.  
  3438. // onAirPlayActiveChange
  3439. // onAirPlayAvailabilityChange
  3440. // onApiChange
  3441. // onAutoplayBlocked
  3442. // onDrmOutputRestricted
  3443. // onFullscreenChange
  3444. // onLoadProgress
  3445. // onLoadedMetadata
  3446. // onVideoDataChange
  3447. // onVideoProgress
  3448.  
  3449. (FIX_maybeUpdateFlexibleMenu || WEAK_REF_BINDING) && (async () => {
  3450.  
  3451.  
  3452. const dummy = await new Promise(resolve => {
  3453.  
  3454. promiseForCustomYtElementsReady.then(() => {
  3455. customElements.whenDefined('ytd-menu-renderer').then(() => {
  3456.  
  3457. resolve(document.createElement('ytd-menu-renderer'));
  3458. });
  3459. });
  3460.  
  3461.  
  3462.  
  3463. });
  3464.  
  3465.  
  3466. if (!dummy || dummy.is !== 'ytd-menu-renderer') return;
  3467.  
  3468. const cProto = insp(dummy).constructor.prototype;
  3469.  
  3470. if (FIX_maybeUpdateFlexibleMenu && typeof cProto.created === 'function' && !cProto.created58) {
  3471. cProto.created58 = cProto.created;
  3472. cProto.created = function (...args) {
  3473. const r = this.created58(...args);
  3474. if (typeof this.maybeUpdateFlexibleMenu === 'function' && !this.maybeUpdateFlexibleMenu57) {
  3475. this.maybeUpdateFlexibleMenu57 = this.maybeUpdateFlexibleMenu;
  3476. this.maybeUpdateFlexibleMenu = function (...args) {
  3477. Promise.resolve().then(() => this.maybeUpdateFlexibleMenu57(...args));
  3478. }
  3479. }
  3480. return r;
  3481. }
  3482.  
  3483. }
  3484.  
  3485.  
  3486.  
  3487. // if (WEAK_REF_BINDING && typeof cProto.setupFlexibleMenu === 'function' && !cProto.setupFlexibleMenu58) {
  3488. // cProto.setupFlexibleMenu58 = cProto.setupFlexibleMenu;
  3489. // cProto.setupFlexibleMenu = function () {
  3490.  
  3491. // const hostElement = this.hostElement;
  3492. // if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  3493. // return void 0;
  3494. // } else {
  3495. // return this.setupFlexibleMenu58.apply(this, arguments);
  3496. // }
  3497.  
  3498. // }
  3499.  
  3500.  
  3501.  
  3502. // }
  3503.  
  3504.  
  3505. // if (WEAK_REF_BINDING && typeof cProto.stampDomArray_ === 'function' && !cProto.stampDomArray58_) {
  3506. // cProto.stampDomArray58_ = cProto.stampDomArray_;
  3507. // cProto.stampDomArray_ = function (a, b, c, d, e, h) {
  3508.  
  3509. // const hostElement = this.hostElement;
  3510. // if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  3511. // return void 0;
  3512. // } else {
  3513. // return this.stampDomArray58_.apply(this, arguments);
  3514. // }
  3515.  
  3516. // }
  3517.  
  3518.  
  3519.  
  3520. // }
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526. //console.log(144,cProto.maybeUpdateFlexibleMenu)
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533. })();
  3534.  
  3535. (ENABLE_discreteTasking || UNLOAD_DETACHED_POLYMER) && (async () => {
  3536.  
  3537. const Polymer = await polymerObservable.obtain();
  3538. if (!Polymer) return;
  3539.  
  3540.  
  3541. if (UNLOAD_DETACHED_POLYMER && typeof Polymer.Base.detached === 'function' && !Polymer.Base.detached92 && Polymer.Base.detached.length === 0) {
  3542. Polymer.Base.detached92 = Polymer.Base.detached;
  3543.  
  3544. const detachedPlus = async function (elem) {
  3545. await delay300.then();
  3546. if (elem.isAttached !== false) return;
  3547. await delay300.then();
  3548. if (elem.isAttached !== false) return;
  3549.  
  3550. if (elem.__dataClientsReady === true) elem.__dataClientsReady = false;
  3551. // if (elem.__dataEnabled === true) elem.__dataEnabled = false;
  3552. if (elem.__dataReady === true) elem.__dataReady = false;
  3553.  
  3554. elem.__dataLinkedPaths = elem.__dataToNotify = elem.__dataPendingClients = null;
  3555. elem.__dataHasPaths = false;
  3556. // elem.__dataCompoundStorage = null;
  3557. elem.__dataHost = null;
  3558. elem.__dataTemp = null;
  3559. elem.__dataClientsInitialized = false;
  3560.  
  3561.  
  3562. // elem.data = {};
  3563. elem.data = null;
  3564. elem.__dataPending = null;
  3565. elem.__dataOld = null;
  3566. elem.__dataInstanceProps = null;
  3567.  
  3568. elem.__dataCounter = 0;
  3569. elem.__serializing = false;
  3570.  
  3571. // if (elem.$) elem.$ = {};
  3572. // if (elem.root) elem.root = null;
  3573.  
  3574. // let hostElement = elem.hostElement, tlm;
  3575. // if (hostElement instanceof Node) {
  3576. // // if (hostElement.isConnected === false) {
  3577. // // while (tlm = hostElement.firstChild) tlm.remove();
  3578. // // }
  3579. // elem.hostElement = hostElement = null;
  3580. // }
  3581.  
  3582.  
  3583. // if (hostElement === null) {
  3584.  
  3585. // if (elem.animatedIconElement instanceof Node) elem.animatedIconElement = null;
  3586. // if (elem._target instanceof Node) elem._target = null;
  3587. // if (elem.iconset instanceof Node) elem.iconset = null;
  3588. // if (elem._svgIcon instanceof Node) elem._svgIcon = null;
  3589.  
  3590. // }
  3591.  
  3592.  
  3593. }
  3594. Polymer.Base.detached = function () {
  3595. Promise.resolve(this).then(detachedPlus);
  3596. return Polymer.Base.detached92();
  3597. };
  3598. }
  3599.  
  3600.  
  3601. if (ENABLE_discreteTasking) {
  3602.  
  3603. Polymer.Base.__connInit__ = function () {
  3604. setupDiscreteTasks(this);
  3605. // if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  3606. // setupWeakRef(this)
  3607. // }
  3608. }
  3609.  
  3610.  
  3611. /** @type {Function} */
  3612. const connectedCallbackK = function (...args) {
  3613. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3614. const r = this[qm53](...args);
  3615. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3616. this.mh35 = 1;
  3617. return r;
  3618. };
  3619.  
  3620. connectedCallbackK.m353 = 1;
  3621.  
  3622.  
  3623. const qt53 = Polymer.Base.connectedCallback;
  3624. Polymer.Base[qm53] = dmf.get(qt53) || qt53;
  3625.  
  3626. Polymer.Base.connectedCallback = connectedCallbackK;
  3627.  
  3628.  
  3629. /** @type {Function} */
  3630. const createdK = function (...args) {
  3631. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3632. const r = this[qn53](...args);
  3633. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3634. this.mh36 = 1;
  3635. return r;
  3636. };
  3637.  
  3638.  
  3639. createdK.m353 = 1;
  3640. Polymer.Base[qn53] = Polymer.Base.created;
  3641. Polymer.Base.created = createdK;
  3642.  
  3643. }
  3644.  
  3645. })();
  3646.  
  3647. CHANGE_appendChild && (() => {
  3648.  
  3649. const f = HTMLElement.prototype.appendChild73 = HTMLElement.prototype.appendChild;
  3650. if (f) HTMLElement.prototype.appendChild = function (a) {
  3651.  
  3652.  
  3653. if (this instanceof HTMLElement) {
  3654.  
  3655. if (!NO_PRELOAD_GENERATE_204_BYPASS && document.head === this) {
  3656. for (let node = this.firstElementChild; node instanceof HTMLElement; node = node.nextElementSibling) {
  3657. if (node.nodeName === 'LINK' && node.rel === 'preload' && node.as === 'fetch' && !node.__m848__) {
  3658. node.__m848__ = 1;
  3659. node.rel = 'prefetch'; // see https://github.com/GoogleChromeLabs/quicklink
  3660. }
  3661. }
  3662. } else if (this.nodeName.startsWith('YT-')) { // yt-animated-rolling-number, yt-attributed-string
  3663. return this.appendChild73.apply(this, arguments);
  3664. }
  3665.  
  3666. if (a instanceof DocumentFragment) {
  3667. if (a.firstElementChild === null) {
  3668. let child = a.firstChild;
  3669. if (child === null) return a;
  3670. let doNormal = false;
  3671. while (child instanceof Node) {
  3672. if (child.nodeType === 3) { doNormal = true; break; }
  3673. child = child.nextSibling;
  3674. }
  3675. if (!doNormal) return a;
  3676. }
  3677. }
  3678.  
  3679. return (this.appendChild73 || f).apply(this, arguments);
  3680. }
  3681.  
  3682.  
  3683. return (HTMLElement.prototype.appendChild73 || f).apply(this, arguments);
  3684. }
  3685.  
  3686.  
  3687. })();
  3688.  
  3689. if (FIX_Shady) {
  3690.  
  3691. observablePromise(() => {
  3692. const { ShadyDOM, ShadyCSS } = window;
  3693. if (ShadyDOM) {
  3694. ShadyDOM.handlesDynamicScoping = false; // 9 of 10
  3695. ShadyDOM.noPatch = true; // 1 of 10
  3696. ShadyDOM.patchOnDemand = false; // 1 of 10
  3697. ShadyDOM.preferPerformance = true; // 1 of 10
  3698. ShadyDOM.querySelectorImplementation = undefined; // 1 of 10
  3699. }
  3700. if (ShadyCSS) {
  3701. ShadyCSS.nativeCss = true; // 1 of 10
  3702. ShadyCSS.nativeShadow = true; // 6 of 10
  3703. ShadyCSS.cssBuild = undefined; // 1 of 10
  3704. ShadyCSS.disableRuntime = true; // 1 of 10
  3705. }
  3706. if (ShadyDOM && ShadyCSS) return 1;
  3707. }, promiseForTamerTimeout).obtain(); // clear until 1 is return
  3708.  
  3709. }
  3710.  
  3711.  
  3712. FIX_schedulerInstanceInstance_V1 && !FIX_schedulerInstanceInstance_V2 && (async () => {
  3713.  
  3714.  
  3715. const schedulerInstanceInstance_ = await schedulerInstanceObservable.obtain();
  3716.  
  3717. if (!schedulerInstanceInstance_) return;
  3718.  
  3719.  
  3720. if (!ytEvented) {
  3721. idleFrom = Date.now() + 2700;
  3722. slowMode = false; // integrity
  3723. }
  3724.  
  3725. const checkOK = typeof schedulerInstanceInstance_.start === 'function' && !schedulerInstanceInstance_.start991 && !schedulerInstanceInstance_.stop && !schedulerInstanceInstance_.cancel && !schedulerInstanceInstance_.terminate && !schedulerInstanceInstance_.interupt;
  3726. if (checkOK) {
  3727.  
  3728.  
  3729. schedulerInstanceInstance_.start991 = schedulerInstanceInstance_.start;
  3730.  
  3731. let requestingFn = null;
  3732. let requestingArgs = null;
  3733. let requestingDT = 0;
  3734.  
  3735. // let timerId = null;
  3736. const entries = [];
  3737. const f = function () {
  3738. requestingFn = this.fn;
  3739. requestingArgs = [...arguments];
  3740. requestingDT = Date.now();
  3741. entries.push({
  3742. fn: requestingFn,
  3743. args: requestingArgs,
  3744. t: requestingDT
  3745. });
  3746. // if (Date.now() < idleFrom) {
  3747. // timerId = this.fn.apply(window, arguments);
  3748. // } else {
  3749. // timerId = this.fn.apply(window, arguments);
  3750.  
  3751. // }
  3752. // timerId = 12377;
  3753. return 12377;
  3754. }
  3755.  
  3756.  
  3757. const fakeFns = [
  3758. f.bind({ fn: requestAnimationFrame }),
  3759. f.bind({ fn: setInterval }),
  3760. f.bind({ fn: setTimeout }),
  3761. f.bind({ fn: requestIdleCallback })
  3762. ]
  3763.  
  3764.  
  3765.  
  3766.  
  3767. let timerResolve = null;
  3768. setInterval(() => {
  3769. timerResolve && timerResolve();
  3770. timerResolve = null;
  3771. if (!slowMode && Date.now() > idleFrom) slowMode = true;
  3772. }, 250);
  3773.  
  3774. let mzt = 0;
  3775.  
  3776. let fnSelectorProp = null;
  3777.  
  3778. schedulerInstanceInstance_.start = function () {
  3779.  
  3780. const mk1 = window.requestAnimationFrame
  3781. const mk2 = window.setInterval
  3782. const mk3 = window.setTimeout
  3783. const mk4 = window.requestIdleCallback
  3784.  
  3785. const tThis = this['$$12378$$'] || this;
  3786.  
  3787.  
  3788. window.requestAnimationFrame = fakeFns[0]
  3789. window.setInterval = fakeFns[1]
  3790. window.setTimeout = fakeFns[2]
  3791. window.requestIdleCallback = fakeFns[3]
  3792.  
  3793. fnSelectorProp = null;
  3794.  
  3795.  
  3796. tThis.start991.call(new Proxy(tThis, {
  3797. get(target, prop, receiver) {
  3798. if (prop === '$$12377$$') return true;
  3799. if (prop === '$$12378$$') return target;
  3800.  
  3801. // console.log('get',prop)
  3802. return target[prop]
  3803. },
  3804. set(target, prop, value, receiver) {
  3805. // console.log('set', prop, value)
  3806.  
  3807.  
  3808. if (value >= 1 && value <= 4) fnSelectorProp = prop;
  3809. if (value === 12377 && fnSelectorProp) {
  3810.  
  3811. const originalSelection = target[fnSelectorProp];
  3812. const timerIdProp = prop;
  3813.  
  3814. /*
  3815.  
  3816.  
  3817. case 1:
  3818. var a = this.K;
  3819. this.g = this.I ? window.requestIdleCallback(a, {
  3820. timeout: 3E3
  3821. }) : window.setTimeout(a, ma);
  3822. break;
  3823. case 2:
  3824. this.g = window.setTimeout(this.M, this.N);
  3825. break;
  3826. case 3:
  3827. this.g = window.requestAnimationFrame(this.L);
  3828. break;
  3829. case 4:
  3830. this.g = window.setTimeout(this.J, 0)
  3831. }
  3832.  
  3833. */
  3834.  
  3835. const doForegroundSlowMode = () => {
  3836.  
  3837. const tir = ++mzt;
  3838. const f = requestingArgs[0];
  3839.  
  3840.  
  3841. getForegroundPromise().then(() => {
  3842.  
  3843.  
  3844. new Promise(r => {
  3845. timerResolve = r
  3846. }).then(() => {
  3847. if (target[timerIdProp] === -tir) f();
  3848. });
  3849.  
  3850. })
  3851.  
  3852. target[fnSelectorProp] = 931;
  3853. target[prop] = -tir;
  3854. }
  3855.  
  3856. if (target[fnSelectorProp] === 2 && requestingFn === setTimeout) {
  3857. if (slowMode && !(requestingArgs[1] > 250)) {
  3858.  
  3859. doForegroundSlowMode();
  3860.  
  3861. } else {
  3862. target[prop] = setTimeout.apply(window, requestingArgs);
  3863.  
  3864. }
  3865.  
  3866. } else if (target[fnSelectorProp] === 3 && requestingFn === requestAnimationFrame) {
  3867.  
  3868. if (slowMode) {
  3869.  
  3870. doForegroundSlowMode();
  3871.  
  3872. } else {
  3873. target[prop] = requestAnimationFrame.apply(window, requestingArgs);
  3874. }
  3875.  
  3876.  
  3877. } else if (target[fnSelectorProp] === 4 && requestingFn === setTimeout && !requestingArgs[1]) {
  3878.  
  3879. const f = requestingArgs[0];
  3880. const tir = ++mzt;
  3881. Promise.resolve().then(() => {
  3882. if (target[timerIdProp] === -tir) f();
  3883. });
  3884. target[fnSelectorProp] = 930;
  3885. target[prop] = -tir;
  3886.  
  3887. } else if (target[fnSelectorProp] === 1 && (requestingFn === requestIdleCallback || requestingFn === setTimeout)) {
  3888.  
  3889. doForegroundSlowMode();
  3890.  
  3891. } else {
  3892. // target[prop] = timerId;
  3893. target[fnSelectorProp] = 0;
  3894. target[prop] = 0;
  3895. }
  3896.  
  3897. // *****
  3898. // console.log('[[set]]', slowMode , prop, value, `fnSelectorProp: ${originalSelection} -> ${target[fnSelectorProp]}`)
  3899. } else {
  3900.  
  3901. target[prop] = value;
  3902. }
  3903. // console.log('set',prop,value)
  3904. return true;
  3905. }
  3906. }));
  3907.  
  3908. fnSelectorProp = null;
  3909.  
  3910.  
  3911. window.requestAnimationFrame = mk1;
  3912. window.setInterval = mk2
  3913. window.setTimeout = mk3
  3914. window.requestIdleCallback = mk4;
  3915.  
  3916.  
  3917.  
  3918. }
  3919.  
  3920. schedulerInstanceInstance_.start.toString = function () {
  3921. return schedulerInstanceInstance_.start991.toString();
  3922. }
  3923.  
  3924. // const funcNames = [...(schedulerInstanceInstance_.start + "").matchAll(/[\(,]this\.(\w{1,2})[,\)]/g)].map(e => e[1]).map(prop => ({
  3925. // prop,
  3926. // value: schedulerInstanceInstance_[prop],
  3927. // type: typeof schedulerInstanceInstance_[prop]
  3928.  
  3929. // }));
  3930. // console.log('fcc', funcNames)
  3931.  
  3932.  
  3933.  
  3934.  
  3935. }
  3936. })();
  3937.  
  3938.  
  3939.  
  3940. FIX_schedulerInstanceInstance_V2 && !FIX_schedulerInstanceInstance_V1 && (async () => {
  3941.  
  3942.  
  3943. const schedulerInstanceInstance_ = await schedulerInstanceObservable.obtain();
  3944.  
  3945. if (!schedulerInstanceInstance_) return;
  3946.  
  3947.  
  3948. const checkOK = typeof schedulerInstanceInstance_.start === 'function' && !schedulerInstanceInstance_.start991 && !schedulerInstanceInstance_.stop && !schedulerInstanceInstance_.cancel && !schedulerInstanceInstance_.terminate && !schedulerInstanceInstance_.interupt;
  3949. if (checkOK) {
  3950.  
  3951. schedulerInstanceInstance_.start991 = schedulerInstanceInstance_.start;
  3952.  
  3953.  
  3954.  
  3955. let busy = false;
  3956.  
  3957. // console.log('1667',schedulerInstanceInstance_.start);
  3958. schedulerInstanceInstance_.start = function () {
  3959.  
  3960. // p59 || console.log(location.pathname, 16400);
  3961.  
  3962. if (busy) {
  3963.  
  3964. return this.start991.call(this);
  3965.  
  3966. }
  3967.  
  3968. busy = true;
  3969.  
  3970. const mk1 = window.requestAnimationFrame
  3971. // const mk2 = window.setInterval
  3972. // const mk3 = window.setTimeout
  3973. // const mk4 = window.requestIdleCallback
  3974.  
  3975. // by pass Youtube Engine's wrapping
  3976. window.requestAnimationFrame = baseRAF;
  3977. // window.setInterval = setInterval
  3978. // window.setTimeout = setTimeout
  3979. // window.requestIdleCallback = requestIdleCallback
  3980.  
  3981.  
  3982. this.start991.call(this);
  3983.  
  3984.  
  3985. window.requestAnimationFrame = mk1;
  3986. // window.setInterval = mk2
  3987. // window.setTimeout = mk3
  3988. // window.requestIdleCallback = mk4;
  3989.  
  3990. busy = false;
  3991.  
  3992.  
  3993.  
  3994. }
  3995.  
  3996. schedulerInstanceInstance_.start.toString = function () {
  3997. return schedulerInstanceInstance_.start991.toString();
  3998. }
  3999.  
  4000. // const funcNames = [...(schedulerInstanceInstance_.start + "").matchAll(/[\(,]this\.(\w{1,2})[,\)]/g)].map(e => e[1]).map(prop => ({
  4001. // prop,
  4002. // value: schedulerInstanceInstance_[prop],
  4003. // type: typeof schedulerInstanceInstance_[prop]
  4004.  
  4005. // }));
  4006. // console.log('fcc', funcNames)
  4007.  
  4008.  
  4009.  
  4010.  
  4011. }
  4012. })();
  4013.  
  4014. FIX_yt_player && (async () => {
  4015.  
  4016.  
  4017.  
  4018. // const rafHub = new RAFHub();
  4019.  
  4020.  
  4021. const _yt_player = await _yt_player_observable.obtain();
  4022.  
  4023.  
  4024.  
  4025. if (!_yt_player || typeof _yt_player !== 'object') return;
  4026.  
  4027.  
  4028.  
  4029. let keyZq = getZq(_yt_player);
  4030. // let keyVG = getVG(_yt_player);
  4031. // let buildVG = _yt_player[keyVG];
  4032. // let u = new buildVG({
  4033. // api: {},
  4034. // element: document.createElement('noscript'),
  4035. // api: {},
  4036. // hide: () => { }
  4037. // }, 250);
  4038. // const timeDelayConstructor = u.delay.constructor; // g.br
  4039. // console.log(keyVG, u)
  4040. // buildVG.prototype.show = function(){}
  4041. // _yt_player[keyZq] = g.k
  4042.  
  4043. if (!keyZq) return;
  4044.  
  4045.  
  4046. const g = _yt_player
  4047. let k = keyZq
  4048.  
  4049. const gk = g[k];
  4050. if (typeof gk !== 'function') return;
  4051. const gkp = gk.prototype;
  4052.  
  4053. let dummyObject = new gk;
  4054. let nilFunc = () => { };
  4055.  
  4056. let nilObj = {};
  4057.  
  4058. // console.log(1111111111)
  4059.  
  4060. let keyBoolD = '';
  4061. let keyWindow = '';
  4062. let keyFuncC = '';
  4063. let keyCidj = '';
  4064.  
  4065. for (const [t, y] of Object.entries(dummyObject)) {
  4066. if (y instanceof Window) keyWindow = t;
  4067. }
  4068.  
  4069. const dummyObjectProxyHandler = {
  4070. get(target, prop) {
  4071. let v = target[prop]
  4072. if (v instanceof Window && !keyWindow) {
  4073. keyWindow = t;
  4074. }
  4075. let y = typeof v === 'function' ? nilFunc : typeof v === 'object' ? nilObj : v;
  4076. if (prop === keyWindow) y = {
  4077. requestAnimationFrame(f) {
  4078. return 3;
  4079. },
  4080. cancelAnimationFrame() {
  4081.  
  4082. }
  4083. }
  4084. if (!keyFuncC && typeof v === 'function' && !(prop in target.constructor.prototype)) {
  4085. keyFuncC = prop;
  4086. }
  4087. // console.log('[get]', prop, typeof target[prop])
  4088.  
  4089.  
  4090. return y;
  4091. },
  4092. set(target, prop, value) {
  4093.  
  4094. if (typeof value === 'boolean' && !keyBoolD) {
  4095. keyBoolD = prop;
  4096. }
  4097. if (typeof value === 'number' && !keyCidj && value >= 2) {
  4098. keyCidj = prop;
  4099. }
  4100.  
  4101. // console.log('[set]', prop, value)
  4102. target[prop] = value
  4103.  
  4104. return true;
  4105. }
  4106. };
  4107.  
  4108. dummyObject.start.call(new Proxy(dummyObject, dummyObjectProxyHandler))
  4109.  
  4110. /*
  4111. console.log({
  4112. keyBoolD,
  4113. keyFuncC,
  4114. keyWindow,
  4115. keyCidj
  4116. })
  4117.  
  4118. console.log( dummyObject[keyFuncC])
  4119.  
  4120.  
  4121. console.log(2222222222)
  4122. */
  4123.  
  4124.  
  4125. // console.log('gkp.start',gkp.start);
  4126. // console.log('gkp.stop',gkp.stop);
  4127. gkp._activation = false;
  4128.  
  4129. gkp.start = function () {
  4130. // p59 || console.log(12100)
  4131. if (!this._activation) {
  4132. this._activation = true;
  4133. getRafPromise().then(() => {
  4134. this._activation = false;
  4135. if (this[keyCidj]) {
  4136. Promise.resolve().then(this[keyFuncC]);
  4137. }
  4138. });
  4139. }
  4140. this[keyCidj] = 1;
  4141. this[keyBoolD] = true;
  4142. }
  4143. ;
  4144. gkp.stop = function () {
  4145. this[keyCidj] = null
  4146. }
  4147.  
  4148.  
  4149. /*
  4150. g[k].start = function() {
  4151. this.stop();
  4152. this.D = true;
  4153. var a = requestAnimationFrame
  4154. , b = cancelAnimationFrame;
  4155. this.j = a.call(this.B, this.C)
  4156. }
  4157. ;
  4158. g[k].stop = function() {
  4159. if (this.isActive()) {
  4160. var a = requestAnimationFrame
  4161. , b = cancelAnimationFrame;
  4162. b.call(this.B, this.j)
  4163. }
  4164. this.j = null
  4165. }
  4166. */
  4167.  
  4168.  
  4169.  
  4170. const keyzo = PERF_471489_ ? getzo(_yt_player) : null;
  4171.  
  4172. if (keyzo) {
  4173.  
  4174. k = keyzo
  4175.  
  4176. const setCSSProp = (() => {
  4177.  
  4178. let animationPropCapable = false;
  4179. try {
  4180. const propName = "--ibxpf"
  4181. const value = 2;
  4182. const keyframes = [{
  4183. [propName]: value
  4184. }];
  4185. window.CSS.registerProperty({
  4186. name: "--ibxpf",
  4187. syntax: "<number>",
  4188. inherits: false,
  4189. initialValue: 1,
  4190. });
  4191. animationPropCapable = '1' === `${getComputedStyle(document.documentElement).getPropertyValue('--ibxpf')}`
  4192. } catch (e) { }
  4193.  
  4194. if (!animationPropCapable) {
  4195. return (element, cssProp, value) => {
  4196.  
  4197.  
  4198. element.style.setProperty(cssProp, value);
  4199.  
  4200. }
  4201. }
  4202.  
  4203. const propMaps = new Map();
  4204.  
  4205. function setCustomCSSProperty(element, propName, value) {
  4206. let wm = propMaps.get(propName);
  4207. if (!wm) {
  4208.  
  4209. try {
  4210. window.CSS.registerProperty({
  4211. name: propName,
  4212. syntax: "*",
  4213. inherits: false
  4214. });
  4215. } catch (e) {
  4216. console.warn(e);
  4217. }
  4218.  
  4219. propMaps.set(propName, (wm = new WeakMap()));
  4220. }
  4221.  
  4222. // Create the animation keyframes with the provided property and value
  4223. const keyframes = [{
  4224. [propName]: value
  4225. }];
  4226.  
  4227. let currentAnimation = wm.get(element);
  4228. if (currentAnimation) {
  4229.  
  4230. currentAnimation.effect.setKeyframes(keyframes);
  4231.  
  4232. } else {
  4233.  
  4234.  
  4235.  
  4236. // Set the animation on the element and immediately pause it
  4237. const animation = animate.call(element, keyframes, {
  4238. duration: 1, // Very short duration as we just want to set the value
  4239. fill: 'forwards',
  4240. iterationStart: 1,
  4241. iterations: 2,
  4242. direction: 'alternate'
  4243. });
  4244.  
  4245.  
  4246. // animation.currentTime = 1;
  4247. animation.pause();
  4248.  
  4249. wm.set(element, animation);
  4250.  
  4251.  
  4252. }
  4253.  
  4254. }
  4255.  
  4256. return setCustomCSSProperty;
  4257.  
  4258.  
  4259. })();
  4260.  
  4261.  
  4262. const attrUpdateFn = g[k];
  4263. g['$$original$$' + k] = attrUpdateFn;
  4264. g[k] = function (a, b, c) {
  4265.  
  4266. // console.log(140000, a, b, c);
  4267.  
  4268. let transformType = '';
  4269. let transformValue = 0;
  4270. let transformUnit = '';
  4271.  
  4272. let byPassDefaultFn = false;
  4273. if (b === "transform" && typeof c === 'string') {
  4274.  
  4275. byPassDefaultFn = true;
  4276.  
  4277. const aStyle = a.style;
  4278.  
  4279. // let beforeMq = aStyle.getPropertyValue('--mq-transform');
  4280. if (!(a instanceof HTMLElement)) return;
  4281. if (c.length === 0) {
  4282.  
  4283. } else if (c.startsWith('scalex(0.') || (c === 'scalex(0)' || c === 'scalex(1)')) {
  4284. let p = c.substring(7, c.length - 1);
  4285. let q = p.length >= 1 ? parseFloat(p) : -1;
  4286. if (q > -1e-5 && q < 1 + 1e-5) {
  4287. transformType = 'scalex'
  4288. transformValue = q;
  4289. transformUnit = '';
  4290. }
  4291.  
  4292.  
  4293. } else if (c.startsWith('translateX(') && c.endsWith('px)')) {
  4294.  
  4295. let p = c.substring(11, c.length - 3);
  4296. let q = p.length >= 1 ? parseFloat(p) : NaN;
  4297.  
  4298. if (typeof q === 'number' && !isNaN(q)) {
  4299. transformType = 'translateX'
  4300. transformValue = q;
  4301. transformUnit = 'px';
  4302. }
  4303.  
  4304.  
  4305. } else if (c.startsWith('scaley(0.') || (c === 'scaley(0)' || c === 'scaley(1)')) {
  4306. let p = c.substring(7, c.length - 1);
  4307. let q = p.length >= 1 ? parseFloat(p) : -1;
  4308. if (q > -1e-5 && q < 1 + 1e-5) {
  4309. transformType = 'scaley'
  4310. transformValue = q;
  4311. transformUnit = '';
  4312. }
  4313.  
  4314.  
  4315. } else if (c.startsWith('translateY(') && c.endsWith('px)')) {
  4316.  
  4317. let p = c.substring(11, c.length - 3);
  4318. let q = p.length >= 1 ? parseFloat(p) : NaN;
  4319.  
  4320. if (typeof q === 'number' && !isNaN(q)) {
  4321. transformType = 'translateY'
  4322. transformValue = q;
  4323. transformUnit = 'px';
  4324. }
  4325.  
  4326.  
  4327. }
  4328.  
  4329. if (transformType) {
  4330.  
  4331. if (transformType === 'scalex' || transformType === 'scaley') {
  4332.  
  4333. const q = transformValue;
  4334.  
  4335.  
  4336. /*
  4337.  
  4338. let vz = Math.round(steppingScaleN * q);
  4339. const customPropName = '--discrete-'+transformType
  4340.  
  4341. const currentValue = aStyle.getPropertyValue(customPropName);
  4342.  
  4343. const transform = (aStyle.transform || '');
  4344. const u = transform.includes(customPropName)
  4345. if (`${currentValue}` === `${vz}`) {
  4346. if (u) return;
  4347. }
  4348.  
  4349.  
  4350. setCSSProp(a,customPropName, vz);
  4351. // aStyle.setProperty(customPropName, vz)
  4352.  
  4353. let ck = '';
  4354.  
  4355. if (c.length === 9) ck = c;
  4356. else if (!u) ck = c.replace(/[.\d]+/, '0.5');
  4357.  
  4358. if (ck && beforeMq !== ck) {
  4359. aStyle.setProperty('--mq-transform', ck);
  4360. }
  4361.  
  4362. if (u) return;
  4363. c = `${transformType}(calc(var(--discrete-${transformType})/${steppingScaleN}))`;
  4364.  
  4365.  
  4366.  
  4367. */
  4368.  
  4369. const vz = +(Math.round(q * steppingScaleN) / steppingScaleN).toFixed(3);
  4370.  
  4371. c = `${transformType === 'scalex' ? 'scaleX' : 'scaleY'}(${vz})`
  4372. const cv = aStyle.transform;
  4373.  
  4374. // console.log(157, cv,c)
  4375.  
  4376. if (c === cv) return;
  4377. // console.log(257, cv,c)
  4378.  
  4379. aStyle.transform = c;
  4380.  
  4381. // return;
  4382.  
  4383. } else if (transformType === 'translateX' || transformType === 'translateY') {
  4384.  
  4385. const q = transformValue;
  4386.  
  4387. /*
  4388.  
  4389. let vz = q.toFixed(1);
  4390. const customPropName = '--discrete-'+transformType
  4391.  
  4392. const aStyle = a.style;
  4393. const currentValue = (aStyle.getPropertyValue(customPropName) || '').replace('px', '');
  4394.  
  4395.  
  4396. const transform = (aStyle.transform || '');
  4397. const u = transform.includes(customPropName)
  4398. if (parseFloat(currentValue).toFixed(1) === vz) {
  4399. if (u) return;
  4400. }
  4401.  
  4402. setCSSProp(a,customPropName, vz + 'px');
  4403. // aStyle.setProperty(customPropName, vz + 'px')
  4404.  
  4405. let ck = '';
  4406. if (c.length === 15) ck = c;
  4407. else if (!u) ck = c.replace(/[.\d]+/, '0.5');
  4408.  
  4409. if (ck && beforeMq !== ck) {
  4410. aStyle.setProperty('--mq-transform', ck);
  4411. }
  4412.  
  4413. if (u) return;
  4414. c = `${transformType}(var(--discrete-${transformType}))`;
  4415.  
  4416. */
  4417.  
  4418.  
  4419. const vz = +q.toFixed(1);
  4420.  
  4421. c = `${transformType}(${vz}${transformUnit})`
  4422. const cv = aStyle.transform;
  4423.  
  4424. // console.log(158, cv,c)
  4425.  
  4426. if (c === cv) return;
  4427. // console.log(258, cv,c)
  4428.  
  4429. aStyle.transform = c;
  4430.  
  4431. // return;
  4432.  
  4433. } else {
  4434. throw new Error();
  4435. }
  4436.  
  4437. } else {
  4438. // if(beforeMq) a.style.setProperty('--mq-transform', '');
  4439. const cv = aStyle.transform
  4440. if (!c && !cv) return;
  4441. else if (c === cv) return;
  4442. aStyle.transform = c;
  4443. // return;
  4444. }
  4445.  
  4446. } else if (b === "display") {
  4447.  
  4448. const cv = a.style.display;
  4449. if (!cv && !c) return;
  4450. if (cv === c) return;
  4451.  
  4452.  
  4453. } else if (b === "width") {
  4454.  
  4455. const cv = a.style.width;
  4456. if (!cv && !c) return;
  4457. if (cv === c) return;
  4458.  
  4459. }
  4460.  
  4461. // console.log(130000, a, b, c);
  4462.  
  4463. if (byPassDefaultFn) return;
  4464. return attrUpdateFn.call(this, a, b, c);
  4465. }
  4466.  
  4467.  
  4468. /*
  4469.  
  4470. g.zo = function(a, b, c) {
  4471. if ("string" === typeof b)
  4472. (b = yo(a, b)) && (a.style[b] = c);
  4473. else
  4474. for (var d in b) {
  4475. c = a;
  4476. var e = b[d]
  4477. , f = yo(c, d);
  4478. f && (c.style[f] = e)
  4479. }
  4480. }
  4481.  
  4482.  
  4483. */
  4484.  
  4485.  
  4486. }
  4487.  
  4488.  
  4489.  
  4490. const keyuG = PERF_471489_ ? getuG(_yt_player) : null;
  4491.  
  4492. if (keyuG) {
  4493.  
  4494. k = keyuG;
  4495.  
  4496. const gk = g[k];
  4497. const gkp = gk.prototype;
  4498.  
  4499.  
  4500. /** @type { Map<string, WeakMap<any, any>> } */
  4501. const ntLogs = new Map();
  4502.  
  4503. if (typeof gkp.updateValue === 'function' && gkp.updateValue.length === 2 && !gkp.updateValue31) {
  4504.  
  4505. gkp.updateValue31 = gkp.updateValue;
  4506. gkp.updateValue = function (a, b) {
  4507. if (typeof a !== 'string') return this.updateValue31(a, b);
  4508.  
  4509. const element = this.element;
  4510. if (!(element instanceof HTMLElement)) return this.updateValue31(a, b);
  4511.  
  4512. let ntLog = ntLogs.get(a);
  4513. if (!ntLog) ntLogs.set(a, (ntLog = new WeakMap()));
  4514.  
  4515. let cache = ntLog.get(element);
  4516. if (cache && cache.value === b) {
  4517. return;
  4518. }
  4519. if (!cache) {
  4520. this.__oldValueByUpdateValue__ = null;
  4521. ntLog.set(element, cache = { value: b });
  4522. } else {
  4523. this.__oldValueByUpdateValue__ = cache.value;
  4524. cache.value = b;
  4525. }
  4526.  
  4527.  
  4528. return this.updateValue31(a, b);
  4529. }
  4530.  
  4531.  
  4532. /*
  4533. g.k.update = function(a) {
  4534. for (var b = g.u(Object.keys(a)), c = b.next(); !c.done; c = b.next())
  4535. c = c.value,
  4536. this.updateValue(c, a[c])
  4537. }
  4538. ;
  4539. g.k.updateValue = function(a, b) {
  4540. (a = this.Td["{{" + a + "}}"]) && wG(this, a[0], a[1], b)
  4541. }
  4542. */
  4543.  
  4544.  
  4545. }
  4546.  
  4547.  
  4548. }
  4549.  
  4550.  
  4551.  
  4552.  
  4553. })();
  4554.  
  4555.  
  4556.  
  4557. FIX_Animation_n_timeline && (async () => {
  4558.  
  4559.  
  4560. const [timeline, Animation] = await Promise.all([timelineObservable.obtain(), animationObservable.obtain()]);
  4561.  
  4562. if (!timeline || !Animation) return;
  4563.  
  4564. const aniProto = Animation.prototype;
  4565. // aniProto.sequenceNumber = 0; // native YouTube engine bug - sequenceNumber is not set
  4566.  
  4567. const getXroto = (x) => {
  4568. try {
  4569. return x.__proto__;
  4570. } catch (e) { }
  4571. return null;
  4572. }
  4573. const timProto = getXroto(timeline);
  4574. if (!timProto) return;
  4575. if (
  4576. (
  4577. typeof timProto.getAnimations === 'function' && typeof timProto.play === 'function' &&
  4578. typeof timProto._discardAnimations === 'function' && typeof timProto._play === 'function' &&
  4579. typeof timProto._updateAnimationsPromises === 'function' && !timProto.nofCQ &&
  4580. typeof aniProto._updatePromises === 'function' && !aniProto.nofYH
  4581. )
  4582.  
  4583. ) {
  4584.  
  4585. timProto.nofCQ = 1;
  4586. aniProto.nofYH = 1;
  4587.  
  4588. const originalAnimationsWithPromises = ((_updateAnimationsPromises) => {
  4589.  
  4590.  
  4591. /*
  4592. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  4593. return c._updatePromises();
  4594. });
  4595. */
  4596.  
  4597. const p = Array.prototype.filter;
  4598.  
  4599. let res = null;
  4600. Array.prototype.filter = function () {
  4601.  
  4602. res = this;
  4603. return this;
  4604.  
  4605. };
  4606.  
  4607. _updateAnimationsPromises.call({});
  4608.  
  4609. Array.prototype.filter = p;
  4610.  
  4611. if (res && typeof res.length === 'number') {
  4612. /** @type {any[]} */
  4613. const _res = res;
  4614. return _res;
  4615. }
  4616.  
  4617.  
  4618. return null;
  4619.  
  4620.  
  4621.  
  4622.  
  4623. })(timProto._updateAnimationsPromises);
  4624.  
  4625. if (!originalAnimationsWithPromises || typeof originalAnimationsWithPromises.length !== 'number') return;
  4626.  
  4627. // console.log('originalAnimationsWithPromises', originalAnimationsWithPromises)
  4628.  
  4629. aniProto._updatePromises31 = aniProto._updatePromises;
  4630.  
  4631. /*
  4632. aniProto._updatePromises = function(){
  4633. console.log('eff',this._oldPlayState, this.playState)
  4634. return this._updatePromises31.apply(this, arguments)
  4635. }
  4636. */
  4637.  
  4638. aniProto._updatePromises = function () {
  4639. var oldPlayState = this._oldPlayState;
  4640. var newPlayState = this.playState;
  4641. // console.log('ett', oldPlayState, newPlayState)
  4642. if (newPlayState !== oldPlayState) {
  4643. this._oldPlayState = newPlayState;
  4644. if (this._readyPromise) {
  4645. if ("idle" == newPlayState) {
  4646. this._rejectReadyPromise();
  4647. this._readyPromise = void 0;
  4648. } else if ("pending" == oldPlayState) {
  4649. this._resolveReadyPromise();
  4650. } else if ("pending" == newPlayState) {
  4651. this._readyPromise = void 0;
  4652. }
  4653. }
  4654. if (this._finishedPromise) {
  4655. if ("idle" == newPlayState) {
  4656. this._rejectFinishedPromise();
  4657. this._finishedPromise = void 0;
  4658. } else if ("finished" == newPlayState) {
  4659. this._resolveFinishedPromise();
  4660. } else if ("finished" == oldPlayState) {
  4661. this._finishedPromise = void 0;
  4662. }
  4663. }
  4664. }
  4665. return this._readyPromise || this._finishedPromise;
  4666. };
  4667.  
  4668.  
  4669. let restartWebAnimationsNextTickFlag = false;
  4670.  
  4671. const looperMethodT = () => {
  4672.  
  4673. const runnerFn = (hRes) => {
  4674. var b = timeline;
  4675. b.currentTime = hRes;
  4676. b._discardAnimations();
  4677. if (0 == b._animations.length) {
  4678. restartWebAnimationsNextTickFlag = false;
  4679. } else {
  4680. getRafPromise().then(runnerFn);
  4681. }
  4682. }
  4683.  
  4684. const restartWebAnimationsNextTick = () => {
  4685. if (!restartWebAnimationsNextTickFlag) {
  4686. restartWebAnimationsNextTickFlag = true;
  4687. getRafPromise().then(runnerFn);
  4688. }
  4689. }
  4690.  
  4691. return { restartWebAnimationsNextTick }
  4692. };
  4693.  
  4694.  
  4695. const looperMethodN = () => {
  4696.  
  4697. const acs = document.createElement('a-f');
  4698. acs.id = 'a-f';
  4699.  
  4700. const style = document.createElement('style');
  4701. style.textContent = `
  4702. @keyFrames aF1 {
  4703. 0% {
  4704. order: 0;
  4705. }
  4706. 100% {
  4707. order: 6;
  4708. }
  4709. }
  4710. #a-f[id] {
  4711. visibility: collapse !important;
  4712. position: fixed !important;
  4713. top: -100px !important;
  4714. left: -100px !important;
  4715. margin:0 !important;
  4716. padding:0 !important;
  4717. outline:0 !important;
  4718. border:0 !important;
  4719. z-index:-1 !important;
  4720. width: 0px !important;
  4721. height: 0px !important;
  4722. contain: strict !important;
  4723. pointer-events: none !important;
  4724. animation: 1ms steps(2) 0ms infinite alternate forwards running aF1 !important;
  4725. }
  4726. `;
  4727. (document.head || document.documentElement).appendChild(style);
  4728.  
  4729. document.documentElement.insertBefore(acs, document.documentElement.firstChild);
  4730.  
  4731. const _onanimationiteration = function (evt) {
  4732. const hRes = evt.timeStamp;
  4733. var b = timeline;
  4734. b.currentTime = hRes;
  4735. b._discardAnimations();
  4736. if (0 == b._animations.length) {
  4737. restartWebAnimationsNextTickFlag = false;
  4738. acs.onanimationiteration = null;
  4739. } else {
  4740. acs.onanimationiteration = _onanimationiteration;
  4741. }
  4742.  
  4743. }
  4744.  
  4745.  
  4746.  
  4747. const restartWebAnimationsNextTick = () => {
  4748. if (!restartWebAnimationsNextTickFlag) {
  4749. restartWebAnimationsNextTickFlag = true;
  4750. acs.onanimationiteration = _onanimationiteration;
  4751.  
  4752. }
  4753. }
  4754.  
  4755. return { restartWebAnimationsNextTick }
  4756. };
  4757.  
  4758.  
  4759.  
  4760. const { restartWebAnimationsNextTick } = ('onanimationiteration' in document.documentElement) ? looperMethodN() : looperMethodT();
  4761.  
  4762.  
  4763. // console.log(571, timProto);
  4764. timProto._play = function (c) {
  4765. c = new Animation(c, this);
  4766. this._animations.push(c);
  4767. restartWebAnimationsNextTick();
  4768. c._updatePromises();
  4769. c._animation.play();
  4770. c._updatePromises();
  4771. return c
  4772. }
  4773.  
  4774. const animationsWithPromisesMap = new Set(originalAnimationsWithPromises);
  4775. originalAnimationsWithPromises.length = 0;
  4776. originalAnimationsWithPromises.push = null;
  4777. originalAnimationsWithPromises.splice = null;
  4778. originalAnimationsWithPromises.slice = null;
  4779. originalAnimationsWithPromises.indexOf = null;
  4780. originalAnimationsWithPromises.unshift = null;
  4781. originalAnimationsWithPromises.shift = null;
  4782. originalAnimationsWithPromises.pop = null;
  4783. originalAnimationsWithPromises.filter = null;
  4784. originalAnimationsWithPromises.forEach = null;
  4785. originalAnimationsWithPromises.map = null;
  4786.  
  4787.  
  4788. const _updateAnimationsPromises = () => {
  4789. animationsWithPromisesMap.forEach(c => {
  4790. if (!c._updatePromises()) animationsWithPromisesMap.delete(c);
  4791. });
  4792. /*
  4793. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  4794. return c._updatePromises();
  4795. });
  4796. */
  4797. }
  4798.  
  4799. timProto._updateAnimationsPromises31 = timProto._updateAnimationsPromises;
  4800.  
  4801. timProto._updateAnimationsPromises = _updateAnimationsPromises;
  4802.  
  4803. delete timProto._updateAnimationsPromises;
  4804. Object.defineProperty(timProto, '_updateAnimationsPromises', {
  4805. get() {
  4806. if (animationsWithPromisesMap.size === 0) return nilFn;
  4807. return _updateAnimationsPromises;
  4808. },
  4809. set(nv) {
  4810. delete this._updateAnimationsPromises;
  4811. this._updateAnimationsPromises = nv;
  4812. },
  4813. enumerable: true,
  4814. configurable: true,
  4815. });
  4816.  
  4817.  
  4818. let pdFinished = Object.getOwnPropertyDescriptor(aniProto, 'finished');
  4819. aniProto.__finished_native_get__ = pdFinished.get;
  4820. if (typeof pdFinished.get === 'function' && !pdFinished.set && pdFinished.configurable === true && pdFinished.enumerable === true) {
  4821.  
  4822.  
  4823. Object.defineProperty(aniProto, 'finished', {
  4824. get() {
  4825. this._finishedPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  4826. this._finishedPromise = new Promise((resolve, reject) => {
  4827. this._resolveFinishedPromise = function () {
  4828. resolve(this)
  4829. };
  4830. this._rejectFinishedPromise = function () {
  4831. reject({
  4832. type: DOMException.ABORT_ERR,
  4833. name: "AbortError"
  4834. })
  4835. };
  4836. }),
  4837. "finished" == this.playState && this._resolveFinishedPromise());
  4838. return this._finishedPromise
  4839. },
  4840. set: undefined,
  4841. enumerable: true,
  4842. configurable: true
  4843. });
  4844.  
  4845. }
  4846.  
  4847.  
  4848.  
  4849. let pdReady = Object.getOwnPropertyDescriptor(aniProto, 'ready');
  4850. aniProto.__ready_native_get__ = pdReady.get;
  4851. if (typeof pdReady.get === 'function' && !pdReady.set && pdReady.configurable === true && pdReady.enumerable === true) {
  4852.  
  4853. Object.defineProperty(aniProto, 'ready', {
  4854. get() {
  4855. this._readyPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  4856. this._readyPromise = new Promise((resolve, reject) => {
  4857. this._resolveReadyPromise = function () {
  4858. resolve(this)
  4859. };
  4860. this._rejectReadyPromise = function () {
  4861. reject({
  4862. type: DOMException.ABORT_ERR,
  4863. name: "AbortError"
  4864. })
  4865. };
  4866. }),
  4867. "pending" !== this.playState && this._resolveReadyPromise());
  4868. return this._readyPromise
  4869. },
  4870. set: undefined,
  4871. enumerable: true,
  4872. configurable: true
  4873. });
  4874.  
  4875. }
  4876.  
  4877.  
  4878. if (IGNORE_bindAnimationForCustomEffect && typeof aniProto._rebuildUnderlyingAnimation === 'function' && !aniProto._rebuildUnderlyingAnimation21 && aniProto._rebuildUnderlyingAnimation.length === 0) {
  4879.  
  4880. aniProto._rebuildUnderlyingAnimation21 = aniProto._rebuildUnderlyingAnimation;
  4881. const _rebuildUnderlyingAnimation = function () {
  4882. // if (isNaN(this._sequenceNumber)) return; // do not rebuild underlying animation if native animation is used.
  4883. this.effect && this.effect._onsample && (this.effect._onsample = null);
  4884. return this._rebuildUnderlyingAnimation21();
  4885. }
  4886. aniProto._rebuildUnderlyingAnimation = _rebuildUnderlyingAnimation;
  4887. // delete aniProto._rebuildUnderlyingAnimation;
  4888. // Object.defineProperty(aniProto, '_rebuildUnderlyingAnimation', {
  4889. // get() {
  4890. // if (isNaN(this._sequenceNumber)) return nilFn;
  4891. // return this._rebuildUnderlyingAnimation21;
  4892. // },
  4893. // set(nv) {
  4894. // delete this._rebuildUnderlyingAnimation;
  4895. // this._rebuildUnderlyingAnimation = nv;
  4896. // },
  4897. // enumerable: true,
  4898. // configurable: true
  4899. // });
  4900. }
  4901.  
  4902.  
  4903. /*
  4904.  
  4905.  
  4906. function f(c) {
  4907. var b = v.timeline;
  4908. b.currentTime = c;
  4909. b._discardAnimations();
  4910. 0 == b._animations.length ? d = !1 : requestAnimationFrame(f)
  4911. }
  4912. var h = window.requestAnimationFrame;
  4913. window.requestAnimationFrame = function(c) {
  4914. return h(function(b) {
  4915. v.timeline._updateAnimationsPromises();
  4916. c(b);
  4917. v.timeline._updateAnimationsPromises()
  4918. })
  4919. }
  4920. ;
  4921. v.AnimationTimeline = function() {
  4922. this._animations = [];
  4923. this.currentTime = void 0
  4924. }
  4925. ;
  4926. v.AnimationTimeline.prototype = {
  4927. getAnimations: function() {
  4928. this._discardAnimations();
  4929. return this._animations.slice()
  4930. },
  4931. _updateAnimationsPromises: function() {
  4932. v.animationsWithPromises = v.animationsWithPromises.filter(function(c) {
  4933. return c._updatePromises()
  4934. })
  4935. },
  4936. _discardAnimations: function() {
  4937. this._updateAnimationsPromises();
  4938. this._animations = this._animations.filter(function(c) {
  4939. return "finished" != c.playState && "idle" != c.playState
  4940. })
  4941. },
  4942. _play: function(c) {
  4943. c = new v.Animation(c,this);
  4944. this._animations.push(c);
  4945. v.restartWebAnimationsNextTick();
  4946. c._updatePromises();
  4947. c._animation.play();
  4948. c._updatePromises();
  4949. return c
  4950. },
  4951. play: function(c) {
  4952. c && c.remove();
  4953. return this._play(c)
  4954. }
  4955. };
  4956. var d = !1;
  4957. v.restartWebAnimationsNextTick = function() {
  4958. d || (d = !0,
  4959. requestAnimationFrame(f))
  4960. }
  4961. ;
  4962. var a = new v.AnimationTimeline;
  4963. v.timeline = a;
  4964. try {
  4965. Object.defineProperty(window.document, "timeline", {
  4966. configurable: !0,
  4967. get: function() {
  4968. return a
  4969. }
  4970. })
  4971. } catch (c) {}
  4972. try {
  4973. window.document.timeline = a
  4974. } catch (c) {}
  4975.  
  4976. */
  4977.  
  4978.  
  4979.  
  4980. /*
  4981.  
  4982. var g = window.getComputedStyle;
  4983. Object.defineProperty(window, "getComputedStyle", {
  4984. configurable: !0,
  4985. enumerable: !0,
  4986. value: function() {
  4987. v.timeline._updateAnimationsPromises();
  4988. var e = g.apply(this, arguments);
  4989. h() && (e = g.apply(this, arguments));
  4990. v.timeline._updateAnimationsPromises();
  4991. return e
  4992. }
  4993. });
  4994.  
  4995. */
  4996.  
  4997.  
  4998.  
  4999.  
  5000. }
  5001.  
  5002.  
  5003.  
  5004.  
  5005. })();
  5006.  
  5007. promiseForCustomYtElementsReady.then(() => {
  5008.  
  5009. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  5010.  
  5011.  
  5012.  
  5013. class LimitedSizeSet extends Set {
  5014. constructor(n) {
  5015. super();
  5016.  
  5017. this.limit = n;
  5018. }
  5019.  
  5020. add(key) {
  5021. if (!super.has(key)) {
  5022. super.add(key); // Set the key with a dummy value (true)
  5023. while (super.size > this.limit) {
  5024. const firstKey = super.values().next().value; // Get the first (oldest) key
  5025. super.delete(firstKey); // Delete the oldest key
  5026. }
  5027. }
  5028. }
  5029.  
  5030. removeAdd(key){
  5031. super.delete(key);
  5032. super.add(key);
  5033. }
  5034.  
  5035. }
  5036.  
  5037. // const wk3 = new WeakMap();
  5038.  
  5039. // let mtxVideoId = '';
  5040. // let aje3 = [];
  5041. const mfvContinuationRecorded = new LimitedSizeSet(8); // record all success continuation keys
  5042. const mfyContinuationIgnored = new LimitedSizeSet(8); // ignore continuation keys by copying the keys in the past
  5043. let mtzlastAllowedContinuation = ''; // the key stored at the last success; clear when scheduling changes
  5044. let mtzCount = 0; // the key keeps unchanged
  5045. // let mjtNextMainKey = '';
  5046. let mjtRecordedPrevKey = ''; // the key stored at the last success (no clear)
  5047. let mjtLockPreviousKey = ''; // the key before fetch() should be discarded. (uncertain continuation)
  5048. let mbCId322 = 0; // cid for delay fetchUpdatedMetadata
  5049. // let allowNoDelay322=false;
  5050. let mbDelayBelowNCalls = 0; // after N calls, by pass delay; reset when scheduling changes
  5051.  
  5052. let mpKey22 = ''; // last success continutation key & url pair
  5053. let mpUrl22 = ''; // last success continutation key & url pair
  5054. let mpKey21 = ''; // latest requested continutation key & url pair
  5055. let mpUrl21 = ''; // latest requested continutation key & url pair
  5056.  
  5057.  
  5058. async function sha1Hex(message) {
  5059. const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
  5060. const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8); // hash the message
  5061. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  5062. const hashHex = hashArray
  5063. .map((b) => b.toString(16).padStart(2, "0"))
  5064. .join(""); // convert bytes to hex string
  5065. return hashHex;
  5066. }
  5067.  
  5068. async function continuationLog(a, ...args) {
  5069. let b = a;
  5070. try {
  5071. if (advanceLogging) b = await sha1Hex(a);
  5072. let c = args.map(e => {
  5073. return e === a ? b : e
  5074. });
  5075. console.log(...c)
  5076. } catch (e) { console.warn(e) }
  5077. }
  5078.  
  5079. function copyPreviousContiuationToIgnored374(toClearRecorded) {
  5080.  
  5081.  
  5082. if (mfvContinuationRecorded.length > 0) {
  5083. for (const [e, d] of mfvContinuationRecorded) {
  5084. mfyContinuationIgnored.removeAdd(e);
  5085. }
  5086. toClearRecorded && mfvContinuationRecorded.clear();
  5087. }
  5088.  
  5089. }
  5090.  
  5091. function setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr) {
  5092.  
  5093. const tmProto = taskMgr.constructor.prototype;
  5094. if (tmProto && typeof tmProto.addJob === 'function' && tmProto.addJob.length === 3 && typeof tmProto.cancelJob === 'function' && tmProto.cancelJob.length === 1) {
  5095.  
  5096. if (!tmProto.addJob714) {
  5097.  
  5098. tmProto.addJob714 = tmProto.addJob;
  5099.  
  5100. tmProto.addJob = function (a, b, c) {
  5101. const jobId = this.addJob714(a, b, c);
  5102. if (jobId > 0) {
  5103. // const ez = wk3.get(this);
  5104. // const dz = ez ? ez.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint : null;
  5105. // aje3.push({mtx, jobId, a,b,c, element: this, dz, data: (ez?.data || null) })
  5106.  
  5107. this.__lastJobId863__ = jobId;
  5108. }
  5109. return jobId;
  5110. }
  5111.  
  5112. }
  5113.  
  5114. if (!tmProto.cancelJob714) {
  5115.  
  5116. tmProto.cancelJob714 = tmProto.cancelJob;
  5117.  
  5118. tmProto.cancelJob = function (a) {
  5119. const res = this.cancelJob714(a);
  5120. // if (a > 0) {
  5121. // for (const e of aje3) {
  5122. // if (e.jobId === a) e.cancelled = true;
  5123. // }
  5124. // }
  5125. return res;
  5126. }
  5127.  
  5128. }
  5129.  
  5130. }
  5131. }
  5132.  
  5133.  
  5134. const FIX_avoid_incorrect_video_meta_bool = FIX_avoid_incorrect_video_meta && (pageSetupVideoId !== null) && check_for_set_key_order;
  5135.  
  5136.  
  5137. FIX_avoid_incorrect_video_meta_bool && customElements.whenDefined('ytd-video-primary-info-renderer').then(() => {
  5138. let dummy;
  5139. let cProto;
  5140. // let mc = 4;
  5141. // dummy = await observablePromise(() => {
  5142. // const r = document.querySelector('ytd-video-primary-info-renderer');
  5143. // if (!r) return;
  5144. // let cProto = insp(r).constructor.prototype;
  5145. // if (cProto.fetchUpdatedMetadata) return r;
  5146. // if (--mc < 0) return -1;
  5147. // return null;
  5148. // }).obtain();
  5149. dummy = document.createElement('ytd-video-primary-info-renderer');
  5150. if (!(dummy instanceof Element)) return;
  5151. // console.log(5022, dummy)
  5152. cProto = insp(dummy).constructor.prototype;
  5153.  
  5154. cProto.__getEmittorTaskMgr859__ = function () {
  5155. let taskMgr_ = null;
  5156. try {
  5157. taskMgr_ = (this.ytTaskEmitterBehavior || 0).getTaskManager() || null;
  5158. } catch (e) { }
  5159. return taskMgr_;
  5160. }
  5161. if (typeof cProto.fetchUpdatedMetadata === 'function' && cProto.fetchUpdatedMetadata.length === 1 && !cProto.fetchUpdatedMetadata717) {
  5162. // console.log(1234, cProto, cProto.is)
  5163. cProto.fetchUpdatedMetadata717 = cProto.fetchUpdatedMetadata;
  5164.  
  5165. let c_;
  5166. cProto.fetchUpdatedMetadata718 = function (a) {
  5167. // delay or immediate call the actual fetchUpdatedMetadata
  5168.  
  5169. let doImmediately = false;
  5170. if (a && typeof a === 'string' && mjtRecordedPrevKey && mjtRecordedPrevKey === mpKey22 && a === mpKey22 && (!pageSetupVideoId || pageSetupVideoId !== mpUrl22)) {
  5171.  
  5172. if (!pageSetupVideoId && videoPlayingY.videoId === mpUrl22) doImmediately = true;
  5173.  
  5174. } else if (typeof a !== 'string' || mbDelayBelowNCalls > 3 || !mpKey22 || (mpKey22 === a && mpKey22 !== mjtLockPreviousKey) || (mjtLockPreviousKey && mjtLockPreviousKey !== a)) {
  5175.  
  5176. doImmediately = true;
  5177.  
  5178. }
  5179.  
  5180. if (mbCId322) {
  5181. clearTimeout(mbCId322);
  5182. mbCId322 = 0;
  5183. }
  5184.  
  5185. if (doImmediately) return this.fetchUpdatedMetadata717(a);
  5186.  
  5187. let delay = mjtLockPreviousKey === a ? 8000 : 800;
  5188.  
  5189. mbCId322 = setTimeout(() => {
  5190. this.fetchUpdatedMetadata717(a);
  5191. }, delay);
  5192.  
  5193. console.log('5190 delayed fetchUpdatedMetadata', delay);
  5194.  
  5195. }
  5196.  
  5197. cProto.fetchUpdatedMetadata = function (a) {
  5198.  
  5199. if (!pageSetupState) {
  5200. if (c_) clearTimeout(c_);
  5201. c_ = setTimeout(() => {
  5202. this.fetchUpdatedMetadata718(a);
  5203. }, 300);
  5204. return;
  5205. }
  5206.  
  5207. // pageSetupState == 0
  5208.  
  5209. try {
  5210.  
  5211. mbDelayBelowNCalls++;
  5212.  
  5213. if (arguments.length > 1 || !(a === undefined || (typeof a === 'string' && a))) {
  5214. console.warn("CAUTION: fetchUpdatedMetadata coding might have to be updated.");
  5215. }
  5216.  
  5217. // console.log('fum377', a)
  5218. if (typeof a === 'string' && mfyContinuationIgnored.has(a)) {
  5219. console.log('5040 skip fetchUpdatedMetadata', a);
  5220. return;
  5221. }
  5222.  
  5223. if (!a && (this.data || 0).updatedMetadataEndpoint) {
  5224. if (mjtRecordedPrevKey && mjtLockPreviousKey !== mjtRecordedPrevKey) {
  5225. mjtLockPreviousKey = mjtRecordedPrevKey;
  5226. continuationLog(mjtLockPreviousKey, '5150 Lock Key', mjtLockPreviousKey);
  5227. }
  5228. // mjtNextMainKey = true;
  5229. mtzlastAllowedContinuation = '';
  5230. mtzCount = 0;
  5231. // allowNoDelay322 = false;
  5232. // fetch new metadata, cancel all previous continuations
  5233. copyPreviousContiuationToIgnored374(true);
  5234. } else if (typeof a === 'string') {
  5235. const videoPlayingId = videoPlayingY.videoId;
  5236.  
  5237. // if(mjtNextMainKey === true) mjtNextMainKey = a;
  5238.  
  5239. let update21 = !!pageSetupVideoId;
  5240. if (mpKey22 === a && mpUrl22 === videoPlayingId && mpUrl22 && videoPlayingId && (!pageSetupVideoId || pageSetupVideoId === videoPlayingId)) {
  5241. update21 = true;
  5242. } else if (mpKey22 === a && mpUrl22 !== pageSetupVideoId) {
  5243. continuationLog(mpKey22, '5060 mpUrl22 mismatched', mpKey22, mpUrl22, pageSetupVideoId || '(null)' , videoPlayingId || '(null)' );
  5244. return;
  5245. }
  5246. if (update21) {
  5247. mpKey21 = a;
  5248. mpUrl21 = pageSetupVideoId || videoPlayingId;
  5249. }
  5250.  
  5251. if (!mfvContinuationRecorded.has(a)) mfvContinuationRecorded.add(a);
  5252. }
  5253. continuationLog(a, '5180 fetchUpdatedMetadata\t', a, pageSetupVideoId || '(null)' , videoPlayingY.videoId || '(null)' );
  5254. // if (!pageSetupVideoId && typeof a === 'string' && a.length > 40) return; // ignore incorrect continuation
  5255. // if(a === mjtNextMainKey) allowNoDelay322 = false;
  5256. return this.fetchUpdatedMetadata718(a);
  5257.  
  5258. } catch (e) {
  5259. console.log('Code Error in fetchUpdatedMetadata', e);
  5260. }
  5261. return this.fetchUpdatedMetadata717(a)
  5262. }
  5263. }
  5264.  
  5265.  
  5266. if (typeof cProto.scheduleInitialUpdatedMetadataRequest === 'function' && cProto.scheduleInitialUpdatedMetadataRequest.length === 0 && !cProto.scheduleInitialUpdatedMetadataRequest717) {
  5267. // console.log(1234, cProto, cProto.is)
  5268. cProto.scheduleInitialUpdatedMetadataRequest717 = cProto.scheduleInitialUpdatedMetadataRequest;
  5269. let mJob = null;
  5270.  
  5271. cProto.scheduleInitialUpdatedMetadataRequest = function () {
  5272.  
  5273. try {
  5274.  
  5275. if (arguments.length > 0) {
  5276. console.warn("CAUTION: scheduleInitialUpdatedMetadataRequest coding might have to be updated.");
  5277. }
  5278. // mfy = mfv;
  5279.  
  5280. // mjtNextMainKey = '';
  5281. mtzlastAllowedContinuation = '';
  5282. mtzCount = 0;
  5283. if (mbCId322) {
  5284. clearTimeout(mbCId322);
  5285. mbCId322 = 0;
  5286. }
  5287. mbDelayBelowNCalls = 0;
  5288. // allowNoDelay322 = false;
  5289. copyPreviousContiuationToIgnored374(true);
  5290.  
  5291. const taskMgr = this.__getEmittorTaskMgr859__();
  5292. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714 && taskMgr.addJob && taskMgr.cancelJob) setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr);
  5293. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714) {
  5294. console.log('YouTube Super Fast Chat', 'scheduleInitialUpdatedMetadataRequest error 507');
  5295. }
  5296.  
  5297. // prevent depulicated schedule job by clearing previous JobId
  5298. if (taskMgr && typeof taskMgr.addLowPriorityJob === 'function' && taskMgr.addLowPriorityJob.length === 2 && typeof taskMgr.cancelJob === 'function' && taskMgr.cancelJob.length === 1) {
  5299.  
  5300. let res;
  5301.  
  5302. if (mJob) {
  5303. const job = mJob;
  5304. mJob = null;
  5305. console.log('cancelJob', job)
  5306. taskMgr.cancelJob(job); // clear previous [Interval Meta Update] job
  5307. // p.cancelJob(a,b);
  5308. }
  5309.  
  5310. // const updatedMetadataEndpoint = this.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint
  5311.  
  5312. let pza = taskMgr.__lastJobId863__;
  5313. try { res = this.scheduleInitialUpdatedMetadataRequest717(); } catch (e) { }
  5314. let pzb = taskMgr.__lastJobId863__
  5315. if (pza !== pzb) {
  5316. mJob = pzb; // set [Interval Meta Update] jobId
  5317. }
  5318.  
  5319. // if (updatedMetadataEndpoint && updatedMetadataEndpoint.videoId) {
  5320. // mtxVideoId = updatedMetadataEndpoint.videoId || ''; // set the current target VideoId
  5321. // } else {
  5322. // mtxVideoId = ''; // sometimes updatedMetadataEndpoint is not ready
  5323. // }
  5324.  
  5325. return res;
  5326.  
  5327. } else {
  5328. console.log('YouTube Super Fast Chat', 'scheduleInitialUpdatedMetadataRequest error 601');
  5329. }
  5330.  
  5331. } catch (e) {
  5332. console.log('Code Error in scheduleInitialUpdatedMetadataRequest', e);
  5333. }
  5334.  
  5335.  
  5336. return this.scheduleInitialUpdatedMetadataRequest717();
  5337. }
  5338. }
  5339.  
  5340.  
  5341. });
  5342.  
  5343. FIX_avoid_incorrect_video_meta_bool && promiseForYtActionCalled.then((ytAppDom) => {
  5344. let dummy;
  5345. let cProto;
  5346. dummy = ytAppDom;
  5347. if (!(dummy instanceof Element)) return;
  5348. cProto = insp(dummy).constructor.prototype;
  5349. if (typeof cProto.sendServiceAjax_ === 'function' && cProto.sendServiceAjax_.length === 4 && !cProto.sendServiceAjax717_) {
  5350. // console.log(1234, cProto, cProto.is);
  5351. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  5352. // cProto.handleServiceRequest_ = function (a, b, c, d) {
  5353. // console.log(123401, arguments);
  5354. // return this.handleServiceRequest717_(a, b, c, d);
  5355. // }
  5356.  
  5357. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  5358.  
  5359. // cProto.handleServiceRequest_ = function(a,b,c,d){
  5360. // console.log(59901, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  5361. // if(a?.is === 'ytd-video-primary-info-renderer' && b?.updatedMetadataEndpoint?.videoId && c?.continuation && typeof c?.continuation ==='string'){
  5362. // console.log('mfv', c.continuation);
  5363. // mfv.add( c.continuation);
  5364. // }
  5365. // return this.handleServiceRequest717_(a,b,c,d);
  5366. // }
  5367.  
  5368. function extraArguments322(a, b, c) {
  5369. let is = (a || 0).is;
  5370. let videoId = ((b || 0).updatedMetadataEndpoint || 0).videoId;
  5371. let continuation = (c || 0).continuation;
  5372. if (typeof is !== 'string') is = null;
  5373. if (typeof videoId !== 'string') videoId = null;
  5374. if (typeof continuation !== 'string') continuation = null;
  5375. return { is, videoId, continuation };
  5376. }
  5377.  
  5378. cProto.sendServiceAjax717_ = cProto.sendServiceAjax_;
  5379. cProto.sendServiceAjax_ = function (a, b, c, d) {
  5380.  
  5381. // console.log(8001)
  5382. try {
  5383.  
  5384. const { is, videoId, continuation } = extraArguments322(a, b, c);
  5385.  
  5386. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  5387. console.warn("CAUTION: sendServiceAjax_ coding might have to be updated.");
  5388. }
  5389.  
  5390. if (pageSetupVideoId && videoId && continuation) {
  5391. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  5392. mfyContinuationIgnored.removeAdd(continuation);
  5393. mfvContinuationRecorded.delete(continuation);
  5394. return;
  5395. }
  5396. }
  5397.  
  5398. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  5399. copyPreviousContiuationToIgnored374(false);
  5400. mfyContinuationIgnored.delete(continuation);
  5401. mfvContinuationRecorded.removeAdd(continuation);
  5402. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  5403. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  5404. mjtLockPreviousKey = '';
  5405. }
  5406. // if (mjtNextMainKey === continuation) {
  5407. // copyPreviousContiuationToIgnored(false);
  5408. // mfyContinuationIgnored.delete(continuation);
  5409. // mfvContinuationRecorded.add(continuation);
  5410. // }
  5411.  
  5412.  
  5413. if (mfyContinuationIgnored && continuation) {
  5414. if (mfyContinuationIgnored.has(continuation)) {
  5415. continuationLog(continuation, '5260 matched01', continuation)
  5416. return;
  5417. }
  5418. }
  5419.  
  5420. // console.log(59902, a?.is, b,c,d)
  5421. // console.log(59903, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  5422. if (is === 'ytd-video-primary-info-renderer' && videoId && continuation && !mfvContinuationRecorded.has(continuation)) {
  5423. // console.log('mfv377', continuation);
  5424. mfvContinuationRecorded.add(continuation);
  5425. }
  5426.  
  5427. // if (videoId) {
  5428. // if (!pageSetupVideoId) return; // ignore page not ready
  5429. // // if (mtxVideoId && b.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  5430. // if (videoId !== pageSetupVideoId) {
  5431. // return;
  5432. // }
  5433. // }
  5434.  
  5435. } catch (e) {
  5436. console.log('Coding Error in sendServiceAjax_', e)
  5437. }
  5438. // console.log(8002)
  5439. // console.log(123402, arguments);
  5440. // console.log(5162, 'a',a?.is,'b',b,'c',c,'d',d);
  5441.  
  5442. // console.log(5211, b?.updatedMetadataEndpoint?.kdkw33);
  5443. // if(b &&b.updatedMetadataEndpoint && !b.updatedMetadataEndpoint.kdkw33){
  5444. // b.updatedMetadataEndpoint = new Proxy(b.updatedMetadataEndpoint, {
  5445. // get(target, prop, receiver){
  5446. // console.log('xxs99', target.videoId, mtx)
  5447. // if(prop ==='kdkw33') return 1;
  5448. // console.log(3322, prop, target)
  5449. // if(prop === 'initialDelayMs') {
  5450. // throw new Error("ABCC");
  5451. // }
  5452. // return target[prop];
  5453. // },
  5454. // set(target, prop, value, receiver){
  5455.  
  5456. // if(prop ==='kdkw33') return true;
  5457. // target[prop]=value;
  5458. // return true;
  5459. // }
  5460. // });
  5461. // }
  5462. // console.log(5533, b?.updatedMetadataEndpoint?.kdkw33)
  5463. return this.sendServiceAjax717_(a, b, c, d);
  5464. }
  5465. }
  5466.  
  5467. function delayClearOtherKeys(lztContinuation) {
  5468. // // schedule delayed removal if mfyContinuationIgnored is not empty
  5469. // getRafPromise().then(() => {
  5470. // // assume the repeat continuation could be only for popstate which is triggered by user interaction
  5471. // // foreground page only
  5472.  
  5473. // });
  5474.  
  5475.  
  5476. if (lztContinuation !== mtzlastAllowedContinuation) return;
  5477. if (lztContinuation !== mpKey21 || lztContinuation !== mpKey22) return;
  5478. if (!mfyContinuationIgnored.size) return;
  5479. if (mfyContinuationIgnored.size > 1) {
  5480. continuationLog(lztContinuation, 'delayClearOtherKeys, current = ', lztContinuation);
  5481. }
  5482. mfyContinuationIgnored.forEach((value, key) => {
  5483. if (key !== lztContinuation) {
  5484. mfyContinuationIgnored.delete(key);
  5485. continuationLog(key, 'previous continuation removed from ignored store', key);
  5486. }
  5487. });
  5488.  
  5489. }
  5490. if (typeof cProto.getCancellableNetworkPromise_ === 'function' && cProto.getCancellableNetworkPromise_.length === 5 && !cProto.getCancellableNetworkPromise717_) {
  5491. cProto.getCancellableNetworkPromise717_ = cProto.getCancellableNetworkPromise_;
  5492. cProto.getCancellableNetworkPromise_ = function (a, b, c, d, e) {
  5493.  
  5494. // console.log(8003)
  5495. try {
  5496.  
  5497.  
  5498. const { is, videoId, continuation } = extraArguments322(b, c, d);
  5499.  
  5500. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  5501. console.warn("CAUTION: getCancellableNetworkPromise_ coding might have to be updated.");
  5502. }
  5503.  
  5504. if (pageSetupVideoId && videoId && continuation) {
  5505. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  5506. mfyContinuationIgnored.removeAdd(continuation);
  5507. mfvContinuationRecorded.delete(continuation);
  5508. return;
  5509. }
  5510. }
  5511.  
  5512. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  5513. copyPreviousContiuationToIgnored374(false);
  5514. mfyContinuationIgnored.delete(continuation);
  5515. mfvContinuationRecorded.removeAdd(continuation);
  5516. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  5517. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  5518. mjtLockPreviousKey = '';
  5519. }
  5520.  
  5521. // if (mjtNextMainKey === continuation) {
  5522. // copyPreviousContiuationToIgnored(false);
  5523. // mfyContinuationIgnored.delete(continuation);
  5524. // mfvContinuationRecorded.add(continuation);
  5525. // }
  5526.  
  5527. const lztContinuation = continuation;
  5528.  
  5529. if (mfyContinuationIgnored && lztContinuation && typeof lztContinuation === 'string') {
  5530. if (mfyContinuationIgnored.has(lztContinuation)) {
  5531. continuationLog(lztContinuation, '5360 matched02', lztContinuation)
  5532. return;
  5533. }
  5534. }
  5535.  
  5536. // if (videoId) {
  5537. // if (!pageSetupVideoId) return; // ignore page not ready
  5538. // // if (mtxVideoId && c.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  5539. // if (videoId !== pageSetupVideoId) {
  5540. // return;
  5541. // }
  5542. // }
  5543.  
  5544. if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation !== lztContinuation) {
  5545. mtzlastAllowedContinuation = lztContinuation;
  5546. // console.log(70401, lztContinuation, mfyContinuationIgnored.size)
  5547.  
  5548. continuationLog(lztContinuation, '5382 Continuation sets to\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  5549. mjtRecordedPrevKey = lztContinuation;
  5550. if (mjtLockPreviousKey === lztContinuation) mjtLockPreviousKey = '';
  5551. // if (mfyContinuationIgnored.size > 0) {
  5552. // delayClearOtherKeys(lztContinuation);
  5553. // }
  5554. mtzCount = 0;
  5555. // allowNoDelay322 = false;
  5556. } else if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation && mtzlastAllowedContinuation === lztContinuation) {
  5557. // repeated
  5558. if (mtzCount > 1e9) mtzCount = 1e4;
  5559. ++mtzCount;
  5560. continuationLog(lztContinuation, '5386 Same Continuation\t\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  5561.  
  5562. // if (mtzCount >= 3) allowNoDelay322 = true;
  5563. if (mtzCount >= 3 && mfyContinuationIgnored.size > 0) {
  5564. Promise.resolve(lztContinuation).then(delayClearOtherKeys).catch(console.warn);
  5565. }
  5566. if (mtzCount === 5) {
  5567. mfvContinuationRecorded.clear();
  5568. mfvContinuationRecorded.add(lztContinuation);
  5569. }
  5570.  
  5571. }
  5572.  
  5573. if (typeof lztContinuation === 'string' && lztContinuation && (pageSetupVideoId || videoPlayingY.videoId) ) {
  5574. mpKey22 = lztContinuation;
  5575. mpUrl22 = pageSetupVideoId || videoPlayingY.videoId;
  5576. }
  5577.  
  5578. if (mbCId322) {
  5579. clearTimeout(mbCId322);
  5580. mbCId322 = 0;
  5581. }
  5582. } catch (e) {
  5583. console.log('Coding Error in getCancellableNetworkPromise_', e)
  5584. }
  5585.  
  5586. // console.log(8004)
  5587. // console.log(123403, arguments);
  5588. // if(c.updatedMetadataEndpoint) console.log(123404, pageSetupVideoId, JSON.stringify(c.updatedMetadataEndpoint))
  5589.  
  5590. // console.log(5163, a?.is,b,c,d,e);
  5591. return this.getCancellableNetworkPromise717_(a, b, c, d, e);
  5592. }
  5593. }
  5594. });
  5595.  
  5596. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  5597.  
  5598.  
  5599. FIX_ytdExpander_childrenChanged && customElements.whenDefined('ytd-expander').then(() => {
  5600.  
  5601. let dummy;
  5602. let cProto;
  5603.  
  5604. dummy = document.createElement('ytd-expander');
  5605. cProto = insp(dummy).constructor.prototype;
  5606.  
  5607. if (fnIntegrity(cProto.initChildrenObserver, '0.48.21') && fnIntegrity(cProto.childrenChanged, '0.40.22')) {
  5608.  
  5609. cProto.initChildrenObserver14 = cProto.initChildrenObserver;
  5610. cProto.childrenChanged14 = cProto.childrenChanged;
  5611.  
  5612. cProto.initChildrenObserver = function () {
  5613. var a = this;
  5614. this.observer = new MutationObserver(function () {
  5615. a.childrenChanged()
  5616. }
  5617. );
  5618. this.observer.observe(this.content, {
  5619. subtree: !0,
  5620. childList: !0,
  5621. attributes: !0,
  5622. characterData: !0
  5623. });
  5624. this.childrenChanged()
  5625. }
  5626. ;
  5627. cProto.childrenChanged = function () {
  5628. if (this.alwaysToggleable) {
  5629. this.canToggle = this.alwaysToggleable;
  5630. } else if (!this.canToggleJobId) {
  5631. this.canToggleJobId = 1;
  5632. getRafPromise().then(() => {
  5633. this.canToggleJobId = 0;
  5634. this.calculateCanCollapse()
  5635. })
  5636. }
  5637. }
  5638.  
  5639. // console.log(cProto.initChildrenObserver)
  5640. console.debug('ytd-expander-fix-childrenChanged');
  5641.  
  5642. }
  5643.  
  5644. });
  5645.  
  5646.  
  5647. FIX_paper_ripple_animate && customElements.whenDefined('paper-ripple').then(() => {
  5648.  
  5649. let dummy;
  5650. let cProto;
  5651. dummy = document.createElement('paper-ripple');
  5652. cProto = insp(dummy).constructor.prototype;
  5653.  
  5654. if (fnIntegrity(cProto.animate, '0.74.5')) {
  5655.  
  5656.  
  5657. cProto.animate34 = cProto.animate;
  5658. cProto.animate = function () {
  5659. if (this._animating) {
  5660. var a;
  5661. const ripples = this.ripples;
  5662. for (a = 0; a < ripples.length; ++a) {
  5663. var b = ripples[a];
  5664. b.draw();
  5665. this.$.background.style.opacity = b.outerOpacity;
  5666. b.isOpacityFullyDecayed && !b.isRestingAtMaxRadius && this.removeRipple(b)
  5667. }
  5668. if ((this.shouldKeepAnimating || 0) !== ripples.length) {
  5669. if (!this._boundAnimate38) this._boundAnimate38 = this.animate.bind(this);
  5670. getRafPromise().then(this._boundAnimate38);
  5671. } else {
  5672. this.onAnimationComplete()
  5673. }
  5674. }
  5675. }
  5676.  
  5677. console.debug('FIX_paper_ripple_animate')
  5678.  
  5679. // console.log(cProto.animate)
  5680.  
  5681. }
  5682.  
  5683. });
  5684.  
  5685. if (FIX_doIdomRender) {
  5686.  
  5687.  
  5688. const xsetTimeout = function (f, d) {
  5689. if (xsetTimeout.m511 === 1 && !d) {
  5690. xsetTimeout.m511 = 2;
  5691. getRafPromise().then(f);
  5692. } else {
  5693. return setTimeout.apply(window, arguments)
  5694. }
  5695.  
  5696. }
  5697.  
  5698. const xrequestAnimationFrame = function (f) {
  5699. const h = f + "";
  5700. if (h.startsWith("function(){setTimeout(function(){") && h.endsWith("})}")) {
  5701. xsetTimeout.m511 = 1;
  5702. f();
  5703. xsetTimeout.m511 = 0;
  5704. } else if (h.includes("requestAninmationFrameResolver")) {
  5705. getRafPromise().then(f);
  5706. } else {
  5707. return requestAnimationFrame.apply(window, arguments);
  5708. }
  5709. }
  5710.  
  5711. let busy = false;
  5712. const doIdomRender = function () {
  5713. if (busy) {
  5714. return this.doIdomRender13.apply(this, arguments);
  5715. }
  5716. busy = true;
  5717. const { requestAnimationFrame, setTimeout } = window;
  5718. window.requestAnimationFrame = xrequestAnimationFrame;
  5719. window.setTimeout = xsetTimeout;
  5720. let r = this.doIdomRender13.apply(this, arguments);
  5721. window.requestAnimationFrame = requestAnimationFrame;
  5722. window.setTimeout = setTimeout;
  5723. busy = false;
  5724. return r;
  5725. };
  5726. 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']) {
  5727.  
  5728.  
  5729. customElements.whenDefined(ytTag).then(() => {
  5730.  
  5731. let dummy;
  5732. let cProto;
  5733. dummy = document.createElement(ytTag);
  5734. cProto = insp(dummy).constructor.prototype;
  5735.  
  5736. cProto.doIdomRender13 = cProto.doIdomRender;
  5737. cProto.doIdomRender = doIdomRender;
  5738.  
  5739. if (cProto.doIdomRender13 === cProto.templatingFn) cProto.templatingFn = doIdomRender;
  5740.  
  5741. console.debug('FIX_doIdomRender', ytTag)
  5742.  
  5743.  
  5744.  
  5745. });
  5746.  
  5747. }
  5748.  
  5749. }
  5750.  
  5751.  
  5752.  
  5753. });
  5754.  
  5755. });
  5756.  
  5757.  
  5758. setupEvents();
  5759.  
  5760.  
  5761.  
  5762. if (isMainWindow) {
  5763.  
  5764. console.groupCollapsed(
  5765. "%cYouTube JS Engine Tamer",
  5766. "background-color: #EDE43B ; color: #000 ; font-weight: bold ; padding: 4px ;"
  5767. );
  5768.  
  5769.  
  5770.  
  5771. console.log("Script is loaded.");
  5772. console.log("This script changes the core mechanisms of the YouTube JS engine.");
  5773.  
  5774. console.log("This script is experimental and subject to further changes.");
  5775.  
  5776. console.log("This might boost your YouTube performance.");
  5777.  
  5778. console.log("CAUTION: This might break your YouTube.");
  5779.  
  5780.  
  5781. if (prepareLogs.length >= 1) {
  5782. console.log(" =========================================================================== ");
  5783.  
  5784. for (const msg of prepareLogs) {
  5785. console.log(msg)
  5786. }
  5787.  
  5788. console.log(" =========================================================================== ");
  5789. }
  5790.  
  5791. console.groupEnd();
  5792.  
  5793. }
  5794.  
  5795.  
  5796.  
  5797. })();