Skip to content

Prevent display sleep and enable wake lock in any Android or iOS web browser.

Notifications You must be signed in to change notification settings

BHSPitMonkey/NoSleep.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoSleep.js

A fork of github.com/richtr/NoSleep.js which works as a Node module.

Prevents display sleep and enable wake lock in all Android and iOS web browsers.

Installation

I'm not publishing this in the npm registry because it would make more sense for the upstream repo to do that eventually.

You can still install this fork using npm using this format:

$ npm install BHSPitMonkey/NoSleep.js

Usage

Create a new NoSleep object and then enable or disable it when needed as follows:

var NoSleep = require("nosleep");
// Or ES6-style:
// import NoSleep from "nosleep";

var noSleep = new NoSleep();

function enableNoSleep() {
  noSleep.enable();
  document.removeEventListener('touchstart', enableNoSleep, false);
}

// Enable NoSleep.
// (must be wrapped in a user input event handler e.g. a mouse or touch handler)
document.addEventListener('touchstart', enableNoSleep, false);

// ...

// Disable wake lock at some point in the future.
// (does not need to be wrapped in any user input event handler)
noSleep.disable();

License

Same as upstream:

MIT. Copyright (c) Rich Tibbett

About

Prevent display sleep and enable wake lock in any Android or iOS web browser.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%