YouTube JS Engine Tamer

To enhance YouTube performance by modifying YouTube JS Engine

当前为 2023-10-05 提交的版本,查看 最新版本

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