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