YouTube CPU Tamer by AnimationFrame

減少YouTube影片所致的能源消耗

目前為 2021-08-30 提交的版本,檢視 最新版本

作者
𝖢𝖸 𝖥𝗎𝗇𝗀
評價
0 0 0
版本
2021.08.30.1
建立日期
2021-08-29
更新日期
2021-08-30
尺寸
6.1 KB
授權條款
MIT
腳本執行於

Inspired by kona's YouTube CPU Tamer

Description

This is for all kinds of YouTube applications, including main page, embedded video, and live chat.

- Faster
- More Stable
- Lower Battery Consumption

Note1: This hijacks to setTimeout, setInterval, clearTimeout, clearInterval
Note2: This uses setInterval(..., 250ms) instead of requestAnimationFrame for background running.

Remarks

This userscript hijacks setTimeout & setInterval leading different browser behaviors as follows:

Case 1

let f=function(){console.log('hello world')};
setTimeout(f,100);setTimeout(f,100);setTimeout(f,100);

Native: print out "hello world" 3 times.
Modified: print out "hellow world" 1 time. (in the same AnimationFrame)

Case 2

let f=function(){console.log('hello world')};
setTimeout(f,100);setTimeout(f,110);setTimeout(f,120);

Native: print out "hello world" 3 times.
Modified: print out "hellow world" 1 ~ 3 time(s) depending on the execution time of function handler, the responsiveness of browser, and the segregation of AnimationFrames;

Case 3

let f=function(){console.log('hello world')};
setTimeout(f,100);setTimeout(f,200);setTimeout(f,300);

Native: print out "hello world" 3 times.
Modified: print out "hello world" 3 times. (in 3 AnimationFrames)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址