YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

当前为 2023-12-09 提交的版本,查看 最新版本

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