YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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