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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址