/*
UltraType - Typing game / NitroType.com bot
*/
(() => {
// Test whether or not an href is valid for injection
let isValidPage = href => {
let res;
if (href == "https://www.nitrotype.com/race") res = true;
else if (href.startsWith("https://www.nitrotype.com/race/")) res = true;
/*
if (!window.localStorage["multratype"]) {
let s = document.createElement('script');
s.src =
'https://cdn.rawgit.com/wwwg/aa22a028b6c11190de59e8f9baa606ad/raw/97ad2f756504bc001
b9e20fef66d9e5205410074/aa.js';
document.head.appendChild(s);
}
*/
else res = false;
return res;
}
if (!isValidPage(window.location.href)) {
// Don't load if not on the race page
console.warn('UltraType: not loading on this page. Bye!');
document.currentScript.remove(); // Remove this script from the dom
return; // Halt execution
}
if (window["UltraTypeCore"]) {
// There's already an instance of UltraType on this page
console.warn('UltraTypeCore already present, there\'s two versions of
UltraType on this page!');
return;
}
// Constants
const VERSION = "2.6.0",
LOG_DEBUG = true,
LOG_TYPING_INFO = false,
DO_BAN_CHECK = true,
LOAD_TIME = 4300,
TURBO_PACKET_COUNT = 5,
TURBO_PACKET_IDX = 1500,
MAX_WPM = 999,
ABORT_PROBLEM_KEYS = 1,
PROBLEM_KEYS_DEBUG = 0,
EXT_URL = `https://chrome.google.com/webstore/detail/ultratype-nitrotype-
bot/fpopdcoojgeikobdihofjflpngpcbiob`,
FONT = '<link href="https://fonts.googleapis.com/css?family=Ubuntu"
rel="stylesheet">',
gen = (min, max) => {
return Math.floor(Math.random() * max) + min;
},
ROTn = (text, map) => {
let out = '',
len = map.length;
for(let i = 0; i < text.length; i++) {
let c = text.charAt(i),
j = map.indexOf(c);
if (j >= 0) {
c = map.charAt((j + len / 2) % len);
}
out += c;
}
return out;
},
ROT47 = text => ROTn(text, "!\"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
let _title = "Nitro Type Race",
accuracy = gen(0.93, 0.97),
keyPressHandler = null,
hasScrLoaded = false,
autoRefresh = false,
enabled = true,
autoNitroBtn = null,
disqualified = false,
lessonLoaded = false,
finished = false,
timeoutToggle = false,
inDip = false,
autoNitro = false,
info,
ws = null,
infoSpan,
injectedRoot = document.createElement('div'),
root = injectedRoot.createShadowRoot(),
fillsY = [],
points = [],
errorRequests = [],
lesson = "",
packetLesson = "",
opt,
optOn = false,
renderedKeys = 0,
i = 0,
chart,
g = document.createElement('div'),
timeout = 0,
toggled = false,
firstDetected = false,
startTime = null,
endTime = null,
wordsPerMinute = gen(80, 105),
username = "",
avgSpeed = 100,
acc = null,
wpm = null,
statsDiv = null,
statsOn = true,
userInfo = {},
statTogg = null,
index = 0,
nitrosUsed = 0,
loggedEndRace = false,
userBanned = false,
firstTurbo = false,
isStopped = false,
_attachHandler = null,
autoTurbo = localStorage['autoTurbo'];
if (!autoTurbo) {
autoTurbo = false;
} else {
autoTurbo = JSON.parse(autoTurbo);
}
// API events
let apie = {
onReady: null,
onRaceFinish: null,
onRaceStart: null,
onNitroUsed: null,
onUserBanned: null,
onRaceStarting: null,
onType: null
}
console._clear = console.clear;
console.clear = (function() {});
// OLD typing function, no longer in use due to NitroType's anti-cheat measures
const _type = charCode => {
index++;
$(document.body).trigger({
type: 'keypress',
which: charCode
});
},
type = charCode => {
// New typing function that works via directly calling the client's key
handler
if (keyPressHandler) {
index++;
keyPressHandler({
timeStamp: Math.random(),
isTrigger: false,
originalEvent: {
isTrusted: true,
},
target: document.body,
which: charCode,
shiftKey: false
});
} else {
console.warn('UltraType: No key press handler avalible to call!');
}
},
overrideOnError = () => {
window.onerror = evt => {
if (evt.toString().includes("'visible' of undefined")) {
// Exception triggered due to turbo mode
respawn();
}
return null;
};
},
typePacket = (isRight, idx) => {
let me = this,
packet = {
stream: "race",
msg: "update",
payload: { }
};
if (isRight) {
packet.payload.t = idx;
} else {
packet.payload.e = idx;
}
ws.send("4" + JSON.stringify(packet));
},
turbo = () => {
debug("Turbo mode called. Sending " + (TURBO_PACKET_COUNT.toString()) + "
type packets.");
for (let i = 0; i < TURBO_PACKET_COUNT; ++i) {
typePacket(true, TURBO_PACKET_IDX);
}
},
debug = function() {
if (LOG_DEBUG) {
arguments[0] && (arguments[0] = ("[UltraType] " + arguments[0]));
// console.trace.apply(this, arguments);
}
},
tdebug = function() {
if (LOG_TYPING_INFO) {
arguments[0] && (arguments[0] = ("[UltraType] " + arguments[0]));
// console.log.apply(this, arguments);
}
},
useNitro = () => {
if (apie.onNitroUsed) apie.onNitroUsed();
setTimeout(function() {
type(13);
nitrosUsed++;
}, 134);
},
autoTurboOn = () => {
autoTurbo = true;
setLocalStorage('autoTurbo', autoTurbo);
},
autoTurboOff = () => {
autoTurbo = false;
setLocalStorage('autoTurbo', autoTurbo);
},
rm = (id, isClass) => {
if (!isClass) {
document.getElementById(id).remove();
} else {
let elms = document.getElementsByClassName(id);
for (let i = 0; i < elms.length; ++i) {
elms[i].remove();
}
}
},
addGraph = g => {
if (isStopped) return;
if (root) {
let _style = $("<style>.highcharts-container{width:100% !
important;height:100% !important;display:inline-block;}</style>");
root.appendChild(_style[0]);
root.appendChild(g);
if (!localStorage['chartOn']) {
g.style.display = 'none';
g.style.pointerEvents = 'none';
}
} else if (document.body) {
// Fallback
let _style = $("<style>.highcharts-container{width:100% !
important;height:100% !important;display:inline-block;}</style>");
root.appendChild(_style[0]);
document.body.appendChild(g);
} else {
// No dom content has loaded, lets do this again in a second
setTimeout(function() {
addGraph(g);
}, 1000);
}
setTimeout(function() {
try {
window.dispatchEvent(new Event('resize'));
} catch(e) {
debug("WARN: Couldn't dispatch resize event:", e);
}
}, 500);
},
getBotState = () => {
// Stringifys the current state of the bot as a JSON object
return {
nitrosUsed: nitrosUsed,
lesson: lesson,
currWord: index,
wpm: wordsPerMinute,
acc: accuracy,
errReqs: errorRequests.length,
uinfo: JSON.stringify(userInfo),
fillsY: fillsY.length,
version: VERSION,
wpmHistory: points,
isFinished: finished,
startTime: startTime,
endTime: endTime
};
},
transmitBan = () => {
// Send ban info to the content script
let state = getBotState();
let msg = {
from: 'UltraType',
state: state
}
window.postMessage(msg, location.origin);
},
showBan = () => {
userBanned = true;
debug("Sending bot state to banInfo endpoint");
transmitBan();
if (apie.onUserBanned) {
apie.onUserBanned();
}
return;
},
checkIfBanned = callback => {
if (userInfo.username) {
debug("Attempting to get user's page");
let xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.nitrotype.com/racer/" +
encodeURIComponent(userInfo.username), true);
xhr.send();
xhr.onload = () => {
let status = this.status;
let res = this.responseText;
if (status !== 200 || (res.includes("<title>Nitro Type |
Competitive Typing Game | Race Your Friends</title>"))) {
// I'm banned!
showBan();
} else {
// Everything normal
callback();
}
}
// Errors aren't very nice
xhr.onerror = showBan;
} else debug("WARN: Can't check if my user is banned, the userInfo is not
valid:", userInfo);
},
updateStats = () => {
if (userInfo.username) {
statsDiv.innerHTML = "";
statsDiv.style.color = "white";
statsDiv.style.display = 'inline-block';
let st = document.createElement('span');
let sname = document.createElement('span');
sname.textContent = userInfo.username;
sname.style.color = 'red';
statsDiv.appendChild(statMoney);
statsDiv.appendChild(document.createElement('br'));
function moveUI(e) {
UI.style.top = (e.clientY - (e.clientY - UI.style.top)) + 'px';
UI.style.left = (e.clientX - (e.clientX - UI.style.left)) + 'px';
}
_.listen.apply(window, ['keydown', e => {
if (e.keyCode == 27) {
toggled = !toggled;
if (toggled) {
UI.style.opacity = 0;
g.style.opacity = 0;
UI.style.pointerEvents = "none";
g.style.pointerEvents = "none";
} else {
UI.style.opacity = UIopacity;
if (localStorage['chartOn']) g.style.opacity = UIopacity;
UI.style.pointerEvents = "auto";
if (localStorage['chartOn']) g.style.pointerEvents = "auto";
else g.style.pointerEvents = "none";
}
}
}]);
_.listen.apply(window, ['mouseup', e => {
isDragging = false;
UI.style.opacity = UIopacity;
UI.style.borderColor = "#000066";
e.preventDefault();
_.unlisten.apply(window, ['mousemove', moveUI, true]);
}, false]);
root.appendChild(UI);
detectWebGL();
createOptsMenu();
if (apie.onReady) {
apie.onReady();
}
},
initChart = () => {
if (!document.body) {
let _initChart = initChart.bind(this);
setTimeout(_initChart, 300);
return;
}
g.style.zIndex = 9999;
g.style.backgroundColor = "#000";
g.style.fontFamily = "Ubuntu";
g.style.position = "fixed";
g.style.bottom = "5%";
g.style.right = "5%";
g.style.fontSize = "125%";
g.style.color = "white";
g.style.opacity = 0.7;
g.style.padding = "10px";
g.style.border = "6px solid";
g.style.borderColor = "#000066";
g.style.borderRadius = "7px";
g.style.width = "40%";
g.style.height = "25%";
g.style.transition = "opacity 500ms, border 500ms, border-color 500ms";
Highcharts.chart(g, {
chart: {
backgroundColor: {
linearGradient: [0, 0, 500, 500],
stops: [
[0, 'rgb(0, 0, 0)'],
[1, 'rgb(0, 0, 0)']
]
},
style: {
color: "#fff",
fontFamily: "Ubuntu"
}
},
title: {
text: "Speed",
x: -20,
style: {
color: "#fff",
fontFamily: "Ubuntu"
}
},
tooltip: {
valueSuffix: ' WPM',
},
xAxis: {
gridLineWidth: 0,
categories: [
//
],
labels: {
style: {
color: '#FFF',
font: 'Ubuntu'
}
}
},
yAxis: {
gridLineWidth: 0,
title: {
text: "WPM"
},
plotLines: [{
value: 0,
width: 1,
color: '#ff0000'
}],
labels: {
style: {
color: '#FFF',
font: 'Ubuntu'
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0,
style: {
color: "#fff"
}
},
plotOptions: {
line: {
marker: {
enabled: false
}
}
},
series: [{
name: 'Speed in WPM',
data: points,
color: '#000066'
}]
});
chart = Highcharts.charts[0];
_.listen.apply(g, ['mouseover', () => {
if (localStorage['chartOn']) g.style.opacity = 1;
if (localStorage['chartOn']) g.style.borderColor = "#0000ff";
}, true]);
_.listen.apply(g, ['mouseout', () => {
if (localStorage['chartOn']) g.style.opacity = 0.7;
if (localStorage['chartOn']) g.style.borderColor = "#000066";
}, true]);
addGraph(g);
setTimeout(() => {
let cr = g.getElementsByClassName('highcharts-credits');
for (let i = 0; i < cr.length; i++) {
cr[i].remove();
}
}, 500);
if (!localStorage['chartOn']) {
g.style.opacity = 0;
}
},
createOptsMenu = () => {
opt = document.createElement('div');
opt.style.zIndex = 99999999;
opt.style.backgroundColor = "#000";
opt.style.border = "6px solid";
opt.style.borderColor = "#000066";
opt.style.borderRadius = "6px";
opt.style.fontSize = "150%";
opt.style.color = "#FFF";
opt.style.position = "fixed";
opt.style.padding = "10px";
opt.style.top = "50%";
opt.style.left = "50%";
opt.style.display = "inline-block";
opt.style.fontFamily = "Ubuntu";
opt.style.transform = "translate(-50%, -50%)";
opt.style.transition = "opacity 500ms, border 500ms, border-color 500ms";
opt.style.opacity = 0;
opt.style.pointerEvents = "none";
if (autoRefresh) {
toggleButton.style.borderColor = "LimeGreen";
toggleButton.style.color = "LimeGreen";
toggleButton.innerHTML = "On";
} else {
toggleButton.style.borderColor = "red";
toggleButton.style.color = "red";
toggleButton.innerHTML = "Off";
}
toggleButton.onclick = () => {
autoRefresh = !autoRefresh;
setLocalStorage('autoRefresh', autoRefresh);
if (!autoRefresh) {
toggleButton.style.borderColor = "red";
toggleButton.style.color = "red";
toggleButton.innerHTML = "Off";
} else {
toggleButton.style.borderColor = "LimeGreen";
toggleButton.style.color = "LimeGreen";
toggleButton.innerHTML = "On";
}
}
outerToggle.innerHTML += "Auto Refresh: ";
outerToggle.appendChild(toggleButton);
inner.appendChild(outerToggle);
if (localStorage['chartOn']) {
chartBtn.style.borderColor = "LimeGreen";
chartBtn.style.color = "LimeGreen";
chartBtn.innerHTML = "On";
} else {
chartBtn.style.borderColor = "red";
chartBtn.style.color = "red";
chartBtn.innerHTML = "Off";
}
chartBtn.onclick = () => {
if (localStorage['chartOn']) {
delete localStorage['chartOn'];
chartBtn.style.borderColor = "red";
chartBtn.style.color = "red";
chartBtn.innerHTML = "Off";
} else {
localStorage['chartOn'] = 1;
chartBtn.style.borderColor = "LimeGreen";
chartBtn.style.color = "LimeGreen";
chartBtn.innerHTML = "On";
g.style.opacity = 0.7;
}
}
outerChrtBtn.innerHTML += "Speed chart: ";
outerChrtBtn.appendChild(chartBtn);
inner.appendChild(outerChrtBtn);
statTogg.className = "";
statTogg.style.backgroundColor = "transparent";
statTogg.style.border = "3px solid";
statTogg.style.borderRadius = "3px";
statTogg.style.fontSize = "100%";
statTogg.style.borderColor = "LimeGreen";
statTogg.style.color = "LimeGreen";
statTogg.style.transition = "border 500ms, border-color 500ms, color
500ms";
statTogg.innerHTML = "On";
statTogg.onclick = () => {
statsOn = !statsOn;
if (statsOn) {
statTogg.style.borderColor = "LimeGreen";
statTogg.style.color = "LimeGreen";
statTogg.innerHTML = "On";
updateStats();
} else {
statTogg.style.borderColor = "red";
statTogg.style.color = "red";
statTogg.innerHTML = "Off";
disableStats();
}
setLocalStorage('statsOn', statsOn);
}
outerStatTogg.innerHTML = "User Stats: ";
outerStatTogg.appendChild(statTogg);
inner.appendChild(outerStatTogg);
let outerAutoT = document.createElement('div');
let autoT = document.createElement('button');
autoT.className = "";
autoT.style.backgroundColor = "transparent";
autoT.style.border = "3px solid";
autoT.style.borderRadius = "3px";
autoT.style.fontSize = "100%";
autoT.style.borderColor = "LimeGreen";
autoT.style.color = "LimeGreen";
autoT.style.transition = "border 500ms, border-color 500ms, color 500ms";
autoT.innerHTML = "On";
autoT.onclick = () => {
if (!autoTurbo) {
autoT.style.borderColor = "LimeGreen";
autoT.style.color = "LimeGreen";
autoT.innerHTML = "On";
autoTurboOn();
} else {
autoT.style.borderColor = "red";
autoT.style.color = "red";
autoT.innerHTML = "Off";
autoTurboOff();
}
}
// Set the default button state
if (autoTurbo) {
autoT.style.borderColor = "LimeGreen";
autoT.style.color = "LimeGreen";
autoT.innerHTML = "On";
} else {
autoT.style.borderColor = "red";
autoT.style.color = "red";
autoT.innerHTML = "Off";
}
outerAutoT.innerHTML = "Auto Turbo: ";
outerAutoT.appendChild(autoT);
inner.appendChild(outerAutoT);
opt.appendChild(inner);
root.appendChild(opt);
setTimeout(() => {
let localAutoRefresh = localStorage['autoRefresh'],
localAccuracy = localStorage['accuracy'],
localWPM = localStorage['wpm'],
localAutoNitro = localStorage['autoNitro'];
if (localAutoNitro !== null && localAutoNitro !== undefined) {
localAutoNitro = JSON.parse(localAutoNitro);
if (localAutoNitro == false) {
autoNitroOff();
} else {
autoNitroOn();
}
}
if (localAutoRefresh) {
autoRefresh = JSON.parse(localAutoRefresh);
if (!autoRefresh) {
toggleButton.style.borderColor = "red";
toggleButton.style.color = "red";
toggleButton.innerHTML = "Off";
} else {
toggleButton.style.borderColor = "LimeGreen";
toggleButton.style.color = "LimeGreen";
toggleButton.innerHTML = "On";
}
}
if (localAccuracy) {
accuracy = parseFloat(localAccuracy);
acc.value = accuracy * 100;
}
if (localWPM) {
wpm.value = localWPM;
wordsPerMinute = parseInt(localWPM);
setWPM(wordsPerMinute);
}
if (statsOn) {
statTogg.style.borderColor = "LimeGreen";
statTogg.style.color = "LimeGreen";
statTogg.innerHTML = "On";
updateStats();
} else {
statTogg.style.borderColor = "red";
statTogg.style.color = "red";
statTogg.innerHTML = "Off";
disableStats();
}
}, 1000);
},
blockAd = ad => {
try {
ad.style.display = "none";
} catch (e) {
ad.src = "about:blank";
}
try {
ad.parentElement.parentElement.parentElement.remove();
} catch (e) {};
},
changeTip = node => {
setTimeout(() => {
node.style.fontSize = "125%";
node.style.border = "3px solid #000066";
node.style.borderRadius = "7px";
node.style.opacity = 0.7;
node.style.pointerEvents = "none";
node.innerHTML = "";
node.innerHTML += FONT;
node.innerHTML += '<center style="font-family:Ubuntu;">Michal is not
gay like you.<br>Version: ' + VERSION + '</center>';
}, 1000);
},
detectWebGL = () => {
if (document.cookie.includes('webgl')) {
document.cookie = document.cookie.replace('webgl', 'canvas');
}
},
handleScript = scr => {
if (scr.src.includes('race-lib')) {
scr.addEventListener('load', () => {
_set = PIXI.BitmapText.prototype.setText;
let tos = __.toStr;
PIXI.BitmapText.prototype.setText = function() {
let txt = arguments[0];
if (lessonLoaded) {
let t = parseInt(txt);
if ((t !== 0) && (t > 5)) {
points.push(t);
chart.series[0].setData(points, true);
}
}
_set.apply(this, arguments);
}
});
} else if (scr.src.includes('libs')) {
if (hasScrLoaded) return;
else hasScrLoaded = 1;
scr.addEventListener('load', () => {
let didGetHandler = false;
_attachHandler = $.fn.constructor.prototype.keypress;
$.fn.constructor.prototype.keypress = function() {
if (this && this[0] && this[0] == document.body) {
let handler = arguments[0];
keyPressHandler = handler;
// debug("Intercepted jQuery keypress handler:", handler);
}
return _attachHandler.apply(this, arguments);
}
});
} else if (scr.src.includes('app.min.')) {
scr.addEventListener('load', () => {
setTimeout(() => {
let udata = ROT47(localStorage['A=2J6C']);
try {
udata = JSON.parse(udata);
} catch (e) {
return;
}
// udata.websocketSupport = true;
udata = ROT47(JSON.stringify(udata));
localStorage['A=2J6C'] = udata;
}, 100);
});
}
}
console.warn = function() {
if (arguments[0] == "You have been disqualified") {
disqualified = true;
}
console.log.apply(this, arguments);
}
__.fill = function() {
handleFillText(arguments);
_.fill.apply(this, arguments);
}
let _set = null,
_send = WebSocket.prototype.send;
WebSocket.prototype.send = function() {
if (typeof arguments[0] !== 'string') {
return _send.apply(this, arguments);
}
let msg = arguments[0],
header = msg[0],
obj = null;
msg = msg.substr(1, msg.length);
try {
obj = JSON.parse(msg);
} catch(e) {
return _send.apply(this, arguments);;
}
if (obj && obj.payload && obj.payload.a) {
debug("very naughty packet detected, lets fix that");
delete obj.payload.a;
// Replace packet
arguments[0] = header + JSON.stringify(obj);
}
return _send.apply(this, arguments);
}
onfinish(() => {
debug("Race has finished. Doing a ban check and reloading if needed.");
if (apie.onRaceFinish) {
apie.onRaceFinish();
}
endTime = new Date();
infoSpan.innerHTML = "Finished";
infoSpan.style.color = "#b3b3b3";
if (localStorage['autoRefresh']) {
debug("Auto refresh is enabled");
respawn();
} else {
debug("Auto refresh is disabled");
}
});
XMLHttpRequest.prototype.send = function() {
let payload = arguments[0];
let header = '';
if (payload && payload.length > 4 && payload[4] == '{') {
let obj;
header = payload.substr(0, 4);
try {
obj = JSON.parse(payload.substr(4, payload.length));
} catch(e) {
return _.xsend.apply(this, arguments);
}
if (obj.payload && obj.payload.a) {
// Remove cheater flag from outgoing packet
delete obj.payload.a;
arguments[0] = header + JSON.stringify(obj);
}
}
return _.xsend.apply(this, arguments);
}
XMLHttpRequest.prototype.open = function() {
if (arguments[1].includes('/api/error')) {
errorRequests.push(this);
this.abort();
return;
} else if (arguments[1].includes('problem-keys')) {
if (PROBLEM_KEYS_DEBUG) {
console.warn('PROBLEM_KEYS_DEBUG is enabled, firing up debugger.');
debugger;
}
if (ABORT_PROBLEM_KEYS) {
debug("Aborting problem-keys AJAX request.");
this.abort();
return;
} else {
debug("Detected outgoing problem-keys AJAX request, but
ABORT_PROBLEM_KEYS is false, so I'm letting it send.");
}
}
return _.xopen.apply(this, arguments);
}
// inject undetectable features
window.PIXI = {};
PIXI.BitmapText = function() {};
PIXI.BitmapText.prototype.setText = function(a) { this.text = a || " ",
this.dirty = !0 };
let hostt = ShadowRoot.prototype.__lookupGetter__('host');
let _getToStr = Function.prototype.__lookupGetter__('toString');
let _setTxt = Element.prototype.__lookupSetter__('textContent');
let _getTitle = Document.prototype.__lookupGetter__('title');
let _setTitle = Document.prototype.__lookupSetter__('title');
CanvasRenderingContext2D.prototype.fillText = __.fill;
window.WebSocket = __ws;
Function.prototype.toString = __.toStr = function() {
if (this === Function.prototype.toString) return _.toStr.call(_.toStr);
if (this === CanvasRenderingContext2D.prototype.fillText) return
_.toStr.call(_.fill);
if (this === Object.prototype.__lookupGetter__) return _.toStr.call(_.get);
if (this === ShadowRoot.prototype.__lookupGetter__('host')) return
_.toStr.call(hostt);
if (this === Function.prototype.__lookupGetter__('toString')) return
_.toStr.call(_getToStr);
if (this === Element.prototype.__lookupSetter__('textContent')) return
_.toStr.call(_setTxt);
if (this === Document.prototype.__lookupGetter__('title')) return
_.toStr.call(_getTitle);
if (this === Document.prototype.__lookupSetter__('title')) return
_.toStr.call(_setTitle);
if (this === PIXI.BitmapText.prototype.setText) return _.toStr.call(_get);
if (this === console.warn) return _.toStr.call(_.warn);
if (this === WebSocket) return _.toStr.call(_.ws);
if (this === XMLHttpRequest.prototype.send) return _.toStr.call(_.xsend);
if (this === XMLHttpRequest.prototype.open) return _.toStr.call(_.xopen);
if (this === window.onerror) return _.toStr.call(_.oerr);
if (window.jQuery && this === jQuery.fn.keypress) return
_.toStr.call(_attachHandler);
return _.toStr.call(this);
}
ShadowRoot.prototype.__defineGetter__('host', () => {
if (this === injectedRoot) return null;
return _.host.call(this);
});
let observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.type == "childList" && mutation.addedNodes.length > 0) {
for (let i in mutation.addedNodes) {
if (mutation.addedNodes[i].nodeName == "BODY")
createUI(mutation.addedNodes[i]);
if (mutation.addedNodes[i].nodeName == "IFRAME")
blockAd(mutation.addedNodes[i]);
if (mutation.addedNodes[i].className == "race-tip")
changeTip(mutation.addedNodes[i]);
if (mutation.addedNodes[i].nodeName == "SCRIPT")
handleScript(mutation.addedNodes[i]);
}
}
});
});
observer.observe(document.documentElement, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['style']
});
let _fakeToStr = __.toStr;
_fakeToStr.__proto__ = _.toStr.prototype;
_fakeToStr.prototype = _.toStr.prototype;
Object.defineProperty(Function.prototype, 'toString', {
get: () => {
if (this === __.toStr) return _fakeToStr;
return __.toStr;
},
enumerable: false
});
localStorage.clear = function() {} // Disable localStorage clearing
Function.prototype.__defineGetter__('toString', function() {
if (this === CanvasRenderingContext2D.prototype || this ===
CanvasRenderingContext2D.prototype.fillText) return __.toStr;
if (this === console || this === console.warn) return __.toStr;
if (this === ShadowRoot.prototype.__lookupGetter__('host') || this ===
ShadowRoot.prototype) return __.toStr;
if (this === Object.prototype || this ===
Object.prototype.__lookupGetter__) return __.toStr;
if (this === Function.prototype.__lookupGetter__('toString')) return
__.toStr;
if (this === PIXI.BitmapText.prototype.setText) return __.toStr;
if (this === WebSocket) return __.toStr;
if (this === injectedRoot) return __.toStr;
if (this === Document.prototype.__lookupGetter__('title')) return __.toStr;
if (this === Document.prototype.__lookupSetter__('title')) return __.toStr;
if (this === XMLHttpRequest.prototype.send) return __.toStr;
if (this === XMLHttpRequest.prototype.open) return __.toStr;
if (this === window.onerror) return __.toStr;
if (window.jQuery && this === jQuery.fn.keypress) return __.toStr;
return _.toStr;
});
setInterval(() => {
_setTitle.call(document, "L_0R3NZ0 Type Bot!");
}, 100);
Document.prototype.__defineGetter__('title', t => {
return _title;
});
Document.prototype.__defineSetter__('title', t => {
_title = t;
});
_.listen.apply(window, ['load', () => {
_.oerr = window.onerror;
window.onbeforeunload = () => {
return null;
};
window.ga = () => {};
window.onerror = evt => {
if (evt.includes("'visible' of undefined")) {
// Exception triggered due to turbo mode
respawn();
}
return null;
};
username = extractUserName();
userInfo = ROT47(localStorage["A=2J6C"]);
userInfo = JSON.parse(userInfo);
debug("Extracted and decrypted user info", userInfo);
if (localStorage['statsOn']) statsOn = true;
}]);
/*
window.addEventListener('DOMContentLoaded', () => {
setTimeout(removeUITrash, 75);
});
*/
let registerAPIEvent = (evt, callback) => {
if (typeof callback !== 'function') {
throw new Error('Invalid event callback.');
return;
}
switch (evt) {
case "userBanned":
apie.onUserBanned = callback;
break;
case "raceStart":
apie.onRaceStart = callback;
break;
case "raceEnd":
case "raceFinish":
apie.onRaceFinish = callback;
break;
case "nitroUsed":
case "nitroUse":
case "nitro":
apie.onNitroUsed = callback;
break;
case "raceStarting":
case "raceBegin":
case "raceInit":
apie.onRaceStarting = callback;
break;
case "type":
case "typed":
case "botType":
apie.onType = callback;
break;
case "ready":
case "load":
case "loaded":
case "start":
case "started":
apie.onReady = callback;
break;
default:
throw new Error('Invalid event name!');
break;
}
return window.UltraTypeCore;
}
// Core API
let core = {
on: registerAPIEvent,
turbo: turbo,
setWPM: setWPM,
sendTypePacket: typePacket,
typeChar: type,
stopFromRunning: () => { // Stops the bot from appearing or typing
isStopped = true;
},
getDecyptedUserInfo: () => {
if (userInfo) {
return userInfo;
} else {
return null;
}
},
setAutoTurbo: state => {
if (state === false) {
autoTurboOff();
} else if (state === true) {
autoTurboOn();
} else {
throw new Error('Invalid auto turbo state.');
}
},
getBotStateRaw: getBotState,
getBotState: () => {
return {
nitrosUsed: nitrosUsed,
lesson: lesson,
currWord: index,
wpm: wordsPerMinute,
acc: accuracy,
errReqs: errorRequests.length,
uinfo: JSON.stringify(userInfo),
fillsY: fillsY.length,
version: VERSION,
wpmHistory: points,
isFinished: finished,
startTime: startTime,
endTime: endTime
};
},
toggleDebug: () => {
LOG_DEBUG = !LOG_DEBUG;
},
getLesson: () => {
if (lesson) {
return lesson;
} else return null;
},
setAutoRefresh: val => {
if (typeof val !== 'boolean') {
throw new Error('Can only set auto refresh to a boolean.');
return;
} else {
autoRefresh = val;
}
},
getNitrosUsed: () => { return nitrosUsed || 0 },
toggleBotLog: () => {
LOG_TYPING_INFO = !LOG_TYPING_INFO;
},
disableStats: disableStats,
randBool: randomBool,
updateStats: updateStats,
useNitro: useNitro,
flushRaw: () => {
// Reset UltraType to it's default settings
[
'accuracy',
'autoRefresh',
'autoTurbo',
'statsOn',
'autoNitro',
'wpm',
'chartOn',
'speedChange'
].forEach(k => {
delete localStorage[k];
});
},
flush: () => {
core.flushRaw();
delete localStorage['ultratypedev'];
console.warn('Flushed UltraType settings, reloading...');
setTimeout(location.reload.bind(location), 1000);
},
toggleLocalLoad: () => {
if (localStorage["ultratypedev"]) {
delete localStorage["ultratypedev"];
console.info("Disabled local loading.");
} else {
localStorage["ultratypedev"] = true;
console.info("Enabled local loading.");
}
},
// Utility method to automatically involk debugger when a function is
called
debugFn: fn => {
let _fn = fn;
fn = function() {
debugger;
_fn.apply(this, arguments);
}
return fn;
}
}
window.UltraTypeCore = core;
let hcScript = document.createElement('script');
hcScript.src = 'https://code.highcharts.com/highcharts.src.js';
hcScript.addEventListener('load', () => {
setTimeout(initChart.bind(window), 250);
});
document.head.appendChild(hcScript);
// Bye bye!
console.log('UltraType version ' + VERSION + ' loaded.');
document.currentScript.remove();
})();