Reduce Browser's Energy Impact for playing YouTube Video
当前为
Inspired by kona's YouTube CPU Tamer
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.
This userscript hijacks setTimeout & setInterval leading different browser behaviors as follows:
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)
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;
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)
clearInterval(window.f1s); clearInterval(window.f2s); let w1=0,w2=0;let f1 = ()=>{w1++}, f2= ()=>{w2++}; window.f1s=setInterval(f1,70); window.f2s=setInterval(f2, 140); setTimeout(()=>{console.log(w1,w2);},3000)
Native: print out "42 21".
Modified: print out "42 21".
clearInterval(window.f1s); clearInterval(window.f2s); let w1=0,w2=0;let f1 = ()=>{w1++}, f2= ()=>{w2++}; window.f1s=setInterval(f1,70); window.f2s=setInterval(f2, 140); setTimeout(()=>{console.log(w1,w2);},3000)
Native (Microsoft Edge): print out values various from 3 to 4. (e.g. "4 4", "4 3")
Modified: print out values various from 3 to 13 (e.g. "13 13", "12 12", "6 5", "4 3", "3 3", "4 4").
Remarks: 3000/250 = 12
clearInterval(window.f1s); clearInterval(window.f2s); let w1=0,w2=0;let f1 = ()=>{w1++}, f2= ()=>{w2++}; window.f1s=setInterval(f1,5); window.f2s=setInterval(f2, 10); setTimeout(()=>{console.log(w1,w2);},3000)
Native: print out "600 300".
Modified: print out "600 301" or "600 300".
clearInterval(window.f1s); clearInterval(window.f2s); let w1=0,w2=0;let f1 = ()=>{w1++}, f2= ()=>{w2++}; window.f1s=setInterval(f1,5); window.f2s=setInterval(f2, 10); setTimeout(()=>{console.log(w1,w2);},3000)
Native (Microsoft Edge): print out values various from 4 to 7. (e.g. "4 4", "7 4")
Modified: print out "4 4".
Remarks: 3000/250 = 12
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址