YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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