YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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