YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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