YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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