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