YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

当前为 2024-04-06 提交的版本,查看 最新版本

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