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