kukuw.com Cheats

2023/11/19 08:36:12

目前为 2023-11-19 提交的版本。查看 最新版本

// ==UserScript==
// @name        kukuw.com Cheats
// @namespace   Violentmonkey Scripts
// @match       https://dazi.kukuw.com/typing.html
// @grant       GM_getValue
// @version     0.1
// @run-at      document-idle
// @author      -
// @license     MIT
// @description 2023/11/19 08:36:12
// @inject-into page
// ==/UserScript==
'use strict';
const delay = n => new Promise(r => setTimeout(r, n));

let elem, elem2;

const press = (() => {
    const conf2 = {
        inputType: "insertText",
    };
    function type(key) {
        elem.value += conf2.data = key;
        elem.dispatchEvent(new InputEvent("input", conf2));
    }
    return type;
})();

const listener = new MutationObserver(list => list.forEach(rec => {
    const t = rec.target;
    if (t.className.includes("typing_on")) elem2 = t, main();

}));

document.querySelectorAll("div.typing").forEach(el => listener.observe(el, {attributeFilter: ["class"]}));

elem2 = document.querySelector("div.typing_on");
main();



async function main() {
    elem = elem2.querySelector("input.typing");
    const dest = elem2.querySelector("input[type=hidden]").value;
    for (const j of dest) {
        press(j);
        await delay(GM_getValue("speed_c", 100) + Math.trunc(Math.random() * GM_getValue("speed_v", 30)));
    }
}

console.log("running...");