Verbal memory bot - humanbenchmark.com

Plays the "verbal memory" game for you on humanbenchmark.com

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Verbal memory bot - humanbenchmark.com
// @namespace   https://reddit.com/u/AliFurkanY
// @match       https://humanbenchmark.com/tests/verbal-memory
// @grant       none
// @version     1.1
// @author      alifurkany
// @description Plays the "verbal memory" game for you on humanbenchmark.com
// @license     GPL-3.0
// ==/UserScript==

// Speed
let INTERVAL = 0;

let botbtn = document.createElement("button");
let startbtn = document.querySelector("button.css-de05nr.e19owgy710");
let settingsdiv = document.createElement("div");
let btndiv = startbtn.parentElement;
botbtn.className = startbtn.className;
botbtn.innerText = "Start Bot";
settingsdiv.className = btndiv.className;
let intervalinput = document.createElement("input");
intervalinput.className = ".css-1gr1qbh";
intervalinput.type = "number";
intervalinput.min = 0;
intervalinput.onchange = () => (INTERVAL = parseInt(intervalinput.value));
intervalinput.value = INTERVAL;
intervalinput.style.color = "black";
intervalinput.placeholder = 0;
settingsdiv.append("Click interval (ms): ");
settingsdiv.append(intervalinput);
let fullnav = document.querySelector("div.full-nav");

function appendStuff() {
	btndiv.append(" ");
	btndiv.append(botbtn);
	btndiv.parentElement.append(settingsdiv);
}

let dict = [];

botbtn.onclick = () => {
	startbtn.click();
	setImmediate(() => {
		let worddiv = document.querySelector("div.word");
		let [seenbtn, newbtn] = document.querySelectorAll(
			"button.css-de05nr.e19owgy710"
		);
		let stopped = false;
		let stopbtn = document.createElement("button");
		stopbtn.className = startbtn.className;
		stopbtn.innerText = "Stop";
		stopbtn.onclick = () => {
			console.log("Stopped");
			stopped = true;
			stopbtn.remove();
		};
		fullnav.append(stopbtn);
		let interval = setInterval(() => {
			if (document.querySelector(".css-0")) {
				console.log("Game ended");
				document
					.querySelector("button.secondary.css-qm6rs9.e19owgy710")
					.addEventListener("click", () =>
						setImmediate(() => {
							dict = [];
							startbtn = document.querySelector(
								"button.css-de05nr.e19owgy710"
							);
							btndiv = startbtn.parentElement;
							appendStuff();
						})
					);
				stopbtn.remove();
				clearInterval(interval);
			} else if (!stopped) {
				let word = worddiv.innerText.trim();
				console.log(word);
				if (dict.includes(word)) seenbtn.click();
				else {
					dict.push(word);
					newbtn.click();
				}
			}
		}, INTERVAL);
	});
};

appendStuff();