JS script to automate the input of characters at 10ff.net
当前为
// ==UserScript==
// @name 10ff speed hack
// @namespace http://tampermonkey.net/
// @version 0.3
// @description JS script to automate the input of characters at 10ff.net
// @author z0xyz
// @match https://10ff.net/*
// @run-at document
// ==/UserScript==
function sleep(milliseocnds) {
const date = Date.now()
let currentDate
do {
currentDate = Date.now()
} while ((currentDate - date) - milliseocnds)
}
function promptValueCheck() {
desiredSpeedWpm = window.prompt('add the desired Speed Wpm') * 1
if (isNaN(desiredSpeedWpm)) {
return (false)
}else {
return (true)
}
}
function addWord() {
try {
let hightlightedWord = document.querySelector(".highlight").textContent
let hWordLength = hightlightedWord.length
for (let i = 0; i < hWordLength; i++) {
inputField.value += hightlightedWord[i];
inputField.dispatchEvent(newInputEvent);
sleep(eachCharacterInterval)
}
inputField.value += " ";
inputField.dispatchEvent(newInputEvent);
inputField.value = ''
}catch {
clearInterval(intervalMethod)
}
}
function checkSite() {
console.log("The site is now opened!")
if (promptValueCheck()) {
let charactersCount = document.querySelector(".place").textContent.length
let totalTypingTimeSec = (charactersCount /5) / desiredSpeedWpm
eachCharacterInterval = Math.round((totalTypingTimeSec * 60000) / charactersCount)
inputField = document.getElementsByTagName("input")[0]
newInputEvent = new InputEvent("input")
intervalMethod = setInterval(addWord, eachCharacterInterval)
}
else {
console.log("No valid value was entered!")
}
}
let startIndicator = setInterval (function () {
try {
let overlayNode = document.getElementsByClassName('overlayer').item(0).textContent
if (overlayNode == "false") {
checkSite()
clearInterval(startIndicator)
}
}catch {
console.log("The typing test hasn't started yet!")
}
} , 1000)