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