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