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