richtr / NoSleep.js

Prevent display sleep and enable wake lock in any Android or iOS web browser.
MIT License
2.19k stars 379 forks source link

Prevent Sleep option #116

Open Merynek opened 3 years ago

Merynek commented 3 years ago

In my case i would like to prevent (system) sleep, not only screen. Is it possible to add parameter for ignore native wakelock (prevents only screen) and use only video element (prevents even system sleep) ?

Thank you.

WesleyAC commented 3 years ago

A workaround for this is to delete the wakeLock property from navigator, before you load the NoSleep.min.js script:

if ("wakeLock" in navigator) {
  delete Object.getPrototypeOf(window.navigator).wakeLock;
}

But I'd love a way to do this that isn't a hack.