YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

当前为 2024-01-01 提交的版本,查看 最新版本

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