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.33
  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; // disabled in old browsers
  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. const ENABLE_weakenStampReferencesQ = ENABLE_weakenStampReferences && typeof DocumentTimeline !== 'undefined' && typeof WeakRef !== 'undefined';
  1679. ENABLE_weakenStampReferencesQ && weakenStampReferences(h);
  1680.  
  1681.  
  1682.  
  1683. /// -----------------------
  1684.  
  1685.  
  1686. // const isMainRenderer = (h) => {
  1687. // if (h.is && h.$ && h.__dataEnabled && h.__dataReady && h.__shady && h.__templateInfo && h.root && h.hostElement) {
  1688. // const q = (h.parentComponent ? 1 : 0) | (h.ytComponentBehavior ? 2 : 0);
  1689. // if (q === 3) {
  1690. // // chat renderer
  1691. // if (h.is.endsWith('-renderer')) {
  1692. // return true;
  1693. // }
  1694. // } else if (q === 0) {
  1695. // // custom lyrics engagement panel
  1696. // if (h.is.endsWith('-renderer')) {
  1697. // return true;
  1698. // }
  1699. // } else if (q === 1) {
  1700. // // input renderer
  1701. // if (h.is.endsWith('-renderer')) {
  1702. // return true;
  1703. // }
  1704. // }
  1705. // }
  1706. // return false;
  1707. // }
  1708.  
  1709. // const skipRenderer = (h) => {
  1710. // return (h.is === 'yt-live-chat-renderer') ||
  1711. // (h.is === 'yt-live-chat-item-list-renderer') ||
  1712. // (h.is === 'yt-live-chat-text-input-field-renderer') ||
  1713. // (h.is === 'yt-live-chat-message-buy-flow-renderer') ||
  1714. // false;
  1715. // }
  1716.  
  1717.  
  1718. /*
  1719. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km31) && h.rendererStamperApplyChangeRecord_.length === 3) {
  1720.  
  1721. const f = h.rendererStamperApplyChangeRecord_;
  1722. h.rendererStamperApplyChangeRecord31_ = f;
  1723. const g = ump3.get(f) || function (a, b, c) {
  1724. if (isMainRenderer(this) || (this.updateChildVisibilityProperties && !this.markDirty)) {
  1725. let y = false;
  1726. if (!this.markDirty) {
  1727. // yt-live-chat-dialog-renderer
  1728. // ytd-engagement-panel-section-list-renderer
  1729. y = true;
  1730. } else if (!this.visibilityObserverForChild_ && !!this.getVisibilityObserverForChild) {
  1731. const lobs = this.localVisibilityObserver_;
  1732. if (this.isRenderer_ === true) {
  1733. if (lobs) {
  1734. if (lobs.observer && lobs.isConnected === true) {
  1735. // if (lobs.observer && lobs.isConnected === true && lobs.pauseObservingUntilReconnect === false && lobs.handlers && lobs.handlers.size > 0) {
  1736. // if ((this.__data || 0).isEmpty === false) {
  1737. // // by pass
  1738. // } else if (this.is === 'yt-live-chat-renderer') {
  1739. // y = true;
  1740. // }
  1741. if (this.is === 'yt-live-chat-renderer') {
  1742. y = true;
  1743. }
  1744. } else {
  1745. y = true;
  1746. }
  1747. } else if (lobs === null) {
  1748. y = true;
  1749. } else {
  1750. console.log('renderer-check-failure 01', this.is)
  1751. }
  1752. } else {
  1753. console.log('renderer-check-failure 02', this.is)
  1754. }
  1755. }
  1756. if (y) {
  1757. return f.apply(this, arguments);
  1758. }
  1759. }
  1760. let c2 = c;
  1761. if (c && typeof c === 'object') {
  1762. c2 = {};
  1763. for (const entry of Object.entries(c)) {
  1764. const [key, value] = entry;
  1765. let choice = 0;
  1766. if (value && typeof value === 'object') {
  1767. if (key === 'base' && value.length >= 1) choice = 1;
  1768. else if (key === 'value' && value.indexSplices && value.indexSplices.length >= 1) choice = 2;
  1769. }
  1770. if (choice === 1) c2[key] = value.slice(0);
  1771. else if (choice === 2) c2[key] = Object.assign({}, value, { indexSplices: value.indexSplices.map(splice=>{
  1772.  
  1773. if (!splice || typeof splice !== 'object') return splice;
  1774. if (splice.removed && splice.removed.length >= 1) splice.removed = splice.removed.slice(0);
  1775. if (splice.object && splice.object.length >= 1) splice.object = splice.object.slice(0);
  1776.  
  1777. return splice;
  1778.  
  1779. }) });
  1780. else c2[key] = value;
  1781. }
  1782. }
  1783. const acceptable = () => {
  1784. return this.isAttached && this.data && this.__dataEnabled
  1785. }
  1786. // sequence on the same proto
  1787. this[qm47] = (this[qm47] || Promise.resolve()).then(() => acceptable() && this.rendererStamperApplyChangeRecord31_(a, b, c2)).catch(console.log);
  1788. }
  1789. ump3.set(f, g);
  1790. g.km31 = 1;
  1791. h.rendererStamperApplyChangeRecord_ = g;
  1792.  
  1793.  
  1794. }
  1795. */
  1796.  
  1797.  
  1798.  
  1799.  
  1800. /*
  1801. if (typeof h.rendererStamperObserver_ === 'function' && !(h.rendererStamperObserver_.km34)) {
  1802.  
  1803. const f = h.rendererStamperObserver_;
  1804. const g = ump3.get(f) || function (a, b, c) {
  1805. if (isMainRenderer(this)) {
  1806. return f.apply(this, arguments);
  1807. }
  1808. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1809. }
  1810. ump3.set(f, g);
  1811. g.km34 = 1;
  1812. h.rendererStamperObserver_ = g;
  1813.  
  1814. }
  1815.  
  1816.  
  1817. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km34)) {
  1818.  
  1819. const f = h.rendererStamperApplyChangeRecord_;
  1820. const g = ump3.get(f) || function () {
  1821. if (isMainRenderer(this)) {
  1822. return f.apply(this, arguments);
  1823. }
  1824. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1825. }
  1826. ump3.set(f, g);
  1827. g.km34 = 1;
  1828. h.rendererStamperApplyChangeRecord_ = g;
  1829.  
  1830. }
  1831.  
  1832.  
  1833.  
  1834. if (typeof h.flushRenderStamperComponentBindings_ === 'function' && !(h.flushRenderStamperComponentBindings_.km34)) {
  1835.  
  1836. const f = h.flushRenderStamperComponentBindings_;
  1837. const g = ump3.get(f) || function () {
  1838. if (isMainRenderer(this)) {
  1839. return f.apply(this, arguments);
  1840. }
  1841. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1842. }
  1843. ump3.set(f, g);
  1844. g.km34 = 1;
  1845. h.flushRenderStamperComponentBindings_ = g;
  1846.  
  1847. }
  1848.  
  1849.  
  1850. if (typeof h.forwardRendererStamperChanges_ === 'function' && !(h.forwardRendererStamperChanges_.km34)) {
  1851.  
  1852. const f = h.forwardRendererStamperChanges_;
  1853. const g = ump3.get(f) || function () {
  1854. if (isMainRenderer(this)) {
  1855. return f.apply(this, arguments);
  1856. }
  1857. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1858. }
  1859. ump3.set(f, g);
  1860. g.km34 = 1;
  1861. h.forwardRendererStamperChanges_ = g;
  1862.  
  1863. }
  1864. */
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870. // console.log(123)
  1871.  
  1872. // return;
  1873.  
  1874.  
  1875. /*
  1876.  
  1877. // buggy for page swtiching
  1878.  
  1879. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km31)) {
  1880.  
  1881.  
  1882.  
  1883.  
  1884. const f = h.dataChanged_;
  1885. h.dataChanged31_ = f;
  1886. const g = ump3.get(f) || function (...args) {
  1887.  
  1888. if (isMainRenderer(this)) {
  1889. return f.apply(this, arguments);
  1890. }
  1891.  
  1892. // sequence on the same proto
  1893. this[qm47] = (this[qm47] || Promise.resolve()).then(() => this.dataChanged31_(...args)).catch(console.log);
  1894. }
  1895. ump3.set(f, g);
  1896. g.km31 = 1;
  1897. h.dataChanged_ = g;
  1898.  
  1899.  
  1900. }
  1901. */
  1902.  
  1903.  
  1904. /*
  1905.  
  1906. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km34)) {
  1907.  
  1908. const f = h.dataChanged_;
  1909. const g = ump3.get(f) || function () {
  1910. if (isMainRenderer(this)) {
  1911. return f.apply(this, arguments);
  1912. }
  1913. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1914. }
  1915. ump3.set(f, g);
  1916. g.km34 = 1;
  1917. h.dataChanged_ = g;
  1918.  
  1919. }
  1920. */
  1921.  
  1922.  
  1923.  
  1924. if (typeof h.tryRenderChunk_ === 'function' && !(h.tryRenderChunk_.km34)) {
  1925.  
  1926. const f = h.tryRenderChunk_;
  1927. const g = ump3.get(f) || function () {
  1928. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1929. }
  1930. ump3.set(f, g);
  1931. g.km34 = 1;
  1932. h.tryRenderChunk_ = g;
  1933.  
  1934. }
  1935.  
  1936.  
  1937. if (typeof h.renderChunk_ === 'function' && !(h.renderChunk_.km34)) {
  1938.  
  1939. const f = h.renderChunk_;
  1940. const g = ump3.get(f) || function () {
  1941. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1942. }
  1943. ump3.set(f, g);
  1944. g.km34 = 1;
  1945. h.renderChunk_ = g;
  1946.  
  1947. }
  1948.  
  1949. if (typeof h.deepLazyListObserver_ === 'function' && !(h.deepLazyListObserver_.km34)) {
  1950.  
  1951. const f = h.deepLazyListObserver_;
  1952. const g = ump3.get(f) || function () {
  1953. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1954. }
  1955. ump3.set(f, g);
  1956. g.km34 = 1;
  1957. h.deepLazyListObserver_ = g;
  1958.  
  1959. }
  1960.  
  1961.  
  1962. if (typeof h.onItemsUpdated_ === 'function' && !(h.onItemsUpdated_.km34)) {
  1963.  
  1964. const f = h.onItemsUpdated_;
  1965. const g = ump3.get(f) || function () {
  1966. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1967. }
  1968. ump3.set(f, g);
  1969. g.km34 = 1;
  1970. h.onItemsUpdated_ = g;
  1971.  
  1972. }
  1973.  
  1974. /*
  1975. // see https://github.com/cyfung1031/userscript-supports/issues/20
  1976. if (typeof h.updateChangeRecord_ === 'function' && !(h.updateChangeRecord_.km34)) {
  1977.  
  1978. const f = h.updateChangeRecord_;
  1979. const g = ump3.get(f) || function () {
  1980. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1981. }
  1982. ump3.set(f, g);
  1983. g.km34 = 1;
  1984. h.updateChangeRecord_ = g;
  1985.  
  1986. }
  1987. */
  1988.  
  1989.  
  1990. if (typeof h.requestRenderChunk_ === 'function' && !(h.requestRenderChunk_.km34)) {
  1991.  
  1992. const f = h.requestRenderChunk_;
  1993. const g = ump3.get(f) || function () {
  1994. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1995. }
  1996. ump3.set(f, g);
  1997. g.km34 = 1;
  1998. h.requestRenderChunk_ = g;
  1999.  
  2000. }
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006. return;
  2007.  
  2008.  
  2009.  
  2010. /*
  2011. if (typeof h.cancelPendingTasks_ === 'function' && !(h.cancelPendingTasks_.km34)) {
  2012.  
  2013. const f = h.cancelPendingTasks_;
  2014. const g = ump3.get(f) || function () {
  2015. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  2016. }
  2017. ump3.set(f, g);
  2018. g.km34 = 1;
  2019. h.cancelPendingTasks_ = g;
  2020.  
  2021. }
  2022.  
  2023.  
  2024. if (typeof h.fillRange_ === 'function' && !(h.fillRange_.km34)) {
  2025.  
  2026. const f = h.fillRange_;
  2027. const g = ump3.get(f) || function () {
  2028. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  2029. }
  2030. ump3.set(f, g);
  2031. g.km34 = 1;
  2032. h.fillRange_ = g;
  2033.  
  2034. }
  2035. */
  2036.  
  2037.  
  2038.  
  2039.  
  2040. if (typeof h.addTextNodes_ === 'function' && !(h.addTextNodes_.km34)) {
  2041.  
  2042. const f = h.addTextNodes_;
  2043. const g = function () {
  2044. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  2045. }
  2046. g.km34 = 1;
  2047. h.addTextNodes_ = g;
  2048.  
  2049. }
  2050.  
  2051.  
  2052.  
  2053.  
  2054. if (typeof h.updateText_ === 'function' && !(h.updateText_.km34)) {
  2055.  
  2056. const f = h.updateText_;
  2057. const g = function () {
  2058. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  2059. }
  2060. g.km34 = 1;
  2061. h.updateText_ = g;
  2062.  
  2063. }
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069. if (typeof h.stampTypeChanged_ === 'function' && !(h.stampTypeChanged_.km34)) {
  2070.  
  2071. const f = h.stampTypeChanged_;
  2072. const g = function () {
  2073. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  2074. }
  2075. g.km34 = 1;
  2076. h.stampTypeChanged_ = g;
  2077.  
  2078. }
  2079.  
  2080.  
  2081.  
  2082.  
  2083. // console.log(166)
  2084.  
  2085.  
  2086.  
  2087.  
  2088. }
  2089.  
  2090. const keyStConnectedCallback = Symbol(); // avoid copying the value
  2091.  
  2092. // const keyStDisconnectedCallback = Symbol(); // avoid copying the value
  2093. const cmf = new WeakMap();
  2094. const dmf = new WeakMap();
  2095.  
  2096. const gvGenerator = (nv) => {
  2097. return function () {
  2098. const cnt = insp(this);
  2099. const hostElement = cnt.hostElement || 0;
  2100. const dollar = hostElement ? (this.$ || indr(this)) : 0;
  2101. let p = (hostElement instanceof HTMLElement) && (dollar || !this.is);
  2102. if (p && (!dollar && !this.is)) {
  2103. const nodeName = hostElement.nodeName;
  2104. if (typeof nodeName !== 'string') {
  2105. // just in case
  2106. } else if (nodeName.startsWith("DOM-")) {
  2107. // dom-if, dom-repeat, etc
  2108. } else {
  2109. // yt element - new model, yt-xxxx, anixxxxxx
  2110. p = false;
  2111. }
  2112. }
  2113. if (p) {
  2114. if (typeof cnt.markDirty === 'function') {
  2115. // the yt element might call markDirty (occasionally)
  2116. p = false;
  2117. } else if (this.is === 'ytd-engagement-panel-section-list-renderer') {
  2118. // see https://github.com/cyfung1031/userscript-supports/issues/20
  2119. p = false;
  2120. }
  2121. }
  2122. if (p) {
  2123.  
  2124. // << dom-repeat & dom-if >>
  2125.  
  2126. // sequence on the same instance
  2127. this[qm57] = (this[qm57] || Promise.resolve()).then(() => nv.apply(this, arguments)).catch(console.log);
  2128. } else {
  2129. nv.apply(this, arguments);
  2130. }
  2131. };
  2132. }
  2133.  
  2134. const setupWeakRef = (h) => {
  2135.  
  2136.  
  2137. if (WEAK_REF_BINDING && !h.kz62 && setup$ && setupD && setupDataHost && (h.is || h.__dataHost)) {
  2138.  
  2139. let skip = false;
  2140. // if (h.is && typeof h.is === 'string' && h.is.length > 15 && h.is.length < 30) {
  2141. // if (h.is.includes('yt-') && !h.$ && h.is.length !== 20 && h.is.length !== 21 && h.is.length !== 22) {
  2142. // skip = true;
  2143. // // return;
  2144. // }
  2145. // }
  2146.  
  2147. h.kz62 = 1;
  2148.  
  2149. //
  2150.  
  2151. setup$(h);
  2152. const hostElement = h.hostElement;
  2153.  
  2154. if (hostElement !== h) {
  2155.  
  2156. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  2157. setupD(h, s);
  2158.  
  2159. }
  2160.  
  2161. const dh = h.__dataHost;
  2162.  
  2163. setupDataHost(dh, skip)
  2164. }
  2165.  
  2166.  
  2167.  
  2168.  
  2169. if (hostElement) {
  2170.  
  2171. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  2172. setupD(hostElement, s);
  2173.  
  2174. }
  2175.  
  2176. const dh = hostElement.__dataHost;
  2177.  
  2178. setupDataHost(dh, skip)
  2179.  
  2180.  
  2181.  
  2182.  
  2183. aDelay().then(() => {
  2184. setupD(hostElement, '__CE_shadowRoot');
  2185. });
  2186.  
  2187.  
  2188. }
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194. }
  2195.  
  2196. }
  2197.  
  2198.  
  2199. let nativeHTMLElement = window.HTMLElement;
  2200.  
  2201. try {
  2202.  
  2203. const q = document.createElement('template');
  2204. q.innerHTML = '<ytz-null361></ytz-null361>';
  2205. nativeHTMLElement = q.content.firstChild.constructor
  2206.  
  2207. } catch (e) { }
  2208.  
  2209. if (!nativeHTMLElement.prototype.connectedCallback) {
  2210. nativeHTMLElement.prototype.connectedCallback79 = nativeHTMLElement.prototype.connectedCallback;
  2211. nativeHTMLElement.prototype.connectedCallback = function () {
  2212. let r;
  2213. if (this.connectedCallback79) r = this.connectedCallback79.apply(this, arguments);
  2214.  
  2215. if (WEAK_REF_BINDING && (this instanceof Node) && (this.is || this.__dataHost)) {
  2216. setupWeakRef(this)
  2217. // setupWeakRef(this.__dataHost)
  2218. }
  2219. return r;
  2220. }
  2221. }
  2222.  
  2223. ENABLE_discreteTasking && Object.defineProperty(Object.prototype, 'connectedCallback', {
  2224. get() {
  2225. const f = this[keyStConnectedCallback];
  2226. if (this.is) {
  2227. setupDiscreteTasks(this, true);
  2228. if (f) this.ky36 = 1;
  2229. }
  2230. if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  2231. setupWeakRef(this)
  2232. }
  2233. return f;
  2234. },
  2235. set(nv) {
  2236. let gv;
  2237. if (typeof nv === 'function') {
  2238.  
  2239. gv = cmf.get(nv) || gvGenerator(nv);
  2240. if (gv !== nv) {
  2241. cmf.set(nv, gv);
  2242. cmf.set(gv, gv);
  2243. dmf.set(gv, nv);
  2244. }
  2245.  
  2246. } else {
  2247. gv = nv;
  2248. }
  2249. this[keyStConnectedCallback] = gv; // proto or object
  2250. if (this.is) {
  2251. setupDiscreteTasks(this);
  2252. }
  2253. if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  2254. setupWeakRef(this)
  2255. }
  2256. return true;
  2257. },
  2258. enumerable: false,
  2259. configurable: true
  2260.  
  2261. });
  2262.  
  2263. const pLoad = new Promise(resolve => {
  2264. if (document.readyState !== 'loading') {
  2265. resolve();
  2266. } else {
  2267. window.addEventListener("DOMContentLoaded", resolve, false);
  2268. }
  2269. });
  2270. pLoad.then(() => {
  2271.  
  2272. let nonce = document.querySelector('style[nonce]');
  2273. nonce = nonce ? nonce.getAttribute('nonce') : null;
  2274. const st = document.createElement('style');
  2275. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  2276. st.textContent = "none-element-k47{order:0}";
  2277. st.addEventListener('load', () => {
  2278. pf31.resolve();
  2279. p59 = 1;
  2280. }, false);
  2281. document.body.appendChild(st);
  2282.  
  2283.  
  2284. // console.debug('90002', location.pathname)
  2285. // console.log(90000, location.pathname)
  2286.  
  2287. });
  2288.  
  2289. const prepareLogs = [];
  2290.  
  2291. const skipAdsDetection = new Set(['/robots.txt', '/live_chat', '/live_chat_replay']);
  2292.  
  2293. let winError00 = window.onerror;
  2294.  
  2295. let fix_error_many_stack_state = !FIX_error_many_stack ? 0 : skipAdsDetection.has(location.pathname) ? 2 : 1;
  2296.  
  2297. if (!JSON || !('parse' in JSON)) fix_error_many_stack_state = 0;
  2298.  
  2299. ; FIX_Iframe_NULL_SRC && (() => {
  2300.  
  2301. const emptyBlobUrl = URL.createObjectURL(new Blob([], { type: 'text/html' }));
  2302. const lcOpt = { sensitivity: 'base' };
  2303. document.createElement24 = document.createElement;
  2304. document.createElement = function (t) {
  2305. if (typeof t === 'string' && t.length === 6) {
  2306. if (t.localeCompare('iframe', undefined, lcOpt) === 0) {
  2307. const p = this.createElement24(t);
  2308. try {
  2309. const stack = new Error().stack;
  2310. const isSearchbox = stack.includes('initializeSearchbox'); // see https://greasyfork.org/scripts/473972-youtube-js-engine-tamer/discussions/217084
  2311. if (!isSearchbox) {
  2312. p.src = emptyBlobUrl; // avoid iframe is appended to DOM without any url
  2313. }
  2314. } catch (e) { }
  2315. return p;
  2316. }
  2317. }
  2318. return this.createElement24.apply(this, arguments);
  2319. };
  2320.  
  2321. })();
  2322.  
  2323. ; fix_error_many_stack_state === 1 && (() => {
  2324.  
  2325.  
  2326. let p1 = winError00;
  2327.  
  2328. let stackNeedleDetails = null;
  2329.  
  2330. Object.defineProperty(Object.prototype, 'matchAll', {
  2331. get() {
  2332. stackNeedleDetails = this;
  2333. return true;
  2334. },
  2335. enumerable: true,
  2336. configurable: true
  2337. });
  2338.  
  2339. try {
  2340. JSON.parse("{}");
  2341. } catch (e) {
  2342. console.warn(e)
  2343. fix_error_many_stack_state = 0;
  2344. }
  2345.  
  2346. delete Object.prototype['matchAll'];
  2347.  
  2348. let p2 = window.onerror;
  2349.  
  2350. window.onerror = p1;
  2351.  
  2352. if (fix_error_many_stack_state === 0) return;
  2353.  
  2354. if (stackNeedleDetails) {
  2355. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  2356. stackNeedleDetails.matchAll = true;
  2357. }
  2358.  
  2359. if (p1 === p2) return (fix_error_many_stack_state = 0);
  2360.  
  2361. // p1!==p2
  2362. fix_error_many_stack_state = !stackNeedleDetails ? 4 : 3;
  2363.  
  2364. })();
  2365.  
  2366. ; fix_error_many_stack_state === 2 && (() => {
  2367.  
  2368.  
  2369. let p1 = winError00;
  2370.  
  2371. let objectPrune = null;
  2372. let stackNeedleDetails = null;
  2373.  
  2374. Object.defineProperty(Function.prototype, 'findOwner', {
  2375. get() {
  2376. objectPrune = this;
  2377. return this._findOwner;
  2378. },
  2379. set(nv) {
  2380. this._findOwner = nv;
  2381. return true;
  2382. },
  2383. enumerable: true,
  2384. configurable: true
  2385. });
  2386.  
  2387. Object.defineProperty(Object.prototype, 'matchAll', {
  2388. get() {
  2389. stackNeedleDetails = this;
  2390. return true;
  2391. },
  2392. enumerable: true,
  2393. configurable: true
  2394. });
  2395.  
  2396. try {
  2397. JSON.parse("{}");
  2398. } catch (e) {
  2399. console.warn(e)
  2400. fix_error_many_stack_state = 0;
  2401. }
  2402.  
  2403. delete Function.prototype['findOwner'];
  2404. delete Object.prototype['matchAll'];
  2405.  
  2406. let p2 = window.onerror;
  2407.  
  2408. if (p1 !== p2) return (fix_error_many_stack_state = 4); // p1 != p2
  2409.  
  2410. if (fix_error_many_stack_state == 0) return;
  2411.  
  2412. // the following will only execute when Brave's scriptlets.js is executed.
  2413.  
  2414. prepareLogs.push("fix_error_many_stack_state NB")
  2415.  
  2416. if (stackNeedleDetails) {
  2417. stackNeedleDetails.pattern = null;
  2418. stackNeedleDetails.re = null;
  2419. stackNeedleDetails.expect = null;
  2420. stackNeedleDetails.matchAll = true;
  2421. }
  2422.  
  2423. if (objectPrune) {
  2424. objectPrune.findOwner = objectPrune.mustProcess = objectPrune.logJson = () => { }
  2425. delete objectPrune._findOwner;
  2426. }
  2427.  
  2428. fix_error_many_stack_state = 3;
  2429. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  2430. JSON.parse.objectPrune = objectPrune;
  2431.  
  2432. })();
  2433.  
  2434. ; fix_error_many_stack_state === 3 && (() => {
  2435.  
  2436.  
  2437. let p1 = winError00;
  2438.  
  2439. try {
  2440. JSON.parse("{}");
  2441. } catch (e) {
  2442. console.warn(e)
  2443. fix_error_many_stack_state = 0;
  2444. }
  2445.  
  2446. let p2 = window.onerror;
  2447.  
  2448. if (p1 === p2) return;
  2449.  
  2450. window.onerror = p1;
  2451.  
  2452. if (fix_error_many_stack_state === 0) return;
  2453.  
  2454. fix_error_many_stack_state = 4; // p1 != p2
  2455.  
  2456.  
  2457. })();
  2458.  
  2459. fix_error_many_stack_state === 4 && (() => {
  2460.  
  2461. // the following will only execute when Brave's scriptlets.js is executed.
  2462.  
  2463. prepareLogs.push("fix_error_many_stack_state AB")
  2464.  
  2465. JSON.parseProxy = JSON.parse;
  2466.  
  2467. JSON.parse = ((parse) => {
  2468.  
  2469. parse = parse.bind(JSON); // get a new instance of the current JSON.parse
  2470. return function (text, reviver) {
  2471. const onerror = window.onerror;
  2472. window.onerror = null;
  2473. let r;
  2474. try {
  2475. r = parse(...arguments);
  2476. } catch (e) {
  2477. r = e;
  2478. }
  2479. window.onerror = onerror;
  2480. if (r instanceof Error) {
  2481. throw r;
  2482. }
  2483. return r;
  2484. }
  2485.  
  2486. })(JSON.parse);
  2487.  
  2488.  
  2489. })();
  2490.  
  2491.  
  2492.  
  2493. // ================================================ 0.4.5 ================================================
  2494.  
  2495.  
  2496. // ; (() => {
  2497.  
  2498. // if (FIX_error_many_stack && self instanceof Window) {
  2499. // // infinite stack due to matchesStackTrace inside objectPrune of AdsBlock
  2500.  
  2501. // const pdK = Object.getOwnPropertyDescriptor(window, 'onerror');
  2502. // if (!pdK || (pdK.get && pdK.configurable)) {
  2503.  
  2504. // } else {
  2505. // return;
  2506. // }
  2507.  
  2508. // let unsupportErrorFix = false;
  2509.  
  2510. // let firstHook = true;
  2511. // let busy33 = false;
  2512.  
  2513. // let state = 0;
  2514.  
  2515. // if (pdK) {
  2516. // delete window['onerror'];
  2517. // }
  2518.  
  2519. // const pd = {
  2520. // get() {
  2521. // const stack = (new Error()).stack;
  2522. // // targetStack = stack;
  2523. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  2524. // state = isGetExceptionToken ? 1 : 0;
  2525. // delete Window.prototype['onerror'];
  2526. // let r = pdK ? pdK.get.call(this) : this.onerror;
  2527. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2528. // // console.log('onerror get', r)
  2529. // return r;
  2530. // },
  2531. // set(nv) {
  2532. // const stack = (new Error()).stack;
  2533. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  2534. // state = state === 1 && isGetExceptionToken ? 2 : 0;
  2535. // /** @type {string?} */
  2536. // let sToken = null;
  2537. // if (unsupportErrorFix || busy33) {
  2538.  
  2539. // } else if (typeof nv === 'function' && state === 2) {
  2540. // if (firstHook) {
  2541. // firstHook = false;
  2542. // console.groupCollapsed('Infinite onerror Bug Found');
  2543. // console.log(location.href);
  2544. // console.log(stack);
  2545. // console.log(nv);
  2546. // console.groupEnd();
  2547. // }
  2548. // let _token = null;
  2549. // busy33 = true;
  2550. // String.prototype.includes76 = String.prototype.includes;
  2551. // String.prototype.includes = function (token) {
  2552. // _token = token;
  2553. // return true;
  2554. // }
  2555. // nv('token');
  2556. // String.prototype.includes = String.prototype.includes76;
  2557. // sToken = _token;
  2558. // busy33 = false;
  2559. // if (typeof sToken !== 'string') {
  2560. // unsupportErrorFix = true;
  2561. // }
  2562. // }
  2563. // delete Window.prototype['onerror'];
  2564. // if (typeof sToken === 'string' && sToken.length > 1) {
  2565. // /** @type {string} */
  2566. // const token = sToken;
  2567. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>?} } */
  2568. // const currentOnerror = pdK ? pdK.get.call(this) : this.onerror;
  2569.  
  2570. // const now = Date.now();
  2571. // const tokenEntry = {
  2572. // token,
  2573. // expired: now + FIX_error_many_stack_keepAliveDuration
  2574. // }
  2575. // /** @typedef {typeof tokenEntry} TokenEntry */
  2576.  
  2577. // /** @type {Set<TokenEntry>} */
  2578. // const errorTokens = currentOnerror.errorTokens;
  2579.  
  2580. // if (errorTokens) {
  2581. // if (errorTokens.size > FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than) {
  2582. // for (const entry of errorTokens) {
  2583. // if (entry.expired < now) {
  2584. // errorTokens.delete(entry);
  2585. // }
  2586. // }
  2587. // }
  2588. // errorTokens.add(tokenEntry)
  2589. // } else {
  2590. // /** @type {Set<TokenEntry>} */
  2591. // const errorTokens = new Set([tokenEntry]);
  2592. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>} } */
  2593. // const newOnerror = ((oe) => {
  2594. // const r = function (msg, ...args) {
  2595. // if (typeof msg === 'string' && errorTokens.size > 0) {
  2596. // for (const entry of errorTokens) {
  2597. // if (msg.includes(entry.token)) return true;
  2598. // }
  2599. // }
  2600. // if (typeof oe === 'function') {
  2601. // return oe.apply(this, arguments);
  2602. // }
  2603. // };
  2604. // r.errorTokens = errorTokens;
  2605. // return r;
  2606. // })(currentOnerror);
  2607.  
  2608. // if (pdK && pdK.set) pdK.set.call(this, newOnerror);
  2609. // else this.onerror = newOnerror;
  2610. // }
  2611. // } else {
  2612. // if (pdK && pdK.set) pdK.set.call(this, nv);
  2613. // else this.onerror = nv;
  2614. // }
  2615. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2616.  
  2617. // // console.log('onerror set', nv)
  2618. // return true;
  2619. // },
  2620. // enumerable: true,
  2621. // configurable: true
  2622. // }
  2623.  
  2624. // Object.defineProperty(Window.prototype, 'onerror', pd);
  2625.  
  2626.  
  2627. // }
  2628.  
  2629.  
  2630. // })();
  2631.  
  2632.  
  2633.  
  2634. // ================================================ 0.4.5 ================================================
  2635.  
  2636.  
  2637. // << if FIX_yt_player >>
  2638.  
  2639. // credit to @nopeless (https://greasyfork.org/scripts/471489-youtube-player-perf/)
  2640. const PERF_471489_ = true;
  2641. // PERF_471489_ is not exactly the same to Youtube Player perf v0.7
  2642. // This script uses a much gentle way to tamer the JS engine instead.
  2643.  
  2644. // << end >>
  2645.  
  2646. const steppingScaleN = 200; // transform: scaleX(k/N); 0<k<N
  2647.  
  2648.  
  2649.  
  2650. const nilFn = () => { };
  2651.  
  2652. let isMainWindow = false;
  2653. try {
  2654. isMainWindow = window.document === window.top.document
  2655. } catch (e) { }
  2656.  
  2657. let NO_PRELOAD_GENERATE_204_BYPASS = NO_PRELOAD_GENERATE_204 ? false : true;
  2658. let headLinkCollection = null;
  2659.  
  2660. const isCustomElementsProvided = typeof customElements !== "undefined" && typeof (customElements || 0).whenDefined === "function";
  2661.  
  2662. const promiseForCustomYtElementsReady = isCustomElementsProvided ? null : new Promise((callback) => {
  2663. const EVENT_KEY_ON_REGISTRY_READY = "ytI-ce-registry-created";
  2664. if (typeof customElements === 'undefined') {
  2665. if (!('__CE_registry' in document)) {
  2666. // https://github.com/webcomponents/polyfills/
  2667. Object.defineProperty(document, '__CE_registry', {
  2668. get() {
  2669. // return undefined
  2670. },
  2671. set(nv) {
  2672. if (typeof nv == 'object') {
  2673. delete this.__CE_registry;
  2674. this.__CE_registry = nv;
  2675. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  2676. }
  2677. return true;
  2678. },
  2679. enumerable: false,
  2680. configurable: true
  2681. })
  2682. }
  2683. let eventHandler = (evt) => {
  2684. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  2685. const f = callback;
  2686. callback = null;
  2687. eventHandler = null;
  2688. f();
  2689. };
  2690. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  2691. } else {
  2692. callback();
  2693. }
  2694. });
  2695.  
  2696. const whenCEDefined = isCustomElementsProvided
  2697. ? (nodeName) => customElements.whenDefined(nodeName)
  2698. : (nodeName) => promiseForCustomYtElementsReady.then(() => customElements.whenDefined(nodeName));
  2699.  
  2700. // const assertor = (f) => f() || console.assert(false, f + "");
  2701.  
  2702. const fnIntegrity = (f, d) => {
  2703. if (!f || typeof f !== 'function') {
  2704. console.warn('f is not a function', f);
  2705. return;
  2706. }
  2707. let p = f + "", s = 0, j = -1, w = 0;
  2708. for (let i = 0, l = p.length; i < l; i++) {
  2709. const t = p[i];
  2710. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  2711. if (j < i - 1) w++;
  2712. j = i;
  2713. } else {
  2714. s++;
  2715. }
  2716. }
  2717. let itz = `${f.length}.${s}.${w}`;
  2718. if (!d) {
  2719. return itz;
  2720. } else {
  2721. return itz === d;
  2722. }
  2723. };
  2724.  
  2725. const getZqOu = (_yt_player) => {
  2726.  
  2727. const w = 'ZqOu';
  2728.  
  2729. let arr = [];
  2730.  
  2731. for (const [k, v] of Object.entries(_yt_player)) {
  2732.  
  2733. const p = typeof v === 'function' ? v.prototype : 0;
  2734. if (p
  2735. && typeof p.start === 'function' && p.start.length === 0 // Ou
  2736. && typeof p.isActive === 'function' && p.isActive.length === 0
  2737. && typeof p.stop === 'function' && p.stop.length === 0
  2738. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  2739. && !p.send && !p.abort
  2740. && !p.sample && !p.initialize && !p.fail && !p.getName
  2741. // && !p.dispose && !p.isDisposed
  2742.  
  2743. ) {
  2744. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2745.  
  2746.  
  2747. }
  2748.  
  2749. }
  2750.  
  2751. if (arr.length === 0) {
  2752.  
  2753. console.warn(`Key does not exist. [${w}]`);
  2754. } else {
  2755.  
  2756. console.log(`[${w}]`, arr);
  2757. return arr[0];
  2758. }
  2759.  
  2760. }
  2761.  
  2762. const getZqQu = (_yt_player) => {
  2763.  
  2764. const w = 'ZqQu';
  2765.  
  2766. let arr = [];
  2767.  
  2768.  
  2769. for (const [k, v] of Object.entries(_yt_player)) {
  2770.  
  2771. const p = typeof v === 'function' ? v.prototype : 0;
  2772. if (p
  2773. && typeof p.start === 'function' && p.start.length === 1 // Qu
  2774. && typeof p.isActive === 'function' && p.isActive.length === 0
  2775. && typeof p.stop === 'function' && p.stop.length === 0
  2776. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  2777. && !p.send && !p.abort
  2778. && !p.sample && !p.initialize && !p.fail && !p.getName
  2779. // && !p.dispose && !p.isDisposed
  2780.  
  2781. ) {
  2782. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2783.  
  2784.  
  2785. }
  2786.  
  2787. }
  2788.  
  2789. if (arr.length === 0) {
  2790.  
  2791. console.warn(`Key does not exist. [${w}]`);
  2792. } else {
  2793.  
  2794. console.log(`[${w}]`, arr);
  2795. return arr[0];
  2796. }
  2797.  
  2798. }
  2799.  
  2800.  
  2801. const getVG = (_yt_player) => {
  2802. const w = 'VG';
  2803.  
  2804. let arr = [];
  2805.  
  2806. for (const [k, v] of Object.entries(_yt_player)) {
  2807.  
  2808. const p = typeof v === 'function' ? v.prototype : 0;
  2809. if (p
  2810. && typeof p.show === 'function' && p.show.length === 1
  2811. && typeof p.hide === 'function' && p.hide.length === 0
  2812. && typeof p.stop === 'function' && p.stop.length === 0) {
  2813.  
  2814. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2815.  
  2816. }
  2817.  
  2818. }
  2819.  
  2820.  
  2821. if (arr.length === 0) {
  2822.  
  2823. console.warn(`Key does not exist. [${w}]`);
  2824. } else {
  2825.  
  2826. console.log(`[${w}]`, arr);
  2827. return arr[0];
  2828. }
  2829.  
  2830.  
  2831.  
  2832. }
  2833.  
  2834.  
  2835. const getzo = (_yt_player) => {
  2836. const w = 'zo';
  2837.  
  2838. let arr = [];
  2839.  
  2840. for (const [k, v] of Object.entries(_yt_player)) {
  2841.  
  2842. if (
  2843. typeof v === 'function' && v.length === 3 && k.length < 3
  2844. && (v + "").includes("a.style[b]=c")
  2845. ) {
  2846.  
  2847. arr.push(k);
  2848.  
  2849. }
  2850.  
  2851. }
  2852.  
  2853.  
  2854. if (arr.length === 0) {
  2855.  
  2856. console.warn(`Key does not exist. [${w}]`);
  2857. } else {
  2858.  
  2859. console.log(`[${w}]`, arr);
  2860. return arr[0];
  2861. }
  2862.  
  2863. }
  2864.  
  2865. const addProtoToArr = (parent, key, arr) => {
  2866.  
  2867.  
  2868. let isChildProto = false;
  2869. for (const sr of arr) {
  2870. if (parent[key].prototype instanceof parent[sr]) {
  2871. isChildProto = true;
  2872. break;
  2873. }
  2874. }
  2875.  
  2876. if (isChildProto) return;
  2877.  
  2878. arr = arr.filter(sr => {
  2879. if (parent[sr].prototype instanceof parent[key]) {
  2880. return false;
  2881. }
  2882. return true;
  2883. });
  2884.  
  2885. arr.push(key);
  2886.  
  2887. return arr;
  2888.  
  2889.  
  2890. }
  2891.  
  2892. const getuG = (_yt_player) => {
  2893.  
  2894. const w = 'uG';
  2895.  
  2896. let arr = [];
  2897.  
  2898. for (const [k, v] of Object.entries(_yt_player)) {
  2899.  
  2900.  
  2901. const p = typeof v === 'function' ? v.prototype : 0;
  2902.  
  2903. if (p
  2904. && typeof p.createElement === 'function' && p.createElement.length === 2
  2905. && typeof p.detach === 'function' && p.detach.length === 0
  2906. && typeof p.update === 'function' && p.update.length === 1
  2907. && typeof p.updateValue === 'function' && p.updateValue.length === 2
  2908. ) {
  2909.  
  2910. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2911.  
  2912. }
  2913.  
  2914. }
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920. if (arr.length === 0) {
  2921.  
  2922. console.warn(`Key does not exist. [${w}]`);
  2923. } else {
  2924.  
  2925. console.log(`[${w}]`, arr);
  2926. return arr[0];
  2927. }
  2928.  
  2929. }
  2930.  
  2931.  
  2932. const isPrepareCachedV = (FIX_avoid_incorrect_video_meta ? true : false) && (window === top);
  2933.  
  2934. let pageSetupVideoId = null; // set at finish; '' for indeterminate state
  2935. let pageSetupState = 0;
  2936.  
  2937. isPrepareCachedV && (() => {
  2938.  
  2939. pageSetupVideoId = '';
  2940. const clearCachedV = () => {
  2941. pageSetupVideoId = '';
  2942. pageSetupState = 0;
  2943. }
  2944. document.addEventListener('yt-navigate-start', clearCachedV, false); // user action
  2945. document.addEventListener('yt-navigate-cache', clearCachedV, false); // pop state
  2946. document.addEventListener('yt-page-data-fetched', clearCachedV, false); // still consider invalid until url is ready in yt-navigate-finish
  2947. document.addEventListener('yt-navigate-finish', () => {
  2948. pageSetupState = 1;
  2949. try {
  2950. const url = new URL(location.href);
  2951. if (!url || url.pathname !== '/watch') {
  2952. pageSetupVideoId = '';
  2953. } else {
  2954. pageSetupVideoId = url.searchParams.get('v') || '';
  2955. }
  2956. } catch (e) {
  2957. pageSetupVideoId = '';
  2958. }
  2959. }, false);
  2960.  
  2961. })();
  2962.  
  2963. let videoPlayingY = null;
  2964.  
  2965. isPrepareCachedV && (() => {
  2966.  
  2967. let getNext = true;
  2968. let videoPlayingX = {
  2969. get videoId() {
  2970. if (getNext) {
  2971. getNext = false;
  2972.  
  2973. let elements = document.querySelectorAll('ytd-watch-flexy[video-id]');
  2974. const arr = [];
  2975. for (const element of elements) {
  2976. if (!element.closest('[hidden]')) arr.push(element);
  2977. }
  2978. if (arr.length !== 1) this.__videoId__ = '';
  2979. else {
  2980. this.__videoId__ = arr[0].getAttribute('video-id');
  2981. }
  2982.  
  2983. }
  2984. return this.__videoId__ || '';
  2985. }
  2986. }
  2987.  
  2988. videoPlayingY = videoPlayingX;
  2989. const handler = (evt) => {
  2990. const target = (evt || 0).target;
  2991. if (target instanceof HTMLVideoElement) {
  2992. getNext = true;
  2993. }
  2994. }
  2995. document.addEventListener('loadedmetadata', handler, true);
  2996. document.addEventListener('durationchange', handler, true);
  2997.  
  2998. })();
  2999.  
  3000.  
  3001.  
  3002. const cleanContext = async (win) => {
  3003. const waitFn = requestAnimationFrame; // shall have been binded to window
  3004. try {
  3005. let mx = 16; // MAX TRIAL
  3006. const frameId = 'vanillajs-iframe-v1';
  3007. /** @type {HTMLIFrameElement | null} */
  3008. let frame = document.getElementById(frameId);
  3009. let removeIframeFn = null;
  3010. if (!frame) {
  3011. frame = document.createElement('iframe');
  3012. frame.id = frameId;
  3013. const blobURL = typeof webkitCancelAnimationFrame === 'function' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  3014. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  3015. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  3016. n.appendChild(frame);
  3017. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  3018. const root = document.documentElement;
  3019. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  3020. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  3021.  
  3022. removeIframeFn = (setTimeout) => {
  3023. const removeIframeOnDocumentReady = (e) => {
  3024. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  3025. e = n;
  3026. n = win = removeIframeFn = 0;
  3027. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  3028. }
  3029. if (!setTimeout || document.readyState !== 'loading') {
  3030. removeIframeOnDocumentReady();
  3031. } else {
  3032. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  3033. }
  3034. }
  3035. }
  3036. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  3037. const fc = frame.contentWindow;
  3038. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  3039. try {
  3040. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle } = fc;
  3041. const res = { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle };
  3042. for (let k in res) res[k] = res[k].bind(win); // necessary
  3043. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  3044. res.animate = fc.HTMLElement.prototype.animate;
  3045. res.perfNow = fc.performance.now;
  3046. return res;
  3047. } catch (e) {
  3048. if (removeIframeFn) removeIframeFn();
  3049. return null;
  3050. }
  3051. } catch (e) {
  3052. console.warn(e);
  3053. return null;
  3054. }
  3055. };
  3056.  
  3057. const promiseForYtActionCalled = new Promise(resolve => {
  3058. if (typeof AbortSignal !== 'undefined') {
  3059. let hn = () => {
  3060. if (!hn) return;
  3061. hn = null;
  3062. resolve(document.querySelector('ytd-app'));
  3063. };
  3064. document.addEventListener('yt-action', hn, { capture: true, passive: true, once: true });
  3065. } else {
  3066. let hn = () => {
  3067. if (!hn) return;
  3068. document.removeEventListener('yt-action', hn, true);
  3069. hn = null;
  3070. resolve(document.querySelector('ytd-app'));
  3071. };
  3072. document.addEventListener('yt-action', hn, true);
  3073. }
  3074. });
  3075.  
  3076.  
  3077.  
  3078. cleanContext(window).then(__CONTEXT__ => {
  3079. if (!__CONTEXT__) return null;
  3080.  
  3081. const { requestAnimationFrame, setTimeout, clearTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, requestIdleCallback, getComputedStyle, perfNow } = __CONTEXT__;
  3082.  
  3083.  
  3084. performance.now17 = perfNow.bind(performance);
  3085.  
  3086.  
  3087.  
  3088. __requestAnimationFrame__ = requestAnimationFrame;
  3089.  
  3090. let rafPromise = null;
  3091.  
  3092. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  3093. requestAnimationFrame(hRes => {
  3094. rafPromise = null;
  3095. resolve(hRes);
  3096. });
  3097. }));
  3098.  
  3099.  
  3100. const wmComputedStyle = new WeakMap();
  3101. // const getComputedStyleCached = (elem) => {
  3102. // let cs = wmComputedStyle.get(elem);
  3103. // if (!cs) {
  3104. // cs = getComputedStyle(elem);
  3105. // wmComputedStyle.set(elem, cs);
  3106. // }
  3107. // return cs;
  3108. // }
  3109.  
  3110. if (!window.__native__getComputedStyle__ && !window.__jst__getComputedStyle__ && typeof window.getComputedStyle === 'function' && window.getComputedStyle.length === 1) {
  3111. window.__native__getComputedStyle__ = getComputedStyle;
  3112. if (ENABLE_COMPUTEDSTYLE_CACHE) {
  3113. window.__original__getComputedStyle__ = window.getComputedStyle;
  3114. window.getComputedStyle = function (elem) {
  3115. if (!(elem instanceof Element) || (arguments.length === 2 && arguments[1]) || (arguments.length > 2)) {
  3116. return window.__native__getComputedStyle__(...arguments);
  3117. }
  3118. let cs = wmComputedStyle.get(elem);
  3119. if (!cs) {
  3120. cs = window.__native__getComputedStyle__(elem);
  3121. wmComputedStyle.set(elem, cs);
  3122. }
  3123. return cs;
  3124. };
  3125. } else {
  3126. window.__original__getComputedStyle__ = null;
  3127. }
  3128. window.__jst__getComputedStyle__ = window.getComputedStyle;
  3129. }
  3130.  
  3131. NO_SCHEDULING_DUE_TO_COMPUTEDSTYLE && promiseForYtActionCalled.then(() => {
  3132. if (typeof window.__jst__getComputedStyle__ === 'function' && window.__jst__getComputedStyle__.length === 1 && window.__jst__getComputedStyle__ !== window.getComputedStyle) {
  3133. window.getComputedStyle = window.__jst__getComputedStyle__;
  3134. }
  3135. });
  3136.  
  3137. const isUrlInEmbed = location.href.includes('.youtube.com/embed/');
  3138. const isAbortSignalSupported = typeof AbortSignal !== "undefined";
  3139.  
  3140. const promiseForTamerTimeout = new Promise(resolve => {
  3141. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  3142. setTimeout(resolve, 480);
  3143. }, { capture: true, passive: true, once: true });
  3144. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  3145. setTimeout(resolve, 1200);
  3146. });
  3147. setTimeout(resolve, 3000);
  3148. });
  3149.  
  3150. const promiseForPageInitied = new Promise(resolve => {
  3151. !isUrlInEmbed && isAbortSignalSupported && document.addEventListener('yt-action', function () {
  3152. setTimeout(resolve, 450);
  3153. }, { capture: true, passive: true, once: true });
  3154. !isUrlInEmbed && isAbortSignalSupported && typeof customElements === "object" && whenCEDefined('ytd-app').then(() => {
  3155. setTimeout(resolve, 900);
  3156. });
  3157. setTimeout(resolve, 1800);
  3158. });
  3159.  
  3160. NO_PRELOAD_GENERATE_204_BYPASS || promiseForPageInitied.then(() => {
  3161. NO_PRELOAD_GENERATE_204_BYPASS = true;
  3162. headLinkCollection = null;
  3163. });
  3164.  
  3165.  
  3166. // class RAFHub {
  3167. // constructor() {
  3168. // /** @type {number} */
  3169. // this.startAt = 8170;
  3170. // /** @type {number} */
  3171. // this.counter = 0;
  3172. // /** @type {number} */
  3173. // this.rid = 0;
  3174. // /** @type {Map<number, FrameRequestCallback>} */
  3175. // this.funcs = new Map();
  3176. // const funcs = this.funcs;
  3177. // /** @type {FrameRequestCallback} */
  3178. // this.bCallback = this.mCallback.bind(this);
  3179. // this.pClear = () => funcs.clear();
  3180. // }
  3181. // /** @param {DOMHighResTimeStamp} highResTime */
  3182. // mCallback(highResTime) {
  3183. // this.rid = 0;
  3184. // Promise.resolve().then(this.pClear);
  3185. // this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  3186. // }
  3187. // /** @param {FrameRequestCallback} f */
  3188. // request(f) {
  3189. // if (this.counter > 1e9) this.counter = 9;
  3190. // let cid = this.startAt + (++this.counter);
  3191. // this.funcs.set(cid, f);
  3192. // if (this.rid === 0) {
  3193. // // console.log(2455)
  3194. // this.rid = requestAnimationFrame(this.bCallback);
  3195. // }
  3196. // return cid;
  3197. // }
  3198. // /** @param {number} cid */
  3199. // cancel(cid) {
  3200. // cid = +cid;
  3201. // if (cid > 0) {
  3202. // if (cid <= this.startAt) {
  3203. // return cancelAnimationFrame(cid);
  3204. // }
  3205. // if (this.rid > 0) {
  3206. // this.funcs.delete(cid);
  3207. // if (this.funcs.size === 0) {
  3208. // cancelAnimationFrame(this.rid);
  3209. // this.rid = 0;
  3210. // }
  3211. // }
  3212. // }
  3213. // }
  3214. // /** @param {number} cid */
  3215. // /** @param {FrameRequestCallback} f */
  3216. // replaceFunc(cid, f) {
  3217. // if (typeof this.funcs.get(cid) === 'function') {
  3218. // this.funcs.set(cid, f);
  3219. // return cid;
  3220. // } else {
  3221. // let r = this.request(f);
  3222. // this.cancel(cid);
  3223. // return r;
  3224. // }
  3225. // }
  3226. // }
  3227.  
  3228.  
  3229. // WEAK_REF_BINDING && (async () => {
  3230.  
  3231. // ['tp-yt-paper-menu-button'].forEach(async tag => {
  3232.  
  3233. // const dummy = await new Promise(resolve => {
  3234. // whenCEDefined(tag).then(() => {
  3235. // resolve(document.createElement(tag));
  3236. // });
  3237.  
  3238. // });
  3239.  
  3240. // if (!dummy || dummy.is !== tag) return;
  3241.  
  3242. // const cProto = insp(dummy).constructor.prototype;
  3243.  
  3244. // if (typeof cProto.close === 'function' && !cProto.close58) {
  3245. // cProto.close58 = cProto.close;
  3246. // console.log(cProto.close58)
  3247. // cProto.close = function () {
  3248. // // const dropdown = (this.$ || 0).dropdown || 0;
  3249. // // if (!dropdown) return;
  3250. // try{
  3251. // return this.close58.apply(this, arguments);
  3252. // }catch(e){
  3253.  
  3254. // }
  3255.  
  3256. // }
  3257. // }
  3258.  
  3259.  
  3260. // });
  3261.  
  3262. // })();
  3263.  
  3264. NATIVE_CANVAS_ANIMATION && (() => {
  3265.  
  3266. observablePromise(() => {
  3267. HTMLCanvasElement.prototype.animate = animate;
  3268. }, promiseForTamerTimeout).obtain();
  3269.  
  3270. })();
  3271.  
  3272. FIX_ytAction_ && (async () => {
  3273.  
  3274. const ytdApp = await new Promise(resolve => {
  3275.  
  3276. whenCEDefined('ytd-app').then(() => {
  3277. const ytdApp = document.querySelector('ytd-app');
  3278. if (ytdApp) {
  3279. resolve(ytdApp);
  3280. return;
  3281. }
  3282. let mo = new MutationObserver(() => {
  3283. const ytdApp = document.querySelector('ytd-app');
  3284. if (!ytdApp) return;
  3285. if (mo) {
  3286. mo.disconnect();
  3287. mo.takeRecords();
  3288. mo = null;
  3289. }
  3290. resolve(ytdApp);
  3291. });
  3292. mo.observe(document, { subtree: true, childList: true });
  3293. });
  3294.  
  3295. });
  3296.  
  3297. if (!ytdApp) return;
  3298. const cProto = insp(ytdApp).constructor.prototype;
  3299.  
  3300. if (!cProto) return;
  3301. let mbd = 0;
  3302.  
  3303. const fixer = (_ytdApp) => {
  3304. const ytdApp = insp(_ytdApp);
  3305. if (ytdApp && typeof ytdApp.onYtActionBoundListener_ === 'function' && !ytdApp.onYtActionBoundListener57_) {
  3306. ytdApp.onYtActionBoundListener57_ = ytdApp.onYtActionBoundListener_;
  3307. ytdApp.onYtActionBoundListener_ = ytdApp.onYtAction_.bind(ytdApp);
  3308. mbd++;
  3309. }
  3310. }
  3311.  
  3312. observablePromise(() => {
  3313.  
  3314. if (typeof cProto.created === 'function' && !cProto.created56) {
  3315. cProto.created56 = cProto.created;
  3316. cProto.created = function (...args) {
  3317. const r = this.created56(...args);
  3318. fixer(this);
  3319. return r;
  3320. };
  3321. mbd++;
  3322. }
  3323.  
  3324. if (typeof cProto.onYtAction_ === 'function' && !cProto.onYtAction57_) {
  3325. cProto.onYtAction57_ = cProto.onYtAction_;
  3326. cProto.onYtAction_ = function (...args) {
  3327. Promise.resolve().then(() => this.onYtAction57_(...args));
  3328. };
  3329. mbd++;
  3330. }
  3331.  
  3332. if (ytdApp) fixer(ytdApp);
  3333.  
  3334. /*
  3335. const actionRouter_ = ytdApp ? ytdApp.actionRouter_ : null;
  3336. if (actionRouter_ && typeof actionRouter_.handleAction === 'function' && !actionRouter_.handleAction57) {
  3337. actionRouter_.handleAction57 = actionRouter_.handleAction;
  3338. actionRouter_.handleAction = function (...args) {
  3339. Promise.resolve().then(() => this.handleAction57(...args));
  3340. }
  3341. mbd++;
  3342. }
  3343. */
  3344.  
  3345. // if(mbd === 3) return 1;
  3346. if (mbd >= 3) return 1;
  3347.  
  3348. }, new Promise(r => setTimeout(r, 1000))).obtain();
  3349.  
  3350. })();
  3351.  
  3352. const observablePromise = (proc, timeoutPromise) => {
  3353. let promise = null;
  3354. return {
  3355. obtain() {
  3356. if (!promise) {
  3357. promise = new Promise(resolve => {
  3358. let mo = null;
  3359. const f = () => {
  3360. let t = proc();
  3361. if (t) {
  3362. mo.disconnect();
  3363. mo.takeRecords();
  3364. mo = null;
  3365. resolve(t);
  3366. }
  3367. }
  3368. mo = new MutationObserver(f);
  3369. mo.observe(document, { subtree: true, childList: true })
  3370. f();
  3371. timeoutPromise && timeoutPromise.then(() => {
  3372. resolve(null)
  3373. });
  3374. });
  3375. }
  3376. return promise
  3377. }
  3378. }
  3379. }
  3380.  
  3381. // let _yt_player_promise = null;
  3382. /*
  3383. const getYtPlayerPromise = () => {
  3384. if (!_yt_player_promise) {
  3385. _yt_player_promise = new Promise(resolve => {
  3386. let cid = setInterval(() => {
  3387. let t = (((window || 0)._yt_player || 0) || 0);
  3388. if (t) {
  3389. clearInterval(cid);
  3390. resolve(t);
  3391. }
  3392. }, 1);
  3393. promiseForTamerTimeout.then(() => {
  3394. resolve(null)
  3395. });
  3396. });
  3397. }
  3398. return _yt_player_promise;
  3399. }
  3400. */
  3401. const _yt_player_observable = observablePromise(() => {
  3402. return (((window || 0)._yt_player || 0) || 0);
  3403. }, promiseForTamerTimeout);
  3404.  
  3405. const polymerObservable = observablePromise(() => {
  3406. const Polymer = window.Polymer;
  3407. if (typeof Polymer !== 'function') return;
  3408. if (!(Polymer.Base || 0).connectedCallback || !(Polymer.Base || 0).disconnectedCallback) return;
  3409. return Polymer;
  3410. }, promiseForTamerTimeout);
  3411.  
  3412. const schedulerInstanceObservable = observablePromise(() => {
  3413. return (((window || 0).ytglobal || 0).schedulerInstanceInstance_ || 0);
  3414. }, promiseForTamerTimeout);
  3415.  
  3416. const timelineObservable = observablePromise(() => {
  3417. let t = (((document || 0).timeline || 0) || 0);
  3418. if (t && typeof t._play === 'function') {
  3419. return t;
  3420. }
  3421. }, promiseForTamerTimeout);
  3422. const animationObservable = observablePromise(() => {
  3423. let t = (((window || 0).Animation || 0) || 0);
  3424. if (t && typeof t === 'function' && t.length === 2 && typeof t.prototype._updatePromises === 'function') {
  3425. return t;
  3426. }
  3427. }, promiseForTamerTimeout);
  3428.  
  3429.  
  3430.  
  3431.  
  3432. const generalEvtHandler = async (_evKey, _fvKey, _debug) => {
  3433.  
  3434. const evKey = `${_evKey}`;
  3435. const fvKey = `${_fvKey}`;
  3436. const debug = !!_debug;
  3437.  
  3438.  
  3439. // const rafHub = new RAFHub();
  3440.  
  3441.  
  3442. const _yt_player = await _yt_player_observable.obtain();
  3443.  
  3444.  
  3445. if (!_yt_player || typeof _yt_player !== 'object') return;
  3446.  
  3447.  
  3448. const getArr = (_yt_player) => {
  3449.  
  3450. let arr = [];
  3451.  
  3452. for (const [k, v] of Object.entries(_yt_player)) {
  3453.  
  3454. const p = typeof v === 'function' ? v.prototype : 0;
  3455. if (p
  3456. && typeof p[evKey] === 'function' && p[evKey].length >= 0 && !p[fvKey]
  3457.  
  3458. ) {
  3459. arr = addProtoToArr(_yt_player, k, arr) || arr;
  3460.  
  3461. }
  3462.  
  3463. }
  3464.  
  3465. if (arr.length === 0) {
  3466.  
  3467. console.warn(`Key prop [${evKey}] does not exist.`);
  3468. } else {
  3469.  
  3470. return arr;
  3471. }
  3472.  
  3473. };
  3474.  
  3475. const arr = getArr(_yt_player);
  3476.  
  3477.  
  3478. if (!arr) return;
  3479.  
  3480. debug && console.log(`FIX_${evKey}`, arr);
  3481.  
  3482. const f = function (...args) {
  3483. Promise.resolve().then(() => this[fvKey](...args));
  3484. };
  3485.  
  3486.  
  3487. for (const k of arr) {
  3488.  
  3489. const g = _yt_player;
  3490. const gk = g[k];
  3491. const gkp = gk.prototype;
  3492.  
  3493. debug && console.log(237, k, gkp)
  3494.  
  3495. if (typeof gkp[evKey] == 'function' && !gkp[fvKey]) {
  3496. gkp[fvKey] = gkp[evKey];
  3497. gkp[evKey] = f;
  3498. }
  3499. }
  3500.  
  3501.  
  3502.  
  3503.  
  3504. }
  3505.  
  3506. FIX_onVideoDataChange && generalEvtHandler('onVideoDataChange', 'onVideoDataChange57');
  3507. // FIX_onClick && generalEvtHandler('onClick', 'onClick57');
  3508. FIX_onStateChange && generalEvtHandler('onStateChange', 'onStateChange57');
  3509. FIX_onLoopRangeChange && generalEvtHandler('onLoopRangeChange', 'onLoopRangeChange57');
  3510. if (FIX_VideoEVENTS_v2) {
  3511. const FIX_VideoEVENTS_DEBUG = 0;
  3512. generalEvtHandler('onVideoProgress', 'onVideoProgress57', FIX_VideoEVENTS_DEBUG); // --
  3513. // generalEvtHandler('onAutoplayBlocked', 'onAutoplayBlocked57', FIX_VideoEVENTS_DEBUG);
  3514. // generalEvtHandler('onLoadProgress', 'onLoadProgress57', FIX_VideoEVENTS_DEBUG); // << CAUSE ISSUE >>
  3515. generalEvtHandler('onFullscreenChange', 'onFullscreenChange57', FIX_VideoEVENTS_DEBUG); // --
  3516. // generalEvtHandler('onLoadedMetadata', 'onLoadedMetadata57', FIX_VideoEVENTS_DEBUG);
  3517. // generalEvtHandler('onDrmOutputRestricted', 'onDrmOutputRestricted57', FIX_VideoEVENTS_DEBUG);
  3518. // generalEvtHandler('onAirPlayActiveChange', 'onAirPlayActiveChange57', FIX_VideoEVENTS_DEBUG);
  3519. // generalEvtHandler('onAirPlayAvailabilityChange', 'onAirPlayAvailabilityChange57', FIX_VideoEVENTS_DEBUG);
  3520. // generalEvtHandler('onApiChange', 'onApiChange57', FIX_VideoEVENTS_DEBUG);
  3521.  
  3522. }
  3523. // onMutedAutoplayChange
  3524. // onVolumeChange
  3525. // onPlaybackRateChange
  3526.  
  3527. // onAirPlayActiveChange
  3528. // onAirPlayAvailabilityChange
  3529. // onApiChange
  3530. // onAutoplayBlocked
  3531. // onDrmOutputRestricted
  3532. // onFullscreenChange
  3533. // onLoadProgress
  3534. // onLoadedMetadata
  3535. // onVideoDataChange
  3536. // onVideoProgress
  3537.  
  3538. // (FIX_maybeUpdateFlexibleMenu || WEAK_REF_BINDING) && (async () => {
  3539.  
  3540.  
  3541. // const dummy = await new Promise(resolve => {
  3542.  
  3543. // whenCEDefined('ytd-menu-renderer').then(() => {
  3544.  
  3545. // resolve(document.createElement('ytd-menu-renderer'));
  3546. // });
  3547.  
  3548.  
  3549.  
  3550. // });
  3551.  
  3552.  
  3553. // if (!dummy || dummy.is !== 'ytd-menu-renderer') return;
  3554.  
  3555. // const cProto = insp(dummy).constructor.prototype;
  3556.  
  3557. // if (FIX_maybeUpdateFlexibleMenu && typeof cProto.created === 'function' && !cProto.created58) {
  3558. // cProto.created58 = cProto.created;
  3559. // cProto.created = function (...args) {
  3560. // const r = this.created58(...args);
  3561. // if (typeof this.maybeUpdateFlexibleMenu === 'function' && !this.maybeUpdateFlexibleMenu57) {
  3562. // this.maybeUpdateFlexibleMenu57 = this.maybeUpdateFlexibleMenu;
  3563. // this.maybeUpdateFlexibleMenu = function (...args) {
  3564. // Promise.resolve().then(() => this.maybeUpdateFlexibleMenu57(...args));
  3565. // }
  3566. // }
  3567. // return r;
  3568. // }
  3569.  
  3570. // }
  3571.  
  3572.  
  3573.  
  3574. // // if (WEAK_REF_BINDING && typeof cProto.setupFlexibleMenu === 'function' && !cProto.setupFlexibleMenu58) {
  3575. // // cProto.setupFlexibleMenu58 = cProto.setupFlexibleMenu;
  3576. // // cProto.setupFlexibleMenu = function () {
  3577.  
  3578. // // const hostElement = this.hostElement;
  3579. // // if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  3580. // // return void 0;
  3581. // // } else {
  3582. // // return this.setupFlexibleMenu58.apply(this, arguments);
  3583. // // }
  3584.  
  3585. // // }
  3586.  
  3587.  
  3588.  
  3589. // // }
  3590.  
  3591.  
  3592. // // if (WEAK_REF_BINDING && typeof cProto.stampDomArray_ === 'function' && !cProto.stampDomArray58_) {
  3593. // // cProto.stampDomArray58_ = cProto.stampDomArray_;
  3594. // // cProto.stampDomArray_ = function (a, b, c, d, e, h) {
  3595.  
  3596. // // const hostElement = this.hostElement;
  3597. // // if (!(hostElement instanceof Node) || hostElement.nodeName === 'NOSCRIPT') {
  3598. // // return void 0;
  3599. // // } else {
  3600. // // return this.stampDomArray58_.apply(this, arguments);
  3601. // // }
  3602.  
  3603. // // }
  3604.  
  3605.  
  3606.  
  3607. // // }
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613. // //console.log(144,cProto.maybeUpdateFlexibleMenu)
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620. // })();
  3621.  
  3622. (ENABLE_discreteTasking || UNLOAD_DETACHED_POLYMER) && (async () => {
  3623.  
  3624. const Polymer = await polymerObservable.obtain();
  3625. if (!Polymer) return;
  3626.  
  3627.  
  3628. if (UNLOAD_DETACHED_POLYMER && typeof Polymer.Base.detached === 'function' && !Polymer.Base.detached92 && Polymer.Base.detached.length === 0) {
  3629. Polymer.Base.detached92 = Polymer.Base.detached;
  3630.  
  3631. const detachedPlus = async function (elem) {
  3632. await delay300.then();
  3633. if (elem.isAttached !== false) return;
  3634. await delay300.then();
  3635. if (elem.isAttached !== false) return;
  3636.  
  3637. if (elem.__dataClientsReady === true) elem.__dataClientsReady = false;
  3638. // if (elem.__dataEnabled === true) elem.__dataEnabled = false;
  3639. if (elem.__dataReady === true) elem.__dataReady = false;
  3640.  
  3641. elem.__dataLinkedPaths = elem.__dataToNotify = elem.__dataPendingClients = null;
  3642. elem.__dataHasPaths = false;
  3643. // elem.__dataCompoundStorage = null;
  3644. elem.__dataHost = null;
  3645. elem.__dataTemp = null;
  3646. elem.__dataClientsInitialized = false;
  3647.  
  3648.  
  3649. // elem.data = {};
  3650. elem.data = null;
  3651. elem.__dataPending = null;
  3652. elem.__dataOld = null;
  3653. elem.__dataInstanceProps = null;
  3654.  
  3655. elem.__dataCounter = 0;
  3656. elem.__serializing = false;
  3657.  
  3658. // if (elem.$) elem.$ = {};
  3659. // if (elem.root) elem.root = null;
  3660.  
  3661. // let hostElement = elem.hostElement, tlm;
  3662. // if (hostElement instanceof Node) {
  3663. // // if (hostElement.isConnected === false) {
  3664. // // while (tlm = hostElement.firstChild) tlm.remove();
  3665. // // }
  3666. // elem.hostElement = hostElement = null;
  3667. // }
  3668.  
  3669.  
  3670. // if (hostElement === null) {
  3671.  
  3672. // if (elem.animatedIconElement instanceof Node) elem.animatedIconElement = null;
  3673. // if (elem._target instanceof Node) elem._target = null;
  3674. // if (elem.iconset instanceof Node) elem.iconset = null;
  3675. // if (elem._svgIcon instanceof Node) elem._svgIcon = null;
  3676.  
  3677. // }
  3678.  
  3679.  
  3680. }
  3681. Polymer.Base.detached = function () {
  3682. Promise.resolve(this).then(detachedPlus);
  3683. return Polymer.Base.detached92();
  3684. };
  3685. }
  3686.  
  3687.  
  3688. if (ENABLE_discreteTasking) {
  3689.  
  3690. Polymer.Base.__connInit__ = function () {
  3691. setupDiscreteTasks(this);
  3692. // if (WEAK_REF_BINDING && (this.is || this instanceof Node)) {
  3693. // setupWeakRef(this)
  3694. // }
  3695. }
  3696.  
  3697.  
  3698. /** @type {Function} */
  3699. const connectedCallbackK = function (...args) {
  3700. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3701. const r = this[qm53](...args);
  3702. !this.mh35 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3703. this.mh35 = 1;
  3704. return r;
  3705. };
  3706.  
  3707. connectedCallbackK.m353 = 1;
  3708.  
  3709.  
  3710. const qt53 = Polymer.Base.connectedCallback;
  3711. Polymer.Base[qm53] = dmf.get(qt53) || qt53;
  3712.  
  3713. Polymer.Base.connectedCallback = connectedCallbackK;
  3714.  
  3715.  
  3716. /** @type {Function} */
  3717. const createdK = function (...args) {
  3718. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3719. const r = this[qn53](...args);
  3720. !this.mh36 && typeof this.__connInit__ === 'function' && this.__connInit__();
  3721. this.mh36 = 1;
  3722. return r;
  3723. };
  3724.  
  3725.  
  3726. createdK.m353 = 1;
  3727. Polymer.Base[qn53] = Polymer.Base.created;
  3728. Polymer.Base.created = createdK;
  3729.  
  3730. }
  3731.  
  3732. })();
  3733.  
  3734.  
  3735. /*
  3736.  
  3737. e.nativeAppendChild = d.prototype.appendChild,
  3738. d.prototype.appendChild = function(h) {
  3739. return function(l) {
  3740. if (l instanceof DocumentFragment) {
  3741. var m = Array.from(l.children);
  3742. l = h.nativeAppendChild.call(this, l);
  3743. if (this.isConnected) {
  3744. m = g(m);
  3745. for (var p = m.next(); !p.done; p = m.next())
  3746. YD(p.value)
  3747. }
  3748. return l
  3749. }
  3750. m = l instanceof Element && l.isConnected;
  3751. p = h.nativeAppendChild.call(this, l);
  3752. m && ZD(l);
  3753. this.isConnected && YD(l);
  3754. return p
  3755. }
  3756. }(e),
  3757.  
  3758. */
  3759.  
  3760. CHANGE_appendChild && !Node.prototype.appendChild73 && Node.prototype.appendChild && (() => {
  3761.  
  3762. let __src__ = '';
  3763. const handlerCanplay = (evt) => {
  3764. const a = evt.target;
  3765. console.log('[yt-js-engine-tamer]', `video element added to dom | canplay`, mWeakRef(a), a.readyState, a.networkState, a.currentTime);
  3766. if (a.currentTime < 1e-8 && a.currentTime > -1e-9 && a.autoplay === false) a.currentTime += 1e-8;
  3767. };
  3768.  
  3769. const handlerTimeupdate = (evt) => {
  3770. const a = evt.target;
  3771. console.log('[yt-js-engine-tamer]', `video element added to dom | ontimeupdate`, mWeakRef(a), a.readyState, a.networkState, a.currentTime);
  3772. if (a.duration < 2.01 && a.duration > 1.99 && a.currentSrc === __src__) {
  3773. try {
  3774. URL.revokeObjectURL(__src__);
  3775. __src__ = '';
  3776. } finally {
  3777. console.log('[yt-js-engine-tamer]', `video element added to dom | revokeObjectURL`, mWeakRef(a), a.readyState, a.networkState, a.currentTime);
  3778. }
  3779. }
  3780. };
  3781.  
  3782. const f = Node.prototype.appendChild73 = Node.prototype.appendChild;
  3783. if (f) Node.prototype.appendChild = function (a) {
  3784. if (this instanceof Element) { // exclude DocumentFragment
  3785. try {
  3786. if (a instanceof HTMLVideoElement && FIX_VIDEO_BLOCKING) {
  3787. const src = `${a.src}`;
  3788. 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';
  3789. if (b) {
  3790. __src__ = src;
  3791. a.addEventListener('canplay', handlerCanplay, { once: true, passive: true, capture: false });
  3792. a.addEventListener('timeupdate', handlerTimeupdate, { once: true, passive: true, capture: false });
  3793. }
  3794. console.log('[yt-js-engine-tamer]', `video element added to dom | treatment = ${b}`, mWeakRef(a), a.readyState, a.networkState);
  3795. } else {
  3796. let checkFragmentA = true;
  3797. if (!NO_PRELOAD_GENERATE_204_BYPASS && document.head === this) {
  3798. if (headLinkCollection === null) headLinkCollection = document.head.getElementsByTagName('LINK');
  3799. for (const node of headLinkCollection) {
  3800. if (node.rel === 'preload' && node.as === 'fetch') {
  3801. node.rel = 'prefetch'; // see https://github.com/GoogleChromeLabs/quicklink
  3802. }
  3803. }
  3804. } else if (this.nodeName.startsWith('YT-')) { // yt-animated-rolling-number, yt-attributed-string
  3805. checkFragmentA = false;
  3806. }
  3807. if ((a instanceof DocumentFragment) && checkFragmentA && a.firstElementChild === null) {
  3808. // no element in fragmentA
  3809. let doNormal = false;
  3810. for (let child = a.firstChild; child instanceof Node; child = child.nextSibling) {
  3811. if (child.nodeType === 3) { doNormal = true; break; }
  3812. }
  3813. if (!doNormal) return a;
  3814. }
  3815. }
  3816. } catch (e) {
  3817. console.log(e);
  3818. }
  3819. }
  3820. return arguments.length === 1 && this.appendChild73 ? this.appendChild73(a) : (this.appendChild73 || Node.prototype.appendChild73 || f).apply(this, arguments);
  3821. }
  3822.  
  3823.  
  3824. })();
  3825.  
  3826. if (FIX_Shady) {
  3827.  
  3828. observablePromise(() => {
  3829. const { ShadyDOM, ShadyCSS } = window;
  3830. if (ShadyDOM) {
  3831. ShadyDOM.handlesDynamicScoping = false; // 9 of 10
  3832. ShadyDOM.noPatch = true; // 1 of 10
  3833. ShadyDOM.patchOnDemand = false; // 1 of 10
  3834. ShadyDOM.preferPerformance = true; // 1 of 10
  3835. ShadyDOM.querySelectorImplementation = undefined; // 1 of 10
  3836. }
  3837. if (ShadyCSS) {
  3838. ShadyCSS.nativeCss = true; // 1 of 10
  3839. ShadyCSS.nativeShadow = true; // 6 of 10
  3840. ShadyCSS.cssBuild = undefined; // 1 of 10
  3841. ShadyCSS.disableRuntime = true; // 1 of 10
  3842. }
  3843. if (ShadyDOM && ShadyCSS) return 1;
  3844. }, promiseForTamerTimeout).obtain(); // clear until 1 is return
  3845.  
  3846. }
  3847.  
  3848.  
  3849. // let schedulerInstancePropOfTimerType = '';
  3850. // let schedulerInstancePropOfTimerId = '';
  3851. (FIX_schedulerInstanceInstance & 2) && (async () => {
  3852.  
  3853. const schedulerInstanceInstance_ = await schedulerInstanceObservable.obtain();
  3854.  
  3855. if (!schedulerInstanceInstance_) return;
  3856.  
  3857. const checkOK = typeof schedulerInstanceInstance_.start === 'function' && !schedulerInstanceInstance_.start993 && !schedulerInstanceInstance_.stop && !schedulerInstanceInstance_.cancel && !schedulerInstanceInstance_.terminate && !schedulerInstanceInstance_.interupt;
  3858. if (checkOK) {
  3859.  
  3860. schedulerInstanceInstance_.start993 = schedulerInstanceInstance_.start;
  3861.  
  3862. let requestingFn = null;
  3863. let requestingArgs = null;
  3864.  
  3865. const f = function () {
  3866. requestingFn = this.fn;
  3867. requestingArgs = [...arguments];
  3868. return 12373;
  3869. };
  3870.  
  3871. const fakeFns = [
  3872. f.bind({ fn: requestAnimationFrame }),
  3873. f.bind({ fn: setInterval }),
  3874. f.bind({ fn: setTimeout }),
  3875. f.bind({ fn: requestIdleCallback })
  3876. ];
  3877.  
  3878. let mzt = 0;
  3879.  
  3880. let _fnSelectorProp = null;
  3881. const mkFns = new Array(4);
  3882.  
  3883. /*
  3884. case 1:
  3885. var a = this.K;
  3886. this.g = this.I ? window.requestIdleCallback(a, {
  3887. timeout: 3E3
  3888. }) : window.setTimeout(a, ma);
  3889. break;
  3890. case 2:
  3891. this.g = window.setTimeout(this.M, this.N);
  3892. break;
  3893. case 3:
  3894. this.g = window.requestAnimationFrame(this.L);
  3895. break;
  3896. case 4:
  3897. this.g = window.setTimeout(this.J, 0)
  3898. }
  3899.  
  3900. */
  3901. const startFnHandler = {
  3902. get(target, prop, receiver) {
  3903. if (prop === '$$12377$$') return true;
  3904. if (prop === '$$12378$$') return target;
  3905.  
  3906. // console.log('get',prop)
  3907. return target[prop]
  3908. },
  3909. set(target, prop, value, receiver) {
  3910. // console.log('set', prop, value)
  3911.  
  3912. if (value >= 1 && value <= 4) _fnSelectorProp = prop;
  3913. if (value === 12373 && _fnSelectorProp) {
  3914.  
  3915. const schedulerTypeSelection = target[_fnSelectorProp];
  3916. const timerIdProp = prop;
  3917.  
  3918. // if (schedulerTypeSelection && schedulerTypeSelection >= 1 && schedulerTypeSelection <= 4 && timerIdProp) {
  3919. // schedulerInstancePropOfTimerType = _fnSelectorProp || '';
  3920. // schedulerInstancePropOfTimerId = timerIdProp || '';
  3921. // }
  3922.  
  3923. if (schedulerTypeSelection === 3 && requestingFn === requestAnimationFrame) { // rAF(fn)
  3924. target[timerIdProp] = baseRAF.apply(window, requestingArgs);
  3925. } else if (schedulerTypeSelection === 2 && requestingFn === setTimeout) { // setTimeout(fn, delay)
  3926. // rare
  3927. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  3928. } else if (schedulerTypeSelection === 4 && requestingFn === setTimeout && !requestingArgs[1]) { // setTimeout(fn, 0)
  3929. // often
  3930. if ((FIX_schedulerInstanceInstance & 4) && typeof nextBrowserTick == 'function') {
  3931. const f = requestingArgs[0];
  3932. const tir = ++mzt;
  3933. nextBrowserTick(() => {
  3934. if (target[timerIdProp] === -tir) f();
  3935. });
  3936. target[_fnSelectorProp] = 940;
  3937. target[timerIdProp] = -tir;
  3938. } else {
  3939. const f = requestingArgs[0];
  3940. const tir = ++mzt;
  3941. Promise.resolve().then(() => {
  3942. if (target[timerIdProp] === -tir) f();
  3943. });
  3944. target[_fnSelectorProp] = 930;
  3945. target[timerIdProp] = -tir;
  3946. }
  3947. } else if (schedulerTypeSelection === 1 && (requestingFn === requestIdleCallback || requestingFn === setTimeout)) { // setTimeout(requestIdleCallback)
  3948. // often
  3949. if (requestingFn === requestIdleCallback) {
  3950. target[timerIdProp] = requestIdleCallback.apply(window, requestingArgs);
  3951. } else {
  3952. target[timerIdProp] = mkFns[2].apply(window, requestingArgs);
  3953. }
  3954. } else {
  3955. target[_fnSelectorProp] = 0;
  3956. target[timerIdProp] = 0;
  3957. }
  3958. } else {
  3959. target[prop] = value;
  3960. }
  3961. return true;
  3962. }
  3963. };
  3964.  
  3965. let startBusy = false;
  3966. schedulerInstanceInstance_.start = function () {
  3967. if (startBusy) return;
  3968. startBusy = true;
  3969. try {
  3970. mkFns[0] = window.requestAnimationFrame;
  3971. mkFns[1] = window.setInterval;
  3972. mkFns[2] = window.setTimeout;
  3973. mkFns[3] = window.requestIdleCallback;
  3974. const tThis = this['$$12378$$'] || this;
  3975. window.requestAnimationFrame = fakeFns[0]
  3976. window.setInterval = fakeFns[1]
  3977. window.setTimeout = fakeFns[2]
  3978. window.requestIdleCallback = fakeFns[3]
  3979. _fnSelectorProp = null;
  3980. tThis.start993.call(new Proxy(tThis, startFnHandler));
  3981. _fnSelectorProp = null;
  3982. window.requestAnimationFrame = mkFns[0];
  3983. window.setInterval = mkFns[1];
  3984. window.setTimeout = mkFns[2];
  3985. window.requestIdleCallback = mkFns[3];
  3986. } catch (e) {
  3987. console.warn(e);
  3988. }
  3989. startBusy = false;
  3990. }
  3991.  
  3992. schedulerInstanceInstance_.start.toString = schedulerInstanceInstance_.start993.toString.bind(schedulerInstanceInstance_.start993);
  3993.  
  3994. }
  3995. })();
  3996.  
  3997. FIX_yt_player && (async () => {
  3998. // rAf scheduling
  3999.  
  4000. // const rafHub = new RAFHub();
  4001.  
  4002. const _yt_player = await _yt_player_observable.obtain();
  4003.  
  4004. if (!_yt_player || typeof _yt_player !== 'object') return;
  4005.  
  4006. let keyZqOu = getZqOu(_yt_player);
  4007.  
  4008.  
  4009. if (!keyZqOu) return;
  4010.  
  4011.  
  4012. const g = _yt_player
  4013. let k = keyZqOu
  4014.  
  4015. const gk = g[k];
  4016. if (typeof gk !== 'function') return;
  4017. const gkp = gk.prototype;
  4018.  
  4019. let dummyObject = new gk;
  4020. let nilFunc = () => { };
  4021.  
  4022. let nilObj = {};
  4023.  
  4024. // console.log(1111111111)
  4025.  
  4026. let keyBoolD = '';
  4027. let keyWindow = '';
  4028. let keyFuncC = '';
  4029. let keyCidj = '';
  4030.  
  4031. for (const [t, y] of Object.entries(dummyObject)) {
  4032. if (y instanceof Window) keyWindow = t;
  4033. }
  4034.  
  4035. const dummyObjectProxyHandler = {
  4036. get(target, prop) {
  4037. let v = target[prop]
  4038. if (v instanceof Window && !keyWindow) {
  4039. keyWindow = t;
  4040. }
  4041. let y = typeof v === 'function' ? nilFunc : typeof v === 'object' ? nilObj : v;
  4042. if (prop === keyWindow) y = {
  4043. requestAnimationFrame(f) {
  4044. return 3;
  4045. },
  4046. cancelAnimationFrame() {
  4047.  
  4048. }
  4049. }
  4050. if (!keyFuncC && typeof v === 'function' && !(prop in target.constructor.prototype)) {
  4051. keyFuncC = prop;
  4052. }
  4053. // console.log('[get]', prop, typeof target[prop])
  4054.  
  4055.  
  4056. return y;
  4057. },
  4058. set(target, prop, value) {
  4059.  
  4060. if (typeof value === 'boolean' && !keyBoolD) {
  4061. keyBoolD = prop;
  4062. }
  4063. if (typeof value === 'number' && !keyCidj && value >= 2) {
  4064. keyCidj = prop;
  4065. }
  4066.  
  4067. // console.log('[set]', prop, value)
  4068. target[prop] = value
  4069.  
  4070. return true;
  4071. }
  4072. };
  4073.  
  4074. dummyObject.start.call(new Proxy(dummyObject, dummyObjectProxyHandler));
  4075.  
  4076. // console.log('gkp.start',gkp.start);
  4077. // console.log('gkp.stop',gkp.stop);
  4078. gkp._activation = false;
  4079.  
  4080. gkp.start = function () {
  4081. // p59 || console.log(12100)
  4082. if (!this._activation) {
  4083. this._activation = true;
  4084. getRafPromise().then(() => {
  4085. this._activation = false;
  4086. if (this[keyCidj]) {
  4087. Promise.resolve().then(this[keyFuncC]);
  4088. }
  4089. });
  4090. }
  4091. this[keyCidj] = 1;
  4092. this[keyBoolD] = true;
  4093. }
  4094. ;
  4095. gkp.stop = function () {
  4096. this[keyCidj] = null
  4097. }
  4098.  
  4099.  
  4100. /*
  4101. g[k].start = function() {
  4102. this.stop();
  4103. this.D = true;
  4104. var a = requestAnimationFrame
  4105. , b = cancelAnimationFrame;
  4106. this.j = a.call(this.B, this.C)
  4107. }
  4108. ;
  4109. g[k].stop = function() {
  4110. if (this.isActive()) {
  4111. var a = requestAnimationFrame
  4112. , b = cancelAnimationFrame;
  4113. b.call(this.B, this.j)
  4114. }
  4115. this.j = null
  4116. }
  4117. */
  4118.  
  4119. const keyzo = PERF_471489_ ? getzo(_yt_player) : null;
  4120.  
  4121. if (keyzo) {
  4122.  
  4123. k = keyzo;
  4124.  
  4125. const attrUpdateFn = g[k];
  4126. // console.log(5992, attrUpdateFn)
  4127. g['$$original$$' + k] = attrUpdateFn;
  4128. const zoTransform = async (a, c) => {
  4129.  
  4130. let transformType = '';
  4131. let transformValue = 0;
  4132. let transformUnit = '';
  4133. let transformTypeI = 0;
  4134.  
  4135. const aStyle = a.style;
  4136.  
  4137. if (c.length < 9) {
  4138.  
  4139. } else if (c.startsWith('scalex(0.') || (c === 'scalex(0)' || c === 'scalex(1)')) {
  4140. let p = c.substring(7, c.length - 1);
  4141. let q = p.length >= 1 ? parseFloat(p) : -1;
  4142. if (q > -1e-5 && q < 1 + 1e-5) {
  4143. transformType = 'scaleX'
  4144. transformValue = q;
  4145. transformUnit = '';
  4146. transformTypeI = 1;
  4147. }
  4148. } else if (c.startsWith('translateX(') && c.endsWith('px)')) {
  4149. let p = c.substring(11, c.length - 3);
  4150. let q = p.length >= 1 ? parseFloat(p) : NaN;
  4151. if (typeof q === 'number' && !isNaN(q)) {
  4152. transformType = 'translateX'
  4153. transformValue = q;
  4154. transformUnit = 'px';
  4155. transformTypeI = 2;
  4156. } else if (p === 'NaN') {
  4157. return;
  4158. }
  4159. } else if (c.startsWith('scaley(0.') || (c === 'scaley(0)' || c === 'scaley(1)')) {
  4160. let p = c.substring(7, c.length - 1);
  4161. let q = p.length >= 1 ? parseFloat(p) : -1;
  4162. if (q > -1e-5 && q < 1 + 1e-5) {
  4163. transformType = 'scaleY'
  4164. transformValue = q;
  4165. transformUnit = '';
  4166. transformTypeI = 1;
  4167. }
  4168. } else if (c.startsWith('translateY(') && c.endsWith('px)')) {
  4169. let p = c.substring(11, c.length - 3);
  4170. let q = p.length >= 1 ? parseFloat(p) : NaN;
  4171. if (typeof q === 'number' && !isNaN(q)) {
  4172. transformType = 'translateY'
  4173. transformValue = q;
  4174. transformUnit = 'px';
  4175. transformTypeI = 2;
  4176. } else if (p === 'NaN') {
  4177. return;
  4178. }
  4179. } else if (c.startsWith('scalex(') && c.includes('e-')) {
  4180. // scalex(1.252057684158767e-16)
  4181. // scalex(3.0393632069734948e-9)
  4182. let p = c.substring(7, c.length - 1);
  4183. let q = p.length >= 1 ? parseFloat(p) : -1;
  4184. if (q > -1e-5 && q < 1e-5) {
  4185. transformType = 'scaleX'
  4186. transformValue = 0;
  4187. transformUnit = '';
  4188. transformTypeI = 1;
  4189. }
  4190. } else if (c.startsWith('scaley(') && c.includes('e-')) {
  4191. let p = c.substring(7, c.length - 1);
  4192. let q = p.length >= 1 ? parseFloat(p) : -1;
  4193. if (q > -1e-5 && q < 1e-5) {
  4194. transformType = 'scaleY'
  4195. transformValue = 0;
  4196. transformUnit = '';
  4197. transformTypeI = 1;
  4198. }
  4199. }
  4200.  
  4201. if (transformTypeI === 1) {
  4202. const q = Math.round(transformValue * steppingScaleN) / steppingScaleN;
  4203. const vz = toFixed2(q, 3);
  4204. c = `${transformType}(${vz})`;
  4205. const cv = aStyle.transform;
  4206. if (c === cv) return;
  4207. aStyle.transform = c;
  4208. } else if (transformTypeI === 2) {
  4209. const q = transformValue;
  4210. const vz = toFixed2(q, 1);
  4211. c = `${transformType}(${vz}${transformUnit})`;
  4212. const cv = aStyle.transform;
  4213. if (c === cv) return;
  4214. aStyle.transform = c;
  4215. } else { // eg empty
  4216. const cv = aStyle.transform;
  4217. if (!c && !cv) return;
  4218. else if (c === cv) return;
  4219. aStyle.transform = c;
  4220. }
  4221.  
  4222. };
  4223.  
  4224. const elmTransformTemp = new WeakMap();
  4225. const elmPropTemps = {
  4226. 'display': new WeakMap(),
  4227. 'width': new WeakMap(),
  4228. 'height': new WeakMap(),
  4229. 'outlineWidth': new WeakMap(),
  4230. 'position': new WeakMap(),
  4231. 'padding': new WeakMap(),
  4232. "cssText": new WeakMap(),
  4233. "right": new WeakMap(),
  4234. "left": new WeakMap(),
  4235. "top": new WeakMap(),
  4236. "bottom": new WeakMap(),
  4237. "transitionDelay": new WeakMap(),
  4238. "marginLeft": new WeakMap(),
  4239. "marginTop": new WeakMap(),
  4240. "marginRight": new WeakMap(),
  4241. "marginBottom": new WeakMap(),
  4242. }
  4243.  
  4244. const ns5 = Symbol();
  4245. const nextModify = (a, c, m, f, immediate) => {
  4246. const a_ = a;
  4247. const m_ = m;
  4248. const noKey = !m_.has(a_);
  4249. if (immediate || noKey) {
  4250. m_.set(a_, ns5);
  4251. f(a_, c);
  4252. noKey && nextBrowserTick_(() => {
  4253. const d = m_.get(a_);
  4254. if (d === undefined) return;
  4255. m_.delete(a_);
  4256. if (d !== ns5) f(a_, d);
  4257. });
  4258. } else {
  4259. m_.set(a_, c);
  4260. }
  4261. };
  4262.  
  4263. const set66 = new Set();
  4264. // const set77 = new Set(['top', 'left', 'bottom', 'right']); // caption positioning - immediate change
  4265.  
  4266. const modifiedFn = (a, b, c, immediateChange = false) => {
  4267.  
  4268. // console.log(140000, a, b, c);
  4269. if (typeof c === 'number' && typeof b === 'string' && a instanceof HTMLElement) {
  4270. const num = c;
  4271. c = `${num}`;
  4272. if (c.length > 5) c = (num < 10 && num > -10) ? toFixed2(num, 3) : toFixed2(num, 1);
  4273. }
  4274.  
  4275. if (typeof b === 'string' && typeof c === 'string' && a instanceof HTMLElement) {
  4276.  
  4277. let elmPropTemp = null;
  4278.  
  4279. if (b === "transform") {
  4280.  
  4281. nextModify(a, c, elmTransformTemp, zoTransform, immediateChange);
  4282. return;
  4283.  
  4284. } else if (elmPropTemp = elmPropTemps[b]) {
  4285.  
  4286. // if (c.length > 5 && c.includes('.')) {
  4287. // console.log(123213, c)
  4288. // }
  4289.  
  4290. const b_ = b;
  4291. nextModify(a, c, elmPropTemp, (a, c) => {
  4292. const style = a.style;
  4293. const cv = style[b_];
  4294. if (!cv && !c) return;
  4295. if (cv === c) return;
  4296. style[b_] = c;
  4297. }, immediateChange);
  4298. return;
  4299.  
  4300. } else if (b === "outline-width") {
  4301.  
  4302. const b_ = 'outlineWidth';
  4303. elmPropTemp = elmPropTemps[b_];
  4304. nextModify(a, c, elmPropTemp, (a, c) => {
  4305. const style = a.style;
  4306. const cv = style[b_];
  4307. if (!cv && !c) return;
  4308. if (cv === c) return;
  4309. style[b_] = c;
  4310. }, immediateChange);
  4311. return;
  4312.  
  4313. } else if (b === 'maxWidth' || b === 'maxHeight') {
  4314. // I think these can be directly assigned.
  4315.  
  4316. const b_ = b;
  4317. const style = a.style;
  4318. const cv = style[b_];
  4319. if (!cv && !c) return;
  4320. if (cv === c) return;
  4321. style[b_] = c;
  4322. return;
  4323.  
  4324. } else {
  4325. // if(immediate && elmPropTemps[b]){
  4326. // console.log(5191, b)
  4327. // }
  4328. // caption-window
  4329. // margin-left max-height max-width font-family fill color font-size background white-space margin
  4330. // text-align background-color
  4331. // console.log(27304, a, b, c)
  4332. if (!set66.has(b)) {
  4333. set66.add(b);
  4334. if (!a.classList.contains('caption-window') && !a.classList.contains('ytp-caption-segment')) {
  4335. console.log(27304, a, b, c)
  4336. }
  4337. }
  4338. }
  4339.  
  4340. attrUpdateFn.call(this, a, b, c);
  4341. return;
  4342. } else if (typeof (b || 0) === 'object') {
  4343.  
  4344. // this is to fix caption positioning
  4345. // const immediate = (a.id || 0).length > 14 && (('top' in b) || ('left' in b) || ('right' in b) || ('bottom' in b));
  4346. const immediate = (a.id || 0).length > 14;
  4347. for (const [k, v] of Object.entries(b)) {
  4348. modifiedFn(a, k, v, immediate);
  4349. }
  4350.  
  4351. } else {
  4352. console.log(27306, a, b, c);
  4353.  
  4354. attrUpdateFn.call(this, a, b, c);
  4355. return;
  4356. }
  4357.  
  4358. // console.log(130000, a, b, c);
  4359.  
  4360. };
  4361. g[k] = modifiedFn;
  4362.  
  4363.  
  4364. /*
  4365.  
  4366. g.zo = function(a, b, c) {
  4367. if ("string" === typeof b)
  4368. (b = yo(a, b)) && (a.style[b] = c);
  4369. else
  4370. for (var d in b) {
  4371. c = a;
  4372. var e = b[d]
  4373. , f = yo(c, d);
  4374. f && (c.style[f] = e)
  4375. }
  4376. }
  4377.  
  4378.  
  4379. */
  4380.  
  4381.  
  4382. }
  4383.  
  4384.  
  4385.  
  4386. const keyuG = PERF_471489_ ? getuG(_yt_player) : null;
  4387.  
  4388. if (keyuG) {
  4389.  
  4390. k = keyuG;
  4391.  
  4392. const gk = g[k];
  4393. const gkp = gk.prototype;
  4394.  
  4395.  
  4396. /** @type { Map<string, WeakMap<any, any>> } */
  4397. const ntLogs = new Map();
  4398.  
  4399. if (typeof gkp.updateValue === 'function' && gkp.updateValue.length === 2 && !gkp.updateValue31) {
  4400.  
  4401. gkp.updateValue31 = gkp.updateValue;
  4402. gkp.updateValue = function (a, b) {
  4403. if (typeof a !== 'string') return this.updateValue31(a, b);
  4404.  
  4405. const element = this.element;
  4406. if (!(element instanceof HTMLElement)) return this.updateValue31(a, b);
  4407.  
  4408. let ntLog = ntLogs.get(a);
  4409. if (!ntLog) ntLogs.set(a, (ntLog = new WeakMap()));
  4410.  
  4411. let cache = ntLog.get(element);
  4412. if (cache && cache.value === b) {
  4413. return;
  4414. }
  4415. if (!cache) {
  4416. this.__oldValueByUpdateValue__ = null;
  4417. ntLog.set(element, cache = { value: b });
  4418. } else {
  4419. this.__oldValueByUpdateValue__ = cache.value;
  4420. cache.value = b;
  4421. }
  4422.  
  4423. return this.updateValue31(a, b);
  4424. }
  4425.  
  4426. /*
  4427. g.k.update = function(a) {
  4428. for (var b = g.u(Object.keys(a)), c = b.next(); !c.done; c = b.next())
  4429. c = c.value,
  4430. this.updateValue(c, a[c])
  4431. }
  4432. ;
  4433. g.k.updateValue = function(a, b) {
  4434. (a = this.Td["{{" + a + "}}"]) && wG(this, a[0], a[1], b)
  4435. }
  4436. */
  4437.  
  4438. }
  4439.  
  4440.  
  4441. }
  4442.  
  4443.  
  4444.  
  4445.  
  4446. })();
  4447.  
  4448. FIX_yt_player && (async () => {
  4449. // timer scheduling
  4450.  
  4451. const _yt_player = await _yt_player_observable.obtain();
  4452.  
  4453. if (!_yt_player || typeof _yt_player !== 'object') return;
  4454.  
  4455. let keyZqQu = getZqQu(_yt_player);
  4456.  
  4457. if (!keyZqQu) return;
  4458.  
  4459. const g = _yt_player
  4460. let k = keyZqQu
  4461.  
  4462. const gk = g[k];
  4463. if (typeof gk !== 'function') return;
  4464. const gkp = gk.prototype;
  4465.  
  4466. const extractKeysZqQu = () => {
  4467.  
  4468.  
  4469. let _keyeC = '';
  4470. try {
  4471. gkp.stop.call(new Proxy({
  4472. isActive: () => { }
  4473. }, {
  4474. set(target, prop, value) {
  4475. if (value === 0) _keyeC = prop;
  4476. return true;
  4477. }
  4478. }));
  4479. } catch (e) { }
  4480. if (!_keyeC) return;
  4481. const keyeC = _keyeC;
  4482.  
  4483. let keyC = ''; // this.C = this.ST.bind(this)
  4484. let keyhj = ''; // 1000ms
  4485. try {
  4486. gkp.start.call(new Proxy({
  4487. stop: () => { },
  4488. [keyeC]: 0,
  4489. }, {
  4490. get(target, prop) {
  4491. if (prop in target) return target[prop];
  4492. if (!keyC) {
  4493. keyC = prop;
  4494. return null; // throw error
  4495. }
  4496. else if (!keyhj) {
  4497. keyhj = prop;
  4498. }
  4499.  
  4500. }
  4501. }));
  4502. } catch (e) {
  4503. if (!keyC || !keyhj) {
  4504. console.log(e)
  4505. }
  4506. }
  4507.  
  4508. if (!keyC || !keyhj) return;
  4509. let keyST = '';
  4510. let keyj = '';
  4511. let keyB = '';
  4512. let keyxa = '';
  4513.  
  4514. const possibleKs = new Set();
  4515.  
  4516. for (const [k, v] of Object.entries(gkp)) {
  4517. if (k === 'stop' || k === 'start' || k === 'isActive' || k === 'constructor' || k === keyeC || k === keyC || k === keyhj) {
  4518. continue;
  4519. }
  4520. if (typeof v === 'function') {
  4521. const m = /this\.(\w+)\.call\(this\.(\w+)\)/.exec(v + '');
  4522. if (m) {
  4523. keyST = k;
  4524. keyj = m[1];
  4525. keyB = m[2];
  4526. } else {
  4527. possibleKs.add(k);
  4528. }
  4529. }
  4530. }
  4531.  
  4532. if (!keyST || !keyj || !keyB) return;
  4533.  
  4534. for (const k of possibleKs) {
  4535. if (k === keyST || k === keyj || k === keyB) {
  4536. continue;
  4537. }
  4538. const v = gkp[k];
  4539. if (typeof v === 'function' && (v + '').includes(`this.stop();delete this.${keyj};delete this.${keyB}`)) {
  4540. keyxa = k;
  4541. }
  4542. }
  4543.  
  4544. return [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa];
  4545.  
  4546. }
  4547.  
  4548. const keys = extractKeysZqQu();
  4549. if (!keys || !keys.length) return;
  4550. const [keyeC, keyC, keyhj, keyST, keyj, keyB, keyxa] = keys; // [timerId, binded executorFn, 1000ms, executorFn, dataJ, objectB, disposeFn]
  4551.  
  4552. if (!keyeC || !keyC || !keyhj || !keyST || !keyj || !keyB || !keyxa) return;
  4553.  
  4554. let disposeKeys = null;
  4555.  
  4556. gkp[keyxa] = function () {
  4557. // dispose
  4558. if (!disposeKeys) {
  4559. disposeKeys = Object.getOwnPropertyNames(this).filter(key => {
  4560. if (key != keyeC && key != keyC && key != keyhj && key != keyST && key != keyj && key != keyB && key != keyxa) {
  4561. const t = typeof this[key];
  4562. return t === 'undefined' || t === 'object'
  4563. }
  4564. return false;
  4565. });
  4566. }
  4567. for (const key of disposeKeys) {
  4568. const v = this[key];
  4569. if ((v || 0).length >= 1) v.length = 0; // function (){if(this.fn)for(;this.fn.length;)this.fn.shift()()}
  4570. }
  4571. if (this[keyeC] > 0) this.stop();
  4572. this[keyj] = null;
  4573. this[keyB] = null;
  4574. };
  4575.  
  4576. gkp.start = function (a) {
  4577. if (this[keyeC] > 0) this.stop();
  4578. const delay = void 0 !== a ? a : this[keyhj];
  4579. this[keyeC] = window.setTimeout(this[keyC], delay);
  4580. };
  4581. gkp.stop = function () {
  4582. if (this[keyeC] > 0) {
  4583. window.clearTimeout(this[keyeC]);
  4584. this[keyeC] = 0;
  4585. }
  4586. };
  4587.  
  4588. gkp.isActive = function () {
  4589. return this[keyeC] > 0;
  4590. };
  4591.  
  4592. gkp[keyST] = function () {
  4593. this.stop(); // this[keyeC] = 0;
  4594. const fn = this[keyj];
  4595. const obj = this[keyB];
  4596. let skip = false;
  4597. if (!fn) skip = true;
  4598. else if (IGNORE_bufferhealth_CHECK && obj) {
  4599. let m;
  4600. if ((m = obj[keyC]) instanceof Map || (m = obj[keyj]) instanceof Map) {
  4601. if (m.has("bufferhealth")) skip = true;
  4602. }
  4603. }
  4604. if (!skip) {
  4605. fn.call(obj);
  4606. }
  4607. };
  4608.  
  4609.  
  4610.  
  4611.  
  4612. /*
  4613.  
  4614. g.k.eC = 0;
  4615. g.k.xa = function() {
  4616. g.Qu.Vf.xa.call(this);
  4617. this.stop();
  4618. delete this.j;
  4619. delete this.B
  4620. }
  4621. ;
  4622. g.k.start = function(a) {
  4623. this.stop();
  4624. this.eC = g.gg(this.C, void 0 !== a ? a : this.hj)
  4625. }
  4626. ;
  4627. g.k.stop = function() {
  4628. this.isActive() && g.Sa.clearTimeout(this.eC);
  4629. this.eC = 0
  4630. }
  4631. ;
  4632. g.k.isActive = function() {
  4633. return 0 != this.eC
  4634. }
  4635. ;
  4636. g.k.ST = function() {
  4637. this.eC = 0;
  4638. this.j && this.j.call(this.B)
  4639. }
  4640. ;
  4641. */
  4642.  
  4643.  
  4644.  
  4645.  
  4646. })();
  4647.  
  4648. FIX_Animation_n_timeline && (async () => {
  4649.  
  4650. const [timeline, Animation] = await Promise.all([timelineObservable.obtain(), animationObservable.obtain()]);
  4651.  
  4652. if (!timeline || !Animation) return;
  4653.  
  4654. const aniProto = Animation.prototype;
  4655. // aniProto.sequenceNumber = 0; // native YouTube engine bug - sequenceNumber is not set
  4656.  
  4657. const getXroto = (x) => {
  4658. try {
  4659. return x.__proto__;
  4660. } catch (e) { }
  4661. return null;
  4662. }
  4663. const timProto = getXroto(timeline);
  4664. if (!timProto) return;
  4665. if (
  4666. (
  4667. typeof timProto.getAnimations === 'function' && typeof timProto.play === 'function' &&
  4668. typeof timProto._discardAnimations === 'function' && typeof timProto._play === 'function' &&
  4669. typeof timProto._updateAnimationsPromises === 'function' && !timProto.nofCQ &&
  4670. typeof aniProto._updatePromises === 'function' && !aniProto.nofYH
  4671. )
  4672.  
  4673. ) {
  4674.  
  4675. timProto.nofCQ = 1;
  4676. aniProto.nofYH = 1;
  4677.  
  4678. const originalAnimationsWithPromises = ((_updateAnimationsPromises) => {
  4679.  
  4680.  
  4681. /*
  4682. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  4683. return c._updatePromises();
  4684. });
  4685. */
  4686.  
  4687. const p = Array.prototype.filter;
  4688.  
  4689. let res = null;
  4690. Array.prototype.filter = function () {
  4691.  
  4692. res = this;
  4693. return this;
  4694.  
  4695. };
  4696.  
  4697. _updateAnimationsPromises.call({});
  4698.  
  4699. Array.prototype.filter = p;
  4700.  
  4701. if (res && typeof res.length === 'number') {
  4702. /** @type {any[]} */
  4703. const _res = res;
  4704. return _res;
  4705. }
  4706.  
  4707.  
  4708. return null;
  4709.  
  4710.  
  4711.  
  4712.  
  4713. })(timProto._updateAnimationsPromises);
  4714.  
  4715. if (!originalAnimationsWithPromises || typeof originalAnimationsWithPromises.length !== 'number') return;
  4716.  
  4717. // console.log('originalAnimationsWithPromises', originalAnimationsWithPromises)
  4718.  
  4719. aniProto._updatePromises31 = aniProto._updatePromises;
  4720.  
  4721. /*
  4722. aniProto._updatePromises = function(){
  4723. console.log('eff',this._oldPlayState, this.playState)
  4724. return this._updatePromises31.apply(this, arguments)
  4725. }
  4726. */
  4727.  
  4728. aniProto._updatePromises = function () {
  4729. var oldPlayState = this._oldPlayState;
  4730. var newPlayState = this.playState;
  4731. // console.log('ett', oldPlayState, newPlayState)
  4732. if (newPlayState !== oldPlayState) {
  4733. this._oldPlayState = newPlayState;
  4734. if (this._readyPromise) {
  4735. if ("idle" == newPlayState) {
  4736. this._rejectReadyPromise();
  4737. this._readyPromise = void 0;
  4738. } else if ("pending" == oldPlayState) {
  4739. this._resolveReadyPromise();
  4740. } else if ("pending" == newPlayState) {
  4741. this._readyPromise = void 0;
  4742. }
  4743. }
  4744. if (this._finishedPromise) {
  4745. if ("idle" == newPlayState) {
  4746. this._rejectFinishedPromise();
  4747. this._finishedPromise = void 0;
  4748. } else if ("finished" == newPlayState) {
  4749. this._resolveFinishedPromise();
  4750. } else if ("finished" == oldPlayState) {
  4751. this._finishedPromise = void 0;
  4752. }
  4753. }
  4754. }
  4755. return this._readyPromise || this._finishedPromise;
  4756. };
  4757.  
  4758.  
  4759. let restartWebAnimationsNextTickFlag = false;
  4760.  
  4761. const looperMethodT = () => {
  4762.  
  4763. const runnerFn = (hRes) => {
  4764. var b = timeline;
  4765. b.currentTime = hRes;
  4766. b._discardAnimations();
  4767. if (0 == b._animations.length) {
  4768. restartWebAnimationsNextTickFlag = false;
  4769. } else {
  4770. getRafPromise().then(runnerFn);
  4771. }
  4772. }
  4773.  
  4774. const restartWebAnimationsNextTick = () => {
  4775. if (!restartWebAnimationsNextTickFlag) {
  4776. restartWebAnimationsNextTickFlag = true;
  4777. getRafPromise().then(runnerFn);
  4778. }
  4779. }
  4780.  
  4781. return { restartWebAnimationsNextTick }
  4782. };
  4783.  
  4784.  
  4785. const looperMethodN = () => {
  4786.  
  4787. const acs = document.createElement('a-f');
  4788. acs.id = 'a-f';
  4789.  
  4790. const style = document.createElement('style');
  4791. style.textContent = `
  4792. @keyFrames aF1 {
  4793. 0% {
  4794. order: 0;
  4795. }
  4796. 100% {
  4797. order: 6;
  4798. }
  4799. }
  4800. #a-f[id] {
  4801. visibility: collapse !important;
  4802. position: fixed !important;
  4803. top: -100px !important;
  4804. left: -100px !important;
  4805. margin:0 !important;
  4806. padding:0 !important;
  4807. outline:0 !important;
  4808. border:0 !important;
  4809. z-index:-1 !important;
  4810. width: 0px !important;
  4811. height: 0px !important;
  4812. contain: strict !important;
  4813. pointer-events: none !important;
  4814. animation: 1ms steps(2, jump-none) 0ms infinite alternate forwards running aF1 !important;
  4815. }
  4816. `;
  4817. (document.head || document.documentElement).appendChild(style);
  4818.  
  4819. document.documentElement.insertBefore(acs, document.documentElement.firstChild);
  4820.  
  4821. const _onanimationiteration = function (evt) {
  4822. const hRes = evt.timeStamp;
  4823. var b = timeline;
  4824. b.currentTime = hRes;
  4825. b._discardAnimations();
  4826. if (0 == b._animations.length) {
  4827. restartWebAnimationsNextTickFlag = false;
  4828. acs.onanimationiteration = null;
  4829. } else {
  4830. acs.onanimationiteration = _onanimationiteration;
  4831. }
  4832.  
  4833. }
  4834.  
  4835.  
  4836.  
  4837. const restartWebAnimationsNextTick = () => {
  4838. if (!restartWebAnimationsNextTickFlag) {
  4839. restartWebAnimationsNextTickFlag = true;
  4840. acs.onanimationiteration = _onanimationiteration;
  4841.  
  4842. }
  4843. }
  4844.  
  4845. return { restartWebAnimationsNextTick }
  4846. };
  4847.  
  4848.  
  4849.  
  4850. const { restartWebAnimationsNextTick } = ('onanimationiteration' in document.documentElement) ? looperMethodN() : looperMethodT();
  4851.  
  4852.  
  4853. // console.log(571, timProto);
  4854. timProto._play = function (c) {
  4855. c = new Animation(c, this);
  4856. this._animations.push(c);
  4857. restartWebAnimationsNextTick();
  4858. c._updatePromises();
  4859. c._animation.play();
  4860. c._updatePromises();
  4861. return c
  4862. }
  4863.  
  4864. const animationsWithPromisesMap = new Set(originalAnimationsWithPromises);
  4865. originalAnimationsWithPromises.length = 0;
  4866. originalAnimationsWithPromises.push = null;
  4867. originalAnimationsWithPromises.splice = null;
  4868. originalAnimationsWithPromises.slice = null;
  4869. originalAnimationsWithPromises.indexOf = null;
  4870. originalAnimationsWithPromises.unshift = null;
  4871. originalAnimationsWithPromises.shift = null;
  4872. originalAnimationsWithPromises.pop = null;
  4873. originalAnimationsWithPromises.filter = null;
  4874. originalAnimationsWithPromises.forEach = null;
  4875. originalAnimationsWithPromises.map = null;
  4876.  
  4877.  
  4878. const _updateAnimationsPromises = () => {
  4879. animationsWithPromisesMap.forEach(c => {
  4880. if (!c._updatePromises()) animationsWithPromisesMap.delete(c);
  4881. });
  4882. /*
  4883. v.animationsWithPromises = v.animationsWithPromises.filter(function (c) {
  4884. return c._updatePromises();
  4885. });
  4886. */
  4887. }
  4888.  
  4889. timProto._updateAnimationsPromises31 = timProto._updateAnimationsPromises;
  4890.  
  4891. timProto._updateAnimationsPromises = _updateAnimationsPromises;
  4892.  
  4893. delete timProto._updateAnimationsPromises;
  4894. Object.defineProperty(timProto, '_updateAnimationsPromises', {
  4895. get() {
  4896. if (animationsWithPromisesMap.size === 0) return nilFn;
  4897. return _updateAnimationsPromises;
  4898. },
  4899. set(nv) {
  4900. delete this._updateAnimationsPromises;
  4901. this._updateAnimationsPromises = nv;
  4902. },
  4903. enumerable: true,
  4904. configurable: true,
  4905. });
  4906.  
  4907.  
  4908. let pdFinished = Object.getOwnPropertyDescriptor(aniProto, 'finished');
  4909. aniProto.__finished_native_get__ = pdFinished.get;
  4910. if (typeof pdFinished.get === 'function' && !pdFinished.set && pdFinished.configurable === true && pdFinished.enumerable === true) {
  4911.  
  4912.  
  4913. Object.defineProperty(aniProto, 'finished', {
  4914. get() {
  4915. this._finishedPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  4916. this._finishedPromise = new Promise((resolve, reject) => {
  4917. this._resolveFinishedPromise = function () {
  4918. resolve(this)
  4919. };
  4920. this._rejectFinishedPromise = function () {
  4921. reject({
  4922. type: DOMException.ABORT_ERR,
  4923. name: "AbortError"
  4924. })
  4925. };
  4926. }),
  4927. "finished" == this.playState && this._resolveFinishedPromise());
  4928. return this._finishedPromise
  4929. },
  4930. set: undefined,
  4931. enumerable: true,
  4932. configurable: true
  4933. });
  4934.  
  4935. }
  4936.  
  4937.  
  4938.  
  4939. let pdReady = Object.getOwnPropertyDescriptor(aniProto, 'ready');
  4940. aniProto.__ready_native_get__ = pdReady.get;
  4941. if (typeof pdReady.get === 'function' && !pdReady.set && pdReady.configurable === true && pdReady.enumerable === true) {
  4942.  
  4943. Object.defineProperty(aniProto, 'ready', {
  4944. get() {
  4945. this._readyPromise || (!animationsWithPromisesMap.has(this) && animationsWithPromisesMap.add(this),
  4946. this._readyPromise = new Promise((resolve, reject) => {
  4947. this._resolveReadyPromise = function () {
  4948. resolve(this)
  4949. };
  4950. this._rejectReadyPromise = function () {
  4951. reject({
  4952. type: DOMException.ABORT_ERR,
  4953. name: "AbortError"
  4954. })
  4955. };
  4956. }),
  4957. "pending" !== this.playState && this._resolveReadyPromise());
  4958. return this._readyPromise
  4959. },
  4960. set: undefined,
  4961. enumerable: true,
  4962. configurable: true
  4963. });
  4964.  
  4965. }
  4966.  
  4967.  
  4968. if (IGNORE_bindAnimationForCustomEffect && typeof aniProto._rebuildUnderlyingAnimation === 'function' && !aniProto._rebuildUnderlyingAnimation21 && aniProto._rebuildUnderlyingAnimation.length === 0) {
  4969.  
  4970. aniProto._rebuildUnderlyingAnimation21 = aniProto._rebuildUnderlyingAnimation;
  4971. const _rebuildUnderlyingAnimation = function () {
  4972. // if (isNaN(this._sequenceNumber)) return; // do not rebuild underlying animation if native animation is used.
  4973. this.effect && this.effect._onsample && (this.effect._onsample = null);
  4974. return this._rebuildUnderlyingAnimation21();
  4975. }
  4976. aniProto._rebuildUnderlyingAnimation = _rebuildUnderlyingAnimation;
  4977. // delete aniProto._rebuildUnderlyingAnimation;
  4978. // Object.defineProperty(aniProto, '_rebuildUnderlyingAnimation', {
  4979. // get() {
  4980. // if (isNaN(this._sequenceNumber)) return nilFn;
  4981. // return this._rebuildUnderlyingAnimation21;
  4982. // },
  4983. // set(nv) {
  4984. // delete this._rebuildUnderlyingAnimation;
  4985. // this._rebuildUnderlyingAnimation = nv;
  4986. // },
  4987. // enumerable: true,
  4988. // configurable: true
  4989. // });
  4990. }
  4991.  
  4992.  
  4993. /*
  4994.  
  4995.  
  4996. function f(c) {
  4997. var b = v.timeline;
  4998. b.currentTime = c;
  4999. b._discardAnimations();
  5000. 0 == b._animations.length ? d = !1 : requestAnimationFrame(f)
  5001. }
  5002. var h = window.requestAnimationFrame;
  5003. window.requestAnimationFrame = function(c) {
  5004. return h(function(b) {
  5005. v.timeline._updateAnimationsPromises();
  5006. c(b);
  5007. v.timeline._updateAnimationsPromises()
  5008. })
  5009. }
  5010. ;
  5011. v.AnimationTimeline = function() {
  5012. this._animations = [];
  5013. this.currentTime = void 0
  5014. }
  5015. ;
  5016. v.AnimationTimeline.prototype = {
  5017. getAnimations: function() {
  5018. this._discardAnimations();
  5019. return this._animations.slice()
  5020. },
  5021. _updateAnimationsPromises: function() {
  5022. v.animationsWithPromises = v.animationsWithPromises.filter(function(c) {
  5023. return c._updatePromises()
  5024. })
  5025. },
  5026. _discardAnimations: function() {
  5027. this._updateAnimationsPromises();
  5028. this._animations = this._animations.filter(function(c) {
  5029. return "finished" != c.playState && "idle" != c.playState
  5030. })
  5031. },
  5032. _play: function(c) {
  5033. c = new v.Animation(c,this);
  5034. this._animations.push(c);
  5035. v.restartWebAnimationsNextTick();
  5036. c._updatePromises();
  5037. c._animation.play();
  5038. c._updatePromises();
  5039. return c
  5040. },
  5041. play: function(c) {
  5042. c && c.remove();
  5043. return this._play(c)
  5044. }
  5045. };
  5046. var d = !1;
  5047. v.restartWebAnimationsNextTick = function() {
  5048. d || (d = !0,
  5049. requestAnimationFrame(f))
  5050. }
  5051. ;
  5052. var a = new v.AnimationTimeline;
  5053. v.timeline = a;
  5054. try {
  5055. Object.defineProperty(window.document, "timeline", {
  5056. configurable: !0,
  5057. get: function() {
  5058. return a
  5059. }
  5060. })
  5061. } catch (c) {}
  5062. try {
  5063. window.document.timeline = a
  5064. } catch (c) {}
  5065.  
  5066. */
  5067.  
  5068.  
  5069.  
  5070. /*
  5071.  
  5072. var g = window.getComputedStyle;
  5073. Object.defineProperty(window, "getComputedStyle", {
  5074. configurable: !0,
  5075. enumerable: !0,
  5076. value: function() {
  5077. v.timeline._updateAnimationsPromises();
  5078. var e = g.apply(this, arguments);
  5079. h() && (e = g.apply(this, arguments));
  5080. v.timeline._updateAnimationsPromises();
  5081. return e
  5082. }
  5083. });
  5084.  
  5085. */
  5086.  
  5087.  
  5088.  
  5089.  
  5090. }
  5091.  
  5092.  
  5093.  
  5094.  
  5095. })();
  5096.  
  5097. !isUrlInEmbed && Promise.resolve().then(() => {
  5098.  
  5099. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  5100.  
  5101.  
  5102.  
  5103. class LimitedSizeSet extends Set {
  5104. constructor(n) {
  5105. super();
  5106.  
  5107. this.limit = n;
  5108. }
  5109.  
  5110. add(key) {
  5111. if (!super.has(key)) {
  5112. super.add(key); // Set the key with a dummy value (true)
  5113. while (super.size > this.limit) {
  5114. const firstKey = super.values().next().value; // Get the first (oldest) key
  5115. super.delete(firstKey); // Delete the oldest key
  5116. }
  5117. }
  5118. }
  5119.  
  5120. removeAdd(key) {
  5121. super.delete(key);
  5122. super.add(key);
  5123. }
  5124.  
  5125. }
  5126.  
  5127. // const wk3 = new WeakMap();
  5128.  
  5129. // let mtxVideoId = '';
  5130. // let aje3 = [];
  5131. const mfvContinuationRecorded = new LimitedSizeSet(8); // record all success continuation keys
  5132. const mfyContinuationIgnored = new LimitedSizeSet(8); // ignore continuation keys by copying the keys in the past
  5133. let mtzlastAllowedContinuation = ''; // the key stored at the last success; clear when scheduling changes
  5134. let mtzCount = 0; // the key keeps unchanged
  5135. // let mjtNextMainKey = '';
  5136. let mjtRecordedPrevKey = ''; // the key stored at the last success (no clear)
  5137. let mjtLockPreviousKey = ''; // the key before fetch() should be discarded. (uncertain continuation)
  5138. let mbCId322 = 0; // cid for delay fetchUpdatedMetadata
  5139. // let allowNoDelay322=false;
  5140. let mbDelayBelowNCalls = 0; // after N calls, by pass delay; reset when scheduling changes
  5141.  
  5142. let mpKey22 = ''; // last success continutation key & url pair
  5143. let mpUrl22 = ''; // last success continutation key & url pair
  5144. let mpKey21 = ''; // latest requested continutation key & url pair
  5145. let mpUrl21 = ''; // latest requested continutation key & url pair
  5146.  
  5147.  
  5148. async function sha1Hex(message) {
  5149. const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
  5150. const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8); // hash the message
  5151. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  5152. const hashHex = hashArray
  5153. .map((b) => b.toString(16).padStart(2, "0"))
  5154. .join(""); // convert bytes to hex string
  5155. return hashHex;
  5156. }
  5157.  
  5158. async function continuationLog(a, ...args) {
  5159. let b = a;
  5160. try {
  5161. if (advanceLogging) b = await sha1Hex(a);
  5162. let c = args.map(e => {
  5163. return e === a ? b : e
  5164. });
  5165. console.log(...c)
  5166. } catch (e) { console.warn(e) }
  5167. }
  5168.  
  5169. function copyPreviousContiuationToIgnored374(toClearRecorded) {
  5170.  
  5171.  
  5172. if (mfvContinuationRecorded.length > 0) {
  5173. for (const [e, d] of mfvContinuationRecorded) {
  5174. mfyContinuationIgnored.removeAdd(e);
  5175. }
  5176. toClearRecorded && mfvContinuationRecorded.clear();
  5177. }
  5178.  
  5179. }
  5180.  
  5181. function setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr) {
  5182.  
  5183. const tmProto = taskMgr.constructor.prototype;
  5184. if (tmProto && typeof tmProto.addJob === 'function' && tmProto.addJob.length === 3 && typeof tmProto.cancelJob === 'function' && tmProto.cancelJob.length === 1) {
  5185.  
  5186. if (!tmProto.addJob714) {
  5187.  
  5188. tmProto.addJob714 = tmProto.addJob;
  5189.  
  5190. tmProto.addJob = function (a, b, c) {
  5191. const jobId = this.addJob714(a, b, c);
  5192. if (jobId > 0) {
  5193. // const ez = wk3.get(this);
  5194. // const dz = ez ? ez.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint : null;
  5195. // aje3.push({mtx, jobId, a,b,c, element: this, dz, data: (ez?.data || null) })
  5196.  
  5197. this.__lastJobId863__ = jobId;
  5198. }
  5199. return jobId;
  5200. }
  5201.  
  5202. }
  5203.  
  5204. if (!tmProto.cancelJob714) {
  5205.  
  5206. tmProto.cancelJob714 = tmProto.cancelJob;
  5207.  
  5208. tmProto.cancelJob = function (a) {
  5209. const res = this.cancelJob714(a);
  5210. // if (a > 0) {
  5211. // for (const e of aje3) {
  5212. // if (e.jobId === a) e.cancelled = true;
  5213. // }
  5214. // }
  5215. return res;
  5216. }
  5217.  
  5218. }
  5219.  
  5220. }
  5221. }
  5222.  
  5223.  
  5224. const FIX_avoid_incorrect_video_meta_bool = FIX_avoid_incorrect_video_meta && isPrepareCachedV && check_for_set_key_order;
  5225.  
  5226.  
  5227. FIX_avoid_incorrect_video_meta_bool && whenCEDefined('ytd-video-primary-info-renderer').then(() => {
  5228. let dummy;
  5229. let cProto;
  5230. // let mc = 4;
  5231. // dummy = await observablePromise(() => {
  5232. // const r = document.querySelector('ytd-video-primary-info-renderer');
  5233. // if (!r) return;
  5234. // let cProto = insp(r).constructor.prototype;
  5235. // if (cProto.fetchUpdatedMetadata) return r;
  5236. // if (--mc < 0) return -1;
  5237. // return null;
  5238. // }).obtain();
  5239. dummy = document.createElement('ytd-video-primary-info-renderer');
  5240. if (!(dummy instanceof Element)) return;
  5241. // console.log(5022, dummy)
  5242. cProto = insp(dummy).constructor.prototype;
  5243.  
  5244. cProto.__getEmittorTaskMgr859__ = function () {
  5245. let taskMgr_ = null;
  5246. try {
  5247. taskMgr_ = (this.ytTaskEmitterBehavior || 0).getTaskManager() || null;
  5248. } catch (e) { }
  5249. return taskMgr_;
  5250. }
  5251. if (typeof cProto.fetchUpdatedMetadata === 'function' && cProto.fetchUpdatedMetadata.length === 1 && !cProto.fetchUpdatedMetadata717) {
  5252. // console.log(1234, cProto, cProto.is)
  5253. cProto.fetchUpdatedMetadata717 = cProto.fetchUpdatedMetadata;
  5254.  
  5255. let c_;
  5256. cProto.fetchUpdatedMetadata718 = function (a) {
  5257. // delay or immediate call the actual fetchUpdatedMetadata
  5258.  
  5259. let doImmediately = false;
  5260. if (a && typeof a === 'string' && mjtRecordedPrevKey && mjtRecordedPrevKey === mpKey22 && a === mpKey22 && (!pageSetupVideoId || pageSetupVideoId !== mpUrl22)) {
  5261.  
  5262. if (!pageSetupVideoId && videoPlayingY.videoId === mpUrl22) doImmediately = true;
  5263.  
  5264. } else if (typeof a !== 'string' || mbDelayBelowNCalls > 3 || !mpKey22 || (mpKey22 === a && mpKey22 !== mjtLockPreviousKey) || (mjtLockPreviousKey && mjtLockPreviousKey !== a)) {
  5265.  
  5266. doImmediately = true;
  5267.  
  5268. }
  5269.  
  5270. if (mbCId322) {
  5271. clearTimeout(mbCId322);
  5272. mbCId322 = 0;
  5273. }
  5274.  
  5275. if (doImmediately) return this.fetchUpdatedMetadata717(a);
  5276.  
  5277. let delay = mjtLockPreviousKey === a ? 8000 : 800;
  5278.  
  5279. mbCId322 = setTimeout(() => {
  5280. this.fetchUpdatedMetadata717(a);
  5281. }, delay);
  5282.  
  5283. console.log('[yt-js-engine-tamer]', '5190 delayed fetchUpdatedMetadata', delay);
  5284.  
  5285. }
  5286.  
  5287. cProto.fetchUpdatedMetadata = function (a) {
  5288.  
  5289. if (!pageSetupState) {
  5290. if (c_) clearTimeout(c_);
  5291. c_ = setTimeout(() => {
  5292. this.fetchUpdatedMetadata718(a);
  5293. }, 300);
  5294. return;
  5295. }
  5296.  
  5297. // pageSetupState == 0
  5298.  
  5299. try {
  5300.  
  5301. mbDelayBelowNCalls++;
  5302.  
  5303. if (arguments.length > 1 || !(a === undefined || (typeof a === 'string' && a))) {
  5304. console.warn("CAUTION: fetchUpdatedMetadata coding might have to be updated.");
  5305. }
  5306.  
  5307. // console.log('fum377', a)
  5308. if (typeof a === 'string' && mfyContinuationIgnored.has(a)) {
  5309. console.log('[yt-js-engine-tamer]', '5040 skip fetchUpdatedMetadata', a);
  5310. return;
  5311. }
  5312.  
  5313. if (!a && (this.data || 0).updatedMetadataEndpoint) {
  5314. if (mjtRecordedPrevKey && mjtLockPreviousKey !== mjtRecordedPrevKey) {
  5315. mjtLockPreviousKey = mjtRecordedPrevKey;
  5316. LOG_FETCHMETA_UPDATE && continuationLog(mjtLockPreviousKey, '5150 Lock Key', mjtLockPreviousKey);
  5317. }
  5318. // mjtNextMainKey = true;
  5319. mtzlastAllowedContinuation = '';
  5320. mtzCount = 0;
  5321. // allowNoDelay322 = false;
  5322. // fetch new metadata, cancel all previous continuations
  5323. copyPreviousContiuationToIgnored374(true);
  5324. } else if (typeof a === 'string') {
  5325. const videoPlayingId = videoPlayingY.videoId;
  5326.  
  5327. // if(mjtNextMainKey === true) mjtNextMainKey = a;
  5328.  
  5329. let update21 = !!pageSetupVideoId;
  5330. if (mpKey22 === a && mpUrl22 === videoPlayingId && mpUrl22 && videoPlayingId && (!pageSetupVideoId || pageSetupVideoId === videoPlayingId)) {
  5331. update21 = true;
  5332. } else if (mpKey22 === a && mpUrl22 !== pageSetupVideoId) {
  5333. LOG_FETCHMETA_UPDATE && continuationLog(mpKey22, '5060 mpUrl22 mismatched', mpKey22, mpUrl22, pageSetupVideoId || '(null)', videoPlayingId || '(null)');
  5334. return;
  5335. }
  5336. if (update21) {
  5337. mpKey21 = a;
  5338. mpUrl21 = pageSetupVideoId || videoPlayingId;
  5339. }
  5340.  
  5341. if (!mfvContinuationRecorded.has(a)) mfvContinuationRecorded.add(a);
  5342. }
  5343. LOG_FETCHMETA_UPDATE && continuationLog(a, '5180 fetchUpdatedMetadata\t', a, pageSetupVideoId || '(null)', videoPlayingY.videoId || '(null)');
  5344. // if (!pageSetupVideoId && typeof a === 'string' && a.length > 40) return; // ignore incorrect continuation
  5345. // if(a === mjtNextMainKey) allowNoDelay322 = false;
  5346. return this.fetchUpdatedMetadata718(a);
  5347.  
  5348. } catch (e) {
  5349. console.log('Code Error in fetchUpdatedMetadata', e);
  5350. }
  5351. return this.fetchUpdatedMetadata717(a)
  5352. }
  5353. }
  5354.  
  5355.  
  5356. if (typeof cProto.scheduleInitialUpdatedMetadataRequest === 'function' && cProto.scheduleInitialUpdatedMetadataRequest.length === 0 && !cProto.scheduleInitialUpdatedMetadataRequest717) {
  5357. // console.log(1234, cProto, cProto.is)
  5358. cProto.scheduleInitialUpdatedMetadataRequest717 = cProto.scheduleInitialUpdatedMetadataRequest;
  5359. let mJob = null;
  5360.  
  5361. cProto.scheduleInitialUpdatedMetadataRequest = function () {
  5362.  
  5363. try {
  5364.  
  5365. if (arguments.length > 0) {
  5366. console.warn("CAUTION: scheduleInitialUpdatedMetadataRequest coding might have to be updated.");
  5367. }
  5368. // mfy = mfv;
  5369.  
  5370. // mjtNextMainKey = '';
  5371. mtzlastAllowedContinuation = '';
  5372. mtzCount = 0;
  5373. if (mbCId322) {
  5374. clearTimeout(mbCId322);
  5375. mbCId322 = 0;
  5376. }
  5377. mbDelayBelowNCalls = 0;
  5378. // allowNoDelay322 = false;
  5379. copyPreviousContiuationToIgnored374(true);
  5380.  
  5381. const taskMgr = this.__getEmittorTaskMgr859__();
  5382. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714 && taskMgr.addJob && taskMgr.cancelJob) setup_ytTaskEmitterBehavior_TaskMgr374(taskMgr);
  5383. if (FIX_avoid_incorrect_video_meta_emitterBehavior && taskMgr && !taskMgr.addJob714) {
  5384. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 507');
  5385. }
  5386.  
  5387. // prevent depulicated schedule job by clearing previous JobId
  5388. if (taskMgr && typeof taskMgr.addLowPriorityJob === 'function' && taskMgr.addLowPriorityJob.length === 2 && typeof taskMgr.cancelJob === 'function' && taskMgr.cancelJob.length === 1) {
  5389.  
  5390. let res;
  5391.  
  5392. if (mJob) {
  5393. const job = mJob;
  5394. mJob = null;
  5395. console.log('cancelJob', job)
  5396. taskMgr.cancelJob(job); // clear previous [Interval Meta Update] job
  5397. // p.cancelJob(a,b);
  5398. }
  5399.  
  5400. // const updatedMetadataEndpoint = this.data?.updatedMetadataEndpoint?.updatedMetadataEndpoint
  5401.  
  5402. let pza = taskMgr.__lastJobId863__;
  5403. try { res = this.scheduleInitialUpdatedMetadataRequest717(); } catch (e) { }
  5404. let pzb = taskMgr.__lastJobId863__
  5405. if (pza !== pzb) {
  5406. mJob = pzb; // set [Interval Meta Update] jobId
  5407. }
  5408.  
  5409. // if (updatedMetadataEndpoint && updatedMetadataEndpoint.videoId) {
  5410. // mtxVideoId = updatedMetadataEndpoint.videoId || ''; // set the current target VideoId
  5411. // } else {
  5412. // mtxVideoId = ''; // sometimes updatedMetadataEndpoint is not ready
  5413. // }
  5414.  
  5415. return res;
  5416.  
  5417. } else {
  5418. console.log('[yt-js-engine-tamer]', 'scheduleInitialUpdatedMetadataRequest error 601');
  5419. }
  5420.  
  5421. } catch (e) {
  5422. console.log('Code Error in scheduleInitialUpdatedMetadataRequest', e);
  5423. }
  5424.  
  5425.  
  5426. return this.scheduleInitialUpdatedMetadataRequest717();
  5427. }
  5428. }
  5429.  
  5430.  
  5431. });
  5432.  
  5433. FIX_avoid_incorrect_video_meta_bool && promiseForYtActionCalled.then((ytAppDom) => {
  5434. let dummy;
  5435. let cProto;
  5436. dummy = ytAppDom;
  5437. if (!(dummy instanceof Element)) return;
  5438. cProto = insp(dummy).constructor.prototype;
  5439. if (typeof cProto.sendServiceAjax_ === 'function' && cProto.sendServiceAjax_.length === 4 && !cProto.sendServiceAjax717_) {
  5440. // console.log(1234, cProto, cProto.is);
  5441. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  5442. // cProto.handleServiceRequest_ = function (a, b, c, d) {
  5443. // console.log(123401, arguments);
  5444. // return this.handleServiceRequest717_(a, b, c, d);
  5445. // }
  5446.  
  5447. // cProto.handleServiceRequest717_ = cProto.handleServiceRequest_;
  5448.  
  5449. // cProto.handleServiceRequest_ = function(a,b,c,d){
  5450. // console.log(59901, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  5451. // if(a?.is === 'ytd-video-primary-info-renderer' && b?.updatedMetadataEndpoint?.videoId && c?.continuation && typeof c?.continuation ==='string'){
  5452. // console.log('mfv', c.continuation);
  5453. // mfv.add( c.continuation);
  5454. // }
  5455. // return this.handleServiceRequest717_(a,b,c,d);
  5456. // }
  5457.  
  5458. function extraArguments322(a, b, c) {
  5459. let is = (a || 0).is;
  5460. let videoId = ((b || 0).updatedMetadataEndpoint || 0).videoId;
  5461. let continuation = (c || 0).continuation;
  5462. if (typeof is !== 'string') is = null;
  5463. if (typeof videoId !== 'string') videoId = null;
  5464. if (typeof continuation !== 'string') continuation = null;
  5465. return { is, videoId, continuation };
  5466. }
  5467.  
  5468. cProto.sendServiceAjax717_ = cProto.sendServiceAjax_;
  5469. cProto.sendServiceAjax_ = function (a, b, c, d) {
  5470.  
  5471. // console.log(8001)
  5472. try {
  5473.  
  5474. const { is, videoId, continuation } = extraArguments322(a, b, c);
  5475.  
  5476. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  5477. console.warn("CAUTION: sendServiceAjax_ coding might have to be updated.");
  5478. }
  5479.  
  5480. if (pageSetupVideoId && videoId && continuation) {
  5481. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  5482. mfyContinuationIgnored.removeAdd(continuation);
  5483. mfvContinuationRecorded.delete(continuation);
  5484. return;
  5485. }
  5486. }
  5487.  
  5488. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  5489. copyPreviousContiuationToIgnored374(false);
  5490. mfyContinuationIgnored.delete(continuation);
  5491. mfvContinuationRecorded.removeAdd(continuation);
  5492. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  5493. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  5494. mjtLockPreviousKey = '';
  5495. }
  5496. // if (mjtNextMainKey === continuation) {
  5497. // copyPreviousContiuationToIgnored(false);
  5498. // mfyContinuationIgnored.delete(continuation);
  5499. // mfvContinuationRecorded.add(continuation);
  5500. // }
  5501.  
  5502.  
  5503. if (mfyContinuationIgnored && continuation) {
  5504. if (mfyContinuationIgnored.has(continuation)) {
  5505. LOG_FETCHMETA_UPDATE && continuationLog(continuation, '5260 matched01', continuation)
  5506. return;
  5507. }
  5508. }
  5509.  
  5510. // console.log(59902, a?.is, b,c,d)
  5511. // console.log(59903, a?.is, b?.updatedMetadataEndpoint?.videoId, c?.continuation)
  5512. if (is === 'ytd-video-primary-info-renderer' && videoId && continuation && !mfvContinuationRecorded.has(continuation)) {
  5513. // console.log('mfv377', continuation);
  5514. mfvContinuationRecorded.add(continuation);
  5515. }
  5516.  
  5517. // if (videoId) {
  5518. // if (!pageSetupVideoId) return; // ignore page not ready
  5519. // // if (mtxVideoId && b.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  5520. // if (videoId !== pageSetupVideoId) {
  5521. // return;
  5522. // }
  5523. // }
  5524.  
  5525. } catch (e) {
  5526. console.log('Coding Error in sendServiceAjax_', e)
  5527. }
  5528. // console.log(8002)
  5529. // console.log(123402, arguments);
  5530. // console.log(5162, 'a',a?.is,'b',b,'c',c,'d',d);
  5531.  
  5532. // console.log(5211, b?.updatedMetadataEndpoint?.kdkw33);
  5533. // if(b &&b.updatedMetadataEndpoint && !b.updatedMetadataEndpoint.kdkw33){
  5534. // b.updatedMetadataEndpoint = new Proxy(b.updatedMetadataEndpoint, {
  5535. // get(target, prop, receiver){
  5536. // console.log('xxs99', target.videoId, mtx)
  5537. // if(prop ==='kdkw33') return 1;
  5538. // console.log(3322, prop, target)
  5539. // if(prop === 'initialDelayMs') {
  5540. // throw new Error("ABCC");
  5541. // }
  5542. // return target[prop];
  5543. // },
  5544. // set(target, prop, value, receiver){
  5545.  
  5546. // if(prop ==='kdkw33') return true;
  5547. // target[prop]=value;
  5548. // return true;
  5549. // }
  5550. // });
  5551. // }
  5552. // console.log(5533, b?.updatedMetadataEndpoint?.kdkw33)
  5553. return this.sendServiceAjax717_(a, b, c, d);
  5554. }
  5555. }
  5556.  
  5557. function delayClearOtherKeys(lztContinuation) {
  5558. // // schedule delayed removal if mfyContinuationIgnored is not empty
  5559. // getRafPromise().then(() => {
  5560. // // assume the repeat continuation could be only for popstate which is triggered by user interaction
  5561. // // foreground page only
  5562.  
  5563. // });
  5564.  
  5565.  
  5566. if (lztContinuation !== mtzlastAllowedContinuation) return;
  5567. if (lztContinuation !== mpKey21 || lztContinuation !== mpKey22) return;
  5568. if (!mfyContinuationIgnored.size) return;
  5569. if (mfyContinuationIgnored.size > 1) {
  5570. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, 'delayClearOtherKeys, current = ', lztContinuation);
  5571. }
  5572. mfyContinuationIgnored.forEach((value, key) => {
  5573. if (key !== lztContinuation) {
  5574. mfyContinuationIgnored.delete(key);
  5575. LOG_FETCHMETA_UPDATE && continuationLog(key, 'previous continuation removed from ignored store', key);
  5576. }
  5577. });
  5578.  
  5579. }
  5580. if (typeof cProto.getCancellableNetworkPromise_ === 'function' && cProto.getCancellableNetworkPromise_.length === 5 && !cProto.getCancellableNetworkPromise717_) {
  5581. cProto.getCancellableNetworkPromise717_ = cProto.getCancellableNetworkPromise_;
  5582. cProto.getCancellableNetworkPromise_ = function (a, b, c, d, e) {
  5583.  
  5584. // console.log(8003)
  5585. try {
  5586.  
  5587.  
  5588. const { is, videoId, continuation } = extraArguments322(b, c, d);
  5589.  
  5590. if ((videoId || continuation) && (is !== 'ytd-video-primary-info-renderer')) {
  5591. console.warn("CAUTION: getCancellableNetworkPromise_ coding might have to be updated.");
  5592. }
  5593.  
  5594. if (pageSetupVideoId && videoId && continuation) {
  5595. if (mpKey21 && mpUrl21 && mpKey21 === continuation && mpUrl21 !== pageSetupVideoId) {
  5596. mfyContinuationIgnored.removeAdd(continuation);
  5597. mfvContinuationRecorded.delete(continuation);
  5598. return;
  5599. }
  5600. }
  5601.  
  5602. if (mjtLockPreviousKey && mjtLockPreviousKey !== continuation && continuation) {
  5603. copyPreviousContiuationToIgnored374(false);
  5604. mfyContinuationIgnored.delete(continuation);
  5605. mfvContinuationRecorded.removeAdd(continuation);
  5606. mfyContinuationIgnored.removeAdd(mjtLockPreviousKey);
  5607. mfvContinuationRecorded.delete(mjtLockPreviousKey);
  5608. mjtLockPreviousKey = '';
  5609. }
  5610.  
  5611. // if (mjtNextMainKey === continuation) {
  5612. // copyPreviousContiuationToIgnored(false);
  5613. // mfyContinuationIgnored.delete(continuation);
  5614. // mfvContinuationRecorded.add(continuation);
  5615. // }
  5616.  
  5617. const lztContinuation = continuation;
  5618.  
  5619. if (mfyContinuationIgnored && lztContinuation && typeof lztContinuation === 'string') {
  5620. if (mfyContinuationIgnored.has(lztContinuation)) {
  5621. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5360 matched02', lztContinuation)
  5622. return;
  5623. }
  5624. }
  5625.  
  5626. // if (videoId) {
  5627. // if (!pageSetupVideoId) return; // ignore page not ready
  5628. // // if (mtxVideoId && c.updatedMetadataEndpoint.videoId !== mtxVideoId) return; // ignore videoID not matched
  5629. // if (videoId !== pageSetupVideoId) {
  5630. // return;
  5631. // }
  5632. // }
  5633.  
  5634. if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation !== lztContinuation) {
  5635. mtzlastAllowedContinuation = lztContinuation;
  5636. // console.log(70401, lztContinuation, mfyContinuationIgnored.size)
  5637.  
  5638. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5382 Continuation sets to\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  5639. mjtRecordedPrevKey = lztContinuation;
  5640. if (mjtLockPreviousKey === lztContinuation) mjtLockPreviousKey = '';
  5641. // if (mfyContinuationIgnored.size > 0) {
  5642. // delayClearOtherKeys(lztContinuation);
  5643. // }
  5644. mtzCount = 0;
  5645. // allowNoDelay322 = false;
  5646. } else if (typeof lztContinuation === 'string' && mtzlastAllowedContinuation && mtzlastAllowedContinuation === lztContinuation) {
  5647. // repeated
  5648. if (mtzCount > 1e9) mtzCount = 1e4;
  5649. ++mtzCount;
  5650. LOG_FETCHMETA_UPDATE && continuationLog(lztContinuation, '5386 Same Continuation\t\t', lztContinuation, `C${mtzCount}.R${mfvContinuationRecorded.size}.I${mfyContinuationIgnored.size}`);
  5651.  
  5652. // if (mtzCount >= 3) allowNoDelay322 = true;
  5653. if (mtzCount >= 3 && mfyContinuationIgnored.size > 0) {
  5654. Promise.resolve(lztContinuation).then(delayClearOtherKeys).catch(console.warn);
  5655. }
  5656. if (mtzCount === 5) {
  5657. mfvContinuationRecorded.clear();
  5658. mfvContinuationRecorded.add(lztContinuation);
  5659. }
  5660.  
  5661. }
  5662.  
  5663. if (typeof lztContinuation === 'string' && lztContinuation && (pageSetupVideoId || videoPlayingY.videoId)) {
  5664. mpKey22 = lztContinuation;
  5665. mpUrl22 = pageSetupVideoId || videoPlayingY.videoId;
  5666. }
  5667.  
  5668. if (mbCId322) {
  5669. clearTimeout(mbCId322);
  5670. mbCId322 = 0;
  5671. }
  5672. } catch (e) {
  5673. console.log('Coding Error in getCancellableNetworkPromise_', e)
  5674. }
  5675.  
  5676. // console.log(8004)
  5677. // console.log(123403, arguments);
  5678. // if(c.updatedMetadataEndpoint) console.log(123404, pageSetupVideoId, JSON.stringify(c.updatedMetadataEndpoint))
  5679.  
  5680. // console.log(5163, a?.is,b,c,d,e);
  5681. return this.getCancellableNetworkPromise717_(a, b, c, d, e);
  5682. }
  5683. }
  5684. });
  5685.  
  5686. // ==================================== FIX_avoid_incorrect_video_meta ====================================
  5687.  
  5688.  
  5689. FIX_ytdExpander_childrenChanged && whenCEDefined('ytd-expander').then(() => {
  5690.  
  5691. let dummy;
  5692. let cProto;
  5693.  
  5694. dummy = document.createElement('ytd-expander');
  5695. cProto = insp(dummy).constructor.prototype;
  5696.  
  5697. if (fnIntegrity(cProto.initChildrenObserver, '0.48.21') && fnIntegrity(cProto.childrenChanged, '0.40.22')) {
  5698.  
  5699. cProto.initChildrenObserver14 = cProto.initChildrenObserver;
  5700. cProto.childrenChanged14 = cProto.childrenChanged;
  5701.  
  5702. cProto.initChildrenObserver = function () {
  5703. var a = this;
  5704. this.observer = new MutationObserver(function () {
  5705. a.childrenChanged()
  5706. }
  5707. );
  5708. this.observer.observe(this.content, {
  5709. subtree: !0,
  5710. childList: !0,
  5711. attributes: !0,
  5712. characterData: !0
  5713. });
  5714. this.childrenChanged()
  5715. }
  5716. ;
  5717. cProto.childrenChanged = function () {
  5718. if (this.alwaysToggleable) {
  5719. this.canToggle = this.alwaysToggleable;
  5720. } else if (!this.canToggleJobId) {
  5721. this.canToggleJobId = 1;
  5722. getRafPromise().then(() => {
  5723. this.canToggleJobId = 0;
  5724. this.calculateCanCollapse()
  5725. })
  5726. }
  5727. }
  5728.  
  5729. // console.log(cProto.initChildrenObserver)
  5730. console.debug('ytd-expander-fix-childrenChanged');
  5731.  
  5732. }
  5733.  
  5734. });
  5735.  
  5736.  
  5737. FIX_paper_ripple_animate && whenCEDefined('paper-ripple').then(() => {
  5738.  
  5739. let dummy;
  5740. let cProto;
  5741. dummy = document.createElement('paper-ripple');
  5742. cProto = insp(dummy).constructor.prototype;
  5743.  
  5744. if (fnIntegrity(cProto.animate, '0.74.5')) {
  5745.  
  5746.  
  5747. cProto.animate34 = cProto.animate;
  5748. cProto.animate = function () {
  5749. if (this._animating) {
  5750. var a;
  5751. const ripples = this.ripples;
  5752. for (a = 0; a < ripples.length; ++a) {
  5753. var b = ripples[a];
  5754. b.draw();
  5755. this.$.background.style.opacity = b.outerOpacity;
  5756. b.isOpacityFullyDecayed && !b.isRestingAtMaxRadius && this.removeRipple(b)
  5757. }
  5758. if ((this.shouldKeepAnimating || 0) !== ripples.length) {
  5759. if (!this._boundAnimate38) this._boundAnimate38 = this.animate.bind(this);
  5760. getRafPromise().then(this._boundAnimate38);
  5761. } else {
  5762. this.onAnimationComplete()
  5763. }
  5764. }
  5765. }
  5766.  
  5767. console.debug('FIX_paper_ripple_animate')
  5768.  
  5769. // console.log(cProto.animate)
  5770.  
  5771. }
  5772.  
  5773. });
  5774.  
  5775. if (FIX_doIdomRender) {
  5776.  
  5777. const xsetTimeout = function (f, d) {
  5778. if (xsetTimeout.m511 === 1 && !d) {
  5779. xsetTimeout.m511 = 2;
  5780. getRafPromise().then(f);
  5781. } else {
  5782. return setTimeout.apply(window, arguments)
  5783. }
  5784.  
  5785. }
  5786.  
  5787. const xrequestAnimationFrame = function (f) {
  5788. const h = f + "";
  5789. if (h.startsWith("function(){setTimeout(function(){") && h.endsWith("})}")) {
  5790. xsetTimeout.m511 = 1;
  5791. f();
  5792. xsetTimeout.m511 = 0;
  5793. } else if (h.includes("requestAninmationFrameResolver")) {
  5794. getRafPromise().then(f);
  5795. } else {
  5796. return requestAnimationFrame.apply(window, arguments);
  5797. }
  5798. }
  5799.  
  5800. let busy = false;
  5801. const doIdomRender = function () {
  5802. if (busy) {
  5803. return this.doIdomRender13.apply(this, arguments);
  5804. }
  5805. busy = true;
  5806. const { requestAnimationFrame, setTimeout } = window;
  5807. window.requestAnimationFrame = xrequestAnimationFrame;
  5808. window.setTimeout = xsetTimeout;
  5809. let r = this.doIdomRender13.apply(this, arguments);
  5810. window.requestAnimationFrame = requestAnimationFrame;
  5811. window.setTimeout = setTimeout;
  5812. busy = false;
  5813. return r;
  5814. };
  5815. 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']) {
  5816.  
  5817.  
  5818. whenCEDefined(ytTag).then(() => {
  5819.  
  5820. let dummy;
  5821. let cProto;
  5822. dummy = document.createElement(ytTag);
  5823. cProto = insp(dummy).constructor.prototype;
  5824.  
  5825. cProto.doIdomRender13 = cProto.doIdomRender;
  5826. cProto.doIdomRender = doIdomRender;
  5827.  
  5828. if (cProto.doIdomRender13 === cProto.templatingFn) cProto.templatingFn = doIdomRender;
  5829.  
  5830. console.debug('FIX_doIdomRender', ytTag)
  5831.  
  5832.  
  5833.  
  5834. });
  5835.  
  5836. }
  5837.  
  5838. }
  5839.  
  5840.  
  5841.  
  5842. });
  5843.  
  5844. });
  5845.  
  5846.  
  5847.  
  5848.  
  5849. if (isMainWindow) {
  5850.  
  5851. console.groupCollapsed(
  5852. "%cYouTube JS Engine Tamer",
  5853. "background-color: #EDE43B ; color: #000 ; font-weight: bold ; padding: 4px ;"
  5854. );
  5855.  
  5856.  
  5857.  
  5858. console.log("Script is loaded.");
  5859. console.log("This script changes the core mechanisms of the YouTube JS engine.");
  5860.  
  5861. console.log("This script is experimental and subject to further changes.");
  5862.  
  5863. console.log("This might boost your YouTube performance.");
  5864.  
  5865. console.log("CAUTION: This might break your YouTube.");
  5866.  
  5867.  
  5868. if (prepareLogs.length >= 1) {
  5869. console.log(" =========================================================================== ");
  5870.  
  5871. for (const msg of prepareLogs) {
  5872. console.log(msg)
  5873. }
  5874.  
  5875. console.log(" =========================================================================== ");
  5876. }
  5877.  
  5878. console.groupEnd();
  5879.  
  5880. }
  5881.  
  5882.  
  5883.  
  5884. })();