YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

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

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