-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtyping.user.js
40 lines (32 loc) · 1.04 KB
/
typing.user.js
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
// ==UserScript==
// @name template
// @namespace template.zero.nao
// @version 0.1
// @description try to tke over the world!
// @author nao [2669774]
// @match https://humanbenchmark.com/tests/typing
// @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @grant none
// @updateURL <UPDATE_URL>
// @downloadURL <DOWNLOAD_URL>
// ==/UserScript==
const element = document.querySelectorAll(".letters");
const text = element.innerText;
function simulateTyping(text, delay = 100) {
let index = 0;
function type() {
if (index < text.length) {
const char = text[index];
// Create and dispatch keydown event
const keydownEvent = new KeyboardEvent("keydown", { key: char });
document.dispatchEvent(keydownEvent);
// Create and dispatch keyup event
const keyupEvent = new KeyboardEvent("keyup", { key: char });
document.dispatchEvent(keyupEvent);
index++;
setTimeout(type, delay);
}
}
type();
}
setTimeout(simulateTyping, 5000, text);