A simple bot for typeracer.
当前为
// ==UserScript==
// @name Bot for typeracer.com
// @namespace type_bot
// @include http://play.typeracer.com/
// @version 1.01
// @grant none
// @description:en A simple bot for typeracer.
// @description A simple bot for typeracer.
// ==/UserScript==
var CURRENT_WORD_ID = "nhwMiddlegwt-uid-8";
var ADDITIONAL_WORD_ID = "nhwMiddleCommagwt-uid-9";
var INPUT_CLASS = "txtInput";
var INPUT_CLASS_UNFOCUSED = "txtInput txtInput-unfocused";
var CLASS_OF_START = "gwt-Anchor";
var CONTAINER_ELEM_ID = "dUI";
var NUMBER_RACE = 3;
var NUMBER_PRACTICE = 4;
var DEFAULT_SPEED = 700;
var tb_container = document.getElementsByClassName("themeContent").item(0);
if(localStorage.type_bot === undefined)
localStorage.type_bot = "active";
var button_text_active = "Bot activated";
var button_text_deactivated = "Bot deactivated";
var INFO_TXT = "Reload page after every race.";
var bot_input;
var words;
var tb_input;
var tb_thread;
var tb_info;
var ev; //enter key event
var space; //space key event
ev = document.createEvent("KeyboardEvent");
ev.initKeyEvent("keypress", true, false, window, 0, 0, 0, 0, 13, 13);
space = document.createEvent("KeyboardEvent");
space.initKeyEvent("keypress",true,false, window, 0,0,0,0,32,32);
setTimeout(function(){
var RACE_ELEM = document.getElementsByClassName(CLASS_OF_START).item(NUMBER_RACE);
var PRACTICE_ELEM = document.getElementsByClassName(CLASS_OF_START).item(NUMBER_PRACTICE);
RACE_ELEM.addEventListener("click",tb_init);
PRACTICE_ELEM.addEventListener("click",tb_init);
},2000);
function tb_init(){
var bot_button = document.createElement("input");
bot_button.id = "bot_button";
bot_button.type = "button";
if(localStorage.type_bot == "active")
bot_button.value = button_text_active;
else bot_button.value = button_text_deactivated;
bot_button.style.position = "absolute";
bot_button.style.top = "100px";
bot_button.style.left = "50px";
bot_button.addEventListener("click",button_pressed);
bot_input = document.createElement("input");
bot_input.id = "bot_input";
bot_input.type = "text";
bot_input.value = DEFAULT_SPEED;
bot_input.style.top = "150px";
bot_input.style.left = "50px";
bot_input.style.position = "absolute";
bot_input.title = "Milliseconds between each word";
tb_info = document.createTextNode(INFO_TXT);
var tb_div = document.createElement("div");
tb_div.style.position = "absolute";
tb_div.style.top = "200px";
tb_div.style.left = "50px";
tb_div.appendChild(tb_info);
tb_container.appendChild(tb_div);
tb_container.appendChild(bot_input);
tb_container.appendChild(bot_button);
setTimeout(tb_wait,2000);
}
function button_pressed(event){
if(localStorage.type_bot == "active"){
localStorage.type_bot = "unactive";
event.target.value = button_text_deactivated;
bot_input.disabled = true;
}
else{
localStorage.type_bot = "active";
event.target.value = button_text_active;
bot_input.disabled = false;
}
}
function tb_wait(){
tb_input = document.getElementsByClassName(INPUT_CLASS_UNFOCUSED).item(0);
tb_thread = window.setInterval(function(){
if(tb_input.className == INPUT_CLASS)
tb_type(tb_input);
},100);
}
function tb_type(input){
clearInterval(tb_thread);
if(localStorage.type_bot == "active"){
var WAIT_BETWEEN_WORDS = parseInt(bot_input.value);
if(isNaN(WAIT_BETWEEN_WORDS) || !WAIT_BETWEEN_WORDS)
WAIT_BETWEEN_WORDS = DEFAULT_SPEED;
words = document.getElementById(CURRENT_WORD_ID);
additional = document.getElementById(ADDITIONAL_WORD_ID);
var word = words.innerHTML;
var add = additional.innerHTML;
tb_thread = window.setInterval(function(){
if(word == null)
clearInterval(tb_thread);
tb_input.value += word + add;
tb_input.dispatchEvent(space);
word = words.innerHTML;
add = additional.innerHTML;
},WAIT_BETWEEN_WORDS);
}
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址