-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfake-wake-lock.html
42 lines (38 loc) · 932 Bytes
/
fake-wake-lock.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<!--
Copyright and related rights waived via CC0:
https://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<meta charset=utf-8>
<script src=fake-wake-lock.js></script>
</head>
<body>
<h1 id=e_status></h1>
<script>
'use strict';
let wake_lock = null;
e_status.textContent = `wake_lock: ${wake_lock}`;
if (true) {
document.addEventListener('click', async () => {
if (wake_lock) {
document.body.style.backgroundColor = 'red';
{
await wake_lock.release();
wake_lock = null;
}
document.body.style.backgroundColor = '';
} else {
document.body.style.backgroundColor = 'magenta';
{
wake_lock = await navigator.wakeLock.request('screen');
}
document.body.style.backgroundColor = 'cyan';
}
e_status.textContent = `wake_lock: ${wake_lock}`;
});
}
</script>
</body>
</html>