mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-20 06:32:05 +00:00
chore: improve readability
This commit is contained in:
@ -37,7 +37,7 @@ export const injectCpuTamerByAnimationFrame = ((__CONTEXT__) => {
|
||||
win[hkey_script] = true;
|
||||
|
||||
/** @type {globalThis.PromiseConstructor} */
|
||||
const Promise = (async () => { })().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
const Promise = (async () => { })().constructor; // hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
const PromiseExternal = ((resolve_, reject_) => {
|
||||
const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
|
||||
return class PromiseExternal extends Promise {
|
||||
@ -64,7 +64,7 @@ export const injectCpuTamerByAnimationFrame = ((__CONTEXT__) => {
|
||||
})();
|
||||
|
||||
if (!isGPUAccelerationAvailable) {
|
||||
throw new Error('Your browser does not support GPU Acceleration. YouTube CPU Tamer by AnimationFrame is skipped.');
|
||||
throw new Error('Your browser does not support GPU Acceleration. CPU Tamer by AnimationFrame is skipped.');
|
||||
}
|
||||
|
||||
const timeupdateDT = (() => {
|
||||
@ -100,7 +100,7 @@ export const injectCpuTamerByAnimationFrame = ((__CONTEXT__) => {
|
||||
frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
|
||||
let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
|
||||
n.appendChild(frame);
|
||||
while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
|
||||
while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by the engine
|
||||
const root = document.documentElement;
|
||||
root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
|
||||
if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
|
||||
|
||||
@ -37,7 +37,7 @@ export const injectCpuTamerByDomMutation = ((__CONTEXT__) => {
|
||||
win[hkey_script] = true;
|
||||
|
||||
/** @type {globalThis.PromiseConstructor} */
|
||||
const Promise = (async () => { })().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
const Promise = (async () => { })().constructor; // hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
const PromiseExternal = ((resolve_, reject_) => {
|
||||
const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
|
||||
return class PromiseExternal extends Promise {
|
||||
@ -89,7 +89,7 @@ export const injectCpuTamerByDomMutation = ((__CONTEXT__) => {
|
||||
frame.sandbox = 'allow-same-origin'; // script cannot be run inside iframe but API can be obtained from iframe
|
||||
let n = document.createElement('noscript'); // wrap into NOSCRPIT to avoid reflow (layouting)
|
||||
n.appendChild(frame);
|
||||
while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by YouTube engine
|
||||
while (!document.documentElement && mx-- > 0) await new Promise(waitFn); // requestAnimationFrame here could get modified by the engine
|
||||
const root = document.documentElement;
|
||||
root.appendChild(n); // throw error if root is null due to exceeding MAX TRIAL
|
||||
if (blobURL) Promise.resolve().then(() => URL.revokeObjectURL(blobURL));
|
||||
|
||||
@ -35,7 +35,7 @@ export const injectRm3 = () => {
|
||||
const DEBUG_dataChangeReflection = true;
|
||||
|
||||
/** @type {globalThis.PromiseConstructor} */
|
||||
const Promise = (async () => {})().constructor; // YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
const Promise = (async () => {})().constructor; // hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
|
||||
|
||||
// https://qiita.com/piroor/items/02885998c9f76f45bfa0
|
||||
// https://gist.github.com/piroor/829ecb32a52c2a42e5393bbeebe5e63f
|
||||
@ -354,7 +354,7 @@ export const injectRm3 = () => {
|
||||
|
||||
const timeCheck = () => {
|
||||
// regularly check elements are old enough to put into the available pools
|
||||
// note: the characterists of YouTube components are non-volatile. So don't need to waste time to check weakRef.deref() is null or not for removing in operations.
|
||||
// note: the characterists of original components are non-volatile. So don't need to waste time to check weakRef.deref() is null or not for removing in operations.
|
||||
|
||||
const ct = Date.now();
|
||||
if (ct - lastTimeCheck < CHECK_INTERVAL || noTimeCheck) return;
|
||||
@ -738,7 +738,7 @@ export const injectRm3 = () => {
|
||||
}
|
||||
|
||||
const acceptance = true;
|
||||
// const acceptance = !cntE.__dataReady && cntE.__dataInvalid !== false; // we might need to change the acceptance condition along with YouTube Coding updates.
|
||||
// const acceptance = !cntE.__dataReady && cntE.__dataInvalid !== false; // we might need to change the acceptance condition along with Coding updates.
|
||||
if (acceptance) {
|
||||
// [[ weak ElementNode, attached time, detached time, time of change, inside availablePool, reuse count ]]
|
||||
const entryRecord = [new WeakRef(newElement), -1, -1, -1, false, 0];
|
||||
|
||||
Reference in New Issue
Block a user