Skip to content

Instantly share code, notes, and snippets.

@nomomon
Last active August 18, 2021 15:06
Show Gist options
  • Save nomomon/5f9b0c65531ac6ce0a25c301aef76288 to your computer and use it in GitHub Desktop.
Save nomomon/5f9b0c65531ac6ce0a25c301aef76288 to your computer and use it in GitHub Desktop.
Bookmarklet to prevent screen from sleeping on a webpage. An alert message is send when the wake lock is released (tab was changed; browser not in focus).
(async () => {
wakeLock = await navigator.wakeLock.request('screen');
wakeLock.addEventListener('release', (e) => {
alert("Wake lock released");
});
})();
@nomomon
Copy link
Author

nomomon commented Aug 18, 2021

Bookmarklets are browser bookmarks that execute JavaScript instead of opening a webpage. They're also known as bookmark applets, favlets, or JavaScript bookmarks.

To use this a bookmarklet follow this tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment