-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathidle.html
37 lines (33 loc) · 1.04 KB
/
idle.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Idle</title>
</head>
<body>
<script>
(async () => {
console.log('Before, run in console the following and reload the page:');
console.log('await IdleDetector.requestPermission()');
console.log('-------------------');
console.log('IdleDetector allows minimum 1 minute, so waiting.');
let cnt = 0;
let second = 0;
const controller = new AbortController();
const idleDetector = new IdleDetector();
idleDetector.addEventListener('change', () => {
if (cnt++ === 50) {
cnt = 0;
document.write('');
}
const userState = idleDetector.userState;
const screenState = idleDetector.screenState;
console.log(`userState: ${userState}, screenState: ${screenState}.`);
});
await idleDetector.start({
threshold: 60 * 1000,
});
})();
</script>
</body>
</html>