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.33
  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. const WEAK_REF_PROXY_DOLLAR = true; // false if your browser is slow
  59. // << end >>
  60.  
  61.  
  62.  
  63. /*
  64. window.addEventListener('edm',()=>{
  65. let p = [...this.onerror.errorTokens][0].token; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  66. });
  67.  
  68. window.addEventListener('edn',()=>{
  69. let p = [...this.onerror.errorTokens][0].token+"X"; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  70. });
  71. window.addEventListener('edr',()=>{
  72. let p = '123'; (()=>{ console.log(p); throw new Error(p);console.log(334,p) })()
  73. });
  74. */
  75.  
  76.  
  77. const win = this instanceof Window ? this : window;
  78.  
  79. // Create a unique key for the script and check if it is already running
  80. const hkey_script = 'jswylcojvzts';
  81. if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  82. win[hkey_script] = true;
  83.  
  84.  
  85.  
  86.  
  87. let p59 = 0;
  88.  
  89. const Promise = (async () => { })().constructor;
  90.  
  91. const PromiseExternal = ((resolve_, reject_) => {
  92. const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
  93. return class PromiseExternal extends Promise {
  94. constructor(cb = h) {
  95. super(cb);
  96. if (cb === h) {
  97. /** @type {(value: any) => void} */
  98. this.resolve = resolve_;
  99. /** @type {(reason?: any) => void} */
  100. this.reject = reject_;
  101. }
  102. }
  103. };
  104. })();
  105.  
  106.  
  107. let pf31 = new PromiseExternal();
  108.  
  109. // native RAF
  110. let __requestAnimationFrame__ = typeof webkitRequestAnimationFrame === 'function' ? window.webkitRequestAnimationFrame.bind(window) : window.requestAnimationFrame.bind(window);
  111.  
  112. // 1st wrapped RAF
  113. const baseRAF = (callback) => {
  114. return p59 ? __requestAnimationFrame__(callback) : __requestAnimationFrame__((hRes) => {
  115. pf31.then(() => {
  116. callback(hRes);
  117. });
  118. });
  119. };
  120.  
  121. // 2nd wrapped RAF
  122. window.requestAnimationFrame = baseRAF;
  123.  
  124. const insp = o => o ? (o.polymerController || o.inst || o || 0) : (o || 0);
  125. const indr = o => insp(o).$ || o.$ || 0;
  126.  
  127. FIX_perfNow && (() => {
  128. let nowh = -1;
  129. const dtl = new DocumentTimeline();
  130. performance.now = performance.now16 = function () {
  131.  
  132. /**
  133. * Bug 1842437 - When attempting to go back on youtube.com, the content remains the same
  134. *
  135. * If consecutive session history entries had history.state.entryTime set to same value,
  136. * back button doesn't work as expected. The entryTime value is coming from performance.now()
  137. * and modifying its return value slightly to make sure two close consecutive calls don't
  138. * get the same result helped with resolving the issue.
  139. */
  140.  
  141. let t = nowh;
  142. let c = dtl.currentTime;
  143. return (nowh = (t + 1e-7 > c ? t + 1e-5 : c));
  144. }
  145. if (performance.now !== performance.now16) { // might not able to set in Firefox
  146. if (performance.now() === performance.now()) console.warn('performance.now() is not mono increasing.');
  147. }
  148. })();
  149.  
  150.  
  151.  
  152. const qm47 = Symbol();
  153. const qm57 = Symbol();
  154. const qm53 = Symbol();
  155. const qn53 = Symbol();
  156.  
  157.  
  158. const ump3 = new WeakMap();
  159.  
  160.  
  161. const setupD = typeof WeakRef !== 'undefined' ? (elm, s) => {
  162.  
  163. const z = `${s}72`;
  164.  
  165. if (s in elm) {
  166. // console.log(1162, elm[s], elm)
  167.  
  168. const p = elm[s];
  169.  
  170. delete elm[s];
  171.  
  172. Object.defineProperty(elm, s, {
  173. get() {
  174. return elm[z] ? elm[z].deref() : null;
  175. },
  176. set(nv) {
  177. elm[z] = nv ? new WeakRef(nv) : null;
  178. return true;
  179. },
  180. configurable: true,
  181. enumerable: true
  182.  
  183. });
  184.  
  185. elm[s] = p;
  186.  
  187.  
  188. }
  189. } : null;
  190.  
  191. const mxMap = new WeakMap();
  192.  
  193. const myMap = new WeakSet();
  194.  
  195. const setup$ = typeof WeakRef !== 'undefined' ? function (dh) {
  196.  
  197. const $ = dh.$;
  198.  
  199. // setupD(dh, '$');
  200.  
  201.  
  202. if (WEAK_REF_PROXY_DOLLAR && $ && typeof $ === 'object' && !dh.$ky37) {
  203.  
  204. dh.$ky37 = 1;
  205.  
  206. if (!myMap.has($)) {
  207.  
  208.  
  209.  
  210. for (const k of Object.keys($)) {
  211.  
  212. const v = $[k];
  213. if ($[k] instanceof Node) {
  214.  
  215. $[k] = new WeakRef($[k]);
  216.  
  217. }
  218.  
  219. }
  220.  
  221.  
  222.  
  223. dh.$ = mxMap.get($) || new Proxy($, {
  224. get(obj, prop) {
  225. const val = obj[prop];
  226. if (typeof (val || 0).deref === 'function') {
  227. return val.deref();
  228. }
  229. return val;
  230. },
  231. set(obj, prop, val) {
  232. if (val instanceof Node) {
  233. obj[prop] = new WeakRef(val);
  234. } else {
  235. obj[prop] = val;
  236. }
  237. return true;
  238. }
  239. });
  240.  
  241. mxMap.set($, dh.$);
  242. myMap.add(dh.$);
  243.  
  244. }
  245.  
  246.  
  247.  
  248.  
  249. }
  250.  
  251.  
  252. } : null;
  253.  
  254.  
  255. const setupDataHost = setupD && setup$ ? function (dh) {
  256.  
  257.  
  258. if (dh && typeof dh === 'object') {
  259.  
  260.  
  261. setupD(dh, 'hostElement');
  262. setupD(dh, 'parentComponent');
  263. setupD(dh, 'localVisibilityObserver_');
  264. setupD(dh, 'cachedProviderNode_');
  265.  
  266. setupD(dh, '__template');
  267. setupD(dh, '__templatizeOwner');
  268. setupD(dh, '__templateInfo');
  269.  
  270.  
  271. setupD(dh, 'root');
  272.  
  273.  
  274.  
  275. setup$(dh);
  276.  
  277. }
  278.  
  279. } : null;
  280.  
  281.  
  282. let delay300 = new PromiseExternal();
  283. setInterval(() => {
  284. delay300.resolve();
  285. delay300 = new PromiseExternal();
  286. }, 300);
  287.  
  288. const aDelay = async function () {
  289. await delay300.then();
  290. await delay300.then();
  291. }
  292.  
  293. const setupDiscreteTasks = (h, rb) => {
  294.  
  295. if (rb) {
  296. if (h.ky36) return;
  297. }
  298.  
  299. if (WEAK_REF_BINDING && !h.kz62 && setup$ && setupD && setupDataHost) {
  300. h.kz62 = 1;
  301.  
  302. //
  303.  
  304. setup$(h);
  305. const hostElement = h.hostElement;
  306.  
  307. if (hostElement !== h) {
  308.  
  309. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  310. setupD(h, s);
  311.  
  312. }
  313.  
  314. const dh = h.__dataHost;
  315.  
  316. setupDataHost(dh)
  317. }
  318.  
  319.  
  320.  
  321.  
  322. if (hostElement) {
  323.  
  324. for (const s of ['__dataHost', '__CE_shadowRoot', '__template', '__templatizeOwner']) {
  325. setupD(hostElement, s);
  326.  
  327. }
  328.  
  329. const dh = hostElement.__dataHost;
  330.  
  331. setupDataHost(dh)
  332.  
  333.  
  334.  
  335.  
  336. aDelay().then(() => {
  337. setupD(hostElement, '__CE_shadowRoot');
  338. });
  339.  
  340.  
  341. }
  342.  
  343.  
  344.  
  345. // });
  346.  
  347.  
  348.  
  349.  
  350.  
  351. }
  352.  
  353.  
  354.  
  355. if (typeof h.onYtRendererstamperFinished === 'function' && !(h.onYtRendererstamperFinished.km34)) {
  356. const f = h.onYtRendererstamperFinished;
  357. const g = ump3.get(f) || function () {
  358. if (this.updateChildVisibilityProperties && !this.markDirty) {
  359. return f.apply(this, arguments);
  360. }
  361. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  362. }
  363. ump3.set(f, g);
  364. g.km34 = 1;
  365. h.onYtRendererstamperFinished = g;
  366.  
  367. }
  368.  
  369.  
  370.  
  371.  
  372. if (typeof h.onYtUpdateDescriptionAction === 'function' && !(h.onYtUpdateDescriptionAction.km34)) {
  373. const f = h.onYtUpdateDescriptionAction;
  374. const g = ump3.get(f) || function (a) {
  375. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  376. }
  377. ump3.set(f, g);
  378. g.km34 = 1;
  379. h.onYtUpdateDescriptionAction = g;
  380.  
  381. }
  382.  
  383.  
  384.  
  385. if (typeof h.handleUpdateDescriptionAction === 'function' && !(h.handleUpdateDescriptionAction.km34)) {
  386. const f = h.handleUpdateDescriptionAction;
  387. const g = ump3.get(f) || function (a) {
  388. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  389. }
  390. ump3.set(f, g);
  391. g.km34 = 1;
  392. h.handleUpdateDescriptionAction = g;
  393.  
  394. }
  395.  
  396. if (typeof h.handleUpdateLiveChatPollAction === 'function' && !(h.handleUpdateLiveChatPollAction.km34)) {
  397. const f = h.handleUpdateLiveChatPollAction;
  398. const g = ump3.get(f) || function (a) {
  399. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  400. }
  401. ump3.set(f, g);
  402. g.km34 = 1;
  403. h.handleUpdateLiveChatPollAction = g;
  404.  
  405. }
  406.  
  407.  
  408.  
  409. /*
  410.  
  411.  
  412. if (typeof h.onYtAction_ === 'function' && !(h.onYtAction_.km34)) {
  413. const f = h.onYtAction_;
  414. const g = ump3.get(f) || function (a) {
  415. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  416. }
  417. ump3.set(f, g);
  418. g.km34 = 1;
  419. h.onYtAction_ = g;
  420.  
  421. }
  422.  
  423. */
  424.  
  425.  
  426.  
  427. if (typeof h.onTextChanged === 'function' && !(h.onTextChanged.km34)) {
  428. const f = h.onTextChanged;
  429. const g = ump3.get(f) || function () {
  430. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  431. }
  432. ump3.set(f, g);
  433. g.km34 = 1;
  434. h.onTextChanged = g;
  435.  
  436. }
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443. if (typeof h.onVideoDataChange === 'function' && !(h.onVideoDataChange.km34)) {
  444. const f = h.onVideoDataChange;
  445. const g = ump3.get(f) || function (a) {
  446. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  447. }
  448. ump3.set(f, g);
  449. g.km34 = 1;
  450. h.onVideoDataChange = g;
  451.  
  452. }
  453.  
  454.  
  455.  
  456.  
  457.  
  458. if (typeof h.onVideoDataChange_ === 'function' && !(h.onVideoDataChange_.km34)) {
  459. const f = h.onVideoDataChange_;
  460. const g = ump3.get(f) || function () {
  461. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  462. }
  463. ump3.set(f, g);
  464. g.km34 = 1;
  465. h.onVideoDataChange_ = g;
  466.  
  467. }
  468.  
  469.  
  470.  
  471.  
  472. if (typeof h.addTooltips === 'function' && !(h.addTooltips.km34)) {
  473.  
  474. const f = h.addTooltips;
  475. const g = ump3.get(f) || function () {
  476. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  477. }
  478. ump3.set(f, g);
  479. g.km34 = 1;
  480. h.addTooltips = g;
  481.  
  482. }
  483.  
  484.  
  485.  
  486.  
  487. if (typeof h.addTooltips_ === 'function' && !(h.addTooltips_.km34)) {
  488.  
  489. const f = h.addTooltips_;
  490. const g = ump3.get(f) || function () {
  491. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  492. }
  493. ump3.set(f, g);
  494. g.km34 = 1;
  495. h.addTooltips_ = g;
  496.  
  497. }
  498.  
  499.  
  500.  
  501. if (typeof h.updateRenderedElements === 'function' && !(h.updateRenderedElements.km34)) {
  502.  
  503. const f = h.updateRenderedElements;
  504. const g = ump3.get(f) || function () {
  505. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  506. }
  507. ump3.set(f, g);
  508. g.km34 = 1;
  509. h.updateRenderedElements = g;
  510.  
  511. }
  512.  
  513.  
  514.  
  515.  
  516. /*
  517. // buggy for yt-player-updated
  518. if (typeof h.startLoadingWatch === 'function' && !(h.startLoadingWatch.km34)) {
  519.  
  520. const f = h.startLoadingWatch;
  521. const g = ump3.get(f) || function () {
  522. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  523. }
  524. ump3.set(f, g);
  525. g.km34 = 1;
  526. h.startLoadingWatch = g;
  527.  
  528. }
  529. */
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543. if (typeof h.loadPage_ === 'function' && !(h.loadPage_.km34)) {
  544. const f = h.loadPage_;
  545. const g = ump3.get(f) || function (a) {
  546. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  547. }
  548. ump3.set(f, g);
  549. g.km34 = 1;
  550. h.loadPage_ = g;
  551.  
  552. }
  553. if (typeof h.updatePageData_ === 'function' && !(h.updatePageData_.km34)) {
  554. const f = h.updatePageData_;
  555. const g = ump3.get(f) || function (a) {
  556. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  557. }
  558. ump3.set(f, g);
  559. g.km34 = 1;
  560. h.updatePageData_ = g;
  561.  
  562. }
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572. if (typeof h.onFocus_ === 'function' && !(h.onFocus_.km34)) {
  573.  
  574. const f = h.onFocus_;
  575. const g = ump3.get(f) || function () {
  576. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  577. }
  578. ump3.set(f, g);
  579. g.km34 = 1;
  580. h.onFocus_ = g;
  581.  
  582. }
  583.  
  584. if (typeof h.onBlur_ === 'function' && !(h.onBlur_.km34)) {
  585.  
  586. const f = h.onBlur_;
  587. const g = ump3.get(f) || function () {
  588. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  589. }
  590. ump3.set(f, g);
  591. g.km34 = 1;
  592. h.onBlur_ = g;
  593.  
  594. }
  595.  
  596.  
  597. if (typeof h.buttonClassChanged_ === 'function' && !(h.buttonClassChanged_.km34)) {
  598.  
  599. const f = h.buttonClassChanged_;
  600. const g = ump3.get(f) || function (a, b) {
  601. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  602. }
  603. ump3.set(f, g);
  604. g.km34 = 1;
  605. h.buttonClassChanged_ = g;
  606.  
  607. }
  608.  
  609.  
  610. if (typeof h.buttonIconChanged_ === 'function' && !(h.buttonIconChanged_.km34)) {
  611.  
  612. const f = h.buttonIconChanged_;
  613. const g = ump3.get(f) || function (a) {
  614. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  615. }
  616. ump3.set(f, g);
  617. g.km34 = 1;
  618. h.buttonIconChanged_ = g;
  619.  
  620. }
  621.  
  622.  
  623. if (typeof h.dataChangedInBehavior_ === 'function' && !(h.dataChangedInBehavior_.km34)) {
  624.  
  625. const f = h.dataChangedInBehavior_;
  626. const g = ump3.get(f) || function () {
  627. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  628. }
  629. ump3.set(f, g);
  630. g.km34 = 1;
  631. h.dataChangedInBehavior_ = g;
  632.  
  633. }
  634.  
  635.  
  636.  
  637.  
  638.  
  639. if (typeof h.continuationsChanged_ === 'function' && !(h.continuationsChanged_.km34)) {
  640.  
  641. const f = h.continuationsChanged_;
  642. const g = ump3.get(f) || function () {
  643. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  644. }
  645. ump3.set(f, g);
  646. g.km34 = 1;
  647. h.continuationsChanged_ = g;
  648.  
  649. }
  650.  
  651.  
  652. if (typeof h.forceChatPoll_ === 'function' && !(h.forceChatPoll_.km34)) {
  653.  
  654. const f = h.forceChatPoll_;
  655. const g = ump3.get(f) || function (a) {
  656. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  657. }
  658. ump3.set(f, g);
  659. g.km34 = 1;
  660. h.forceChatPoll_ = g;
  661.  
  662. }
  663.  
  664.  
  665.  
  666. if (typeof h.onEndpointClick_ === 'function' && !(h.onEndpointClick_.km34)) {
  667.  
  668. const f = h.onEndpointClick_;
  669. const g = ump3.get(f) || function (a) {
  670. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  671. }
  672. ump3.set(f, g);
  673. g.km34 = 1;
  674. h.onEndpointClick_ = g;
  675.  
  676. }
  677.  
  678.  
  679. if (typeof h.onEndpointTap_ === 'function' && !(h.onEndpointTap_.km34)) {
  680.  
  681. const f = h.onEndpointTap_;
  682. const g = ump3.get(f) || function (a) {
  683. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  684. }
  685. ump3.set(f, g);
  686. g.km34 = 1;
  687. h.onEndpointTap_ = g;
  688.  
  689. }
  690.  
  691.  
  692. if (typeof h.handleClick_ === 'function' && !(h.handleClick_.km34)) {
  693.  
  694. const f = h.handleClick_;
  695. const g = ump3.get(f) || function (a, b) {
  696. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  697. }
  698. ump3.set(f, g);
  699. g.km34 = 1;
  700. h.handleClick_ = g;
  701.  
  702. }
  703.  
  704.  
  705.  
  706. // return;
  707.  
  708.  
  709.  
  710. if (typeof h.onReadyStateChange_ === 'function' && !(h.onReadyStateChange_.km34)) {
  711.  
  712. const f = h.onReadyStateChange_;
  713. const g = ump3.get(f) || function () {
  714. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  715. }
  716. ump3.set(f, g);
  717. g.km34 = 1;
  718. h.onReadyStateChange_ = g;
  719.  
  720. }
  721.  
  722. if (typeof h.onReadyStateChangeEntryPoint_ === 'function' && !(h.onReadyStateChangeEntryPoint_.km34)) {
  723.  
  724. const f = h.onReadyStateChangeEntryPoint_;
  725. const g = ump3.get(f) || function () {
  726. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  727. }
  728. ump3.set(f, g);
  729. g.km34 = 1;
  730. h.onReadyStateChangeEntryPoint_ = g;
  731.  
  732. }
  733.  
  734.  
  735. if (typeof h.readyStateChangeHandler_ === 'function' && !(h.readyStateChangeHandler_.km34)) {
  736.  
  737. const f = h.readyStateChangeHandler_;
  738. const g = ump3.get(f) || function (a) {
  739. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  740. }
  741. ump3.set(f, g);
  742. g.km34 = 1;
  743. h.readyStateChangeHandler_ = g;
  744.  
  745. }
  746.  
  747.  
  748.  
  749.  
  750. if (typeof h.xmlHttpHandler_ === 'function' && !(h.xmlHttpHandler_.km34)) {
  751.  
  752. const f = h.xmlHttpHandler_;
  753. const g = ump3.get(f) || function (a) {
  754. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  755. }
  756. ump3.set(f, g);
  757. g.km34 = 1;
  758. h.xmlHttpHandler_ = g;
  759.  
  760. }
  761.  
  762.  
  763. if (typeof h.executeCallbacks_ === 'function' && !(h.executeCallbacks_.km34)) {
  764.  
  765. const f = h.executeCallbacks_; // overloaded
  766. const g = ump3.get(f) || function (a) {
  767. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  768. }
  769. ump3.set(f, g);
  770. g.km34 = 1;
  771. h.executeCallbacks_ = g;
  772.  
  773. }
  774.  
  775.  
  776.  
  777. if (typeof h.handleInvalidationData_ === 'function' && !(h.handleInvalidationData_.km34)) {
  778.  
  779. const f = h.handleInvalidationData_;
  780. const g = ump3.get(f) || function (a, b) {
  781. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  782. }
  783. ump3.set(f, g);
  784. g.km34 = 1;
  785. h.handleInvalidationData_ = g;
  786.  
  787. }
  788.  
  789. if (typeof h.onInput_ === 'function' && !(h.onInput_.km34)) {
  790.  
  791. const f = h.onInput_;
  792. const g = ump3.get(f) || function () {
  793. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  794. }
  795. ump3.set(f, g);
  796. g.km34 = 1;
  797. h.onInput_ = g;
  798.  
  799. }
  800.  
  801.  
  802. if (typeof h.trigger_ === 'function' && !(h.trigger_.km34)) {
  803.  
  804. const f = h.trigger_;
  805. const g = ump3.get(f) || function (a) {
  806. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  807. }
  808. ump3.set(f, g);
  809. g.km34 = 1;
  810. h.trigger_ = g;
  811.  
  812. }
  813.  
  814.  
  815. if (typeof h.requestData_ === 'function' && !(h.requestData_.km34)) {
  816.  
  817. const f = h.requestData_;
  818. const g = ump3.get(f) || function (a) {
  819. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  820. }
  821. ump3.set(f, g);
  822. g.km34 = 1;
  823. h.requestData_ = g;
  824.  
  825. }
  826.  
  827. if (typeof h.onLoadReloadContinuation_ === 'function' && !(h.onLoadReloadContinuation_.km34)) {
  828.  
  829. const f = h.onLoadReloadContinuation_;
  830. const g = ump3.get(f) || function (a, b) {
  831. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  832. }
  833. ump3.set(f, g);
  834. g.km34 = 1;
  835. h.onLoadReloadContinuation_ = g;
  836.  
  837. }
  838.  
  839.  
  840.  
  841. if (typeof h.onLoadIncrementalContinuation_ === 'function' && !(h.onLoadIncrementalContinuation_.km34)) {
  842.  
  843. const f = h.onLoadIncrementalContinuation_;
  844. const g = ump3.get(f) || function (a, b) {
  845. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  846. }
  847. ump3.set(f, g);
  848. g.km34 = 1;
  849. h.onLoadIncrementalContinuation_ = g;
  850.  
  851. }
  852.  
  853. if (typeof h.onLoadSeekContinuation_ === 'function' && !(h.onLoadSeekContinuation_.km34)) {
  854.  
  855. const f = h.onLoadSeekContinuation_;
  856. const g = ump3.get(f) || function (a, b) {
  857. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  858. }
  859. ump3.set(f, g);
  860. g.km34 = 1;
  861. h.onLoadSeekContinuation_ = g;
  862.  
  863. }
  864. if (typeof h.onLoadReplayContinuation_ === 'function' && !(h.onLoadReplayContinuation_.km34)) {
  865.  
  866. const f = h.onLoadReplayContinuation_;
  867. const g = ump3.get(f) || function (a, b) {
  868. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  869. }
  870. ump3.set(f, g);
  871. g.km34 = 1;
  872. h.onLoadReplayContinuation_ = g;
  873.  
  874. }
  875. if (typeof h.onNavigate_ === 'function' && !(h.onNavigate_.km34)) {
  876.  
  877. const f = h.onNavigate_;
  878. const g = ump3.get(f) || function (a) {
  879. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  880. }
  881. ump3.set(f, g);
  882. g.km34 = 1;
  883. h.onNavigate_ = g;
  884.  
  885. }
  886.  
  887. /*
  888. if(typeof h.deferRenderStamperBinding_ ==='function' && !(h.deferRenderStamperBinding_.km34)){
  889.  
  890. const f = h.deferRenderStamperBinding_;
  891. const g = function(){
  892. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  893. }
  894. g.km34 = 1;
  895. h.deferRenderStamperBinding_ = g;
  896.  
  897. }
  898. */
  899.  
  900.  
  901.  
  902. if (typeof h.ytRendererBehaviorDataObserver_ === 'function' && !(h.ytRendererBehaviorDataObserver_.km34)) {
  903.  
  904. const f = h.ytRendererBehaviorDataObserver_;
  905. const g = ump3.get(f) || function () {
  906. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  907. }
  908. ump3.set(f, g);
  909. g.km34 = 1;
  910. h.ytRendererBehaviorDataObserver_ = g;
  911.  
  912. }
  913.  
  914. if (typeof h.ytRendererBehaviorTargetIdObserver_ === 'function' && !(h.ytRendererBehaviorTargetIdObserver_.km34)) {
  915.  
  916. const f = h.ytRendererBehaviorTargetIdObserver_;
  917. const g = ump3.get(f) || function () {
  918. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  919. }
  920. ump3.set(f, g);
  921. g.km34 = 1;
  922. h.ytRendererBehaviorTargetIdObserver_ = g;
  923.  
  924. }
  925.  
  926. if (typeof h.unregisterRenderer_ === 'function' && !(h.unregisterRenderer_.km34)) {
  927.  
  928. const f = h.unregisterRenderer_;
  929. const g = ump3.get(f) || function (a) {
  930. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  931. }
  932. ump3.set(f, g);
  933. g.km34 = 1;
  934. h.unregisterRenderer_ = g;
  935.  
  936. }
  937.  
  938.  
  939.  
  940. if (typeof h.textChanged_ === 'function' && !(h.textChanged_.km34)) {
  941.  
  942. const f = h.textChanged_;
  943. const g = ump3.get(f) || function (a) {
  944. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  945. }
  946. ump3.set(f, g);
  947. g.km34 = 1;
  948. h.textChanged_ = g;
  949.  
  950. }
  951.  
  952.  
  953.  
  954.  
  955. /*
  956. if(typeof h.stampDomArray_ ==='function' && !(h.stampDomArray_.km34)){
  957.  
  958. if( h.stampDomArray_.length === 6){
  959.  
  960. const f = h.stampDomArray_;
  961. const g = function(a,b,c,d,e,h){
  962. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  963. }
  964. g.km34 = 1;
  965. h.stampDomArray_ = g;
  966.  
  967. }else{
  968.  
  969.  
  970.  
  971. const f = h.stampDomArray_;
  972. const g = function(){
  973. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  974. }
  975. g.km34 = 1;
  976. h.stampDomArray_ = g;
  977. }
  978.  
  979.  
  980. }
  981. */
  982.  
  983. /*
  984. if(typeof h.stampDomArraySplices_ ==='function' && !(h.stampDomArraySplices_.km34)){
  985.  
  986. if(h.stampDomArraySplices_.length === 3){
  987.  
  988.  
  989.  
  990. const f = h.stampDomArraySplices_;
  991. const g = function(a,b,c){
  992. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  993. }
  994. g.km34 = 1;
  995. h.stampDomArraySplices_ = g;
  996.  
  997.  
  998. }else{
  999.  
  1000.  
  1001.  
  1002. const f = h.stampDomArraySplices_;
  1003. const g = function(){
  1004. Promise.resolve().then(()=>f.apply(this, arguments)).catch(console.log);;
  1005. }
  1006. g.km34 = 1;
  1007. h.stampDomArraySplices_ = g;
  1008.  
  1009.  
  1010. }
  1011.  
  1012. }
  1013. */
  1014.  
  1015.  
  1016.  
  1017.  
  1018. // RP.prototype.searchChanged_ = RP.prototype.searchChanged_;
  1019. // RP.prototype.skinToneChanged_ = RP.prototype.skinToneChanged_;
  1020. // RP.prototype.onEmojiHover_ = RP.prototype.onEmojiHover_;
  1021. // RP.prototype.onSelectCategory_ = RP.prototype.onSelectCategory_;
  1022. // RP.prototype.onShowEmojiVariantSelector = RP.prototype.onShowEmojiVariantSelector;
  1023. // RP.prototype.updateCategoriesAndPlaceholder_ = RP.prototype.updateCategoriesAndPlaceholder_;
  1024.  
  1025.  
  1026.  
  1027. if (typeof h.searchChanged_ === 'function' && !(h.searchChanged_.km34)) {
  1028.  
  1029. const f = h.searchChanged_;
  1030. const g = ump3.get(f) || function () {
  1031. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1032. }
  1033. ump3.set(f, g);
  1034. g.km34 = 1;
  1035. h.searchChanged_ = g;
  1036.  
  1037. }
  1038.  
  1039. if (typeof h.skinToneChanged_ === 'function' && !(h.skinToneChanged_.km34)) {
  1040.  
  1041. const f = h.skinToneChanged_;
  1042. const g = ump3.get(f) || function (a) {
  1043. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1044. }
  1045. ump3.set(f, g);
  1046. g.km34 = 1;
  1047. h.skinToneChanged_ = g;
  1048.  
  1049. }
  1050.  
  1051. if (typeof h.onEmojiHover_ === 'function' && !(h.onEmojiHover_.km34)) {
  1052.  
  1053. const f = h.onEmojiHover_;
  1054. const g = ump3.get(f) || function (a) {
  1055. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1056. }
  1057. ump3.set(f, g);
  1058. g.km34 = 1;
  1059. h.onEmojiHover_ = g;
  1060.  
  1061. }
  1062.  
  1063. if (typeof h.onSelectCategory_ === 'function' && !(h.onSelectCategory_.km34)) {
  1064.  
  1065. const f = h.onSelectCategory_;
  1066. const g = ump3.get(f) || function (a) {
  1067. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1068. }
  1069. ump3.set(f, g);
  1070. g.km34 = 1;
  1071. h.onSelectCategory_ = g;
  1072.  
  1073. }
  1074.  
  1075. if (typeof h.onShowEmojiVariantSelector === 'function' && !(h.onShowEmojiVariantSelector.km34)) {
  1076.  
  1077. const f = h.onShowEmojiVariantSelector;
  1078. const g = ump3.get(f) || function (a) {
  1079. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1080. }
  1081. ump3.set(f, g);
  1082. g.km34 = 1;
  1083. h.onShowEmojiVariantSelector = g;
  1084.  
  1085. }
  1086.  
  1087. if (typeof h.updateCategoriesAndPlaceholder_ === 'function' && !(h.updateCategoriesAndPlaceholder_.km34)) {
  1088.  
  1089. const f = h.updateCategoriesAndPlaceholder_;
  1090. const g = ump3.get(f) || function () {
  1091. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1092. }
  1093. ump3.set(f, g);
  1094. g.km34 = 1;
  1095. h.updateCategoriesAndPlaceholder_ = g;
  1096.  
  1097. }
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103. if (typeof h.watchPageActiveChanged_ === 'function' && !(h.watchPageActiveChanged_.km34)) {
  1104.  
  1105. const f = h.watchPageActiveChanged_;
  1106. const g = ump3.get(f) || function () {
  1107. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1108. }
  1109. ump3.set(f, g);
  1110. g.km34 = 1;
  1111. h.watchPageActiveChanged_ = g;
  1112.  
  1113. }
  1114.  
  1115.  
  1116. if (typeof h.activate_ === 'function' && !(h.activate_.km34)) {
  1117.  
  1118. const f = h.activate_;
  1119. const g = ump3.get(f) || function () {
  1120. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1121. }
  1122. ump3.set(f, g);
  1123. g.km34 = 1;
  1124. h.activate_ = g;
  1125.  
  1126. }
  1127. if (typeof h.onYtPlaylistDataUpdated_ === 'function' && !(h.onYtPlaylistDataUpdated_.km34)) {
  1128.  
  1129. const f = h.onYtPlaylistDataUpdated_;
  1130. const g = ump3.get(f) || function () {
  1131. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1132. }
  1133. ump3.set(f, g);
  1134. g.km34 = 1;
  1135. h.onYtPlaylistDataUpdated_ = g;
  1136.  
  1137. }
  1138.  
  1139.  
  1140.  
  1141. /// -----------------------
  1142.  
  1143.  
  1144. const isMainRenderer = (h) => {
  1145.  
  1146. if (h.is && h.$ && h.__dataEnabled && h.__dataReady && h.__shady && h.__templateInfo && h.root && h.hostElement) {
  1147.  
  1148. const q = (h.parentComponent ? 1 : 0) | (h.ytComponentBehavior ? 2 : 0);
  1149. if (q === 3) {
  1150. // chat renderer
  1151. if (h.is.endsWith('-renderer')) {
  1152. return true;
  1153. }
  1154. } else if (q === 0) {
  1155. // custom lyrics engagement panel
  1156. if (h.is.endsWith('-renderer')) {
  1157. return true;
  1158. }
  1159. } else if (q === 1) {
  1160. // input renderer
  1161. if (h.is.endsWith('-renderer')) {
  1162. return true;
  1163. }
  1164. }
  1165.  
  1166. }
  1167.  
  1168. return false;
  1169. /*
  1170. return (h.is === 'yt-live-chat-renderer') ||
  1171. (h.is === 'yt-live-chat-item-list-renderer') ||
  1172. (h.is === 'yt-live-chat-text-input-field-renderer') ||
  1173. 0;
  1174. */
  1175. }
  1176.  
  1177.  
  1178.  
  1179. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km31)) {
  1180.  
  1181.  
  1182.  
  1183.  
  1184. const f = h.rendererStamperApplyChangeRecord_;
  1185. h.rendererStamperApplyChangeRecord31_ = f;
  1186. const g = ump3.get(f) || function (a, b, c) {
  1187. if (isMainRenderer(this) || (this.updateChildVisibilityProperties && !this.markDirty)) {
  1188. let b = false;
  1189. if (!this.markDirty) {
  1190. b = true;
  1191. } else if (!this.localVisibilityObserver_) {
  1192. // b = false
  1193. } else if (!this.visibilityObserverForChild_ && !!this.getVisibilityObserverForChild) {
  1194. b = true;
  1195. }
  1196. if (b) {
  1197. return f.apply(this, arguments);
  1198. }
  1199. }
  1200.  
  1201. // sequence on the same proto
  1202. this[qm47] = (this[qm47] || Promise.resolve()).then(() => this.rendererStamperApplyChangeRecord31_(a, b, c)).catch(console.log);
  1203. }
  1204. ump3.set(f, g);
  1205. g.km31 = 1;
  1206. h.rendererStamperApplyChangeRecord_ = g;
  1207.  
  1208.  
  1209. }
  1210.  
  1211.  
  1212.  
  1213.  
  1214. /*
  1215. if (typeof h.rendererStamperObserver_ === 'function' && !(h.rendererStamperObserver_.km34)) {
  1216.  
  1217. const f = h.rendererStamperObserver_;
  1218. const g = ump3.get(f) || function (a, b, c) {
  1219. if (isMainRenderer(this)) {
  1220. return f.apply(this, arguments);
  1221. }
  1222. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1223. }
  1224. ump3.set(f, g);
  1225. g.km34 = 1;
  1226. h.rendererStamperObserver_ = g;
  1227.  
  1228. }
  1229.  
  1230.  
  1231. if (typeof h.rendererStamperApplyChangeRecord_ === 'function' && !(h.rendererStamperApplyChangeRecord_.km34)) {
  1232.  
  1233. const f = h.rendererStamperApplyChangeRecord_;
  1234. const g = ump3.get(f) || function () {
  1235. if (isMainRenderer(this)) {
  1236. return f.apply(this, arguments);
  1237. }
  1238. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1239. }
  1240. ump3.set(f, g);
  1241. g.km34 = 1;
  1242. h.rendererStamperApplyChangeRecord_ = g;
  1243.  
  1244. }
  1245.  
  1246.  
  1247.  
  1248. if (typeof h.flushRenderStamperComponentBindings_ === 'function' && !(h.flushRenderStamperComponentBindings_.km34)) {
  1249.  
  1250. const f = h.flushRenderStamperComponentBindings_;
  1251. const g = ump3.get(f) || function () {
  1252. if (isMainRenderer(this)) {
  1253. return f.apply(this, arguments);
  1254. }
  1255. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1256. }
  1257. ump3.set(f, g);
  1258. g.km34 = 1;
  1259. h.flushRenderStamperComponentBindings_ = g;
  1260.  
  1261. }
  1262.  
  1263.  
  1264. if (typeof h.forwardRendererStamperChanges_ === 'function' && !(h.forwardRendererStamperChanges_.km34)) {
  1265.  
  1266. const f = h.forwardRendererStamperChanges_;
  1267. const g = ump3.get(f) || function () {
  1268. if (isMainRenderer(this)) {
  1269. return f.apply(this, arguments);
  1270. }
  1271. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1272. }
  1273. ump3.set(f, g);
  1274. g.km34 = 1;
  1275. h.forwardRendererStamperChanges_ = g;
  1276.  
  1277. }
  1278. */
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284. // console.log(123)
  1285.  
  1286. // return;
  1287.  
  1288.  
  1289. /*
  1290.  
  1291. // buggy for page swtiching
  1292.  
  1293. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km31)) {
  1294.  
  1295.  
  1296.  
  1297.  
  1298. const f = h.dataChanged_;
  1299. h.dataChanged31_ = f;
  1300. const g = ump3.get(f) || function (...args) {
  1301.  
  1302. if (isMainRenderer(this)) {
  1303. return f.apply(this, arguments);
  1304. }
  1305.  
  1306. // sequence on the same proto
  1307. this[qm47] = (this[qm47] || Promise.resolve()).then(() => this.dataChanged31_(...args)).catch(console.log);
  1308. }
  1309. ump3.set(f, g);
  1310. g.km31 = 1;
  1311. h.dataChanged_ = g;
  1312.  
  1313.  
  1314. }
  1315. */
  1316.  
  1317.  
  1318. /*
  1319.  
  1320. if (typeof h.dataChanged_ === 'function' && !(h.dataChanged_.km34)) {
  1321.  
  1322. const f = h.dataChanged_;
  1323. const g = ump3.get(f) || function () {
  1324. if (isMainRenderer(this)) {
  1325. return f.apply(this, arguments);
  1326. }
  1327. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1328. }
  1329. ump3.set(f, g);
  1330. g.km34 = 1;
  1331. h.dataChanged_ = g;
  1332.  
  1333. }
  1334. */
  1335.  
  1336.  
  1337.  
  1338. if (typeof h.tryRenderChunk_ === 'function' && !(h.tryRenderChunk_.km34)) {
  1339.  
  1340. const f = h.tryRenderChunk_;
  1341. const g = ump3.get(f) || function () {
  1342. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1343. }
  1344. ump3.set(f, g);
  1345. g.km34 = 1;
  1346. h.tryRenderChunk_ = g;
  1347.  
  1348. }
  1349.  
  1350.  
  1351. if (typeof h.renderChunk_ === 'function' && !(h.renderChunk_.km34)) {
  1352.  
  1353. const f = h.renderChunk_;
  1354. const g = ump3.get(f) || function () {
  1355. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1356. }
  1357. ump3.set(f, g);
  1358. g.km34 = 1;
  1359. h.renderChunk_ = g;
  1360.  
  1361. }
  1362.  
  1363. if (typeof h.deepLazyListObserver_ === 'function' && !(h.deepLazyListObserver_.km34)) {
  1364.  
  1365. const f = h.deepLazyListObserver_;
  1366. const g = ump3.get(f) || function () {
  1367. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1368. }
  1369. ump3.set(f, g);
  1370. g.km34 = 1;
  1371. h.deepLazyListObserver_ = g;
  1372.  
  1373. }
  1374.  
  1375.  
  1376. if (typeof h.onItemsUpdated_ === 'function' && !(h.onItemsUpdated_.km34)) {
  1377.  
  1378. const f = h.onItemsUpdated_;
  1379. const g = ump3.get(f) || function () {
  1380. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1381. }
  1382. ump3.set(f, g);
  1383. g.km34 = 1;
  1384. h.onItemsUpdated_ = g;
  1385.  
  1386. }
  1387.  
  1388. /*
  1389. // see https://github.com/cyfung1031/userscript-supports/issues/20
  1390. if (typeof h.updateChangeRecord_ === 'function' && !(h.updateChangeRecord_.km34)) {
  1391.  
  1392. const f = h.updateChangeRecord_;
  1393. const g = ump3.get(f) || function () {
  1394. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1395. }
  1396. ump3.set(f, g);
  1397. g.km34 = 1;
  1398. h.updateChangeRecord_ = g;
  1399.  
  1400. }
  1401. */
  1402.  
  1403.  
  1404. if (typeof h.requestRenderChunk_ === 'function' && !(h.requestRenderChunk_.km34)) {
  1405.  
  1406. const f = h.requestRenderChunk_;
  1407. const g = ump3.get(f) || function () {
  1408. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1409. }
  1410. ump3.set(f, g);
  1411. g.km34 = 1;
  1412. h.requestRenderChunk_ = g;
  1413.  
  1414. }
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420. return;
  1421.  
  1422.  
  1423.  
  1424. /*
  1425. if (typeof h.cancelPendingTasks_ === 'function' && !(h.cancelPendingTasks_.km34)) {
  1426.  
  1427. const f = h.cancelPendingTasks_;
  1428. const g = ump3.get(f) || function () {
  1429. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1430. }
  1431. ump3.set(f, g);
  1432. g.km34 = 1;
  1433. h.cancelPendingTasks_ = g;
  1434.  
  1435. }
  1436.  
  1437.  
  1438. if (typeof h.fillRange_ === 'function' && !(h.fillRange_.km34)) {
  1439.  
  1440. const f = h.fillRange_;
  1441. const g = ump3.get(f) || function () {
  1442. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);
  1443. }
  1444. ump3.set(f, g);
  1445. g.km34 = 1;
  1446. h.fillRange_ = g;
  1447.  
  1448. }
  1449. */
  1450.  
  1451.  
  1452.  
  1453.  
  1454. if (typeof h.addTextNodes_ === 'function' && !(h.addTextNodes_.km34)) {
  1455.  
  1456. const f = h.addTextNodes_;
  1457. const g = function () {
  1458. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1459. }
  1460. g.km34 = 1;
  1461. h.addTextNodes_ = g;
  1462.  
  1463. }
  1464.  
  1465.  
  1466.  
  1467.  
  1468. if (typeof h.updateText_ === 'function' && !(h.updateText_.km34)) {
  1469.  
  1470. const f = h.updateText_;
  1471. const g = function () {
  1472. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1473. }
  1474. g.km34 = 1;
  1475. h.updateText_ = g;
  1476.  
  1477. }
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483. if (typeof h.stampTypeChanged_ === 'function' && !(h.stampTypeChanged_.km34)) {
  1484.  
  1485. const f = h.stampTypeChanged_;
  1486. const g = function () {
  1487. Promise.resolve().then(() => f.apply(this, arguments)).catch(console.log);;
  1488. }
  1489. g.km34 = 1;
  1490. h.stampTypeChanged_ = g;
  1491.  
  1492. }
  1493.  
  1494.  
  1495.  
  1496.  
  1497. // console.log(166)
  1498.  
  1499.  
  1500.  
  1501.  
  1502. }
  1503.  
  1504. const keyStConnectedCallback = Symbol(); // avoid copying the value
  1505.  
  1506. const keyStDisconnectedCallback = Symbol(); // avoid copying the value
  1507. const cmf = new WeakMap();
  1508. const dmf = new WeakMap();
  1509.  
  1510. const gvGenerator = (nv) => {
  1511. return function () {
  1512. const cnt = insp(this);
  1513. const hostElement = cnt.hostElement || 0;
  1514. const dollar = hostElement ? (this.$ || indr(this)) : 0;
  1515. let p = (hostElement instanceof HTMLElement) && (dollar || !this.is);
  1516. if (p && (!dollar && !this.is)) {
  1517. const nodeName = hostElement.nodeName;
  1518. if (typeof nodeName !== 'string') {
  1519. // just in case
  1520. } else if (nodeName.startsWith("DOM-")) {
  1521. // dom-if, dom-repeat, etc
  1522. } else {
  1523. // yt element - new model, yt-xxxx, anixxxxxx
  1524. p = false;
  1525. }
  1526. }
  1527. if (p) {
  1528. if (typeof cnt.markDirty === 'function') {
  1529. // the yt element might call markDirty (occasionally)
  1530. p = false;
  1531. } else if (this.is === 'ytd-engagement-panel-section-list-renderer') {
  1532. // see https://github.com/cyfung1031/userscript-supports/issues/20
  1533. p = false;
  1534. }
  1535. }
  1536. if (p) {
  1537.  
  1538. // << dom-repeat & dom-if >>
  1539.  
  1540. // sequence on the same instance
  1541. this[qm57] = (this[qm57] || Promise.resolve()).then(() => nv.apply(this, arguments)).catch(console.log);
  1542. } else {
  1543. nv.apply(this, arguments);
  1544. }
  1545. };
  1546. }
  1547.  
  1548. ENABLE_discreteTasking && Object.defineProperty(Object.prototype, 'connectedCallback', {
  1549. get() {
  1550. const f = this[keyStConnectedCallback];
  1551. if (this.is) {
  1552. setupDiscreteTasks(this, true);
  1553. if (f) this.ky36 = 1;
  1554. }
  1555. return f;
  1556. },
  1557. set(nv) {
  1558. let gv;
  1559. if (typeof nv === 'function') {
  1560.  
  1561. gv = cmf.get(nv) || gvGenerator(nv);
  1562. if (gv !== nv) {
  1563. cmf.set(nv, gv);
  1564. cmf.set(gv, gv);
  1565. dmf.set(gv, nv);
  1566. }
  1567.  
  1568. } else {
  1569. gv = nv;
  1570. }
  1571. this[keyStConnectedCallback] = gv; // proto or object
  1572. if (this.is) {
  1573. setupDiscreteTasks(this);
  1574. }
  1575. return true;
  1576. },
  1577. enumerable: false,
  1578. configurable: true
  1579.  
  1580. });
  1581.  
  1582. const pLoad = new Promise(resolve => {
  1583. if (document.readyState !== 'loading') {
  1584. resolve();
  1585. } else {
  1586. window.addEventListener("DOMContentLoaded", resolve, false);
  1587. }
  1588. });
  1589. pLoad.then(() => {
  1590.  
  1591. let nonce = document.querySelector('style[nonce]');
  1592. nonce = nonce ? nonce.getAttribute('nonce') : null;
  1593. const st = document.createElement('style');
  1594. if (typeof nonce === 'string') st.setAttribute('nonce', nonce);
  1595. st.textContent = "none-element-k47{order:0}";
  1596. st.addEventListener('load', () => {
  1597. pf31.resolve();
  1598. p59 = 1;
  1599. }, false);
  1600. document.body.appendChild(st);
  1601.  
  1602.  
  1603. // console.debug('90002', location.pathname)
  1604. // console.log(90000, location.pathname)
  1605.  
  1606. });
  1607.  
  1608. const prepareLogs = [];
  1609.  
  1610. const skipAdsDetection = new Set(['/robots.txt', '/live_chat', '/live_chat_replay']);
  1611.  
  1612. let winError00 = window.onerror;
  1613.  
  1614. let fix_error_many_stack_state = !FIX_error_many_stack ? 0 : skipAdsDetection.has(location.pathname) ? 2 : 1;
  1615.  
  1616. if (!JSON || !('parse' in JSON)) fix_error_many_stack_state = 0;
  1617.  
  1618. ; FIX_Iframe_NULL_SRC && (() => {
  1619.  
  1620. let emptyBlobUrl = URL.createObjectURL(new Blob([], { type: 'text/html' }));
  1621. const lcOpt = { sensitivity: 'base' };
  1622. document.createElement24 = document.createElement;
  1623. document.createElement = function (t) {
  1624. if (typeof t === 'string' && t.length === 6) {
  1625. if (t.localeCompare('iframe', undefined, lcOpt) === 0) {
  1626. let p = this.createElement24(t);
  1627. p.src = emptyBlobUrl; // avoid iframe is appended to DOM without any url
  1628. return p;
  1629. }
  1630. }
  1631. return this.createElement24.apply(this, arguments);
  1632. };
  1633.  
  1634. })();
  1635.  
  1636. ; fix_error_many_stack_state === 1 && (() => {
  1637.  
  1638.  
  1639. let p1 = winError00;
  1640.  
  1641. let stackNeedleDetails = null;
  1642.  
  1643. Object.defineProperty(Object.prototype, 'matchAll', {
  1644. get() {
  1645. stackNeedleDetails = this;
  1646. return true;
  1647. },
  1648. enumerable: true,
  1649. configurable: true
  1650. });
  1651.  
  1652. try {
  1653. JSON.parse("{}");
  1654. } catch (e) {
  1655. console.warn(e)
  1656. fix_error_many_stack_state = 0;
  1657. }
  1658.  
  1659. delete Object.prototype['matchAll'];
  1660.  
  1661. let p2 = window.onerror;
  1662.  
  1663. window.onerror = p1;
  1664.  
  1665. if (fix_error_many_stack_state === 0) return;
  1666.  
  1667. if (stackNeedleDetails) {
  1668. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  1669. stackNeedleDetails.matchAll = true;
  1670. }
  1671.  
  1672. if (p1 === p2) return (fix_error_many_stack_state = 0);
  1673.  
  1674. // p1!==p2
  1675. fix_error_many_stack_state = !stackNeedleDetails ? 4 : 3;
  1676.  
  1677. })();
  1678.  
  1679. ; fix_error_many_stack_state === 2 && (() => {
  1680.  
  1681.  
  1682. let p1 = winError00;
  1683.  
  1684. let objectPrune = null;
  1685. let stackNeedleDetails = null;
  1686.  
  1687. Object.defineProperty(Function.prototype, 'findOwner', {
  1688. get() {
  1689. objectPrune = this;
  1690. return this._findOwner;
  1691. },
  1692. set(nv) {
  1693. this._findOwner = nv;
  1694. return true;
  1695. },
  1696. enumerable: true,
  1697. configurable: true
  1698. });
  1699.  
  1700. Object.defineProperty(Object.prototype, 'matchAll', {
  1701. get() {
  1702. stackNeedleDetails = this;
  1703. return true;
  1704. },
  1705. enumerable: true,
  1706. configurable: true
  1707. });
  1708.  
  1709. try {
  1710. JSON.parse("{}");
  1711. } catch (e) {
  1712. console.warn(e)
  1713. fix_error_many_stack_state = 0;
  1714. }
  1715.  
  1716. delete Function.prototype['findOwner'];
  1717. delete Object.prototype['matchAll'];
  1718.  
  1719. let p2 = window.onerror;
  1720.  
  1721. if (p1 !== p2) return (fix_error_many_stack_state = 4); // p1 != p2
  1722.  
  1723. if (fix_error_many_stack_state == 0) return;
  1724.  
  1725. // the following will only execute when Brave's scriptlets.js is executed.
  1726.  
  1727. prepareLogs.push("fix_error_many_stack_state NB")
  1728.  
  1729. if (stackNeedleDetails) {
  1730. stackNeedleDetails.pattern = null;
  1731. stackNeedleDetails.re = null;
  1732. stackNeedleDetails.expect = null;
  1733. stackNeedleDetails.matchAll = true;
  1734. }
  1735.  
  1736. if (objectPrune) {
  1737. objectPrune.findOwner = objectPrune.mustProcess = objectPrune.logJson = () => { }
  1738. delete objectPrune._findOwner;
  1739. }
  1740.  
  1741. fix_error_many_stack_state = 3;
  1742. JSON.parse.stackNeedleDetails = stackNeedleDetails;
  1743. JSON.parse.objectPrune = objectPrune;
  1744.  
  1745. })();
  1746.  
  1747. ; fix_error_many_stack_state === 3 && (() => {
  1748.  
  1749.  
  1750. let p1 = winError00;
  1751.  
  1752. try {
  1753. JSON.parse("{}");
  1754. } catch (e) {
  1755. console.warn(e)
  1756. fix_error_many_stack_state = 0;
  1757. }
  1758.  
  1759. let p2 = window.onerror;
  1760.  
  1761. if (p1 === p2) return;
  1762.  
  1763. window.onerror = p1;
  1764.  
  1765. if (fix_error_many_stack_state === 0) return;
  1766.  
  1767. fix_error_many_stack_state = 4; // p1 != p2
  1768.  
  1769.  
  1770. })();
  1771.  
  1772. fix_error_many_stack_state === 4 && (() => {
  1773.  
  1774. // the following will only execute when Brave's scriptlets.js is executed.
  1775.  
  1776. prepareLogs.push("fix_error_many_stack_state AB")
  1777.  
  1778. JSON.parseProxy = JSON.parse;
  1779.  
  1780. JSON.parse = ((parse) => {
  1781.  
  1782. parse = parse.bind(JSON); // get a new instance of the current JSON.parse
  1783. return function (text, reviver) {
  1784. const onerror = window.onerror;
  1785. window.onerror = null;
  1786. let r;
  1787. try {
  1788. r = parse(...arguments);
  1789. } catch (e) {
  1790. r = e;
  1791. }
  1792. window.onerror = onerror;
  1793. if (r instanceof Error) {
  1794. throw r;
  1795. }
  1796. return r;
  1797. }
  1798.  
  1799. })(JSON.parse);
  1800.  
  1801.  
  1802. })();
  1803.  
  1804.  
  1805.  
  1806. // ================================================ 0.4.5 ================================================
  1807.  
  1808.  
  1809. // ; (() => {
  1810.  
  1811. // if (FIX_error_many_stack && self instanceof Window) {
  1812. // // infinite stack due to matchesStackTrace inside objectPrune of AdsBlock
  1813.  
  1814. // const pdK = Object.getOwnPropertyDescriptor(window, 'onerror');
  1815. // if (!pdK || (pdK.get && pdK.configurable)) {
  1816.  
  1817. // } else {
  1818. // return;
  1819. // }
  1820.  
  1821. // let unsupportErrorFix = false;
  1822.  
  1823. // let firstHook = true;
  1824. // let busy33 = false;
  1825.  
  1826. // let state = 0;
  1827.  
  1828. // if (pdK) {
  1829. // delete window['onerror'];
  1830. // }
  1831.  
  1832. // const pd = {
  1833. // get() {
  1834. // const stack = (new Error()).stack;
  1835. // // targetStack = stack;
  1836. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  1837. // state = isGetExceptionToken ? 1 : 0;
  1838. // delete Window.prototype['onerror'];
  1839. // let r = pdK ? pdK.get.call(this) : this.onerror;
  1840. // Object.defineProperty(Window.prototype, 'onerror', pd);
  1841. // // console.log('onerror get', r)
  1842. // return r;
  1843. // },
  1844. // set(nv) {
  1845. // const stack = (new Error()).stack;
  1846. // let isGetExceptionToken = stack.indexOf('getExceptionToken') >= 0;
  1847. // state = state === 1 && isGetExceptionToken ? 2 : 0;
  1848. // /** @type {string?} */
  1849. // let sToken = null;
  1850. // if (unsupportErrorFix || busy33) {
  1851.  
  1852. // } else if (typeof nv === 'function' && state === 2) {
  1853. // if (firstHook) {
  1854. // firstHook = false;
  1855. // console.groupCollapsed('Infinite onerror Bug Found');
  1856. // console.log(location.href);
  1857. // console.log(stack);
  1858. // console.log(nv);
  1859. // console.groupEnd();
  1860. // }
  1861. // let _token = null;
  1862. // busy33 = true;
  1863. // String.prototype.includes76 = String.prototype.includes;
  1864. // String.prototype.includes = function (token) {
  1865. // _token = token;
  1866. // return true;
  1867. // }
  1868. // nv('token');
  1869. // String.prototype.includes = String.prototype.includes76;
  1870. // sToken = _token;
  1871. // busy33 = false;
  1872. // if (typeof sToken !== 'string') {
  1873. // unsupportErrorFix = true;
  1874. // }
  1875. // }
  1876. // delete Window.prototype['onerror'];
  1877. // if (typeof sToken === 'string' && sToken.length > 1) {
  1878. // /** @type {string} */
  1879. // const token = sToken;
  1880. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>?} } */
  1881. // const currentOnerror = pdK ? pdK.get.call(this) : this.onerror;
  1882.  
  1883. // const now = Date.now();
  1884. // const tokenEntry = {
  1885. // token,
  1886. // expired: now + FIX_error_many_stack_keepAliveDuration
  1887. // }
  1888. // /** @typedef {typeof tokenEntry} TokenEntry */
  1889.  
  1890. // /** @type {Set<TokenEntry>} */
  1891. // const errorTokens = currentOnerror.errorTokens;
  1892.  
  1893. // if (errorTokens) {
  1894. // if (errorTokens.size > FIX_error_many_stack_keepAliveDuration_check_if_n_larger_than) {
  1895. // for (const entry of errorTokens) {
  1896. // if (entry.expired < now) {
  1897. // errorTokens.delete(entry);
  1898. // }
  1899. // }
  1900. // }
  1901. // errorTokens.add(tokenEntry)
  1902. // } else {
  1903. // /** @type {Set<TokenEntry>} */
  1904. // const errorTokens = new Set([tokenEntry]);
  1905. // /** @type {OnErrorEventHandler & {errorTokens: Set<string>} } */
  1906. // const newOnerror = ((oe) => {
  1907. // const r = function (msg, ...args) {
  1908. // if (typeof msg === 'string' && errorTokens.size > 0) {
  1909. // for (const entry of errorTokens) {
  1910. // if (msg.includes(entry.token)) return true;
  1911. // }
  1912. // }
  1913. // if (typeof oe === 'function') {
  1914. // return oe.apply(this, arguments);
  1915. // }
  1916. // };
  1917. // r.errorTokens = errorTokens;
  1918. // return r;
  1919. // })(currentOnerror);
  1920.  
  1921. // if (pdK && pdK.set) pdK.set.call(this, newOnerror);
  1922. // else this.onerror = newOnerror;
  1923. // }
  1924. // } else {
  1925. // if (pdK && pdK.set) pdK.set.call(this, nv);
  1926. // else this.onerror = nv;
  1927. // }
  1928. // Object.defineProperty(Window.prototype, 'onerror', pd);
  1929.  
  1930. // // console.log('onerror set', nv)
  1931. // return true;
  1932. // },
  1933. // enumerable: true,
  1934. // configurable: true
  1935. // }
  1936.  
  1937. // Object.defineProperty(Window.prototype, 'onerror', pd);
  1938.  
  1939.  
  1940. // }
  1941.  
  1942.  
  1943. // })();
  1944.  
  1945.  
  1946.  
  1947. // ================================================ 0.4.5 ================================================
  1948.  
  1949.  
  1950. // << if FIX_yt_player >>
  1951.  
  1952. // credit to @nopeless (https://greasyfork.org/scripts/471489-youtube-player-perf/)
  1953. const PERF_471489_ = true;
  1954. // PERF_471489_ is not exactly the same to Youtube Player perf v0.7
  1955. // This script uses a much gentle way to tamer the JS engine instead.
  1956.  
  1957. // << end >>
  1958.  
  1959. const steppingScaleN = 200; // transform: scaleX(k/N); 0<k<N
  1960.  
  1961.  
  1962.  
  1963. const nilFn = () => { };
  1964.  
  1965. let isMainWindow = false;
  1966. try {
  1967. isMainWindow = window.document === window.top.document
  1968. } catch (e) { }
  1969.  
  1970. let NO_PRELOAD_GENERATE_204_BYPASS = NO_PRELOAD_GENERATE_204 ? false : true;
  1971.  
  1972. const onRegistryReady = (callback) => {
  1973. if (typeof customElements === 'undefined') {
  1974. if (!('__CE_registry' in document)) {
  1975. // https://github.com/webcomponents/polyfills/
  1976. Object.defineProperty(document, '__CE_registry', {
  1977. get() {
  1978. // return undefined
  1979. },
  1980. set(nv) {
  1981. if (typeof nv == 'object') {
  1982. delete this.__CE_registry;
  1983. this.__CE_registry = nv;
  1984. this.dispatchEvent(new CustomEvent(EVENT_KEY_ON_REGISTRY_READY));
  1985. }
  1986. return true;
  1987. },
  1988. enumerable: false,
  1989. configurable: true
  1990. })
  1991. }
  1992. let eventHandler = (evt) => {
  1993. document.removeEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  1994. const f = callback;
  1995. callback = null;
  1996. eventHandler = null;
  1997. f();
  1998. };
  1999. document.addEventListener(EVENT_KEY_ON_REGISTRY_READY, eventHandler, false);
  2000. } else {
  2001. callback();
  2002. }
  2003. };
  2004.  
  2005.  
  2006. const assertor = (f) => f() || console.assert(false, f + "");
  2007.  
  2008. const fnIntegrity = (f, d) => {
  2009. if (!f || typeof f !== 'function') {
  2010. console.warn('f is not a function', f);
  2011. return;
  2012. }
  2013. let p = f + "", s = 0, j = -1, w = 0;
  2014. for (let i = 0, l = p.length; i < l; i++) {
  2015. const t = p[i];
  2016. if (((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))) {
  2017. if (j < i - 1) w++;
  2018. j = i;
  2019. } else {
  2020. s++;
  2021. }
  2022. }
  2023. let itz = `${f.length}.${s}.${w}`;
  2024. if (!d) {
  2025. return itz;
  2026. } else {
  2027. return itz === d;
  2028. }
  2029. };
  2030.  
  2031. const getZq = (_yt_player) => {
  2032.  
  2033. const w = 'Zq';
  2034.  
  2035. let arr = [];
  2036.  
  2037. for (const [k, v] of Object.entries(_yt_player)) {
  2038.  
  2039. const p = typeof v === 'function' ? v.prototype : 0;
  2040. if (p
  2041. && typeof p.start === 'function' && p.start.length === 0
  2042. && typeof p.isActive === 'function' && p.isActive.length === 0
  2043. && typeof p.stop === 'function' && p.stop.length === 0
  2044. && !p.isComplete && !p.getStatus && !p.getResponseHeader && !p.getLastError
  2045. && !p.send && !p.abort
  2046. && !p.sample && !p.initialize && !p.fail && !p.getName
  2047. // && !p.dispose && !p.isDisposed
  2048.  
  2049. ) {
  2050. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2051.  
  2052.  
  2053. }
  2054.  
  2055. }
  2056.  
  2057. if (arr.length === 0) {
  2058.  
  2059. console.warn(`Key does not exist. [${w}]`);
  2060. } else {
  2061.  
  2062. console.log(`[${w}]`, arr);
  2063. return arr[0];
  2064. }
  2065.  
  2066.  
  2067.  
  2068.  
  2069. }
  2070.  
  2071.  
  2072. const getVG = (_yt_player) => {
  2073. const w = 'VG';
  2074.  
  2075. let arr = [];
  2076.  
  2077. for (const [k, v] of Object.entries(_yt_player)) {
  2078.  
  2079. const p = typeof v === 'function' ? v.prototype : 0;
  2080. if (p
  2081. && typeof p.show === 'function' && p.show.length === 1
  2082. && typeof p.hide === 'function' && p.hide.length === 0
  2083. && typeof p.stop === 'function' && p.stop.length === 0) {
  2084.  
  2085. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2086.  
  2087. }
  2088.  
  2089. }
  2090.  
  2091.  
  2092. if (arr.length === 0) {
  2093.  
  2094. console.warn(`Key does not exist. [${w}]`);
  2095. } else {
  2096.  
  2097. console.log(`[${w}]`, arr);
  2098. return arr[0];
  2099. }
  2100.  
  2101.  
  2102.  
  2103. }
  2104.  
  2105.  
  2106. const getzo = (_yt_player) => {
  2107. const w = 'zo';
  2108.  
  2109. let arr = [];
  2110.  
  2111. for (const [k, v] of Object.entries(_yt_player)) {
  2112.  
  2113. if (
  2114. typeof v === 'function' && v.length === 3 && k.length < 3
  2115. && (v + "").includes("a.style[b]=c")
  2116. ) {
  2117.  
  2118. arr.push(k);
  2119.  
  2120. }
  2121.  
  2122. }
  2123.  
  2124.  
  2125. if (arr.length === 0) {
  2126.  
  2127. console.warn(`Key does not exist. [${w}]`);
  2128. } else {
  2129.  
  2130. console.log(`[${w}]`, arr);
  2131. return arr[0];
  2132. }
  2133.  
  2134. }
  2135.  
  2136. const addProtoToArr = (parent, key, arr) => {
  2137.  
  2138.  
  2139. let isChildProto = false;
  2140. for (const sr of arr) {
  2141. if (parent[key].prototype instanceof parent[sr]) {
  2142. isChildProto = true;
  2143. break;
  2144. }
  2145. }
  2146.  
  2147. if (isChildProto) return;
  2148.  
  2149. arr = arr.filter(sr => {
  2150. if (parent[sr].prototype instanceof parent[key]) {
  2151. return false;
  2152. }
  2153. return true;
  2154. });
  2155.  
  2156. arr.push(key);
  2157.  
  2158. return arr;
  2159.  
  2160.  
  2161. }
  2162.  
  2163. const getuG = (_yt_player) => {
  2164.  
  2165. const w = 'uG';
  2166.  
  2167. let arr = [];
  2168.  
  2169. for (const [k, v] of Object.entries(_yt_player)) {
  2170.  
  2171.  
  2172. const p = typeof v === 'function' ? v.prototype : 0;
  2173.  
  2174. if (p
  2175. && typeof p.createElement === 'function' && p.createElement.length === 2
  2176. && typeof p.detach === 'function' && p.detach.length === 0
  2177. && typeof p.update === 'function' && p.update.length === 1
  2178. && typeof p.updateValue === 'function' && p.updateValue.length === 2
  2179. ) {
  2180.  
  2181. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2182.  
  2183. }
  2184.  
  2185. }
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191. if (arr.length === 0) {
  2192.  
  2193. console.warn(`Key does not exist. [${w}]`);
  2194. } else {
  2195.  
  2196. console.log(`[${w}]`, arr);
  2197. return arr[0];
  2198. }
  2199.  
  2200. }
  2201.  
  2202.  
  2203.  
  2204. // << if FIX_schedulerInstanceInstance_ >>
  2205.  
  2206. let idleFrom = Date.now() + 2700;
  2207. let slowMode = false;
  2208.  
  2209. let ytEvented = false;
  2210.  
  2211.  
  2212. const setupEvents = FIX_schedulerInstanceInstance_V1 && !FIX_schedulerInstanceInstance_V2 ? () => {
  2213.  
  2214. document.addEventListener('yt-navigate', () => {
  2215.  
  2216. ytEvented = true;
  2217. slowMode = false;
  2218. idleFrom = Date.now() + 2700;
  2219.  
  2220. });
  2221. document.addEventListener('yt-navigate-start', () => {
  2222.  
  2223. ytEvented = true;
  2224. slowMode = false;
  2225. idleFrom = Date.now() + 2700;
  2226.  
  2227. });
  2228.  
  2229. document.addEventListener('yt-page-type-changed', () => {
  2230.  
  2231. ytEvented = true;
  2232. slowMode = false;
  2233. idleFrom = Date.now() + 1700;
  2234.  
  2235. });
  2236.  
  2237.  
  2238. document.addEventListener('yt-player-updated', () => {
  2239.  
  2240. ytEvented = true;
  2241. slowMode = false;
  2242. idleFrom = Date.now() + 1700;
  2243.  
  2244. });
  2245.  
  2246.  
  2247. document.addEventListener('yt-page-data-fetched', () => {
  2248.  
  2249. ytEvented = true;
  2250. slowMode = false;
  2251. idleFrom = Date.now() + 1700;
  2252.  
  2253. });
  2254.  
  2255. document.addEventListener('yt-navigate-finish', () => {
  2256.  
  2257. ytEvented = true;
  2258. slowMode = false;
  2259. let t = Date.now() + 700;
  2260. if (t > idleFrom) idleFrom = t;
  2261.  
  2262. });
  2263.  
  2264. document.addEventListener('yt-page-data-updated', () => {
  2265.  
  2266. ytEvented = true;
  2267. slowMode = false;
  2268. let t = Date.now() + 700;
  2269. if (t > idleFrom) idleFrom = t;
  2270.  
  2271. });
  2272.  
  2273. document.addEventListener('yt-watch-comments-ready', () => {
  2274.  
  2275. ytEvented = true;
  2276. slowMode = false;
  2277. let t = Date.now() + 700;
  2278. if (t > idleFrom) idleFrom = t;
  2279.  
  2280. });
  2281. } : () => { };
  2282.  
  2283.  
  2284. // << end >>
  2285.  
  2286. const cleanContext = async (win) => {
  2287. const waitFn = requestAnimationFrame; // shall have been binded to window
  2288. try {
  2289. let mx = 16; // MAX TRIAL
  2290. const frameId = 'vanillajs-iframe-v1';
  2291. /** @type {HTMLIFrameElement | null} */
  2292. let frame = document.getElementById(frameId);
  2293. let removeIframeFn = null;
  2294. if (!frame) {
  2295. frame = document.createElement('iframe');
  2296. frame.id = frameId;
  2297. const blobURL = typeof webkitCancelAnimationFrame === 'function' ? (frame.src = URL.createObjectURL(new Blob([], { type: 'text/html' }))) : null; // avoid Brave Crash
  2298. frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
  2299. let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
  2300. n.appendChild(frame);
  2301. while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
  2302. const root = document.documentElement;
  2303. root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
  2304. if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
  2305.  
  2306. removeIframeFn = (setTimeout) => {
  2307. const removeIframeOnDocumentReady = (e) => {
  2308. e && win.removeEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2309. e = n;
  2310. n = win = removeIframeFn = 0;
  2311. setTimeout ? setTimeout(() => e.remove(), 200) : e.remove();
  2312. }
  2313. if (!setTimeout || document.readyState !== 'loading') {
  2314. removeIframeOnDocumentReady();
  2315. } else {
  2316. win.addEventListener("DOMContentLoaded", removeIframeOnDocumentReady, false);
  2317. }
  2318. }
  2319. }
  2320. while (!frame.contentWindow && mx-- > 0) await new Promise(waitFn);
  2321. const fc = frame.contentWindow;
  2322. if (!fc) throw "window is not found."; // throw error if root is null due to exceeding MAX TRIAL
  2323. try {
  2324. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle } = fc;
  2325. const res = { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, requestIdleCallback, getComputedStyle };
  2326. for (let k in res) res[k] = res[k].bind(win); // necessary
  2327. if (removeIframeFn) Promise.resolve(res.setTimeout).then(removeIframeFn);
  2328. res.animate = fc.HTMLElement.prototype.animate;
  2329. res.perfNow = fc.performance.now;
  2330. return res;
  2331. } catch (e) {
  2332. if (removeIframeFn) removeIframeFn();
  2333. return null;
  2334. }
  2335. } catch (e) {
  2336. console.warn(e);
  2337. return null;
  2338. }
  2339. };
  2340.  
  2341.  
  2342. const promiseForCustomYtElementsReady = new Promise(onRegistryReady);
  2343.  
  2344. cleanContext(window).then(__CONTEXT__ => {
  2345. if (!__CONTEXT__) return null;
  2346.  
  2347. const { requestAnimationFrame, setTimeout, cancelAnimationFrame, setInterval, clearInterval, animate, requestIdleCallback, getComputedStyle, perfNow } = __CONTEXT__;
  2348.  
  2349.  
  2350. performance.now17 = perfNow.bind(performance);
  2351. // performance.now = performance.now16;
  2352. /*
  2353. let nowh = -1;
  2354. performance.now = function () {
  2355. let t = nowh;
  2356. let c = this.now17();
  2357. return (nowh = (t + 1e-7 > c ? t + 0.1 : c));
  2358. }
  2359. */
  2360.  
  2361. // console.log(performance.now())
  2362. // console.log(performance.now())
  2363. // console.log(performance.now())
  2364. // console.log(performance.now())
  2365.  
  2366.  
  2367.  
  2368. __requestAnimationFrame__ = requestAnimationFrame;
  2369.  
  2370. let rafPromise = null;
  2371.  
  2372. const getRafPromise = () => rafPromise || (rafPromise = new Promise(resolve => {
  2373. requestAnimationFrame(hRes => {
  2374. rafPromise = null;
  2375. resolve(hRes);
  2376. });
  2377. }));
  2378.  
  2379. const getForegroundPromise = () => {
  2380. if (document.visibilityState === 'visible') {
  2381. return Promise.resolve();
  2382. } else {
  2383. return getRafPromise();
  2384. }
  2385. };
  2386.  
  2387. NO_PRELOAD_GENERATE_204_BYPASS || promiseForCustomYtElementsReady.then(() => {
  2388. setTimeout(() => {
  2389. NO_PRELOAD_GENERATE_204_BYPASS = true;
  2390. }, 1270);
  2391. });
  2392.  
  2393. const promiseForTamerTimeout = new Promise(resolve => {
  2394. promiseForCustomYtElementsReady.then(() => {
  2395. customElements.whenDefined('ytd-app').then(() => {
  2396. setTimeout(resolve, 1200);
  2397. });
  2398. });
  2399. setTimeout(resolve, 3000);
  2400. });
  2401.  
  2402.  
  2403. class RAFHub {
  2404. constructor() {
  2405. /** @type {number} */
  2406. this.startAt = 8170;
  2407. /** @type {number} */
  2408. this.counter = 0;
  2409. /** @type {number} */
  2410. this.rid = 0;
  2411. /** @type {Map<number, FrameRequestCallback>} */
  2412. this.funcs = new Map();
  2413. const funcs = this.funcs;
  2414. /** @type {FrameRequestCallback} */
  2415. this.bCallback = this.mCallback.bind(this);
  2416. this.pClear = () => funcs.clear();
  2417. }
  2418. /** @param {DOMHighResTimeStamp} highResTime */
  2419. mCallback(highResTime) {
  2420. this.rid = 0;
  2421. Promise.resolve().then(this.pClear);
  2422. this.funcs.forEach(func => Promise.resolve(highResTime).then(func).catch(console.warn));
  2423. }
  2424. /** @param {FrameRequestCallback} f */
  2425. request(f) {
  2426. if (this.counter > 1e9) this.counter = 9;
  2427. let cid = this.startAt + (++this.counter);
  2428. this.funcs.set(cid, f);
  2429. if (this.rid === 0) {
  2430. console.log(2455)
  2431. this.rid = requestAnimationFrame(this.bCallback);
  2432. }
  2433. return cid;
  2434. }
  2435. /** @param {number} cid */
  2436. cancel(cid) {
  2437. cid = +cid;
  2438. if (cid > 0) {
  2439. if (cid <= this.startAt) {
  2440. return cancelAnimationFrame(cid);
  2441. }
  2442. if (this.rid > 0) {
  2443. this.funcs.delete(cid);
  2444. if (this.funcs.size === 0) {
  2445. cancelAnimationFrame(this.rid);
  2446. this.rid = 0;
  2447. }
  2448. }
  2449. }
  2450. }
  2451. /** @param {number} cid */
  2452. /** @param {FrameRequestCallback} f */
  2453. replaceFunc(cid, f) {
  2454. if (typeof this.funcs.get(cid) === 'function') {
  2455. this.funcs.set(cid, f);
  2456. return cid;
  2457. } else {
  2458. let r = this.request(f);
  2459. this.cancel(cid);
  2460. return r;
  2461. }
  2462. }
  2463. }
  2464.  
  2465.  
  2466.  
  2467. NATIVE_CANVAS_ANIMATION && (() => {
  2468.  
  2469. HTMLCanvasElement.prototype.animate = animate;
  2470.  
  2471. let cid = setInterval(() => {
  2472. HTMLCanvasElement.prototype.animate = animate;
  2473. }, 1);
  2474.  
  2475. promiseForTamerTimeout.then(() => {
  2476. clearInterval(cid)
  2477. });
  2478.  
  2479. })();
  2480.  
  2481. FIX_ytAction_ && (async () => {
  2482.  
  2483. const ytdApp = await new Promise(resolve => {
  2484.  
  2485. promiseForCustomYtElementsReady.then(() => {
  2486. customElements.whenDefined('ytd-app').then(() => {
  2487. const ytdApp = document.querySelector('ytd-app');
  2488. if (ytdApp) {
  2489. resolve(ytdApp);
  2490. return;
  2491. }
  2492. let mo = new MutationObserver(() => {
  2493. const ytdApp = document.querySelector('ytd-app');
  2494. if (!ytdApp) return;
  2495. if (mo) {
  2496. mo.disconnect();
  2497. mo.takeRecords();
  2498. mo = null;
  2499. }
  2500. resolve(ytdApp);
  2501. });
  2502. mo.observe(document, { subtree: true, childList: true });
  2503. });
  2504. });
  2505.  
  2506.  
  2507.  
  2508. });
  2509.  
  2510.  
  2511.  
  2512. if (!ytdApp) return;
  2513. const cProto = insp(ytdApp).constructor.prototype;
  2514.  
  2515.  
  2516. if (!cProto) return;
  2517. let mbd = 0;
  2518.  
  2519. const fixer = (_ytdApp) => {
  2520.  
  2521. const ytdApp = insp(_ytdApp);
  2522.  
  2523. if (ytdApp && typeof ytdApp.onYtActionBoundListener_ === 'function' && !ytdApp.onYtActionBoundListener57_) {
  2524. ytdApp.onYtActionBoundListener57_ = ytdApp.onYtActionBoundListener_;
  2525. ytdApp.onYtActionBoundListener_ = ytdApp.onYtAction_.bind(ytdApp);
  2526. mbd++;
  2527. }
  2528.  
  2529.  
  2530. }
  2531.  
  2532. let cid = setInterval(() => {
  2533.  
  2534.  
  2535. if (typeof cProto.created === 'function' && !cProto.created56) {
  2536. cProto.created56 = cProto.created;
  2537. cProto.created = function (...args) {
  2538. const r = this.created56(...args);
  2539. fixer(this);
  2540. return r;
  2541. };
  2542. mbd++;
  2543. }
  2544.  
  2545.  
  2546. if (typeof cProto.onYtAction_ === 'function' && !cProto.onYtAction57_) {
  2547. cProto.onYtAction57_ = cProto.onYtAction_;
  2548. cProto.onYtAction_ = function (...args) {
  2549. Promise.resolve().then(() => this.onYtAction57_(...args));
  2550. };
  2551. mbd++;
  2552. }
  2553.  
  2554. if (ytdApp) fixer(ytdApp);
  2555.  
  2556. /*
  2557. const actionRouter_ = ytdApp ? ytdApp.actionRouter_ : null;
  2558. if (actionRouter_ && typeof actionRouter_.handleAction === 'function' && !actionRouter_.handleAction57) {
  2559. actionRouter_.handleAction57 = actionRouter_.handleAction;
  2560. actionRouter_.handleAction = function (...args) {
  2561. Promise.resolve().then(() => this.handleAction57(...args));
  2562. }
  2563. mbd++;
  2564. }
  2565. */
  2566.  
  2567. // if(mbd === 3) clearInterval(cid);
  2568. if (mbd >= 3) clearInterval(cid);
  2569.  
  2570. }, 1);
  2571.  
  2572. setTimeout(() => {
  2573.  
  2574. clearInterval(cid);
  2575. }, 1000);
  2576.  
  2577. })();
  2578.  
  2579.  
  2580. const generalEvtHandler = async (_evKey, _fvKey, _debug) => {
  2581.  
  2582. const evKey = `${_evKey}`;
  2583. const fvKey = `${_fvKey}`;
  2584. const debug = !!_debug;
  2585.  
  2586.  
  2587. // const rafHub = new RAFHub();
  2588.  
  2589.  
  2590. const _yt_player = await new Promise(resolve => {
  2591.  
  2592. let cid = setInterval(() => {
  2593. let t = (((window || 0)._yt_player || 0) || 0);
  2594. if (t) {
  2595.  
  2596. clearInterval(cid);
  2597. resolve(t);
  2598. }
  2599. }, 1);
  2600.  
  2601. promiseForTamerTimeout.then(() => {
  2602. resolve(null)
  2603. });
  2604.  
  2605. });
  2606.  
  2607.  
  2608. if (!_yt_player || typeof _yt_player !== 'object') return;
  2609.  
  2610.  
  2611. const getArr = (_yt_player) => {
  2612.  
  2613. let arr = [];
  2614.  
  2615. for (const [k, v] of Object.entries(_yt_player)) {
  2616.  
  2617. const p = typeof v === 'function' ? v.prototype : 0;
  2618. if (p
  2619. && typeof p[evKey] === 'function' && p[evKey].length >= 0 && !p[fvKey]
  2620.  
  2621. ) {
  2622. arr = addProtoToArr(_yt_player, k, arr) || arr;
  2623.  
  2624. }
  2625.  
  2626. }
  2627.  
  2628. if (arr.length === 0) {
  2629.  
  2630. console.warn(`Key prop [${evKey}] does not exist.`);
  2631. } else {
  2632.  
  2633. return arr;
  2634. }
  2635.  
  2636. };
  2637.  
  2638. const arr = getArr(_yt_player);
  2639.  
  2640.  
  2641. if (!arr) return;
  2642.  
  2643. debug && console.log(`FIX_${evKey}`, arr);
  2644.  
  2645. const f = function (...args) {
  2646. Promise.resolve().then(() => this[fvKey](...args));
  2647. };
  2648.  
  2649.  
  2650. for (const k of arr) {
  2651.  
  2652. const g = _yt_player;
  2653. const gk = g[k];
  2654. const gkp = gk.prototype;
  2655.  
  2656. debug && console.log(237, k, gkp)
  2657.  
  2658. if (typeof gkp[evKey] == 'function' && !gkp[fvKey]) {
  2659. gkp[fvKey] = gkp[evKey];
  2660. gkp[evKey] = f;
  2661. }
  2662. }
  2663.  
  2664.  
  2665.  
  2666.  
  2667. }
  2668.  
  2669. FIX_onVideoDataChange && generalEvtHandler('onVideoDataChange', 'onVideoDataChange57');
  2670. // FIX_onClick && generalEvtHandler('onClick', 'onClick57');
  2671. FIX_onStateChange && generalEvtHandler('onStateChange', 'onStateChange57');
  2672. FIX_onLoopRangeChange && generalEvtHandler('onLoopRangeChange', 'onLoopRangeChange57');
  2673. if (FIX_VideoEVENTS_v2) {
  2674. const FIX_VideoEVENTS_DEBUG = 0;
  2675. generalEvtHandler('onVideoProgress', 'onVideoProgress57', FIX_VideoEVENTS_DEBUG); // --
  2676. // generalEvtHandler('onAutoplayBlocked', 'onAutoplayBlocked57', FIX_VideoEVENTS_DEBUG);
  2677. // generalEvtHandler('onLoadProgress', 'onLoadProgress57', FIX_VideoEVENTS_DEBUG); // << CAUSE ISSUE >>
  2678. generalEvtHandler('onFullscreenChange', 'onFullscreenChange57', FIX_VideoEVENTS_DEBUG); // --
  2679. // generalEvtHandler('onLoadedMetadata', 'onLoadedMetadata57', FIX_VideoEVENTS_DEBUG);
  2680. // generalEvtHandler('onDrmOutputRestricted', 'onDrmOutputRestricted57', FIX_VideoEVENTS_DEBUG);
  2681. // generalEvtHandler('onAirPlayActiveChange', 'onAirPlayActiveChange57', FIX_VideoEVENTS_DEBUG);
  2682. // generalEvtHandler('onAirPlayAvailabilityChange', 'onAirPlayAvailabilityChange57', FIX_VideoEVENTS_DEBUG);
  2683. // generalEvtHandler('onApiChange', 'onApiChange57', FIX_VideoEVENTS_DEBUG);
  2684.  
  2685. }
  2686. // onMutedAutoplayChange
  2687. // onVolumeChange
  2688. // onPlaybackRateChange
  2689.  
  2690. // onAirPlayActiveChange
  2691. // onAirPlayAvailabilityChange
  2692. // onApiChange
  2693. // onAutoplayBlocked
  2694. // onDrmOutputRestricted
  2695. // onFullscreenChange
  2696. // onLoadProgress
  2697. // onLoadedMetadata
  2698. // onVideoDataChange
  2699. // onVideoProgress
  2700.  
  2701. FIX_maybeUpdateFlexibleMenu && (async () => {
  2702.  
  2703.  
  2704. const dummy = await new Promise(resolve => {
  2705.  
  2706. promiseForCustomYtElementsReady.then(() => {
  2707. customElements.whenDefined('ytd-menu-renderer').then(() => {
  2708.  
  2709. resolve(document.createElement('ytd-menu-renderer'));
  2710. });
  2711. });
  2712.  
  2713.  
  2714.  
  2715. });
  2716.  
  2717.  
  2718. if (!dummy || dummy.is !== 'ytd-menu-renderer') return;
  2719.  
  2720. const cProto = insp(dummy).constructor.prototype;
  2721.  
  2722. if (typeof cProto.created === 'function' && !cProto.created58) {
  2723. cProto.created58 = cProto.created;
  2724. cProto.created = function (...args) {
  2725. const r = this.created58(...args);
  2726. if (typeof this.maybeUpdateFlexibleMenu === 'function' && !this.maybeUpdateFlexibleMenu57) {
  2727. this.maybeUpdateFlexibleMenu57 = this.maybeUpdateFlexibleMenu;
  2728. this.maybeUpdateFlexibleMenu = function (...args) {
  2729. Promise.resolve().then(() => this.maybeUpdateFlexibleMenu57(...args));
  2730. }
  2731. }
  2732. return r;
  2733. }
  2734.  
  2735. }
  2736.  
  2737. //console.log(144,cProto.maybeUpdateFlexibleMenu)
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744. })();
  2745.  
  2746. ENABLE_discreteTasking && (async () => {
  2747.  
  2748. const Polymer = await new Promise(resolve => {
  2749.  
  2750. let cid = 0;
  2751. const f = () => {
  2752. const Polymer = window.Polymer;
  2753. if (typeof Polymer !== 'function') return;
  2754. if (!(Polymer.Base || 0).connectedCallback || !(Polymer.Base || 0).disconnectedCallback) return;
  2755. cid && clearInterval(cid);
  2756. cid = 0;
  2757. resolve(Polymer);
  2758. };
  2759. cid = setInterval(f, 1);
  2760.  
  2761. });
  2762. if (!Polymer) return;
  2763.  
  2764.  
  2765. if (UNLOAD_DETACHED_POLYMER && typeof Polymer.Base.detached === 'function' && !Polymer.Base.detached92 && Polymer.Base.detached.length === 0) {
  2766. Polymer.Base.detached92 = Polymer.Base.detached;
  2767.  
  2768. let delay300 = new PromiseExternal();
  2769. setInterval(() => {
  2770. delay300.resolve();
  2771. delay300 = new PromiseExternal();
  2772. }, 300);
  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. })();