Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
// ==UserScript==
// @name Bonk Commands
// @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
// @version 24.1
// @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
// @author LEGENDBOSS123 + left paren + mastery3
// @match https://bonk.io/*
// @match https://bonkisback.io/*
// @match https://multiplayer.gg/physics/*
// @run-at document-idle
// @grant none
// @icon https://www.google.com/s2/favicons?sz=64&domain=bonk.io
// @unwrap
// ==/UserScript==
function BonkCommandsScriptInjector(f) {
if (window.location == window.parent.location) {
if (document.readyState == "complete") { f(); }
else { document.addEventListener('readystatechange', function () { setTimeout(f, 1500); }); }
}
}
BonkCommandsScriptInjector(function () {
var scope = window;
scope.scope = scope;
scope.Gwindow = document.getElementById("maingameframe").contentWindow;
scope.Gdocument = document.getElementById("maingameframe").contentDocument;
Gwindow.Gwindow = window;
Gwindow.Gdocument = document;
if (Gdocument.getElementById("passwarn")) { Gdocument.getElementById("passwarn").remove(); }
scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
if (typeof (scope.injectedBonkCommandsScript) == 'undefined') {
scope.injectedBonkCommandsScript = true;
}
else {
clearInterval(injectedBonkCommandsScript);
}
scope.GENERATE_COPRIME_NUMBER = function (mini = 0, maxi = 0, coprimewith = 0, choices = []) {
if (choices.length == 0) {
for (var i = mini; i < maxi + 1; i++) {
choices.push(i);
}
}
firstTry = choices[Math.floor(Math.random() * choices.length)];
for (var i = 2; i < firstTry + 1; i++) {
if (firstTry % i == 0 && coprimewith % i == 0) {
choices.splice(choices.indexOf(firstTry), 1);
if (choices.length == 0) {
return 0;
}
return GENERATE_COPRIME_NUMBER(mini, maxi, coprimewith, choices);
}
}
return firstTry;
};
scope.GENERATE_PRIME_NUMBER = function (mini = 0, maxi = 0, choices = []) {
if (choices.length == 0) {
for (var i = mini; i < maxi + 1; i++) {
choices.push(i);
}
}
firstTry = choices[Math.floor(Math.random() * choices.length)];
for (var i = 2; i < Math.floor(Math.sqrt(firstTry) + 1); i++) {
if (i != firstTry) {
if (firstTry % i == 0) {
choices.splice(choices.indexOf(firstTry), 1);
if (choices.length == 0) {
return 0;
}
return GENERATE_PRIME_NUMBER(mini, maxi, choices);
}
}
}
return firstTry;
};
scope.SHOW_MESSAGE = function (message) {
const theme = {
backdropBg: 'rgba(0, 0, 0, 0.4)',
modalBg: 'rgba(255, 255, 255, 0.9)',
textColor: '#222',
buttonBg: '#4A90E2',
buttonShadow: '4px 4px 8px rgba(0,0,0,0.1), -4px -4px 8px rgba(255,255,255,0.7)',
buttonHoverBg: '#357ABD',
borderRadius: '10px',
fontFamily: '"Segoe UI", Roboto, Arial, sans-serif',
fontSize: '1.25rem',
zIndex: '2147483647'
};
const backdrop = document.createElement('div');
Object.assign(backdrop.style, {
position: 'fixed',
inset: '0',
backgroundColor: theme.backdropBg,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: theme.zIndex,
animation: 'fadeIn 0.3s ease'
});
const modal = document.createElement('div');
Object.assign(modal.style, {
backgroundColor: theme.modalBg,
borderRadius: theme.borderRadius,
boxShadow: '0 12px 24px rgba(0, 0, 0, 0.2)',
maxWidth: '90%',
width: '380px',
padding: '28px',
fontFamily: theme.fontFamily,
textAlign: 'center',
color: theme.textColor,
transform: 'translateY(-20px)',
animation: 'slideIn 0.4s ease forwards'
});
const textEl = document.createElement('p');
textEl.textContent = message;
Object.assign(textEl.style, {
margin: '0 0 24px',
fontSize: theme.fontSize,
lineHeight: '1.5'
});
const btn = document.createElement('button');
btn.textContent = 'OK';
Object.assign(btn.style, {
backgroundColor: theme.buttonBg,
border: 'none',
color: '#fff',
padding: '12px 28px',
fontSize: '1rem',
borderRadius: theme.borderRadius,
cursor: 'pointer',
boxShadow: theme.buttonShadow,
transition: 'background-color 0.2s ease, transform 0.2s ease'
});
btn.addEventListener('mouseenter', () => {
btn.style.backgroundColor = theme.buttonHoverBg;
btn.style.transform = 'scale(1.05)';
});
btn.addEventListener('mouseleave', () => {
btn.style.backgroundColor = theme.buttonBg;
btn.style.transform = 'scale(1)';
});
btn.addEventListener('click', () => {
document.body.removeChild(backdrop);
});
if (!document.getElementById('show-message-keyframes')) {
const styleTag = document.createElement('style');
styleTag.id = 'show-message-keyframes';
styleTag.textContent = `
@keyframes fadeIn {
from { opacity: 0 }
to { opacity: 1 }
}
@keyframes slideIn {
to { transform: translateY(0) }
}
`;
document.head.appendChild(styleTag);
}
modal.appendChild(textEl);
modal.appendChild(btn);
backdrop.appendChild(modal);
document.body.appendChild(backdrop);
};
scope.SHUFFLE_LIST = function (x) {
var nl = x.slice();
for (var i = nl.length - 1; i > 0; i--) {
var r = Math.floor(Math.random() * (i + 1));
var t = nl[i];
nl[i] = nl[r];
nl[r] = t;
}
return nl;
};
scope.str2ab = function (str) {
const buf = new ArrayBuffer(str.length);
const bufView = new Uint8Array(buf);
for (let i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
};
scope.ab2str = function (buffer) {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
};
scope.GENERATE_KEYS = async function () {
return crypto.subtle.generateKey({ name: "RSA-OAEP", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: { name: "SHA-256" } }, true, ["encrypt", "decrypt"]);
};
scope.ENCRYPT_MESSAGE = async function (key, data) {
try {
var encrypted = await window.crypto.subtle.encrypt(
{
name: "RSA-OAEP"
},
key,
new TextEncoder().encode(data)
);
return btoa(ab2str(encrypted));
}
catch (E) {
return 0;
}
};
scope.DECRYPT_MESSAGE = async function (key, data) {
try {
var decrypted = await window.crypto.subtle.decrypt(
{
name: "RSA-OAEP"
},
key,
str2ab(atob(data))
);
return new TextDecoder().decode(decrypted);
}
catch {
return 0;
}
};
scope.IMPORT_KEY = async function (key) {
return await crypto.subtle.importKey("spki", str2ab(atob(key)), public_key.algorithm, true, ["encrypt"]);
};
scope.EXPORT_KEY = async function (key) {
var result = await crypto.subtle.exportKey("spki", key);
return btoa(ab2str(result));
};
scope.loadMap = function (m, encode = true) {
var mapdata = encode ? encodeToDatabase(m) : m;
RECIEVE('42' + JSON.stringify([29, mapdata]));
SEND('42' + JSON.stringify([23, { "m": mapdata }]));
};
if (typeof (scope.textdecoder) == 'undefined') { scope.textdecoder = new Gwindow.TextDecoder; }
if (typeof (scope.textencoder) == 'undefined') { scope.textencoder = new Gwindow.TextEncoder; }
function loadImage(dataUrl) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = dataUrl;
});
}
const skinShapes = [
null,
""
];
const skinImages = [null];
let skinImagesPromise = null;
async function getSkinImages() {
if (skinImagesPromise) {
return skinImagesPromise;
}
skinImagesPromise = (async () => {
const images = [];
for (let i = 1; i < skinShapes.length; i++) {
images.push(await loadImage(skinShapes[i]));
}
skinImages.push(...images);
return skinImages;
})();
return skinImagesPromise;
}
class Layer {
static properties = new Set(['id', 'scale', 'angle', 'x', 'y', 'flipX', 'flipY', 'color']);
constructor(id) {
this.id = id;
this.scale = 0.25;
this.angle = 0;
this.x = 0;
this.y = 0;
this.flipX = false;
this.flipY = false;
this.color = 0xffffff;
}
static fromJSON(json) {
for (let key of Object.keys(json)) {
if (!Layer.properties.has(key)) {
throw new Error(`Unknown property in Layer JSON: ${key}`);
}
}
for (let property of Layer.properties) {
if (!(property in json)) {
throw new Error(`Missing property in Layer JSON: ${property}`);
}
}
const layer = new Layer(json.id);
layer.scale = json.scale;
layer.angle = json.angle;
layer.x = json.x;
layer.y = json.y;
layer.flipX = json.flipX;
layer.flipY = json.flipY;
layer.color = json.color;
return layer;
}
toJSON() {
return {
id: this.id,
scale: this.scale,
angle: this.angle,
x: this.x,
y: this.y,
flipX: this.flipX,
flipY: this.flipY,
color: this.color
};
}
copy() {
const newLayer = new Layer(this.id);
newLayer.scale = this.scale;
newLayer.angle = this.angle;
newLayer.x = this.x;
newLayer.y = this.y;
newLayer.flipX = this.flipX;
newLayer.flipY = this.flipY;
newLayer.color = this.color;
return newLayer;
}
static fromDataView(dataView, offset) {
const layer = new Layer(0);
let letter = (dataView.getUint8(offset)).toString(16);
offset += 1;
if (letter != "a") {
return [layer, offset];
}
if (dataView.getUint8(offset) == 7) {
offset += 3;
}
offset += 3;
layer.id = dataView.getUint16(offset);
offset += 2;
layer.scale = dataView.getFloat32(offset);
offset += 4;
layer.angle = dataView.getFloat32(offset);
offset += 4;
layer.x = dataView.getFloat32(offset);
offset += 4;
layer.y = dataView.getFloat32(offset);
offset += 4;
layer.flipX = dataView.getUint8(offset) !== 0;
offset += 1;
layer.flipY = dataView.getUint8(offset) !== 0;
offset += 1;
layer.color = dataView.getUint32(offset);
offset += 4;
return [layer, offset];
}
}
class Skin {
static offScreenCanvas = new OffscreenCanvas(1, 1);
static properties = new Set(['layers', 'bc']);
constructor() {
this.layers = [];
this.bc = 0x448aff;
}
addLayer(layer) {
this.layers.push(layer);
}
async exportCanvas(size = 735) {
const off = new OffscreenCanvas(size, size);
const offCtx = off.getContext('2d');
await this.draw(offCtx, size / 2, 0, 0, 1);
return off;
}
async exportBlob(size = 735) {
const canvas = await this.exportCanvas(size);
return await canvas.convertToBlob({ type: 'image/png' });
}
async download(size = 735, filename = 'skin.png') {
const blob = await this.exportBlob(size);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
}
async draw(ctx, radius = 100, offsetX = 0, offsetY = 0, scale = 1) {
const off = Skin.offScreenCanvas;
off.width = ctx.canvas.width;
off.height = ctx.canvas.height;
const offCtx = off.getContext('2d');
const cx = ctx.canvas.width / 2;
const cy = ctx.canvas.height / 2;
ctx.save();
ctx.translate(offsetX, offsetY);
ctx.scale(scale, scale);
ctx.beginPath();
ctx.arc(cx, cy, radius, 0, Math.PI * 2);
ctx.clip();
offCtx.save();
offCtx.translate(offsetX, offsetY);
offCtx.scale(scale, scale);
offCtx.beginPath();
offCtx.arc(cx, cy, radius, 0, Math.PI * 2);
offCtx.clip();
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.fillStyle = this.toHexString(this.bc);
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.restore();
offCtx.translate(cx, cy);
offCtx.scale(radius / 15, radius / 15);
for (let i = this.layers.length - 1; i >= 0; i--) {
const layer = this.layers[i];
const skinImage = (await getSkinImages())[layer.id];
if (!skinImage) {
continue;
}
const { x, y, scale, angle, flipX, flipY, color } = layer;
const width = skinImage.width * scale;
const height = skinImage.height * scale;
offCtx.save();
offCtx.setTransform(1, 0, 0, 1, 0, 0);
offCtx.clearRect(0, 0, offCtx.canvas.width, offCtx.canvas.height);
offCtx.restore();
offCtx.save();
offCtx.translate(x, y);
offCtx.rotate(angle * (Math.PI / 180));
offCtx.scale(flipX ? -1 : 1, flipY ? -1 : 1);
offCtx.drawImage(skinImage, -width / 2, -height / 2, width, height);
offCtx.globalCompositeOperation = 'source-in';
offCtx.fillStyle = this.toHexString(color);
offCtx.fillRect(-width / 2, -height / 2, width, height);
offCtx.globalCompositeOperation = 'source-over';
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(off, 0, 0);
ctx.restore();
offCtx.restore();
}
offCtx.restore();
ctx.restore();
}
toHexString(color) {
return `#${color.toString(16).padStart(6, '0')}`;
}
static fromJSON(json) {
for (let key of Object.keys(json)) {
if (!Skin.properties.has(key)) {
throw new Error(`Unknown property in Skin JSON: ${key}`);
}
}
for (let property of Skin.properties) {
if (!(property in json)) {
throw new Error(`Missing property in Skin JSON: ${property}`);
}
}
const skin = new Skin();
skin.layers = json.layers;
for (let i = 0; i < skin.layers.length; i++) {
skin.layers[i] = Layer.fromJSON(skin.layers[i]);
}
skin.bc = json.bc;
return skin;
}
toJSON() {
return {
layers: this.layers.map(layer => layer.toJSON()),
bc: this.bc
};
}
copy() {
const newSkin = new Skin();
newSkin.bc = this.bc;
for (const layer of this.layers) {
newSkin.layers.push(layer.copy());
}
return newSkin;
}
toString() {
let view = new DataView(new ArrayBuffer(1024));
let offset = 0;
view.setUint8(offset, 0x0A);
offset += 1;
view.setUint8(offset, 0x07);
offset += 1;
view.setUint8(offset, 0x03);
offset += 1;
view.setUint8(offset, 0x61);
offset += 1;
view.setUint16(offset, 0x02);
offset += 2;
view.setUint8(offset, 0x09);
offset += 1;
view.setUint8(offset, this.layers.length * 2 + 1);
offset += 1;
view.setUint8(offset, 0x01);
offset += 1;
for (let i = 0; i < this.layers.length; i++) {
const layer = this.layers[i];
view.setUint8(offset, 0x0A);
offset += 1;
if (i == 0) {
view.setUint8(offset, 0x07);
offset += 1;
view.setUint8(offset, 0x05);
offset += 1;
view.setUint8(offset, 0x61);
offset += 1;
view.setUint8(offset, 0x6C);
offset += 1;
}
else {
view.setUint8(offset, 0x05);
offset += 1;
}
view.setUint16(offset, 1);
offset += 2;
view.setUint16(offset, layer.id);
offset += 2;
view.setFloat32(offset, layer.scale);
offset += 4;
view.setFloat32(offset, layer.angle);
offset += 4;
view.setFloat32(offset, layer.x);
offset += 4;
view.setFloat32(offset, layer.y);
offset += 4;
view.setUint8(offset, layer.flipX ? 1 : 0);
offset += 1;
view.setUint8(offset, layer.flipY ? 1 : 0);
offset += 1;
view.setUint32(offset, layer.color);
offset += 4;
}
view.setUint32(offset, this.bc);
offset += 4;
const u8arr = new Uint8Array(view.buffer, 0, offset);
return btoa(String.fromCharCode(...u8arr));
}
static fromString(str) {
let u8arr;
try {
u8arr = Uint8Array.from(atob(decodeURIComponent(str)), c => c.charCodeAt(0));
}
catch (e) {
try {
u8arr = Uint8Array.from(atob(str), c => c.charCodeAt(0));
}
catch (e) {
throw new Error("Invalid skin string");
}
}
let dataView = new DataView(u8arr.buffer);
let offset = 0;
let skin = new Skin();
offset += 4;
let x5 = dataView.getUint16(offset);
offset += 3;
let layerCount = (dataView.getUint8(offset) - 1) / 2;
offset += 1;
let x7 = dataView.getUint8(offset);;
offset += 1;
while (x7 != 1) {
let x8 = 0;
if (x7 == 3) {
x8 = dataView.getUint8(offset) - 48;
offset += 1;
}
else if (x7 == 5) {
let x9 = dataView.getUint8(offset);
offset += 1;
let x10 = dataView.getUint8(offset);
offset += 1;
x8 = (x9 - 48) * 10 + (x10 - 48);
}
let [layer, newOffset] = Layer.fromDataView(dataView, offset);
skin.layers[x8] = layer;
x7 = dataView.getUint8(newOffset);
offset = newOffset + 1;
}
for (let i = 0; i < layerCount; i++) {
let [layer, newOffset] = Layer.fromDataView(dataView, offset);
skin.layers[i] = layer;
offset = newOffset;
}
if (x5 >= 2) {
skin.bc = dataView.getUint32(offset);
offset += 4;
}
return skin;
}
}
scope.pako = Gwindow.pako;
scope.v2k49 = class {
constructor() {
this["localX"] = 0;
this["localY"] = 0;
this["width"] = 0;
this["height"] = 0;
this["localAngle"] = 0;
this["shapeID"] = 0;
this["color"] = 0xff0000;
this["death"] = false;
this["noPhysics"] = false;
}
}
scope.post = async function (url, data) {
var d = {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: data,
}
const response = await fetch(url, d);
return response.json();
}
scope.q2z = class {
static T_UNDEFINED = 0;
static T_FALSE = 2;
static T_TRUE = 3;
static T_INT = 4;
static T_DOUBLE = 5;
static T_STRING = 6;
static T_ARRAY = 9;
static T_OBJ = 10;
static T_NULL = 1;
static aliases = {
gmp: class {
constructor() {
this["version"] = 0;
this["mapname"] = ""
this["author"] = ""
this["platformArray"] = [];
this["spawnArray"] = [];
this["platformNames"] = [];
this["spawnNames"] = [];
this["capZoneArray"] = [];
this["capZoneNames"] = [];
this["gravity"] = 20;
this["ppm"] = 12;
this["discFriction"] = 0;
this["discRestitution"] = 0.8;
this["discDensity"] = 1.0;
this["discLinearDamping"] = 0.0;
this["discRadius"] = 1.0;
this["discAllForce"] = 12;
this["respawn"] = false;
this["noCollide"] = false;
}
writeExternal(V0H) {
}
readExternal(g0H) {
var d6k = [arguments];
this["version"] = d6k[0][0]["readShort"]();
this["mapname"] = d6k[0][0]["readUTF"]();
if (this["mapname"]["length"] > 25) {
this["mapname"] = this["mapname"]["slice"](0, 25);
}
this["author"] = d6k[0][0]["readUTF"]();
if (this["author"]["length"] > 25) {
this["author"] = this["author"]["slice"](0, 35);
}
this["gravity"] = d6k[0][0]["readDouble"]();
this["ppm"] = d6k[0][0]["readDouble"]();
this["ppm"] = Math["max"](5, this["ppm"]);
this["ppm"] = Math["min"](30, this["ppm"]);
this["discFriction"] = d6k[0][0]["readDouble"]();
this["discRestitution"] = d6k[0][0]["readDouble"]();
this["discDensity"] = d6k[0][0]["readDouble"]();
this["discLinearDamping"] = d6k[0][0]["readDouble"]();
this["discRadius"] = d6k[0][0]["readDouble"]();
this["discAllForce"] = d6k[0][0]["readDouble"]();
d6k[2] = d6k[0][0]["readShort"]();
this["platformArray"] = [];
this["platformNames"] = [];
for (d6k[4] = 0; d6k[4] < d6k[2]; d6k[4]++) {
this["platformArray"]["push"](d6k[0][0]["readObject"]());
this["platformNames"]["push"](d6k[0][0]["readUTF"]());
}
d6k[6] = d6k[0][0]["readShort"]();
this["spawnArray"] = [];
this["spawnNames"] = [];
for (d6k[9] = 0; d6k[9] < d6k[6]; d6k[9]++) {
this["spawnArray"]["push"](d6k[0][0]["readObject"]());
this["spawnNames"]["push"](d6k[0][0]["readUTF"]());
}
if (this["version"] >= 2) {
this["capZoneArray"] = d6k[0][0]["readObject"]();
} else {
this["capZoneArray"] = [];
}
if (this["version"] >= 3) {
this["capZoneNames"] = d6k[0][0]["readObject"]();
} else {
this["capZoneNames"] = [];
}
if (this["version"] == 4) {
d6k[1] = d6k[0][0]["readBoolean"]();
this["noCollide"] = d6k[1];
this["respawn"] = d6k[1];
} else if (this["version"] > 4) {
this["noCollide"] = d6k[0][0]["readBoolean"]();
this["respawn"] = d6k[0][0]["readBoolean"]();
}
}
},
ps: class {
constructor() {
this["version"] = 0;
this["x"] = 0;
this["y"] = 0;
this["shapeArray"] = [];
this["restitution"] = 0.8;
this["friction"] = 0;
this["density"] = 1;
this["angle"] = 0;
this["angularVelocity"] = 0;
this["isDynamic"] = false;
this["xv"] = 0;
this["yv"] = 0;
this["linearDamping"] = 0;
this["angularDamping"] = 0;
this["rotates"] = false;
this["rotatePivotX"] = 0;
this["rotatePivotY"] = 0;
this["stiffness"] = 0;
this["springy"] = false;
this["springyUpper"] = 100;
this["springyLower"] = -100;
this["springyAnchorX"] = 0;
this["springyAnchorY"] = 0;
this["springyForce"] = 1000000;
this["path"] = false;
this["pathAngle"] = Math.PI / 2;
this["pathUpper"] = 100;
this["pathLower"] = -100;
this["pathAnchorX"] = 0;
this["pathAnchorY"] = 0;
this["pathMaxSpeed"] = 50;
this["pathForce"] = 1000000;
;
}
writeExternal(U0H) {
}
readExternal(B0H) {
var l6k = [arguments];
this["version"] = l6k[0][0]["readShort"]();
if (this["version"] <= 3) {
this["x"] = l6k[0][0]["readDouble"]();
this["y"] = l6k[0][0]["readDouble"]();
this["shapeArray"] = [new v2k49()];
this["shapeArray"][0]["localX"] = 0;
this["shapeArray"][0]["localY"] = 0;
this["shapeArray"][0]["localAngle"] = 0;
this["shapeArray"][0]["width"] = l6k[0][0]["readDouble"]();
this["shapeArray"][0]["height"] = l6k[0][0]["readDouble"]();
this["restitution"] = l6k[0][0]["readDouble"]();
this["density"] = l6k[0][0]["readDouble"]();
this["friction"] = l6k[0][0]["readDouble"]();
this["angle"] = l6k[0][0]["readDouble"]();
this["angularVelocity"] = l6k[0][0]["readDouble"]();
this["shapeArray"][0]["shapeID"] = l6k[0][0]["readShort"]();
this["isDynamic"] = l6k[0][0]["readBoolean"]();
if (this["isDynamic"]) {
this["xv"] = l6k[0][0]["readDouble"]();
this["yv"] = l6k[0][0]["readDouble"]();
this["linearDamping"] = l6k[0][0]["readDouble"]();
this["angularDamping"] = l6k[0][0]["readDouble"]();
this["rotates"] = l6k[0][0]["readBoolean"]();
if (this["rotates"]) {
this["rotatePivotX"] = l6k[0][0]["readDouble"]();
this["rotatePivotY"] = l6k[0][0]["readDouble"]();
this["stiffness"] = l6k[0][0]["readDouble"]();
}
}
if (this["version"] >= 2) {
this["shapeArray"][0]["color"] = l6k[0][0]["readUint"]();
} else {
if (this["isDynamic"]) {
this["shapeArray"][0]["color"] = 0x8bc34a;
} else {
this["shapeArray"][0]["color"] = 0x58b173;
}
}
if (this["version"] >= 3) {
l6k[8] = l6k[0][0]["readShort"]();
this["shapeArray"][0]["death"] = l6k[0][0]["readBoolean"]();
;
} else {
this["shapeArray"][0]["death"] = false;
}
}
if (this["version"] >= 4) {
this["x"] = l6k[0][0]["readDouble"]();
this["y"] = l6k[0][0]["readDouble"]();
l6k[7] = l6k[0][0]["readShort"]();
this["shapeArray"] = [];
for (l6k[3] = 0; l6k[3] < l6k[7]; l6k[3]++) {
this["shapeArray"][l6k[3]] = new v2k49();
this["shapeArray"][l6k[3]]["localX"] = l6k[0][0]["readDouble"]();
this["shapeArray"][l6k[3]]["localY"] = l6k[0][0]["readDouble"]();
this["shapeArray"][l6k[3]]["width"] = l6k[0][0]["readDouble"]();
this["shapeArray"][l6k[3]]["height"] = l6k[0][0]["readDouble"]();
this["shapeArray"][l6k[3]]["localAngle"] = l6k[0][0]["readDouble"]();
this["shapeArray"][l6k[3]]["shapeID"] = l6k[0][0]["readShort"]();
this["shapeArray"][l6k[3]]["color"] = l6k[0][0]["readUint"]();
this["shapeArray"][l6k[3]]["death"] = l6k[0][0]["readBoolean"]();
if (this["version"] >= 7) {
this["shapeArray"][l6k[3]]["noPhysics"] = l6k[0][0]["readBoolean"]();
}
if (this["version"] == 4 && this["shapeArray"][l6k[3]]["shapeID"] == 5) {
this["shapeArray"][l6k[3]]["height"] = Math["round"](0.866 * this["shapeArray"][l6k[3]]["width"]);
}
}
this["restitution"] = l6k[0][0]["readDouble"]();
this["density"] = l6k[0][0]["readDouble"]();
this["friction"] = l6k[0][0]["readDouble"]();
this["angle"] = l6k[0][0]["readDouble"]();
this["angularVelocity"] = l6k[0][0]["readDouble"]();
this["isDynamic"] = l6k[0][0]["readBoolean"]();
if (this["isDynamic"]) {
this["xv"] = l6k[0][0]["readDouble"]();
this["yv"] = l6k[0][0]["readDouble"]();
this["linearDamping"] = l6k[0][0]["readDouble"]();
this["angularDamping"] = l6k[0][0]["readDouble"]();
this["rotates"] = l6k[0][0]["readBoolean"]();
if (this["rotates"]) {
this["rotatePivotX"] = l6k[0][0]["readDouble"]();
this["rotatePivotY"] = l6k[0][0]["readDouble"]();
this["stiffness"] = l6k[0][0]["readDouble"]();
}
if (this["version"] >= 6) {
this["springy"] = l6k[0][0]["readBoolean"]();
if (this["springy"]) {
this["springyUpper"] = l6k[0][0]["readDouble"]();
this["springyLower"] = -this["springyUpper"];
this["springyForce"] = l6k[0][0]["readDouble"]();
this["springyAnchorX"] = l6k[0][0]["readDouble"]();
this["springyAnchorY"] = l6k[0][0]["readDouble"]();
}
this["path"] = l6k[0][0]["readBoolean"]();
if (this["path"]) {
this["pathAngle"] = l6k[0][0]["readDouble"]();
this["pathUpper"] = l6k[0][0]["readDouble"]();
this["pathLower"] = -this["pathUpper"];
this["pathMaxSpeed"] = l6k[0][0]["readDouble"]();
this["pathForce"] = l6k[0][0]["readDouble"]();
this["pathAnchorX"] = l6k[0][0]["readDouble"]();
this["pathAnchorY"] = l6k[0][0]["readDouble"]();
}
}
}
}
}
},
mspn: class {
constructor() {
this["x"] = 0;
this["y"] = 0;
this["xv"] = 0;
this["yv"] = 0;
this["ffa"] = false;
this["blue"] = false;
this["red"] = false;
this["priority"] = 0;
}
writeExternal(a0H) {
}
readExternal(t0H) {
var L6k = [arguments];
this["x"] = L6k[0][0]["readDouble"]();
this["y"] = L6k[0][0]["readDouble"]();
this["xv"] = L6k[0][0]["readDouble"]();
this["yv"] = L6k[0][0]["readDouble"]();
this["ffa"] = L6k[0][0]["readBoolean"]();
this["blue"] = L6k[0][0]["readBoolean"]();
this["red"] = L6k[0][0]["readBoolean"]();
this["priority"] = L6k[0][0]["readShort"]();
}
},
czs: class c12 {
constructor() {
this["version"] = 0;
this["radius"] = 0;
this["x"] = 0;
this["y"] = 0;
this["captureLimit"] = 0;
this["ownerID"] = 0;
this["framesToDetonate"] = 0;
}
writeExternal(E0H) {
}
readExternal(R0H) {
var X6k = [arguments];
for (X6k[7] = 0; X6k[7] < 8; X6k[7]++) {
X6k[3] = X6k[0][0]["readByte"]();
if (X6k[3] == q2z["T_INT"]) {
this[X6k[0][0]["bodgeCaptureZoneDataIdentifierArray"][X6k[7]]] = X6k[0][0]["readInt29"]();
} else if (X6k[3] == q2z["T_DOUBLE"]) {
this[X6k[0][0]["bodgeCaptureZoneDataIdentifierArray"][X6k[7]]] = X6k[0][0]["readDouble"]();
}
}
}
readAnonymous(j5H) {
var m6k = [arguments];
m6k[0][0]["bodgeCaptureZoneDataIdentifierArray"] = [];
for (m6k[5] = 0; m6k[5] < 8; m6k[5]++) {
m6k[4] = m6k[0][0]["readByte"]();
m6k[6] = (m6k[4] - 1) / 2
m6k[3] = new Uint8Array(m6k[6]);
for (m6k[9] = 0; m6k[9] < m6k[6]; m6k[9]++) {
m6k[3][m6k[9]] = m6k[0][0]["readByte"]();
}
m6k[7] = q2z["textDec"]["decode"](m6k[3]);
m6k[0][0]["bodgeCaptureZoneDataIdentifierArray"]["push"](m6k[7]);
}
this["readExternal"](m6k[0][0]);
}
}
};
static textEnc = new TextEncoder();
static textDec = new TextDecoder("utf-8");
}
scope.bytebuffer2 = class {
constructor() {
this.index = 0;
this.buffer = new ArrayBuffer(100 * 1024);
this.view = new DataView(this.buffer);
this.implicitClassAliasArray = [];
this.implicitStringArray = [];
this.bodgeCaptureZoneDataIdentifierArray = [];
}
reset() {
this.index = 0;
}
readInt29() {
var p7k = [arguments];
p7k[2] = 1;
p7k[4] = this["readByte"]();
p7k[1] = 0;
p7k[6] = 0;
p7k[8] = 0;
if (p7k[4] & 0b10000000) {
p7k[1] = this["readByte"]();
p7k[2] = 2;
if (p7k[1] & 0b10000000) {
p7k[6] = this["readByte"]();
p7k[2] = 3;
if (p7k[6] & 0b10000000) {
p7k[8] = this["readByte"]();
p7k[2] = 4;
}
}
}
p7k[3] = 0;
if (p7k[2] == 1) {
p7k[3] += (p7k[4] & 0b00000001) << 0;
p7k[3] += (p7k[4] & 0b00000010) << 0;
p7k[3] += (p7k[4] & 0b00000100) << 0;
p7k[3] += (p7k[4] & 0b00001000) << 0;
p7k[3] += (p7k[4] & 0b00010000) << 0;
p7k[3] += (p7k[4] & 0b00100000) << 0;
p7k[3] += (p7k[4] & 0b01000000) << 0;
}
if (p7k[2] == 2) {
p7k[3] += (p7k[4] & 0b00000001) << 7;
p7k[3] += (p7k[4] & 0b00000010) << 7;
p7k[3] += (p7k[4] & 0b00000100) << 7;
p7k[3] += (p7k[4] & 0b00001000) << 7;
p7k[3] += (p7k[4] & 0b00010000) << 7;
p7k[3] += (p7k[4] & 0b00100000) << 7;
p7k[3] += (p7k[4] & 0b01000000) << 7;
p7k[3] += (p7k[1] & 0b00000001) << 0;
p7k[3] += (p7k[1] & 0b00000010) << 0;
p7k[3] += (p7k[1] & 0b00000100) << 0;
p7k[3] += (p7k[1] & 0b00001000) << 0;
p7k[3] += (p7k[1] & 0b00010000) << 0;
p7k[3] += (p7k[1] & 0b00100000) << 0;
p7k[3] += (p7k[1] & 0b01000000) << 0;
}
if (p7k[2] == 3) {
p7k[3] += (p7k[4] & 0b00000001) << 14;
p7k[3] += (p7k[4] & 0b00000010) << 14;
p7k[3] += (p7k[4] & 0b00000100) << 14;
p7k[3] += (p7k[4] & 0b00001000) << 14;
p7k[3] += (p7k[4] & 0b00010000) << 14;
p7k[3] += (p7k[4] & 0b00100000) << 14;
p7k[3] += (p7k[4] & 0b01000000) << 14;
p7k[3] += (p7k[1] & 0b00000001) << 7;
p7k[3] += (p7k[1] & 0b00000010) << 7;
p7k[3] += (p7k[1] & 0b00000100) << 7;
p7k[3] += (p7k[1] & 0b00001000) << 7;
p7k[3] += (p7k[1] & 0b00010000) << 7;
p7k[3] += (p7k[1] & 0b00100000) << 7;
p7k[3] += (p7k[1] & 0b01000000) << 7;
p7k[3] += (p7k[6] & 0b00000001) << 0;
p7k[3] += (p7k[6] & 0b00000010) << 0;
p7k[3] += (p7k[6] & 0b00000100) << 0;
p7k[3] += (p7k[6] & 0b00001000) << 0;
p7k[3] += (p7k[6] & 0b00010000) << 0;
p7k[3] += (p7k[6] & 0b00100000) << 0;
p7k[3] += (p7k[6] & 0b01000000) << 0;
}
if (p7k[2] == 4) {
p7k[3] += (p7k[4] & 0b00000001) << 22;
p7k[3] += (p7k[4] & 0b00000010) << 22;
p7k[3] += (p7k[4] & 0b00000100) << 22;
p7k[3] += (p7k[4] & 0b00001000) << 22;
p7k[3] += (p7k[4] & 0b00010000) << 22;
p7k[3] += (p7k[4] & 0b00100000) << 22;
p7k[3] -= (p7k[4] & 0b01000000) << 22;
p7k[3] += (p7k[1] & 0b00000001) << 15;
p7k[3] += (p7k[1] & 0b00000010) << 15;
p7k[3] += (p7k[1] & 0b00000100) << 15;
p7k[3] += (p7k[1] & 0b00001000) << 15;
p7k[3] += (p7k[1] & 0b00010000) << 15;
p7k[3] += (p7k[1] & 0b00100000) << 15;
p7k[3] += (p7k[1] & 0b01000000) << 15;
p7k[3] += (p7k[6] & 0b00000001) << 8;
p7k[3] += (p7k[6] & 0b00000010) << 8;
p7k[3] += (p7k[6] & 0b00000100) << 8;
p7k[3] += (p7k[6] & 0b00001000) << 8;
p7k[3] += (p7k[6] & 0b00010000) << 8;
p7k[3] += (p7k[6] & 0b00100000) << 8;
p7k[3] += (p7k[6] & 0b01000000) << 8;
p7k[3] += (p7k[8] & 0b00000001) << 0;
p7k[3] += (p7k[8] & 0b00000010) << 0;
p7k[3] += (p7k[8] & 0b00000100) << 0;
p7k[3] += (p7k[8] & 0b00001000) << 0;
p7k[3] += (p7k[8] & 0b00010000) << 0;
p7k[3] += (p7k[8] & 0b00100000) << 0;
p7k[3] += (p7k[8] & 0b01000000) << 0;
p7k[3] += (p7k[8] & 0b10000000) << 0;
}
return p7k[3];
}
readByte() {
var N0H = [arguments];
N0H[4] = this.view.getUint8(this.index);
this.index += 1;
return N0H[4];
}
writeByte(z0w) {
var v8$ = [arguments];
this.view.setUint8(this.index, v8$[0][0]);
this.index += 1;
}
readInt() {
var A71 = [arguments];
A71[6] = this.view.getInt32(this.index);
this.index += 4;
return A71[6];
}
writeInt(W6i) {
var p5u = [arguments];
this.view.setInt32(this.index, p5u[0][0]);
this.index += 4;
}
readShort() {
var R1R = [arguments];
R1R[9] = this.view.getInt16(this.index);
this.index += 2;
return R1R[9];
}
writeShort(H8B) {
var d_3 = [arguments];
this.view.setInt16(this.index, d_3[0][0]);
this.index += 2;
}
readUint() {
var W2$ = [arguments];
W2$[8] = this.view.getUint32(this.index);
this.index += 4;
return W2$[8];
}
writeUint(B2X) {
var f8B = [arguments];
this.view.setUint32(this.index, f8B[0][0]);
this.index += 4;
}
readBoolean() {
var h6P = [arguments];
h6P[6] = this.readByte();
return h6P[6] == 1;
}
writeBoolean(Y3I) {
var l79 = [arguments];
if (l79[0][0]) {
this.writeByte(1);
} else {
this.writeByte(0);
}
}
readDouble() {
var V60 = [arguments];
V60[4] = this.view.getFloat64(this.index);
this.index += 8;
return V60[4];
}
writeDouble(z4Z) {
var O41 = [arguments];
this.view.setFloat64(this.index, O41[0][0]);
this.index += 8;
}
readFloat() {
var I0l = [arguments];
I0l[5] = this.view.getFloat32(this.index);
this.index += 4;
return I0l[5];
}
writeFloat(y4B) {
var B0v = [arguments];
this.view.setFloat32(this.index, B0v[0][0]);
this.index += 4;
}
readUTF() {
var d6I = [arguments];
d6I[8] = this.readByte();
d6I[7] = this.readByte();
d6I[9] = d6I[8] * 256 + d6I[7];
d6I[1] = new Uint8Array(d6I[9]);
for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
d6I[1][d6I[6]] = this.readByte();
}
return (new TextDecoder()).decode(d6I[1]);
}
writeUTF(L3Z) {
var Z75 = [arguments];
Z75[4] = (new TextEncoder()).encode(Z75[0][0]);
Z75[3] = Z75[4].length;
Z75[5] = Math.floor(Z75[3] / 256);
Z75[8] = Z75[3] % 256;
this.writeByte(Z75[5]);
this.writeByte(Z75[8]);
Z75[7] = this;
Z75[4].forEach(I_O);
function I_O(s0Q, H4K, j$o) {
var N0o = [arguments];
Z75[7].writeByte(N0o[0][0]);
}
}
toBase64() {
var P4$ = [arguments];
P4$[4] = "";
P4$[9] = new Uint8Array(this.buffer);
P4$[8] = this.index;
for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
}
return btoa(P4$[4]);
}
fromBase64(W69, A8Q) {
var o0n = [arguments];
o0n[8] = pako;
o0n[6] = atob(o0n[0][0]);
o0n[9] = o0n[6].length;
o0n[4] = new Uint8Array(o0n[9]);
for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
}
if (o0n[0][1] === true) {
o0n[5] = o0n[8].inflate(o0n[4]);
o0n[4] = o0n[5];
}
this.buffer = o0n[4].buffer.slice(
o0n[4].byteOffset,
o0n[4].byteLength + o0n[4].byteOffset
);
this.view = new DataView(this.buffer);
this.index = 0;
}
readObject() {
var N7k = [arguments];
N7k[9] = () => {
var T82, U82, d82, E82, D82, P82, q82, B82, Z82;
T82 = this.readByte();
if (T82 == 0x07) {
U82 = this.readByte();
d82 = (U82 - 1) / 2;
E82 = new Uint8Array(d82);
for (var M82 = 0; M82 < d82; M82++) {
E82[M82] = this.readByte();
}
D82 = q2z["textDec"]["decode"](E82);
if (!q2z["aliases"][D82]) {
throw new Error();
}
this["implicitClassAliasArray"]["push"](D82);
P82 = new q2z["aliases"][D82]();
P82["readExternal"](this);
return P82;
} else {
q82 = (T82 - 1) / 4;
B82 = this["implicitClassAliasArray"][q82];
if (!q2z["aliases"][B82]) {
throw new Error();
}
Z82 = new q2z["aliases"][B82]();
Z82["readExternal"](this);
return Z82;
}
};
N7k[7] = () => {
var Q42, v42, H82, y42, z82, g42, t82, w42, O42, L42, s42, A42, p42, F42, k42, J42, n42, f42, r42, x42, i82, I42, S42, N42;
Q42 = 0;
v42 = 0;
H82 = [];
do {
v42 = (this["readByte"]() - 1) / 2;
Q42 += v42;
} while (v42 == 64);
y42 = this["readByte"]();
for (var o42 = 0; o42 < Q42; o42++) {
z82 = this["readByte"]();
if (z82 === q2z["T_UNDEFINED"]) {
H82["push"](undefined);
}
if (z82 === q2z["T_NULL"]) {
H82["push"](null);
}
if (z82 === q2z["T_TRUE"]) {
H82["push"](true);
}
if (z82 === q2z["T_FALSE"]) {
H82["push"](false);
}
if (z82 === q2z["T_OBJ"]) {
g42 = this["readByte"]();
t82 = null;
if (g42 == 7) {
w42 = this["readByte"]();
O42 = (w42 - 1) / 2;
L42 = new Uint8Array(O42);
for (var W42 = 0; W42 < O42; W42++) {
L42[W42] = this["readByte"]();
}
t82 = q2z["textDec"]["decode"](L42);
this["implicitClassAliasArray"]["push"](t82);
if (!q2z["aliases"][t82]) {
throw new Error();
}
s42 = new q2z["aliases"][t82]();
s42["readExternal"](this);
H82["push"](s42);
} else if (g42 > 128) {
A42 = this["readByte"]();
p42 = this["readByte"]();
F42 = (p42 - 1) / 2;
k42 = new Uint8Array(F42);
for (var K42 = 0; K42 < F42; K42++) {
k42[K42] = this["readByte"]();
}
t82 = q2z["textDec"]["decode"](k42);
this["implicitClassAliasArray"]["push"](t82);
if (!q2z["aliases"][t82]) {
throw new Error();
}
J42 = new q2z["aliases"][t82]();
J42["readAnonymous"](this);
H82["push"](J42);
} else {
n42 = (g42 - 1) / 4;
t82 = this["implicitClassAliasArray"][n42];
if (!q2z["aliases"][t82]) {
throw new Error();
}
f42 = new q2z["aliases"][t82]();
f42["readExternal"](this);
H82["push"](f42);
}
}
if (z82 === q2z["T_ARRAY"]) { }
if (z82 === q2z["T_STRING"]) {
r42 = this["readByte"]();
if (r42 % 2 == 0) {
x42 = r42 / 2;
H82["push"](this["implicitStringArray"][x42]);
} else {
i82 = 0;
I42 = (r42 - 1) / 2;
i82 += I42;
while (I42 == 64) {
I42 = (this["readByte"]() - 1) / 2;
i82 += I42;
}
S42 = new Uint8Array(i82);
for (var R42 = 0; R42 < i82; R42++) {
S42[R42] = this["readByte"]();
}
N42 = q2z["textDec"]["decode"](S42);
H82["push"](N42);
this["implicitStringArray"]["push"](N42);
}
}
}
return H82;
}
;
N7k[8] = this["readByte"]();
if (N7k[8] == q2z["T_NULL"]) {
return null;
}
if (N7k[8] == q2z["T_UNDEFINED"]) {
return undefined;
}
if (N7k[8] == q2z["T_OBJ"]) {
return (1, N7k[9])();
} else if (N7k[8] == q2z["T_ARRAY"]) {
return (1, N7k[7])();
} else {
throw new Error();
}
}
};
scope.fromOldFormat = function (g6x) {
var d8q = [arguments];
var map = { v: 1, s: { re: false, nc: false, pq: 1, gd: 25, fl: false }, physics: { shapes: [], fixtures: [], bodies: [], bro: [], joints: [], ppm: 12, }, spawns: [], capZones: [], m: { a: "noauthor", n: "noname", dbv: 2, dbid: -1, authid: -1, date: "", rxid: 0, rxn: "", rxa: "", rxdb: 1, cr: [], pub: false, mo: "", } };
d8q.__9__map = map;
d8q.__9__map.m.a = d8q[0][0].author;
d8q.__9__map.m.n = d8q[0][0].mapname;
d8q.__9__map.s.fl = d8q[0][0].discAllForce == 20;
d8q.__9__map.s.a1 = true;
d8q.__9__map.s.a2 = false;
d8q.__9__map.s.a3 = false;
d8q.__9__map.s.re = d8q[0][0].respawn;
d8q.__9__map.s.nc = d8q[0][0].noCollide;
d8q.__9__map.physics.ppm = d8q[0][0].ppm;
d8q.__7__pixelsPerMeter = d8q[0][0].ppm;
for (let i = 0; i < d8q[0][0].spawnArray.length; i++) {
d8q.__6__spawn = d8q[0][0].spawnArray[i];
d8q.__9__map.spawns.push({
x: d8q.__6__spawn.x,
y: d8q.__6__spawn.y,
xv: d8q.__6__spawn.xv,
yv: d8q.__6__spawn.yv,
priority: d8q.__6__spawn.priority,
r: d8q.__6__spawn.red,
f: d8q.__6__spawn.ffa,
b: d8q.__6__spawn.blue,
n: d8q[0][0].spawnNames[i]
});
}
for (let i = 0; i < d8q[0][0].platformArray.length; i++) {
d8q.__3__platform = d8q[0][0].platformArray[i];
d8q.__5__body = { type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true, t: 0, cf: 0 } };
d8q.__5__body.type = d8q.__3__platform.isDynamic == true ? "d" : "s";
d8q.__5__body.n = d8q[0][0].platformNames[i];
d8q.__5__body.p[0] = d8q.__3__platform.x;
d8q.__5__body.p[1] = d8q.__3__platform.y;
d8q.__5__body.lv[0] = d8q.__3__platform.xv;
d8q.__5__body.lv[1] = d8q.__3__platform.yv;
d8q.__5__body.a = d8q.__3__platform.angle;
d8q.__5__body.av = d8q.__3__platform.angularVelocity;
d8q.__5__body.ld = d8q.__3__platform.linearDamping;
d8q.__5__body.ad = d8q.__3__platform.angularDamping;
d8q.__5__body.de = d8q.__3__platform.density;
d8q.__5__body.fric = d8q.__3__platform.friction;
d8q.__5__body.re = d8q.__3__platform.restitution;
d8q.__5__body.fr = false;
d8q.__5__body.bu = false;
d8q.__5__body.cf;
d8q.__5__body.fx = [];
d8q.__9__map.physics.bodies.push(d8q.__5__body);
for (let _i = 0; _i < d8q.__3__platform.shapeArray.length; _i++) {
d8q.__1__shape = d8q.__3__platform.shapeArray[_i];
var safeCos = function (r) {
r = Math.cos(r);
r *= 10000000;
r = Math.round(r);
r /= 10000000;
return r;
}
var safeSin = function (r) {
r = Math.sin(r);
r *= 10000000;
r = Math.round(r);
r /= 10000000;
return r;
}
d8q[8] = safeCos(d8q.__1__shape.localAngle);
d8q[76] = safeSin(d8q.__1__shape.localAngle);
d8q[28] = Math.abs(d8q.__1__shape.width);
d8q[85] = Math.abs(d8q.__1__shape.height);
d8q.__41__transformedShape = {};
if (d8q.__1__shape.shapeID == 1) {
d8q.__41__transformedShape = { type: "ci", r: 25, c: [0, 0], sk: false };
d8q.__41__transformedShape.r = d8q[28];
d8q.__41__transformedShape.sk = false;
} else if (d8q.__1__shape.shapeID == 2 || d8q.__1__shape.shapeID == 4) {
d8q.__41__transformedShape = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
d8q.__41__transformedShape.w = d8q[28] * 2;
d8q.__41__transformedShape.h = d8q[85] * 2
d8q.__41__transformedShape.sk = d8q.__1__shape.shapeID == 4;
} else if (d8q.__1__shape.shapeID == 5) {
d8q.__41__transformedShape = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
d8q[39] = [d8q[28], 0];
d8q[43] = [-0.5 * d8q[28], d8q[85]];
d8q[79] = [-0.5 * d8q[28], -d8q[85]];
d8q.__41__transformedShape.v = [d8q[39], d8q[43], d8q[79]];
d8q.__41__transformedShape.sk = false;
} else if (d8q.__1__shape.shapeID == 6) {
d8q.__41__transformedShape = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
d8q[54] = 2 * d8q.__7__pixelsPerMeter;
d8q[72] = Math.min(d8q[28], d8q[85]);
d8q[26] = Math.min(d8q[54], d8q[72] * 0.4);
d8q[95] = d8q[28] - d8q[26];
d8q[22] = d8q[28];
d8q[90] = d8q[85] - d8q[26];
d8q[94] = d8q[85];
d8q[59] = [-d8q[22], -d8q[90]];
d8q[64] = [-d8q[95], -d8q[94]];
d8q[52] = [d8q[95], -d8q[94]];
d8q[73] = [d8q[22], -d8q[90]];
d8q[24] = [d8q[22], d8q[90]];
d8q[30] = [d8q[95], d8q[94]];
d8q[86] = [-d8q[95], d8q[94]];
d8q[57] = [-d8q[22], d8q[90]];
d8q.__41__transformedShape.v = [d8q[59], d8q[64], d8q[52], d8q[73], d8q[24], d8q[30], d8q[86], d8q[57]];
d8q.__41__transformedShape.sk = false;
} else {
throw new Error("unknown shape ID");
}
d8q.__41__transformedShape.c[0] = d8q.__1__shape.localX;
d8q.__41__transformedShape.c[1] = d8q.__1__shape.localY;
d8q.__41__transformedShape.a = d8q.__1__shape.localAngle;
d8q.__9__map.physics.shapes.push(d8q.__41__transformedShape);
d8q.__47__fixture = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
d8q.__47__fixture.n = "";
d8q.__47__fixture.fr = null;
d8q.__47__fixture.fp = null;
d8q.__47__fixture.re = null;
d8q.__47__fixture.de = null;
d8q.__47__fixture.sn = false;
d8q.__47__fixture.f = d8q.__1__shape.color;
d8q.__47__fixture.d = d8q.__1__shape.death;
d8q.__47__fixture.np = d8q.__1__shape.noPhysics;
d8q.__47__fixture.sh = d8q.__9__map.physics.shapes.length - 1;
d8q.__9__map.physics.fixtures.push(d8q.__47__fixture);
d8q.__5__body.fx.push(d8q.__9__map.physics.fixtures.length - 1);
}
if (d8q.__3__platform.rotates) {
d8q[12] = d8q.__3__platform.stiffness;
d8q[96] = {
type: "rv",
n: "",
d: {
la: 0,
ua: 0,
mmt: d8q[12],
ms: 0,
el: false,
em: true,
cc: false,
bf: 0,
dl: true
},
ba: d8q.__9__map.physics.bodies.length - 1,
bb: -1,
aa: [d8q.__3__platform.rotatePivotX, d8q.__3__platform.rotatePivotY]
};
d8q.__9__map.physics.joints.push(d8q[96]);
}
if (d8q.__3__platform.springy) {
d8q[71] = { "type": "lsj", "d": { "cc": false, "bf": 0, "dl": true }, "sax": 0, "say": 0, "sf": 0, "slen": 0, ba: d8q.__9__map.physics.bodies.length - 1, bb: -1 };
d8q[71].sax = d8q.__3__platform.springyAnchorX;
d8q[71].say = d8q.__3__platform.springyAnchorY;
d8q[71].sf = d8q.__3__platform.springyForce;
d8q[71].slen = d8q.__3__platform.springyUpper;
d8q.__9__map.physics.joints.push(d8q[71]);
}
if (d8q.__3__platform.path) {
d8q[62] = { "type": "lpj", "d": { "cc": false, "bf": 0, "dl": true }, "pax": 0, "pay": 0, "pa": 0, "pf": 0, "pl": 0, "pu": 0, "plen": 0, "pms": 0, "ba": d8q.__9__map.physics.bodies.length - 1, "bb": -1 };
d8q[62].pax = 0;
d8q[62].pay = 0;
d8q[62].pa = d8q.__3__platform.pathAngle;
d8q[62].pf = d8q.__3__platform.pathForce;
d8q[62].plen = d8q.__3__platform.pathUpper;
d8q[62].pms = d8q.__3__platform.pathMaxSpeed;
d8q.__9__map.physics.joints.push(d8q[62]);
}
}
for (let i = d8q.__9__map.physics.bodies.length - 1; i >= 0; i--) {
d8q.__9__map.physics.bro.push(i);
}
for (let i = 0; i < d8q[0][0].capZoneArray.length; i++) {
d8q[34] = d8q[0][0].capZoneArray[i];
d8q[82] = { type: "ci", r: 25, c: [0, 0], sk: false };
d8q[82].r = d8q[34].radius * d8q.__7__pixelsPerMeter;
d8q.__9__map.physics.shapes.push(d8q[82]);
d8q[84] = { sh: d8q.__9__map.physics.shapes.length - 1, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
d8q.__9__map.physics.fixtures.push(d8q[84]);
d8q[49] = { type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true, t: 0, cf: 0 } };
d8q[49].n = "Cap Zone Body";
d8q[49].fx = [d8q.__9__map.physics.fixtures.length - 1];
d8q[49].p[0] = d8q[34].x;
d8q[49].p[1] = d8q[34].y;
d8q[49].f_1 = false;
d8q[49].f_2 = false;
d8q[49].f_3 = false;
d8q[49].f_4 = false;
d8q.__9__map.physics.bodies.push(d8q[49]);
d8q.__9__map.capZones.push({
n: d8q[0][0].capZoneNames[i],
l: d8q[34].captureLimit,
i: d8q.__9__map.physics.fixtures.length - 1,
ty: 1
});
d8q.__9__map.physics.bro.unshift(d8q.__9__map.physics.bodies.length - 1);
}
return d8q.__9__map;
};
scope.fromOldString = function (N_p) {
var c4M = [arguments];
c4M.__7__binaryData = new bytebuffer2();
c4M.__7__binaryData.fromBase64(decodeURIComponent(N_p), true);
c4M[9] = c4M.__7__binaryData.readObject();
c4M[6] = fromOldFormat(c4M[9]);
return c4M[6];
};
if (typeof (scope.originalSend) == 'undefined') { scope.originalSend = Gwindow.WebSocket.prototype.send; }
if (typeof (scope.originalDatenow) == 'undefined') { scope.originalDatenow = Gwindow.Date.now; }
if (typeof (scope.originalXMLOpen) == 'undefined') { scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open; }
if (typeof (scope.originalWebSocket) == 'undefined') { scope.originalWebSocket = Gwindow.WebSocket; }
if (typeof (scope.originalXMLSend) == 'undefined') { scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send; }
if (typeof (scope.originalFetch) == 'undefined') { scope.originalFetch = Gwindow.fetch; }
if (typeof (scope.searchrequested) == 'undefined') { scope.searchrequested = 0; }
if (typeof (scope.originalDrawCircle) == 'undefined') { scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle; }
if (typeof (scope.parentDraw) == 'undefined') { scope.parentDraw = 0; }
if (typeof (scope.pixiCircle) == 'undefined') { scope.pixiCircle = new Gwindow.PIXI.Graphics(); }
if (typeof (scope.container) == 'undefined') { scope.container = new Gwindow.PIXI.Container(); container.addChild(pixiCircle); }
if (typeof (scope.trajLine) == 'undefined') { scope.trajLine = new Gwindow.PIXI.Graphics(); container.addChild(trajLine); }
if (typeof (scope.canvasWidth) == 'undefined') { scope.canvasWidth = -1; }
if (typeof (scope.savedrooms) == 'undefined') { scope.savedrooms = []; }
if (typeof (scope.inroom) == 'undefined') { scope.inroom = false; }
if (typeof (scope.currentroomaddress) == 'undefined') { scope.currentroomaddress = -1; }
if (typeof (scope.savedroomsdata) == 'undefined') { scope.savedroomsdata = {}; }
if (typeof (scope.gameStartTimeStamp) == 'undefined') { scope.gameStartTimeStamp = 0; }
if (typeof (scope.requestAnimationFrameOriginal) == 'undefined') { scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame; }
if (typeof (scope.bonkwss) == 'undefined') { scope.bonkwss = 0; }
if (typeof (scope.bonkwssextra) == 'undefined') { scope.bonkwssextra = []; }
if (typeof (scope.chatlog) == 'undefined') { scope.chatlog = ["ROOM START"]; }
if (typeof (scope.wsssendrecievelog) == 'undefined') { scope.wsssendrecievelog = []; }
if (typeof (scope.wsssendlog) == 'undefined') { scope.wsssendlog = []; }
if (typeof (scope.wssrecievelog) == 'undefined') { scope.wssrecievelog = []; }
if (typeof (scope.wsslogpaused) == 'undefined') { scope.wsslogpaused = false; }
if (typeof (scope.debuggeropen) == 'undefined') { scope.debuggeropen = false; }
if (typeof (scope.debuggercount) == 'undefined') { scope.debuggercount = true; }
if (typeof (scope.packetcount) == 'undefined') { scope.packetcount = 0; }
if (typeof (scope.requestedmaps) == 'undefined') { scope.requestedmaps = []; }
if (typeof (scope.playlists) == 'undefined') { scope.playlists = {}; }
if (typeof (scope.playlistMode) == 'undefined') { scope.playlistMode = "list"; }
if (typeof (scope.openPlaylistName) == 'undefined') { scope.openPlaylistName = ""; }
if (typeof (scope.maponclick) == 'undefined') { scope.maponclick = 0; }
if (typeof (scope.LZString) == 'undefined') { scope.LZString = Gwindow.LZString; }
if (typeof (scope.PSON) == 'undefined') { scope.PSON = Gwindow.dcodeIO.PSON; }
if (typeof (scope.bytebuffer) == 'undefined') { scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer; }
if (typeof (scope.speech) == 'undefined') { scope.speech = new SpeechSynthesisUtterance(); speech.pitch = 0.75; }
if (typeof (scope.sayer) == 'undefined') { scope.sayer = speechSynthesis; sayer.volume = 0.5; sayer.rate = 1.25; }
if (typeof (scope.pollactive) == 'undefined') { scope.pollactive = [false, 0, 0, []]; }
if (typeof (scope.pollactive2) == 'undefined') { scope.pollactive2 = [false, 0, []]; }
if (typeof (scope.mode) == 'undefined') { scope.mode = ''; }
if (typeof (scope.FFA) == 'undefined') { scope.FFA = true; }
if (typeof (scope.recording) == 'undefined') { scope.recording = false; }
if (typeof (scope.recordingdata) == 'undefined') { scope.recordingdata = []; }
if (typeof (scope.recorddata) == 'undefined') { scope.recorddata = {}; }
if (typeof (scope.recordingid) == 'undefined') { scope.recordingid = -1; }
if (typeof (scope.currentmap) == 'undefined') { scope.currentmap = []; }
if (typeof (scope.wordlist) == 'undefined') {
scope.wordlist = [];
fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/google-10000-english.txt").then(function (data) {
return data.json();
}).then(function (data) {
fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/" + data.sha).then(function (data) {
return data.json();
}).then(function (data) {
scope.wordlist = atob(data.content).split("\n");
});
});
}
if (typeof (scope.allstyles) == 'undefined') { scope.allstyles = {}; }
if (typeof (scope.mystyle) == 'undefined') { scope.mystyle = [0, 0, 0]; }
if (typeof (scope.ISpsonpair) == 'undefined') { scope.ISpsonpair = new Gwindow.dcodeIO.PSON.StaticPair(["physics", "shapes", "fixtures", "bodies", "bro", "joints", "ppm", "lights", "spawns", "lasers", "capZones", "type", "w", "h", "c", "a", "v", "l", "s", "sh", "fr", "re", "de", "sn", "fc", "fm", "f", "d", "n", "bg", "lv", "av", "ld", "ad", "fr", "bu", "cf", "rv", "p", "d", "bf", "ba", "bb", "aa", "ab", "axa", "dr", "em", "mmt", "mms", "ms", "ut", "lt", "New body", "Box Shape", "Circle Shape", "Polygon Shape", "EdgeChain Shape", "priority", "Light", "Laser", "Cap Zone", "BG Shape", "Background Layer", "Rotate Joint", "Slider Joint", "Rod Joint", "Gear Joint", 65535, 16777215]); }
if (typeof (scope.sandboxon) == 'undefined') { scope.sandboxon = false; }
if (typeof (scope.sandboxid) == 'undefined') { scope.sandboxid = 200; }
if (typeof (scope.playerids) == 'undefined') { scope.playerids = {}; }
if (typeof (scope.delplayerids) == 'undefined') { scope.delplayerids = {}; }
if (typeof (scope.myid) == 'undefined') { scope.myid = -1; }
if (typeof (scope.hostid) == 'undefined') { scope.hostid = -1; }
if (typeof (scope.sandboxplayerids) == 'undefined') { scope.sandboxplayerids = {}; }
if (typeof (scope.originalMapLoad) == 'undefined') { scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild; }
if (typeof (scope.originalLobbyChat) == 'undefined') { scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild; }
if (typeof (scope.originalIngameChat) == 'undefined') { scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild; }
if (typeof (scope.private_chat_keys) == 'undefined') { GENERATE_KEYS().then(function (e) { scope.private_chat_keys = e; scope.private_key = private_chat_keys.privateKey; scope.public_key = private_chat_keys.publicKey; }); }
if (Gdocument.getElementById("createqproomlabel") == null) {
scope.createqproomlabel = Gdocument.createElement("div");
createqproomlabel.id = "createqproomlabel";
createqproomlabel.className = "roomlistcreatewindowlabel";
createqproomlabel.textContent = "Room Type";
createqproomlabel.style["left"] = "26px";
createqproomlabel.style["top"] = "305px";
createqproomlabel.style["position"] = "absolute";
Gdocument.getElementById("roomlistcreatewindow").children[0].appendChild(createqproomlabel);
Gdocument.getElementById("roomlistcreatewindow").style["height"] = "115%";
scope.createqproominput = Gdocument.createElement("select");
createqproominput.id = "createqproominput";
createqproominput.className = "roomlistcreatewindowinput fieldShadow";
createqproominput.style["left"] = "0";
createqproominput.style["top"] = "327px";
var customoption = Gdocument.createElement("option");
customoption.value = "custom";
customoption.textContent = "Custom Lobby";
var arrowoption = Gdocument.createElement("option");
arrowoption.value = "arrowsquick";
arrowoption.textContent = "Arrows Quickplay";
var classicoption = Gdocument.createElement("option");
classicoption.value = "bonkquick";
classicoption.textContent = "Classic Quickplay";
var grappleoption = Gdocument.createElement("option");
grappleoption.value = "grapplequick";
grappleoption.textContent = "Grapple Quickplay";
createqproominput.appendChild(customoption);
Gdocument.getElementById("roomlistcreatewindow").children[0].appendChild(createqproominput);
}
if (Gdocument.getElementById("savedroombutton") == null) {
scope.savedroombutton = Gdocument.createElement("div");
savedroombutton.id = "savedroombutton";
savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
savedroombutton.textContent = "Save Room";
savedroombutton.style["left"] = "120px";
savedroombutton.style["position"] = "absolute";
savedroombutton.style["width"] = "90px";
savedroombutton.style["height"] = "30px";
savedroombutton.style["color"] = "#ffffff";
savedroombutton.style["text-align"] = "center";
savedroombutton.style["vertical-align"] = "middle";
savedroombutton.style["line-height"] = "30px";
savedroombutton.style["right"] = "0";
savedroombutton.style["cursor"] = "pointer";
savedroombutton.style["bottom"] = "10px";
savedroombutton.style["margin"] = "auto";
savedroombutton.style["bottom"] = "10px";
savedroombutton.onclick = function () {
if (!savedrooms.includes(currentroomaddress) && currentroomaddress != -1) {
savedrooms.push(currentroomaddress);
savedroomsdata[currentroomaddress] = { "exists": true };
}
Gdocument.getElementById("sm_connectingWindowCancelButton").click();
};
Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
}
if (Gdocument.getElementById("maploadtypedropdowntitlerequested") == null) {
scope.clearmaprequests = Gdocument.createElement("div");
clearmaprequests.id = "clearmaprequests";
clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
clearmaprequests.textContent = "Clear";
clearmaprequests.style["position"] = "absolute";
clearmaprequests.style["display"] = "none";
if (typeof (ishost) != 'undefined') {
if (ishost && (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS" || Gdocument.getElementById("maploadtypedropdowntitle").textContent == "HISTORY")) {
clearmaprequests.style["display"] = "block";
}
}
clearmaprequests.style["right"] = "306px";
clearmaprequests.style["top"] = "57px";
clearmaprequests.style["height"] = "23px";
clearmaprequests.style["width"] = "47px";
clearmaprequests.style["line-height"] = "23px";
clearmaprequests.style["font-size"] = "14px";
clearmaprequests.addEventListener("click", function () {
if (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
requestedmaps = [];
}
else if (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "HISTORY") {
currentmap = [];
}
Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
while (Gdocument.getElementById("maploadwindowmapscontainer").children.length > 0) {
Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
}
});
Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests, Gdocument.getElementById("maploadwindowsearchinput"));
scope.refreshmaprequests = Gdocument.createElement("div");
refreshmaprequests.id = "refreshmaprequests";
refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
refreshmaprequests.textContent = "Refresh";
refreshmaprequests.style["position"] = "absolute";
refreshmaprequests.style["display"] = "none";
if (typeof (ishost) != 'undefined') {
if (ishost && (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS" || Gdocument.getElementById("maploadtypedropdowntitle").textContent == "HISTORY")) {
refreshmaprequests.style["display"] = "block";
}
}
refreshmaprequests.style["right"] = "357px";
refreshmaprequests.style["top"] = "57px";
refreshmaprequests.style["height"] = "23px";
refreshmaprequests.style["width"] = "47px";
refreshmaprequests.style["line-height"] = "23px";
refreshmaprequests.style["font-size"] = "14px";
refreshmaprequests.addEventListener("click", function () {
var dropdown;
if (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
searchrequested = 1;
dropdown = dropdownrequested;
}
else if (Gdocument.getElementById("maploadtypedropdowntitle").textContent == "HISTORY") {
searchrequested = 2;
dropdown = dropdownrequested;
}
Gdocument.getElementById("maploadtypedropdowntitle").click();
Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdown.textContent;
dropdown.style["display"] = "none";
clearmaprequests.style["display"] = "block";
refreshmaprequests.style["display"] = "block";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
Gdocument.getElementById("maploadtypedropdownoption10").click();
});
Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests, Gdocument.getElementById("maploadwindowsearchinput"));
scope.dropdownrequested = Gdocument.createElement("div");
dropdownrequested.classList = "dropdown-option dropdown_classic";
dropdownrequested.style["display"] = "none";
dropdownrequested.id = "maploadtypedropdowntitlerequested";
if (Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block") {
dropdownrequested.style["display"] = "block";
}
dropdownrequested.textContent = "MAP REQUESTS";
dropdownrequested.onclick = function () {
searchrequested = 1;
Gdocument.getElementById("maploadtypedropdowntitle").click();
Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
dropdownrequested.style["display"] = "none";
clearmaprequests.style["display"] = "block";
refreshmaprequests.style["display"] = "block";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
Gdocument.getElementById("maploadtypedropdownoption10").click();
};
Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested, Gdocument.getElementById("maploadtypedropdownoption1"));
Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight", function () { if (Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS") { return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height; } else { return 0; } });
scope.dropdownhistory = Gdocument.createElement("div");
dropdownhistory.classList = "dropdown-option dropdown_classic";
dropdownhistory.style["display"] = "none";
dropdownhistory.id = "maploadtypedropdowntitlehistory";
if (Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block") {
dropdownhistory.style["display"] = "block";
}
dropdownhistory.textContent = "HISTORY";
dropdownhistory.onclick = function () {
searchrequested = 2;
Gdocument.getElementById("maploadtypedropdowntitle").click();
Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownhistory.textContent;
dropdownhistory.style["display"] = "none";
clearmaprequests.style["display"] = "block";
refreshmaprequests.style["display"] = "block";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
Gdocument.getElementById("maploadtypedropdownoption10").click();
};
(new MutationObserver(function () { if (Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "none") { dropdownhistory.style["display"] = "none"; dropdownrequested.style["display"] = "none"; clearmaprequests.style["display"] = "none"; refreshmaprequests.style["display"] = "none"; if (typeof dropdownplaylists != "undefined" && dropdownplaylists) { dropdownplaylists.style["display"] = "none"; } } else { dropdownhistory.style["display"] = "block"; dropdownrequested.style["display"] = "block"; if (typeof dropdownplaylists != "undefined" && dropdownplaylists) { dropdownplaylists.style["display"] = "block"; } } })).observe(Gdocument.getElementById("maploadtypedropdownoption10"), { attributes: true, childList: true });
Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownhistory, Gdocument.getElementById("maploadtypedropdownoption1"));
Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight", function () { var t = Gdocument.getElementById("maploadtypedropdowntitle").textContent; if (t != "HISTORY" && t != "MAP REQUESTS" && t != "PLAYLISTS") { return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height; } else { return 0; } });
scope.dropdownplaylists = Gdocument.createElement("div");
dropdownplaylists.classList = "dropdown-option dropdown_classic";
dropdownplaylists.style["display"] = "none";
dropdownplaylists.id = "maploadtypedropdowntitleplaylists";
if (Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block") { dropdownplaylists.style["display"] = "block"; }
dropdownplaylists.textContent = "PLAYLISTS";
dropdownplaylists.onclick = function () {
Gdocument.getElementById("maploadtypedropdowntitle").click();
Gdocument.getElementById("maploadtypedropdowntitle").textContent = "PLAYLISTS";
dropdownplaylists.style["display"] = "none";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
playlistMode = "list";
showPlaylistList();
};
Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownplaylists, Gdocument.getElementById("maploadtypedropdownoption1"));
scope.playlistBackBtn = Gdocument.createElement("div");
playlistBackBtn.classList.value = "brownButton brownButton_classic buttonShadow";
playlistBackBtn.textContent = "Back";
playlistBackBtn.style["position"] = "absolute";
playlistBackBtn.style["display"] = "none";
playlistBackBtn.style["left"] = "204px";
playlistBackBtn.style["top"] = "57px";
playlistBackBtn.style["height"] = "23px";
playlistBackBtn.style["width"] = "40px";
playlistBackBtn.style["line-height"] = "23px";
playlistBackBtn.style["font-size"] = "12px";
playlistBackBtn.onclick = function () { playlistMode = "list"; showPlaylistList(); };
Gdocument.getElementById("maploadwindow").insertBefore(playlistBackBtn, Gdocument.getElementById("maploadwindowsearchinput"));
scope.playlistShuffleBtn = Gdocument.createElement("div");
playlistShuffleBtn.classList.value = "brownButton brownButton_classic buttonShadow";
playlistShuffleBtn.textContent = "Shuffle";
playlistShuffleBtn.style["position"] = "absolute";
playlistShuffleBtn.style["display"] = "none";
playlistShuffleBtn.style["left"] = "250px";
playlistShuffleBtn.style["top"] = "57px";
playlistShuffleBtn.style["height"] = "23px";
playlistShuffleBtn.style["width"] = "55px";
playlistShuffleBtn.style["line-height"] = "23px";
playlistShuffleBtn.style["font-size"] = "12px";
playlistShuffleBtn.onclick = function () {
var arr = playlists[openPlaylistName];
if (!arr) { return; }
for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var t = arr[i]; arr[i] = arr[j]; arr[j] = t; }
savePlaylists();
openPlaylistDetail(openPlaylistName);
};
Gdocument.getElementById("maploadwindow").insertBefore(playlistShuffleBtn, Gdocument.getElementById("maploadwindowsearchinput"));
scope.playlistRefreshBtn = Gdocument.createElement("div");
playlistRefreshBtn.classList.value = "brownButton brownButton_classic buttonShadow";
playlistRefreshBtn.textContent = "Refresh";
playlistRefreshBtn.style["position"] = "absolute";
playlistRefreshBtn.style["display"] = "none";
playlistRefreshBtn.style["left"] = "312px";
playlistRefreshBtn.style["top"] = "57px";
playlistRefreshBtn.style["height"] = "23px";
playlistRefreshBtn.style["width"] = "55px";
playlistRefreshBtn.style["line-height"] = "23px";
playlistRefreshBtn.style["font-size"] = "12px";
playlistRefreshBtn.onclick = function () { if (playlistMode == "detail") { openPlaylistDetail(openPlaylistName); } else { showPlaylistList(); } };
Gdocument.getElementById("maploadwindow").insertBefore(playlistRefreshBtn, Gdocument.getElementById("maploadwindowsearchinput"));
scope.showPlaylistList = function () {
playlistMode = "list";
Gdocument.getElementById("maploadtypedropdowntitle").textContent = "PLAYLISTS";
Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
var cont = Gdocument.getElementById("maploadwindowmapscontainer");
while (cont.firstChild) { cont.removeChild(cont.firstChild); }
var wrap = Gdocument.createElement("div");
wrap.style["padding"] = "12px";
wrap.style["width"] = "100%";
wrap.style["box-sizing"] = "border-box";
var addBtn = Gdocument.createElement("div");
addBtn.classList.value = "brownButton brownButton_classic buttonShadow";
addBtn.textContent = "ADD";
addBtn.style["display"] = "inline-block";
addBtn.style["height"] = "26px";
addBtn.style["line-height"] = "26px";
addBtn.style["padding"] = "0 14px";
addBtn.style["font-size"] = "13px";
var nameInput = Gdocument.createElement("input");
nameInput.type = "text";
nameInput.placeholder = "Playlist Name";
nameInput.className = "fieldShadow";
nameInput.style["display"] = "block";
nameInput.style["margin-top"] = "8px";
nameInput.style["width"] = "200px";
nameInput.style["height"] = "24px";
nameInput.style["font-size"] = "13px";
addBtn.onclick = function () {
var nm = nameInput.value.replace(/^\s+|\s+$/g, "");
if (!nm) { notify("Enter a playlist name."); return; }
if (playlists[nm]) { notify("Playlist \"" + nm + "\" already exists."); return; }
playlists[nm] = [];
savePlaylists();
nameInput.value = "";
showPlaylistList();
};
wrap.appendChild(addBtn);
wrap.appendChild(nameInput);
var codeBox = Gdocument.createElement("textarea");
codeBox.placeholder = "Paste a playlist code here to import, or press Export to fill this box.";
codeBox.className = "fieldShadow";
codeBox.style["display"] = "block";
codeBox.style["margin-top"] = "12px";
codeBox.style["width"] = "320px";
codeBox.style["height"] = "46px";
codeBox.style["font-size"] = "11px";
codeBox.style["resize"] = "vertical";
codeBox.style["font-family"] = "monospace";
var ioRow = Gdocument.createElement("div");
ioRow.style["display"] = "flex";
ioRow.style["gap"] = "8px";
ioRow.style["margin-top"] = "6px";
var importBtn = Gdocument.createElement("div");
importBtn.classList.value = "brownButton brownButton_classic buttonShadow";
importBtn.textContent = "IMPORT";
importBtn.style["height"] = "26px";
importBtn.style["line-height"] = "26px";
importBtn.style["padding"] = "0 14px";
importBtn.style["font-size"] = "12px";
importBtn.onclick = function () {
var code = codeBox.value.replace(/^\s+|\s+$/g, "");
if (!code) { notify("Paste a playlist code into the box first."); return; }
var res = importPlaylistsFromCode(code);
if (!res) { return; }
if (res.playlists == 0 && res.maps == 0) { notify("Nothing new to import - those maps are already in your playlists."); }
else { notify("Imported " + res.maps + " map" + (res.maps == 1 ? "" : "s") + (res.playlists ? " (" + res.playlists + " new playlist" + (res.playlists == 1 ? "" : "s") + ")." : " into existing playlists.")); }
codeBox.value = "";
showPlaylistList();
};
var exportAllBtn = Gdocument.createElement("div");
exportAllBtn.classList.value = "brownButton brownButton_classic buttonShadow";
exportAllBtn.textContent = "EXPORT ALL";
exportAllBtn.style["height"] = "26px";
exportAllBtn.style["line-height"] = "26px";
exportAllBtn.style["padding"] = "0 14px";
exportAllBtn.style["font-size"] = "12px";
exportAllBtn.onclick = function () {
if (Object.keys(playlists).length == 0) { notify("No playlists to export."); return; }
var code = encodePlaylistsCode(playlists);
codeBox.value = code;
codeBox.focus(); codeBox.select();
notify(copyToClipboard(code) ? "All playlists exported - code copied to clipboard (also shown in the box)." : "All playlists exported - select the code in the box and copy it.");
};
ioRow.appendChild(importBtn);
ioRow.appendChild(exportAllBtn);
wrap.appendChild(codeBox);
wrap.appendChild(ioRow);
var listWrap = Gdocument.createElement("div");
listWrap.style["margin-top"] = "16px";
var names = Object.keys(playlists);
if (names.length == 0) {
var empty = Gdocument.createElement("div");
empty.textContent = "No playlists yet. Add one above, then use /addmap <name> in a map to fill it.";
empty.style["color"] = "#555";
empty.style["font-size"] = "13px";
listWrap.appendChild(empty);
}
for (var i = 0; i < names.length; i++) {
(function (nm) {
var row = Gdocument.createElement("div");
row.style["display"] = "flex";
row.style["align-items"] = "center";
row.style["gap"] = "8px";
row.style["margin-bottom"] = "8px";
var open = Gdocument.createElement("div");
open.classList.value = "brownButton brownButton_classic buttonShadow";
open.textContent = nm + " (" + playlists[nm].length + ")";
open.style["height"] = "30px";
open.style["line-height"] = "30px";
open.style["padding"] = "0 16px";
open.style["font-size"] = "14px";
open.style["min-width"] = "160px";
open.onclick = function () { openPlaylistDetail(nm); };
var del = Gdocument.createElement("div");
del.classList.value = "brownButton brownButton_classic buttonShadow";
del.textContent = "X";
del.title = "Delete playlist";
del.style["height"] = "30px";
del.style["line-height"] = "30px";
del.style["width"] = "30px";
del.style["font-size"] = "13px";
del.onclick = function () {
delete playlists[nm];
savePlaylists();
showPlaylistList();
};
var exp = Gdocument.createElement("div");
exp.classList.value = "brownButton brownButton_classic buttonShadow";
exp.textContent = "Export";
exp.title = "Copy this playlist's share code";
exp.style["height"] = "30px";
exp.style["line-height"] = "30px";
exp.style["padding"] = "0 12px";
exp.style["font-size"] = "12px";
exp.onclick = function () {
var one = {}; one[nm] = playlists[nm];
var code = encodePlaylistsCode(one);
codeBox.value = code;
codeBox.focus(); codeBox.select();
notify(copyToClipboard(code) ? ("\"" + nm + "\" exported - code copied to clipboard (also shown in the box).") : ("\"" + nm + "\" exported - select the code in the box and copy it."));
};
row.appendChild(open);
row.appendChild(exp);
row.appendChild(del);
listWrap.appendChild(row);
})(names[i]);
}
wrap.appendChild(listWrap);
originalMapLoad.call(cont, wrap);
};
scope.openPlaylistDetail = function (name) {
if (!playlists[name]) { showPlaylistList(); return; }
openPlaylistName = name;
playlistMode = "detail";
searchrequested = 3;
Gdocument.getElementById("maploadtypedropdowntitle").textContent = "PLAYLISTS";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
Gdocument.getElementById("maploadtypedropdownoption10").click();
};
scope.updatePlaylistChrome = function () {
var titleEl = Gdocument.getElementById("maploadtypedropdowntitle");
if (!titleEl) { return; }
var isPl = titleEl.textContent == "PLAYLISTS";
var detail = isPl && playlistMode == "detail";
playlistBackBtn.style["display"] = detail ? "block" : "none";
playlistShuffleBtn.style["display"] = detail ? "block" : "none";
playlistRefreshBtn.style["display"] = isPl ? "block" : "none";
if (isPl) {
if (typeof loadall != "undefined" && loadall) { loadall.style["display"] = "none"; }
if (typeof clearmaprequests != "undefined" && clearmaprequests) { clearmaprequests.style["display"] = "none"; }
if (typeof refreshmaprequests != "undefined" && refreshmaprequests) { refreshmaprequests.style["display"] = "none"; }
} else {
if (typeof loadall != "undefined" && loadall) { loadall.style["display"] = "block"; }
}
};
};
scope.sandboxonclick = function () {
Gdocument.getElementById("roomlistrefreshbutton").click();
Gdocument.getElementById("roomlistcreatebutton").click();
sandboxon = true;
};
scope.checkboxclearbuttononclick = function () {
var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
var e = true;
for (var i = 0; i < classes.length; i++) {
if (classes[i].checked == true) {
e = false
}
classes[i].checked = false;
}
if (e) {
for (var i = 0; i < classes.length; i++) {
classes[i].checked = true;
}
}
};
Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount", function () { return this.children.length / 50; });
if (Gdocument.getElementById("classic_mid_sandbox") == null) {
Gdocument.getElementById("roomlistrefreshbutton").click();
scope.sandboxbutton = Gdocument.createElement("div");
sandboxbutton.id = "classic_mid_sandbox";
sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
sandboxbutton.textContent = "Sandbox";
sandboxbutton.addEventListener("click", sandboxonclick);
Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton, Gdocument.getElementById("classic_mid_news"));
}
if (Gdocument.getElementById("clearallcheckboxes") == null) {
scope.checkboxclearbutton = Gdocument.createElement("div");
checkboxclearbutton.id = "clearallcheckboxes";
checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
checkboxclearbutton.textContent = "On/Off";
checkboxclearbutton.style["position"] = "absolute";
checkboxclearbutton.style["display"] = "none";
if (typeof (ishost) != 'undefined') {
}
checkboxclearbutton.style["right"] = "255px";
checkboxclearbutton.style["top"] = "57px";
checkboxclearbutton.style["height"] = "23px";
checkboxclearbutton.style["width"] = "47px";
checkboxclearbutton.style["line-height"] = "23px";
checkboxclearbutton.style["font-size"] = "13px";
checkboxclearbutton.addEventListener("click", checkboxclearbuttononclick);
Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton, Gdocument.getElementById("maploadwindowsearchinput"));
}
scope.holdloadbuttonTimeout = [];
scope.holdloadbutton = function () {
var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
mapwindow.scroll(0, mapwindow.scrollHeight);
};
if (Gdocument.getElementById("mapwindowloadall") == null) {
scope.loadall = Gdocument.createElement("div");
loadall.id = "mapwindowloadall";
loadall.classList.value = "brownButton brownButton_classic buttonShadow";
loadall.textContent = "Load";
loadall.style["position"] = "absolute";
loadall.style["display"] = "block";
loadall.style["left"] = "204px";
loadall.style["top"] = "57px";
loadall.style["height"] = "23px";
loadall.style["width"] = "34px";
loadall.style["line-height"] = "23px";
loadall.style["font-size"] = "12px";
var repeat = function () { holdloadbutton(); holdloadbuttonTimeout.push(setTimeout(repeat, 25)); };
loadall.onmousedown = function () { repeat(); };
loadall.onmouseup = function () { for (var i = 0; i < holdloadbuttonTimeout.length; i++) { clearTimeout(holdloadbuttonTimeout[i]); } };
loadall.onmouseout = function () { for (var i = 0; i < holdloadbuttonTimeout.length; i++) { clearTimeout(holdloadbuttonTimeout[i]); } };
Gdocument.getElementById("maploadwindow").insertBefore(loadall, Gdocument.getElementById("maploadwindowsearchinput"));
}
if (Gdocument.getElementById("BonkCommandsDebuggerContainer") == null) {
Gdocument.getElementById("leaveconfirmwindow").style["z-index"] = 3;
scope.packetOpcodeNames = {
3: "pong", 4: "join/bcast", 5: "leave", 6: "host left", 7: "inputs",
9: "kick/ban", 10: "chat out", 13: "skin", 15: "game start", 16: "notice",
18: "team set", 20: "chat in", 21: "init", 23: "map reset", 24: "kicked",
26: "team req", 29: "set balance", 33: "map data", 36: "balance",
41: "host change", 47: "round end", 48: "init"
};
scope.packetOpcode = function (text) {
if (typeof text != "string") { return -1; }
var m = /^42\[(\d+)/.exec(text);
return m ? parseInt(m[1]) : -1;
};
scope.dbgSearch = "";
scope.dbgDir = "all";
scope.dbgOpFilter = "";
scope.dbgAutoscroll = true;
scope.dbgWrap = false;
scope.dbgSendMode = 0;
if (Gdocument.getElementById("BonkCommandsDebuggerStyle") == null) {
var dbgStyle = Gdocument.createElement("style");
dbgStyle.id = "BonkCommandsDebuggerStyle";
dbgStyle.textContent =
"#BonkCommandsDebuggerContainer{font-family:futura,Arial,sans-serif;}" +
"#dbgRoot{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;color:#2a2f33;}" +
"#dbgHeader{display:flex;align-items:center;gap:10px;padding:9px 14px;background:#3ca69b;border-bottom:2px solid #2c7d75;}" +
"#dbgHeader .dbgTitle{font-weight:bold;font-size:16px;color:#ffffff;}" +
"#dbgHeader .dbgCount{font-size:12px;color:#e6f4f1;}" +
"#dbgToolbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:8px 14px;background:#c2ccd0;border-bottom:1px solid #a9b3b8;}" +
".dbgInput{background:#ffffff;border:1px solid #9aa6ab;color:#2a2f33;border-radius:3px;padding:5px 8px;font-size:12px;outline:none;}" +
".dbgInput::placeholder{color:#8a969c;}" +
".dbgInput:focus{border-color:#3ca69b;}" +
".dbgBtn{background:#7c5c3e;border:1px solid #5e442d;color:#f5ecdd;border-radius:3px;padding:5px 11px;font-size:12px;cursor:pointer;user-select:none;}" +
".dbgBtn:hover{background:#8d6a49;}" +
".dbgBtn.on{background:#3ca69b;border-color:#2c7d75;color:#ffffff;}" +
".dbgSeg{display:flex;border:1px solid #5e442d;border-radius:3px;overflow:hidden;}" +
".dbgSeg>div{padding:5px 11px;font-size:12px;cursor:pointer;background:#7c5c3e;color:#f5ecdd;user-select:none;}" +
".dbgSeg>div+div{border-left:1px solid #5e442d;}" +
".dbgSeg>div.on{background:#3ca69b;color:#ffffff;}" +
".dbgSpacer{margin-left:auto;}" +
"#dbgList{flex:1;overflow-y:auto;overflow-x:hidden;background:#cfd8dc;font-family:Consolas,Menlo,monospace;font-size:11.5px;}" +
".dbgRow{display:flex;align-items:center;gap:8px;padding:2px 12px;border-left:4px solid transparent;border-bottom:1px solid #bcc6cb;cursor:pointer;white-space:nowrap;}" +
".dbgRow.zebra{background:#c6cfd3;}" +
".dbgRow[hidden]{display:none;}" +
".dbgRow:hover{background:#b9c8cd;}" +
".dbgRow.send{border-left-color:#3f8f5f;}" +
".dbgRow.recv{border-left-color:#3a72a8;}" +
".dbgRow .dbgDir{font-weight:bold;font-size:10px;width:36px;flex:none;}" +
".dbgRow.send .dbgDir{color:#2f7a4c;}" +
".dbgRow.recv .dbgDir{color:#31608f;}" +
".dbgRow .dbgTime{color:#5c6b72;width:86px;flex:none;}" +
".dbgRow .dbgOp{color:#7c5c3e;font-weight:bold;width:104px;flex:none;overflow:hidden;text-overflow:ellipsis;}" +
".dbgRow .dbgOp:hover{text-decoration:underline;}" +
".dbgRow .dbgPay{flex:1;overflow:hidden;text-overflow:ellipsis;color:#2a2f33;}" +
".dbgRow .dbgCopy{flex:none;color:#7c5c3e;padding:0 5px;font-family:Arial,sans-serif;font-size:11px;}" +
".dbgRow .dbgCopy:hover{color:#2a2f33;text-decoration:underline;}" +
"#dbgList.wrap .dbgRow{white-space:normal;align-items:flex-start;}" +
"#dbgList.wrap .dbgPay{overflow:visible;white-space:pre-wrap;word-break:break-all;}" +
"#dbgComposer{display:flex;align-items:center;gap:6px;padding:9px 14px;background:#c2ccd0;border-top:1px solid #a9b3b8;}" +
"#dbgComposer .dbgInput{flex:1;font-family:Consolas,Menlo,monospace;}";
(Gdocument.head || Gdocument.getElementsByTagName("head")[0]).appendChild(dbgStyle);
}
scope.debuggermenu = Gdocument.createElement("div");
debuggermenu.id = "BonkCommandsDebuggerContainer";
debuggermenu.style["position"] = "fixed";
debuggermenu.style["top"] = "50%";
debuggermenu.style["left"] = "50%";
debuggermenu.style["transform"] = "translate(-50%, -50%)";
debuggermenu.style["display"] = "none";
if (typeof (debuggeropen) != 'undefined' && debuggeropen) { debuggermenu.style["display"] = "block"; }
debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
debuggermenu.style["background"] = "#cfd8dc";
debuggermenu.style["border"] = "2px solid #2c7d75";
debuggermenu.style["border-radius"] = "6px";
debuggermenu.style["overflow"] = "hidden";
debuggermenu.style["box-shadow"] = "0 6px 20px rgba(0, 0, 0, 0.35)";
scope.dbgRoot = Gdocument.createElement("div");
dbgRoot.id = "dbgRoot";
debuggermenu.appendChild(dbgRoot);
var dbgHeader = Gdocument.createElement("div");
dbgHeader.id = "dbgHeader";
var dbgTitle = Gdocument.createElement("div");
dbgTitle.className = "dbgTitle";
dbgTitle.textContent = "Packet Debugger";
scope.dbgCount = Gdocument.createElement("div");
dbgCount.className = "dbgCount";
dbgCount.textContent = "Total 0";
scope.debuggermenuclose = Gdocument.createElement("div");
debuggermenuclose.id = "debuggerclose";
debuggermenuclose.className = "windowCloseButton brownButton brownButton_classic buttonShadow dbgSpacer";
debuggermenuclose.style["position"] = "static";
debuggermenuclose.onclick = function () { setDebuggerOpen(false); };
dbgHeader.appendChild(dbgTitle);
dbgHeader.appendChild(dbgCount);
dbgHeader.appendChild(debuggermenuclose);
dbgRoot.appendChild(dbgHeader);
var dbgToolbar = Gdocument.createElement("div");
dbgToolbar.id = "dbgToolbar";
scope.dbgSearchInput = Gdocument.createElement("input");
dbgSearchInput.className = "dbgInput";
dbgSearchInput.placeholder = "Search payload";
dbgSearchInput.style["width"] = "220px";
dbgSearchInput.oninput = function () { dbgSearch = this.value.toLowerCase(); dbgApplyFilters(); };
scope.dbgOpInput = Gdocument.createElement("input");
dbgOpInput.className = "dbgInput";
dbgOpInput.placeholder = "Opcode";
dbgOpInput.style["width"] = "70px";
dbgOpInput.oninput = function () { dbgOpFilter = this.value.replace(/[^0-9]/g, ""); dbgApplyFilters(); };
scope.dbgDirSeg = Gdocument.createElement("div");
dbgDirSeg.className = "dbgSeg";
var dirDefs = [["all", "All"], ["send", "Sent"], ["recv", "Recv"]];
for (var di = 0; di < dirDefs.length; di++) {
(function (val, label) {
var seg = Gdocument.createElement("div");
seg.textContent = label;
if (val == dbgDir) { seg.className = "on"; }
seg.onclick = function () {
dbgDir = val;
var kids = dbgDirSeg.children;
for (var k = 0; k < kids.length; k++) { kids[k].className = (kids[k] === seg) ? "on" : ""; }
dbgApplyFilters();
};
dbgDirSeg.appendChild(seg);
})(dirDefs[di][0], dirDefs[di][1]);
}
scope.debuggerpausebutton = Gdocument.createElement("div");
debuggerpausebutton.className = "dbgBtn dbgSpacer";
debuggerpausebutton.textContent = "Pause";
debuggerpausebutton.onclick = function () {
wsslogpaused = !wsslogpaused;
this.textContent = wsslogpaused ? "Resume" : "Pause";
this.className = wsslogpaused ? "dbgBtn on dbgSpacer" : "dbgBtn dbgSpacer";
dbgUpdateCounter();
};
var dbgAutoBtn = Gdocument.createElement("div");
dbgAutoBtn.className = "dbgBtn on";
dbgAutoBtn.textContent = "Autoscroll";
dbgAutoBtn.onclick = function () {
dbgAutoscroll = !dbgAutoscroll;
this.className = dbgAutoscroll ? "dbgBtn on" : "dbgBtn";
};
var dbgWrapBtn = Gdocument.createElement("div");
dbgWrapBtn.className = "dbgBtn";
dbgWrapBtn.textContent = "Wrap";
dbgWrapBtn.onclick = function () {
dbgWrap = !dbgWrap;
this.className = dbgWrap ? "dbgBtn on" : "dbgBtn";
if (dbgWrap) { dbgList.classList.add("wrap"); } else { dbgList.classList.remove("wrap"); }
};
var dbgClearBtn = Gdocument.createElement("div");
dbgClearBtn.className = "dbgBtn";
dbgClearBtn.textContent = "Clear";
dbgClearBtn.onclick = function () {
while (dbgList.firstChild) { dbgList.removeChild(dbgList.firstChild); }
packetcount = wsssendrecievelog.length;
dbgUpdateCounter();
};
dbgToolbar.appendChild(dbgSearchInput);
dbgToolbar.appendChild(dbgOpInput);
dbgToolbar.appendChild(dbgDirSeg);
dbgToolbar.appendChild(dbgAutoBtn);
dbgToolbar.appendChild(dbgWrapBtn);
dbgToolbar.appendChild(dbgClearBtn);
dbgToolbar.appendChild(debuggerpausebutton);
dbgRoot.appendChild(dbgToolbar);
scope.logmenu = Gdocument.createElement("div");
logmenu.id = "dbgList";
scope.dbgList = logmenu;
dbgRoot.appendChild(logmenu);
var dbgComposer = Gdocument.createElement("div");
dbgComposer.id = "dbgComposer";
scope.debuggersendrecieve = Gdocument.createElement("div");
debuggersendrecieve.className = "dbgSeg";
var modeDefs = [[0, "Send"], [1, "Recv"]];
for (var mi = 0; mi < modeDefs.length; mi++) {
(function (val, label) {
var seg = Gdocument.createElement("div");
seg.textContent = label;
if (val == dbgSendMode) { seg.className = "on"; }
seg.onclick = function () {
dbgSendMode = val;
var kids = debuggersendrecieve.children;
for (var k = 0; k < kids.length; k++) { kids[k].className = (kids[k] === seg) ? "on" : ""; }
};
debuggersendrecieve.appendChild(seg);
})(modeDefs[mi][0], modeDefs[mi][1]);
}
scope.dbgSetMode = function (mode) {
dbgSendMode = mode;
var kids = debuggersendrecieve.children;
kids[0].className = (mode == 0) ? "on" : "";
kids[1].className = (mode == 1) ? "on" : "";
};
scope.debuggereval = Gdocument.createElement("input");
debuggereval.className = "dbgInput";
debuggereval.placeholder = "Packet to send or receive, Enter to fire";
scope.debuggerinput = debuggereval;
scope.dbgFire = function () {
var v = debuggereval.value;
if (!v.length) { return; }
if (dbgSendMode == 0) { SEND(v); } else { RECIEVE(v); }
};
debuggereval.addEventListener("keypress", function (e) {
if (e.repeat) { return; }
if (e.code == "Enter") { dbgFire(); }
});
debuggereval.addEventListener("keydown", function (e) {
if (e.code == "Escape") { setDebuggerOpen(false); }
});
var dbgFireBtn = Gdocument.createElement("div");
dbgFireBtn.className = "dbgBtn on";
dbgFireBtn.textContent = "Fire";
dbgFireBtn.onclick = function () { dbgFire(); };
dbgComposer.appendChild(debuggersendrecieve);
dbgComposer.appendChild(debuggereval);
dbgComposer.appendChild(dbgFireBtn);
dbgRoot.appendChild(dbgComposer);
scope.dbgRowMatches = function (row) {
if (dbgDir == "send" && row._dir != 0) { return false; }
if (dbgDir == "recv" && row._dir != 1) { return false; }
if (dbgOpFilter !== "" && String(row._op) !== dbgOpFilter) { return false; }
if (dbgSearch && row._low.indexOf(dbgSearch) === -1) { return false; }
return true;
};
scope.dbgApplyFilters = function () {
var rows = dbgList.children;
for (var i = 0; i < rows.length; i++) { rows[i].hidden = !dbgRowMatches(rows[i]); }
dbgUpdateCounter();
};
scope.dbgUpdateCounter = function () {
var total = wsssendrecievelog.length;
var rows = dbgList.children, shown = 0;
for (var i = 0; i < rows.length; i++) { if (!rows[i].hidden) { shown++; } }
var txt = "Total " + total + " · " + shown + " shown";
if (rows.length < total) { txt += " (buffer " + rows.length + ")"; }
if (wsslogpaused) { txt += " · PAUSED"; }
dbgCount.textContent = txt;
};
scope.dbgPad2 = function (n) { return n < 10 ? "0" + n : "" + n; };
scope.dbgClock = function (ts) {
var d = new Date(ts);
return dbgPad2(d.getHours()) + ":" + dbgPad2(d.getMinutes()) + ":" + dbgPad2(d.getSeconds()) +
"." + (d.getMilliseconds() < 100 ? (d.getMilliseconds() < 10 ? "00" : "0") : "") + d.getMilliseconds();
};
scope.dbgMakeRow = function (dir, text, ts) {
var op = packetOpcode(text);
var row = Gdocument.createElement("div");
row.className = "dbgRow " + (dir == 0 ? "send" : "recv");
row._dir = dir;
row._op = op;
row._low = (typeof text == "string" ? text : String(text)).toLowerCase();
row._text = text;
var dirEl = Gdocument.createElement("span");
dirEl.className = "dbgDir";
dirEl.textContent = dir == 0 ? "SEND" : "RECV";
var timeEl = Gdocument.createElement("span");
timeEl.className = "dbgTime";
timeEl.textContent = dbgClock(ts);
var opEl = Gdocument.createElement("span");
opEl.className = "dbgOp";
var name = packetOpcodeNames[op];
opEl.textContent = op >= 0 ? (op + (name ? " " + name : "")) : "raw";
opEl.title = "Filter by opcode " + op;
opEl.onclick = function (e) {
e.stopPropagation();
if (op < 0) { return; }
dbgOpFilter = (dbgOpFilter === String(op)) ? "" : String(op);
dbgOpInput.value = dbgOpFilter;
dbgApplyFilters();
};
var payEl = Gdocument.createElement("span");
payEl.className = "dbgPay";
payEl.textContent = text;
payEl.title = text;
var copyEl = Gdocument.createElement("span");
copyEl.className = "dbgCopy";
copyEl.textContent = "copy";
copyEl.title = "Copy";
copyEl.onclick = function (e) {
e.stopPropagation();
try { (Gwindow.navigator.clipboard || navigator.clipboard).writeText(text); } catch (err) { }
var old = copyEl.textContent; copyEl.textContent = "ok";
setTimeout(function () { copyEl.textContent = old; }, 700);
};
row.onclick = function () {
debuggereval.value = text;
dbgSetMode(dir);
debuggereval.focus();
};
row.appendChild(dirEl);
row.appendChild(timeEl);
row.appendChild(opEl);
row.appendChild(payEl);
row.appendChild(copyEl);
row.hidden = !dbgRowMatches(row);
return row;
};
scope.dbgGuardInput = function (el) {
["keydown", "keyup", "keypress"].forEach(function (ev) {
el.addEventListener(ev, function (e) { e.stopPropagation(); });
});
};
dbgGuardInput(dbgSearchInput);
dbgGuardInput(dbgOpInput);
dbgGuardInput(debuggereval);
scope.setDebuggerOpen = function (open) {
debuggeropen = open;
debuggermenu.style["display"] = open ? "block" : "none";
var lob = Gdocument.getElementById("newbonklobby_chat_input");
var ing = Gdocument.getElementById("ingamechatinputtext");
if (open) {
if (lob) { lob.style["display"] = "none"; }
if (ing) { ing.style["display"] = "none"; }
try { if (Gdocument.activeElement && Gdocument.activeElement.blur) { Gdocument.activeElement.blur(); } } catch (e) { }
setTimeout(function () { try { debuggereval.focus(); } catch (e) { } }, 0);
} else {
if (lob) { lob.style["display"] = ""; }
if (ing) { ing.style["display"] = ""; }
}
};
scope.toggleDebugger = function () {
setDebuggerOpen(debuggermenu.style["display"] == "none");
};
Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
}
scope.ISdecode = function (rawdata) {
rawdata_caseflipped = "";
for (i = 0; i < rawdata.length; i++) {
if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
} else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
} else {
rawdata_caseflipped += rawdata.charAt(i);
}
}
data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
databuffer = bytebuffer.fromBase64(data_deLZd);
data = ISpsonpair.decode(databuffer.buffer);
return data;
};
scope.avatarToBase64 = function (buff) {
var uint8 = new Uint8Array(buff.buffer);
var index = buff.index;
var result = "";
for (var i = 0; i < index; i++) {
result += String.fromCharCode(uint8[i]);
}
return btoa(result);
};
scope.avatarToString = function (avatar) {
var buff = new bytebuffer2();
buff.writeByte(0x0A);
buff.writeByte(0x07);
buff.writeByte(0x03);
buff.writeByte(0x61);
buff.writeShort(0x02);
buff.writeByte(0x09);
buff.writeByte(avatar.layers.length * 2 + 1);
buff.writeByte(0x01);
for (var i = 0; i < avatar.layers.length; i++) {
var layer = avatar.layers[i];
buff.writeByte(0x0A);
if (i == 0) {
buff.writeByte(0x07);
buff.writeByte(0x05);
buff.writeByte(0x61);
buff.writeByte(0x6c);
}
else {
buff.writeByte(0x05);
}
buff.writeShort(1);
buff.writeShort(layer.id);
buff.writeFloat(layer.scale);
buff.writeFloat(layer.angle);
buff.writeFloat(layer.x);
buff.writeFloat(layer.y);
buff.writeBoolean(layer.flipX);
buff.writeBoolean(layer.flipY);
buff.writeInt(layer.color);
}
buff.writeInt(avatar.bc);
return encodeURIComponent(avatarToBase64(buff));
};
scope.avatarToBonkLeagueLink = async function (avatar, name, author) {
var skin_str = avatarToString(avatar);
var x = new URLSearchParams({ author: author, title: name, data: skin_str });
var data = await fetchMessage("https://bonkleagues.io/api/shorten", x.toString());
return JSON.parse(data).url;
};
scope.ISencode = function (obj) {
data = ISpsonpair.encode(obj);
b64 = data.toBase64();
lzd = LZString.compressToEncodedURIComponent(b64);
caseflipped = "";
for (i = 0; i < lzd.length; i++) {
if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
caseflipped += lzd.charAt(i).toUpperCase();
} else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
caseflipped += lzd.charAt(i).toLowerCase();
} else {
caseflipped += lzd.charAt(i);
}
}
return caseflipped;
};
scope.decodeIS = function (x) {
return ISdecode(x);
};
scope.encodeIS = function (x) {
return ISencode(x);
};
scope.encodeToDatabase = function (W2A) {
var M3n = [arguments];
M3n[1] = new bytebuffer2;
M3n[9] = M3n[0][0].physics;
M3n[0][0].v = 15;
M3n[1].writeShort(M3n[0][0].v);
M3n[1].writeBoolean(M3n[0][0].s.re);
M3n[1].writeBoolean(M3n[0][0].s.nc);
M3n[1].writeShort(M3n[0][0].s.pq);
M3n[1].writeFloat(M3n[0][0].s.gd);
M3n[1].writeBoolean(M3n[0][0].s.fl);
M3n[1].writeUTF(M3n[0][0].m.rxn);
M3n[1].writeUTF(M3n[0][0].m.rxa);
M3n[1].writeUint(M3n[0][0].m.rxid);
M3n[1].writeShort(M3n[0][0].m.rxdb);
M3n[1].writeUTF(M3n[0][0].m.n);
M3n[1].writeUTF(M3n[0][0].m.a);
M3n[1].writeUint(M3n[0][0].m.vu);
M3n[1].writeUint(M3n[0][0].m.vd);
M3n[1].writeShort(M3n[0][0].m.cr.length);
for (
M3n[84] = 0;
M3n[84] < M3n[0][0].m.cr.length;
M3n[84]++
) {
M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
}
M3n[1].writeUTF(M3n[0][0].m.mo);
M3n[1].writeInt(M3n[0][0].m.dbid);
M3n[1].writeBoolean(M3n[0][0].m.pub);
M3n[1].writeInt(M3n[0][0].m.dbv);
M3n[1].writeShort(M3n[9].ppm);
M3n[1].writeShort(M3n[9].bro.length);
for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
M3n[1].writeShort(M3n[9].bro[M3n[17]]);
}
M3n[1].writeShort(M3n[9].shapes.length);
for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
M3n[2] = M3n[9].shapes[M3n[80]];
if (M3n[2].type == "bx") {
M3n[1].writeShort(1);
M3n[1].writeDouble(M3n[2].w);
M3n[1].writeDouble(M3n[2].h);
M3n[1].writeDouble(M3n[2].c[0]);
M3n[1].writeDouble(M3n[2].c[1]);
M3n[1].writeDouble(M3n[2].a);
M3n[1].writeBoolean(M3n[2].sk);
}
if (M3n[2].type == "ci") {
M3n[1].writeShort(2);
M3n[1].writeDouble(M3n[2].r);
M3n[1].writeDouble(M3n[2].c[0]);
M3n[1].writeDouble(M3n[2].c[1]);
M3n[1].writeBoolean(M3n[2].sk);
}
if (M3n[2].type == "po") {
M3n[1].writeShort(3);
M3n[1].writeDouble(M3n[2].s);
M3n[1].writeDouble(M3n[2].a);
M3n[1].writeDouble(M3n[2].c[0]);
M3n[1].writeDouble(M3n[2].c[1]);
M3n[1].writeShort(M3n[2].v.length);
for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
}
}
}
M3n[1].writeShort(M3n[9].fixtures.length);
for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
M3n[7] = M3n[9].fixtures[M3n[20]];
M3n[1].writeShort(M3n[7].sh);
M3n[1].writeUTF(M3n[7].n);
if (M3n[7].fr === null) {
M3n[1].writeDouble(Number.MAX_VALUE);
} else {
M3n[1].writeDouble(M3n[7].fr);
}
if (M3n[7].fp === null) {
M3n[1].writeShort(0);
}
if (M3n[7].fp === false) {
M3n[1].writeShort(1);
}
if (M3n[7].fp === true) {
M3n[1].writeShort(2);
}
if (M3n[7].re === null) {
M3n[1].writeDouble(Number.MAX_VALUE);
} else {
M3n[1].writeDouble(M3n[7].re);
}
if (M3n[7].de === null) {
M3n[1].writeDouble(Number.MAX_VALUE);
} else {
M3n[1].writeDouble(M3n[7].de);
}
M3n[1].writeUint(M3n[7].f);
M3n[1].writeBoolean(M3n[7].d);
M3n[1].writeBoolean(M3n[7].np);
M3n[1].writeBoolean(M3n[7].ng);
M3n[1].writeBoolean(M3n[7].ig);
}
M3n[1].writeShort(M3n[9].bodies.length);
for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
M3n[4] = M3n[9].bodies[M3n[37]];
M3n[1].writeUTF(M3n[4].type);
M3n[1].writeUTF(M3n[4].n);
M3n[1].writeDouble(M3n[4].p[0]);
M3n[1].writeDouble(M3n[4].p[1]);
M3n[1].writeDouble(M3n[4].a);
M3n[1].writeDouble(M3n[4].fric);
M3n[1].writeBoolean(M3n[4].fricp);
M3n[1].writeDouble(M3n[4].re);
M3n[1].writeDouble(M3n[4].de);
M3n[1].writeDouble(M3n[4].lv[0]);
M3n[1].writeDouble(M3n[4].lv[1]);
M3n[1].writeDouble(M3n[4].av);
M3n[1].writeDouble(M3n[4].ld);
M3n[1].writeDouble(M3n[4].ad);
M3n[1].writeBoolean(M3n[4].fr);
M3n[1].writeBoolean(M3n[4].bu);
M3n[1].writeDouble(M3n[4].cf.x);
M3n[1].writeDouble(M3n[4].cf.y);
M3n[1].writeDouble(M3n[4].cf.ct);
M3n[1].writeBoolean(M3n[4].cf.w);
M3n[1].writeShort(M3n[4].f_c);
M3n[1].writeBoolean(M3n[4].f_1);
M3n[1].writeBoolean(M3n[4].f_2);
M3n[1].writeBoolean(M3n[4].f_3);
M3n[1].writeBoolean(M3n[4].f_4);
M3n[1].writeBoolean(M3n[4].f_p);
M3n[1].writeBoolean(M3n[4].fz.on);
if (M3n[4].fz.on) {
M3n[1].writeDouble(M3n[4].fz.x);
M3n[1].writeDouble(M3n[4].fz.y);
M3n[1].writeBoolean(M3n[4].fz.d);
M3n[1].writeBoolean(M3n[4].fz.p);
M3n[1].writeBoolean(M3n[4].fz.a);
M3n[1].writeShort(M3n[4].fz.t);
M3n[1].writeDouble(M3n[4].fz.cf);
}
M3n[1].writeShort(M3n[4].fx.length);
for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
M3n[1].writeShort(M3n[4].fx[M3n[28]]);
}
}
M3n[1].writeShort(M3n[0][0].spawns.length);
for (
M3n[30] = 0;
M3n[30] < M3n[0][0].spawns.length;
M3n[30]++
) {
M3n[6] = M3n[0][0].spawns[M3n[30]];
M3n[1].writeDouble(M3n[6].x);
M3n[1].writeDouble(M3n[6].y);
M3n[1].writeDouble(M3n[6].xv);
M3n[1].writeDouble(M3n[6].yv);
M3n[1].writeShort(M3n[6].priority);
M3n[1].writeBoolean(M3n[6].r);
M3n[1].writeBoolean(M3n[6].f);
M3n[1].writeBoolean(M3n[6].b);
M3n[1].writeBoolean(M3n[6].gr);
M3n[1].writeBoolean(M3n[6].ye);
M3n[1].writeUTF(M3n[6].n);
}
M3n[1].writeShort(M3n[0][0].capZones.length);
for (
M3n[74] = 0;
M3n[74] < M3n[0][0].capZones.length;
M3n[74]++
) {
M3n[3] = M3n[0][0].capZones[M3n[74]];
M3n[1].writeUTF(M3n[3].n);
M3n[1].writeDouble(M3n[3].l);
M3n[1].writeShort(M3n[3].i);
M3n[1].writeShort(M3n[3].ty);
}
M3n[1].writeShort(M3n[9].joints.length);
for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
M3n[5] = M3n[9].joints[M3n[89]];
if (M3n[5].type == "rv") {
M3n[1].writeShort(1);
M3n[1].writeDouble(M3n[5].d.la);
M3n[1].writeDouble(M3n[5].d.ua);
M3n[1].writeDouble(M3n[5].d.mmt);
M3n[1].writeDouble(M3n[5].d.ms);
M3n[1].writeBoolean(M3n[5].d.el);
M3n[1].writeBoolean(M3n[5].d.em);
M3n[1].writeDouble(M3n[5].aa[0]);
M3n[1].writeDouble(M3n[5].aa[1]);
}
if (M3n[5].type == "d") {
M3n[1].writeShort(2);
M3n[1].writeDouble(M3n[5].d.fh);
M3n[1].writeDouble(M3n[5].d.dr);
M3n[1].writeDouble(M3n[5].aa[0]);
M3n[1].writeDouble(M3n[5].aa[1]);
M3n[1].writeDouble(M3n[5].ab[0]);
M3n[1].writeDouble(M3n[5].ab[1]);
}
if (M3n[5].type == "lpj") {
M3n[1].writeShort(3);
M3n[1].writeDouble(M3n[5].pax);
M3n[1].writeDouble(M3n[5].pay);
M3n[1].writeDouble(M3n[5].pa);
M3n[1].writeDouble(M3n[5].pf);
M3n[1].writeDouble(M3n[5].pl);
M3n[1].writeDouble(M3n[5].pu);
M3n[1].writeDouble(M3n[5].plen);
M3n[1].writeDouble(M3n[5].pms);
}
if (M3n[5].type == "lsj") {
M3n[1].writeShort(4);
M3n[1].writeDouble(M3n[5].sax);
M3n[1].writeDouble(M3n[5].say);
M3n[1].writeDouble(M3n[5].sf);
M3n[1].writeDouble(M3n[5].slen);
}
if (M3n[5].type == "g") {
M3n[1].writeShort(5);
M3n[1].writeUTF(M3n[5].n);
M3n[1].writeShort(M3n[5].ja);
M3n[1].writeShort(M3n[5].jb);
M3n[1].writeDouble(M3n[5].r);
}
if (M3n[5].type != "g") {
M3n[1].writeShort(M3n[5].ba);
M3n[1].writeShort(M3n[5].bb);
M3n[1].writeBoolean(M3n[5].d.cc);
M3n[1].writeDouble(M3n[5].d.bf);
M3n[1].writeBoolean(M3n[5].d.dl);
}
}
M3n[32] = M3n[1].toBase64();
M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
return M3n[77];
};
scope.decodeFromDatabase = function (map) {
var F5W = [arguments];
var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
var binaryReader = new bytebuffer2;
binaryReader.fromBase64(b64mapdata, false);
var map = { v: 1, s: { re: false, nc: false, pq: 1, gd: 25, fl: false }, physics: { shapes: [], fixtures: [], bodies: [], bro: [], joints: [], ppm: 12, }, spawns: [], capZones: [], m: { a: "noauthor", n: "noname", dbv: 2, dbid: -1, authid: -1, date: "", rxid: 0, rxn: "", rxa: "", rxdb: 1, cr: [], pub: false, mo: "", } };
map.v = binaryReader.readShort();
if (map.v > 15) {
throw new Error("Future map version, please refresh page");
}
map.s.re = binaryReader.readBoolean();
map.s.nc = binaryReader.readBoolean();
if (map.v >= 3) {
map.s.pq = binaryReader.readShort();
}
if (map.v >= 4 && map.v <= 12) {
map.s.gd = binaryReader.readShort();
} else if (map.v >= 13) {
map.s.gd = binaryReader.readFloat();
}
if (map.v >= 9) {
map.s.fl = binaryReader.readBoolean();
}
map.m.rxn = binaryReader.readUTF();
map.m.rxa = binaryReader.readUTF();
map.m.rxid = binaryReader.readUint();
map.m.rxdb = binaryReader.readShort();
map.m.n = binaryReader.readUTF();
map.m.a = binaryReader.readUTF();
if (map.v >= 10) {
map.m.vu = binaryReader.readUint();
map.m.vd = binaryReader.readUint();
}
if (map.v >= 4) {
F5W[7] = binaryReader.readShort();
for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
map.m.cr.push(binaryReader.readUTF());
}
}
if (map.v >= 5) {
map.m.mo = binaryReader.readUTF();
map.m.dbid = binaryReader.readInt();
}
if (map.v >= 7) {
map.m.pub = binaryReader.readBoolean();
}
if (map.v >= 8) {
map.m.dbv = binaryReader.readInt();
}
map.physics.ppm = binaryReader.readShort();
F5W[4] = binaryReader.readShort();
for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
map.physics.bro[F5W[15]] = binaryReader.readShort();
}
F5W[6] = binaryReader.readShort();
for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
F5W[5] = binaryReader.readShort();
if (F5W[5] == 1) {
map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
map.physics.shapes[F5W[28]].c = [
binaryReader.readDouble(),
binaryReader.readDouble(),
];
map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
}
if (F5W[5] == 2) {
map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
map.physics.shapes[F5W[28]].c = [
binaryReader.readDouble(),
binaryReader.readDouble(),
];
map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
}
if (F5W[5] == 3) {
map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
map.physics.shapes[F5W[28]].c = [
binaryReader.readDouble(),
binaryReader.readDouble(),
];
F5W[74] = binaryReader.readShort();
map.physics.shapes[F5W[28]].v = [];
for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
map.physics.shapes[F5W[28]].v.push([
binaryReader.readDouble(),
binaryReader.readDouble(),
]);
}
}
}
F5W[71] = binaryReader.readShort();
for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
map.physics.fixtures[F5W[17]].fr = null;
}
F5W[12] = binaryReader.readShort();
if (F5W[12] == 0) {
map.physics.fixtures[F5W[17]].fp = null;
}
if (F5W[12] == 1) {
map.physics.fixtures[F5W[17]].fp = false;
}
if (F5W[12] == 2) {
map.physics.fixtures[F5W[17]].fp = true;
}
map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
map.physics.fixtures[F5W[17]].re = null;
}
map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
map.physics.fixtures[F5W[17]].de = null;
}
map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
if (map.v >= 11) {
map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
}
if (map.v >= 12) {
map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
}
}
F5W[63] = binaryReader.readShort();
for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
map.physics.bodies[F5W[52]] = { type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true, t: 0, cf: 0 } };
map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
map.physics.bodies[F5W[52]].lv = [
binaryReader.readDouble(),
binaryReader.readDouble(),
];
map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
if (map.v >= 2) {
map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
}
if (map.v >= 14) {
map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
if (map.physics.bodies[F5W[52]].fz.on) {
map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
if (map.v >= 15) {
map.physics.bodies[F5W[52]].fz.t = binaryReader.readShort();
map.physics.bodies[F5W[52]].fz.cf = binaryReader.readDouble();
}
}
}
F5W[88] = binaryReader.readShort();
for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
}
}
F5W[97] = binaryReader.readShort();
for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
map.spawns[F5W[41]] = { "x": 400, "y": 300, "xv": 0, "yv": 0, "priority": 5, "r": true, "f": true, "b": true, "gr": false, "ye": false, "n": "Spawn" };
F5W[35] = map.spawns[F5W[41]];
F5W[35].x = binaryReader.readDouble();
F5W[35].y = binaryReader.readDouble();
F5W[35].xv = binaryReader.readDouble();
F5W[35].yv = binaryReader.readDouble();
F5W[35].priority = binaryReader.readShort();
F5W[35].r = binaryReader.readBoolean();
F5W[35].f = binaryReader.readBoolean();
F5W[35].b = binaryReader.readBoolean();
F5W[35].gr = binaryReader.readBoolean();
F5W[35].ye = binaryReader.readBoolean();
F5W[35].n = binaryReader.readUTF();
}
F5W[16] = binaryReader.readShort();
for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
map.capZones[F5W[25]] = { "n": "Cap Zone", "ty": 1, "l": 10, "i": -1 };
map.capZones[F5W[25]].n = binaryReader.readUTF();
map.capZones[F5W[25]].l = binaryReader.readDouble();
map.capZones[F5W[25]].i = binaryReader.readShort();
if (map.v >= 6) {
map.capZones[F5W[25]].ty = binaryReader.readShort();
}
}
F5W[98] = binaryReader.readShort();
for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
F5W[31] = binaryReader.readShort();
if (F5W[31] == 1) {
map.physics.joints[F5W[19]] = { "type": "rv", "d": { "la": 0, "ua": 0, "mmt": 0, "ms": 0, "el": false, "em": false, "cc": false, "bf": 0, "dl": true }, "aa": [0, 0] };
F5W[20] = map.physics.joints[F5W[19]];
F5W[20].d.la = binaryReader.readDouble();
F5W[20].d.ua = binaryReader.readDouble();
F5W[20].d.mmt = binaryReader.readDouble();
F5W[20].d.ms = binaryReader.readDouble();
F5W[20].d.el = binaryReader.readBoolean();
F5W[20].d.em = binaryReader.readBoolean();
F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
}
if (F5W[31] == 2) {
map.physics.joints[F5W[19]] = { "type": "d", "d": { "fh": 0, "dr": 0, "cc": false, "bf": 0, "dl": true }, "aa": [0, 0], "ab": [0, 0] };
F5W[87] = map.physics.joints[F5W[19]];
F5W[87].d.fh = binaryReader.readDouble();
F5W[87].d.dr = binaryReader.readDouble();
F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
}
if (F5W[31] == 3) {
map.physics.joints[F5W[19]] = { "type": "lpj", "d": { "cc": false, "bf": 0, "dl": true }, "pax": 0, "pay": 0, "pa": 0, "pf": 0, "pl": 0, "pu": 0, "plen": 0, "pms": 0 };
F5W[90] = map.physics.joints[F5W[19]];
F5W[90].pax = binaryReader.readDouble();
F5W[90].pay = binaryReader.readDouble();
F5W[90].pa = binaryReader.readDouble();
F5W[90].pf = binaryReader.readDouble();
F5W[90].pl = binaryReader.readDouble();
F5W[90].pu = binaryReader.readDouble();
F5W[90].plen = binaryReader.readDouble();
F5W[90].pms = binaryReader.readDouble();
}
if (F5W[31] == 4) {
map.physics.joints[F5W[19]] = { "type": "lsj", "d": { "cc": false, "bf": 0, "dl": true }, "sax": 0, "say": 0, "sf": 0, "slen": 0 };
F5W[44] = map.physics.joints[F5W[19]];
F5W[44].sax = binaryReader.readDouble();
F5W[44].say = binaryReader.readDouble();
F5W[44].sf = binaryReader.readDouble();
F5W[44].slen = binaryReader.readDouble();
}
if (F5W[31] == 5) {
map.physics.joints[F5W[19]] = { type: "g", n: "", ja: -1, jb: -1, r: 1 };
F5W[91] = map.physics.joints[F5W[19]];
F5W[91].n = binaryReader.readUTF();
F5W[91].ja = binaryReader.readShort();
F5W[91].jb = binaryReader.readShort();
F5W[91].r = binaryReader.readDouble();
}
if (F5W[31] != 5) {
map.physics.joints[F5W[19]].ba = binaryReader.readShort();
map.physics.joints[F5W[19]].bb = binaryReader.readShort();
map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
}
}
return map;
};
scope.updateWssLog = function () {
if (wsslogpaused) { return; }
if (typeof dbgList == "undefined" || packetcount >= wsssendrecievelog.length) { return; }
var atBottom = dbgList.scrollHeight - dbgList.scrollTop - dbgList.clientHeight < 6;
for (; packetcount < wsssendrecievelog.length; packetcount++) {
var entry = wsssendrecievelog[packetcount];
var ts = (entry.length > 2 && entry[2]) ? entry[2] : Date.now();
var newRow = dbgMakeRow(entry[0], entry[1], ts);
if (packetcount % 2) { newRow.classList.add("zebra"); }
dbgList.appendChild(newRow);
}
while (dbgList.children.length > 1500) { dbgList.removeChild(dbgList.firstChild); }
dbgUpdateCounter();
if (dbgAutoscroll && atBottom) { dbgList.scrollTop = dbgList.scrollHeight; }
};
Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function (args) {
var checkbox = Gdocument.createElement("input");
checkbox.type = "checkbox";
checkbox.style["position"] = "absolute";
checkbox.style["margin-top"] = "135px";
checkbox.style["margin-left"] = "140px";
checkbox.style["scale"] = "2";
checkbox.style["display"] = "none";
checkbox.className = "quickplaycheckbox quickplayunchecked";
checkbox.checked = true;
checkbox.onclick = function (e) { e.stopPropagation(); };
args.appendChild(checkbox);
originalMapLoad.call(this, args);
};
Gdocument.getElementById("newbonklobby_chat_content").appendChild = function (args) {
if (beenKickedTimeStamp + 100 > Date.now() && args.children.length > 0) {
if (args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")) {
var kickedorbanned = "banned";
if (onlykicked) {
kickedorbanned = "kicked";
}
args.children[0].textContent = args.children[0].textContent.substring(0, args.children[0].textContent.length - 19) + " has been " + kickedorbanned + " from the game ";
}
}
setTimeout(function () {
if (args.textContent.startsWith("* ") && args.children.length >= 5) {
var newarg = args.cloneNode();
for (var i = 0; i < args.children.length; i++) {
var newarg2 = args.children[i].cloneNode();
newarg2.textContent = args.children[i].textContent;
newarg2.style.color = '#ffffffd6';
newarg2.onclick = args.children[i].onclick;
newarg2.suggestID = args.children[i].suggestID;
newarg.appendChild(newarg2);
}
Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
}
}, 0);
originalLobbyChat.call(this, args);
};
Gdocument.getElementById("ingamechatcontent").appendChild = function (args) {
if (beenKickedTimeStamp + 100 > Date.now() && args.children.length > 0) {
if (args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")) {
var kickedorbanned = "banned";
if (onlykicked) {
kickedorbanned = "kicked";
}
args.children[0].textContent = args.children[0].textContent.substring(0, args.children[0].textContent.length - 19) + " has been " + kickedorbanned + " from the game.";
}
}
if (recordedTimeStamp + 100 > Date.now() && args.children.length > 0) {
if (args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")) {
args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
}
}
originalIngameChat.call(this, args);
};
Gwindow.Date.now = function () {
if (overideDate[0]) {
return overideDate[1];
}
else if (causelag) {
return originalDatenow.call(this, ...arguments) - causelag2;
}
return originalDatenow.call(this, ...arguments);
};
Gwindow.XMLHttpRequest.prototype.open = function (_, url) {
if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
if (searchrequested > 0) {
Gdocument.getElementById("maploadtypedropdowntitle").click();
var dropdown;
if (searchrequested == 1) {
dropdown = dropdownrequested;
}
else if (searchrequested == 2) {
dropdown = dropdownhistory;
}
else if (searchrequested == 3) {
dropdown = dropdownplaylists;
}
Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdown.textContent;
dropdown.style["display"] = "none";
clearmaprequests.style["display"] = "block";
refreshmaprequests.style["display"] = "block";
Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
this.isSearchMap = true;
this.isSearchMap2 = searchrequested;
searchrequested = 0;
}
}
else if (url.includes("getrooms.php")) {
this.isGetRooms = true;
}
else if (url.includes("avatar_update.php")) {
this.saveAvatar = true;
}
else if (url.includes("getroomaddress.php")) {
this.isGetRoomAddress = true;
}
else if (url.includes("replay_get.php")) {
this.replay_get = true;
}
originalXMLOpen.call(this, ...arguments);
};
Gwindow.XMLHttpRequest.prototype.send = function (data) {
if (overideToken) {
var b = new URLSearchParams(data);
if (b.has("token")) {
b.set("token", overideToken);
data = b.toString();
}
}
if (this.isGetRoomAddress) {
currentroomaddress = parseInt(data.slice(3));
this.onreadystatechange = function () {
if (this.readyState == 4) {
var jsonargs = JSON.parse(this.response);
var jsonargs2 = JSON.stringify(jsonargs);
function stringifyjsonargs() {
return jsonargs2;
}
this.__defineGetter__("responseText", stringifyjsonargs);
this.__defineGetter__("response", stringifyjsonargs);
}
}
}
else if (this.isGetRooms) {
this.onreadystatechange = function () {
if (this.readyState == 4) {
lastrooms = JSON.parse(this.response)["rooms"];
var jsonargs = JSON.parse(this.response);
jsonargs.rooms = jsonargs.rooms.filter(function (e) {
return !ghostRooms[e.id];
})
if (lastrooms) {
var keys = Object.keys(savedroomsdata);
for (var i = 0; i < lastrooms.length; i++) {
if (savedrooms.includes(lastrooms[i].id)) {
exists = true;
savedroomsdata[lastrooms[i].id] = lastrooms[i];
savedroomsdata[lastrooms[i].id].exists = true;
savedroomsdata[lastrooms[i].id].exists2 = true;
if (lastrooms[i].maxplayers > lastrooms[i].players) {
if (1 == 1) {
if (lastrooms[i].id != currentroomaddress) {
SHOW_MESSAGE('The room ' + JSON.stringify(lastrooms[i].roomname) + ' is now open with ' + lastrooms[i].players + "/" + lastrooms[i].maxplayers + " players.", "#DA0808", "#1EBCC1");
savedrooms.splice(savedrooms.indexOf(lastrooms[i].id), 1);
delete savedroomsdata[lastrooms[i].id];
keys.splice(keys.indexOf((lastrooms[i].id).toString()), 1);
}
else {
savedrooms.splice(savedrooms.indexOf(lastrooms[i].id), 1);
delete savedroomsdata[lastrooms[i].id];
keys.splice(keys.indexOf((lastrooms[i].id).toString()), 1);
}
}
}
}
}
for (var i = 0; i < keys.length; i++) {
if (!savedroomsdata[keys[i]].exists2) {
savedroomsdata[keys[i]].exists = false;
}
savedroomsdata[keys[i]].exists2 = false;
}
for (var i = 0; i < keys.length; i++) {
if (!savedroomsdata[keys[i]].exists) {
savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])), 1);
SHOW_MESSAGE('The room ' + JSON.stringify(savedroomsdata[keys[i]].roomname) + " does not exist anymore.", "#DA0808", "#1EBCC1");
delete savedroomsdata[keys[i]];
}
}
}
var jsonargs2 = JSON.stringify(jsonargs);
function stringifyjsonargs() {
return jsonargs2;
}
this.__defineGetter__("responseText", stringifyjsonargs);
this.__defineGetter__("response", stringifyjsonargs);
}
}
}
else if (this.isSearchMap) {
this.onreadystatechange = function () {
if (this.readyState == 4) {
var jsonargs = { r: "success", maps: [], more: true };
if (this.isSearchMap2 == 1) {
for (var i = 0; i < requestedmaps.length; i++) {
var dec = requestedmaps[i][0];
var undec = requestedmaps[i][1];
var map = {};
map.id = dec["m"]["dbid"];
map.name = dec["m"]["n"];
map.authorname = dec["m"]["a"];
map.leveldata = undec;
map.publisheddate = dec["m"]["date"];
map.remixauthor = dec["m"]["rxa"];
map.remixdb = dec["m"]["rxdb"];
map.remixid = dec["m"]["rxid"];
map.remixname = dec["m"]["rxn"];
map.vd = dec["m"]["vd"];
map.vu = dec["m"]["vu"];
jsonargs.maps.push(map);
}
}
if (this.isSearchMap2 == 2) {
currentmap.reverse();
for (var i = 0; i < currentmap.length; i++) {
try {
var dec = currentmap[i];
var undec = encodeToDatabase(currentmap[i]);
var map = {};
map.id = dec["m"]["dbid"];
map.name = dec["m"]["n"];
map.authorname = dec["m"]["a"];
map.leveldata = undec;
map.publisheddate = dec["m"]["date"];
map.remixauthor = dec["m"]["rxa"];
map.remixdb = dec["m"]["rxdb"];
map.remixid = dec["m"]["rxid"];
map.remixname = dec["m"]["rxn"];
map.vd = dec["m"]["vd"];
map.vu = dec["m"]["vu"];
jsonargs.maps.push(map);
} catch (e) { }
}
currentmap.reverse();
}
if (this.isSearchMap2 == 3) {
var plarr = playlists[openPlaylistName] || [];
for (var i = 0; i < plarr.length; i++) {
try {
var undec = plarr[i];
var dec = decodeFromDatabase(undec);
var map = {};
map.id = dec["m"]["dbid"];
map.name = dec["m"]["n"];
map.authorname = dec["m"]["a"];
map.leveldata = undec;
map.publisheddate = dec["m"]["date"];
map.remixauthor = dec["m"]["rxa"];
map.remixdb = dec["m"]["rxdb"];
map.remixid = dec["m"]["rxid"];
map.remixname = dec["m"]["rxn"];
map.vd = dec["m"]["vd"];
map.vu = dec["m"]["vu"];
jsonargs.maps.push(map);
} catch (e) { }
}
}
jsonargs2 = JSON.stringify(jsonargs);
function stringifyjsonargs() {
return jsonargs2;
}
this.__defineGetter__("responseText", stringifyjsonargs);
this.__defineGetter__("response", stringifyjsonargs);
}
}
}
else if (this.saveAvatar) {
if (overideSkin != 0) {
var jsondata = typeof (overideSkin) == "string" ? JSON.parse(overideSkin) : overideSkin;
var skin_str = avatarToString(jsondata);
var regex = data.match(/newavatar=.*/);
if (regex) {
data = data.substring(0, regex.index + 10) + skin_str;
}
else {
var ogdata = data;
data = data + "&newavatar=" + skin_str;
data = data.replace("newactive", "newavatarslot");
data = data.replace("updateslot", "updateavatar");
var xml = new Gwindow.XMLHttpRequest();
originalXMLOpen.call(xml, "POST", this.responseURL);
originalXMLSend.call(xml, ogdata);
}
}
}
else if (this.replay_get) {
this.onreadystatechange = function () {
if (this.readyState == 4) {
var jsonargs = JSON.parse(this.responseText);
for (var i = 0; i < jsonargs.replays.length; i++) {
var rp = decodeIS(jsonargs.replays[i].replaydata);
var rpd = Gwindow.dcodeIO.ByteBuffer.fromBase64(rp.inputs);
var rpd2 = rpd.clone().reset();
var amount = rpd.readUint16();
rpd2.writeUint16(amount);
for (var j = 0; j < amount; j++) {
var x = rpd.readUint16();
rpd2.writeUint16(x);
var y = rpd.readUint32();
rpd2.writeUint32(y);
var z = rpd.readByte();
rpd2.writeByte(z);
}
rp.inputs = rpd2.toBase64(0);
jsonargs.replays[i].replaydata = encodeIS(rp);
}
jsonargs2 = JSON.stringify(jsonargs);
function stringifyjsonargs() {
return jsonargs2;
}
this.__defineGetter__("responseText", stringifyjsonargs);
this.__defineGetter__("response", stringifyjsonargs);
}
}
}
originalXMLSend.call(this, ...arguments);
};
scope.STB = function (x) {
if (x == "0") {
return 0;
}
else {
return 1;
}
};
scope.BTS = function (x) {
if (x == 0) {
return "0";
}
else {
return "1";
}
};
scope.makePlayer = function (base) {
return Object.assign({
movecount: 0,
bal: 0,
commands: false,
ratelimit: { pm: 0, mode: 0, team: 0, poll: 0, join: Date.now(), style: 0 },
vote: { poll: -1 }
}, base);
};
scope.balanceToRadius = function (bal) {
var d = (bal || 0) / 100;
if (d < -0.95) { d = -0.95; }
if (d > 1) { d = 1; }
return 1 + d;
};
scope.playerRadiusMeters = function (id) {
return balanceToRadius(playerids[id] ? playerids[id].bal : 0);
};
scope.setBalance = function (id, bal) {
if (playerids[id]) { playerids[id].bal = bal; }
if (playerids[id] && playerids[id].playerData2) { playerids[id].playerData2.balance = bal; }
};
scope.applyBalArray = function (bal) {
if (!Array.isArray(bal)) { return; }
for (var i = 0; i < bal.length; i++) {
if (playerids[i] && typeof bal[i] == "number") { setBalance(i, bal[i]); }
}
};
scope.pixelsPerMeter = function () {
var me = playerids[myid];
if (me && me.playerData2 && me.playerData2.radius) {
return me.playerData2.radius / playerRadiusMeters(myid);
}
return scale * (currentIS?.physics?.ppm ?? 7);
};
scope.ARROW_CHARGE_TIME = 10 / 3;
scope.arrowSpeed = function (chargeMs) {
var ds = chargeMs > 0 ? Math.min(chargeMs / 1000 / ARROW_CHARGE_TIME, 1) * 100 : 100;
var v = 15 + ds;
return v > 60 ? 60 : v;
};
scope.arrowHolderIndex = function (playerData) {
if (!playerData || !playerData.children) { return -1; }
for (var i = 0; i < playerData.children.length; i++) {
if (playerData.children[i].constructor.name == "e") { return i; }
}
return -1;
};
scope.GETPLAYERBYUSER = function (x) {
for (var i in playerids) {
if (playerids[i].userName == x) {
return playerids[i];
}
}
return -1;
}
scope.GETIDBYUSER = function (x) {
for (var i in playerids) {
if (playerids[i].userName == x) {
return i;
}
}
return -1;
}
scope.resolveUserId = function (query) {
if (query == null) { return -1; }
var q = String(query).trim().toLowerCase();
if (q === "") { return -1; }
var ids = Object.keys(playerids);
var byLen = function (a, b) { return playerids[a].userName.length - playerids[b].userName.length; };
for (var i = 0; i < ids.length; i++) {
if (playerids[ids[i]].userName.toLowerCase() === q) { return ids[i]; }
}
var pref = ids.filter(function (id) { return playerids[id].userName.toLowerCase().startsWith(q); });
if (pref.length) { pref.sort(byLen); return pref[0]; }
var sub = ids.filter(function (id) { return playerids[id].userName.toLowerCase().indexOf(q) !== -1; });
if (sub.length) { sub.sort(byLen); return sub[0]; }
var best = -1, bestD = Infinity;
for (var j = 0; j < ids.length; j++) {
var d = stringdistance(q, playerids[ids[j]].userName.toLowerCase());
if (d < bestD) { bestD = d; best = ids[j]; }
}
if (best !== -1 && bestD <= Math.max(2, Math.floor(q.length / 2))) { return best; }
return -1;
};
scope.resolveUserName = function (query) {
var id = resolveUserId(query);
return id === -1 ? "" : playerids[id].userName;
};
scope.GET_KEYS = function (x) {
var x2 = ((x + 64) >>> 0).toString(2).substring(1).split("");
return { "left": STB(x2[5]), "right": STB(x2[4]), "up": STB(x2[3]), "down": STB(x2[2]), "heavy": STB(x2[1]), "special": STB(x2[0]) }
};
scope.MAKE_KEYS = function (x) {
return x.special * 32 + x.heavy * 16 + x.down * 8 + x.up * 4 + x.right * 2 + x.left
};
Gwindow.PIXI.Graphics.prototype.drawCircle = function (...args) {
var This = this;
var Args = [...args];
setTimeout(function () {
if (This.parent) {
var childs = This.parent.children;
var user = 0;
for (var i = 0; i < childs.length; i++) {
if (childs[i]._text) {
user = childs[i]._text;
}
if (i == 2 && childs[i] != This) {
return;
}
}
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == user) {
playerids[keys[i]].playerData = This.parent;
if (!playerids[keys[i]].playerData2) {
playerids[keys[i]].playerData2 = { alive: true, radius: 12, timeStamp: 0, timeStamp2: 0, px: 0, py: 0, pvx: 0, pvy: 0, xacc: 0, yacc: 0, axs: 0, ays: 0, xvel: 0, yvel: 0, avel: 0, pa: 0, balance: 0 };
}
playerids[keys[i]].playerData2.radius = Args[2];
parentDraw = This.parent;
while (parentDraw.parent) {
parentDraw = parentDraw.parent;
}
}
}
}
}, 0);
return originalDrawCircle.call(this, ...args);
};
scope.applyPlayerStyles = function (keys) {
for (var i = 0; i < keys.length; i++) {
if (allstyles[playerids[keys[i]].userName]) {
var isadmin = [false, 0];
for (var i3 = 0; i3 < admins.length; i3++) {
if (admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]) {
isadmin = [true, i3];
break;
}
}
if (playerids[keys[i]].playerData?.children) {
for (var i2 = 0; i2 < playerids[keys[i]].playerData.children.length; i2++) {
if (playerids[keys[i]].playerData.children[i2].text) {
if (allstyles[playerids[keys[i]].userName][0] == 0 && allstyles[playerids[keys[i]].userName][1] == 0 && allstyles[playerids[keys[i]].userName][2] == 0) {
playerids[keys[i]].playerData.children[i2].tint = 255 * 256 ** 3 - 1;
}
else {
playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0] * 256 ** 2 + allstyles[playerids[keys[i]].userName][1] * 256 + allstyles[playerids[keys[i]].userName][2];
}
}
}
}
if (isadmin[1] <= 2) {
if (isadmin[0]) {
if (playerids[keys[i]].playerData?.children && playerids[keys[i]].guest == false) {
for (var i2 = 0; i2 < playerids[keys[i]].playerData.children.length; i2++) {
if (playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0] == 0 && allstyles[playerids[keys[i]].userName][1] == 0 && allstyles[playerids[keys[i]].userName][2] == 0)) {
playerids[keys[i]].playerData.children[i2].tint = (75 + Math.abs(180 - admins[isadmin[1]][1][0])) * 256 ** 2 + (75 + Math.abs(180 - admins[isadmin[1]][1][1])) * 256 + 75 + Math.abs(180 - admins[isadmin[1]][1][2]);
}
if (!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)) {
playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
}
var rotatevalue = 0;
if (admins[isadmin[1]][1][3] < 90) {
rotatevalue = admins[isadmin[1]][1][3] / 2;
}
else if (admins[isadmin[1]][1][3] < 270) {
rotatevalue = (180 - admins[isadmin[1]][1][3]) / 2;
}
else if (admins[isadmin[1]][1][3] < 360) {
rotatevalue = (-360 + admins[isadmin[1]][1][3]) / 2;
}
playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
}
}
}
}
}
}
};
scope.applyPan = function () {
if (pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount > 0 && (keys_being_held["ShiftLeft"] || keys_being_held["ShiftRight"])) {
var temp_zoom = zoom;
if (keys_being_held["ArrowUp"]) {
pan.y += pan_speed / temp_zoom;
}
if (keys_being_held["ArrowDown"]) {
pan.y -= pan_speed / temp_zoom;
}
if (keys_being_held["ArrowRight"]) {
pan.x -= pan_speed / temp_zoom;
}
if (keys_being_held["ArrowLeft"]) {
pan.x += pan_speed / temp_zoom;
}
}
};
scope.computeAutocamZoom = function (keys) {
if (autocam) {
var autocamx = 365 * scale;
var autocamy = 250 * scale;
var camId = (playerids[followTarget] && playerids[followTarget].playerData) ? followTarget : myid;
if (FollowCam && playerids[camId] && playerids[camId].playerData?.transform) {
autocamx = playerids[camId].playerData.transform.position.x;
autocamy = playerids[camId].playerData.transform.position.y;
}
var distances = {};
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].playerData && playerids[keys[i]].playerData2) {
if (playerids[keys[i]].playerData.transform) {
var ypos = playerids[keys[i]].playerData.transform.position.y;
if (ypos > 460 * scale && ypos < 500 * scale) {
ypos = scale * 460;
}
distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x - autocamx, ypos - autocamy];
}
}
}
distances["topleft"] = [autocamx - 40, autocamy - 40];
distances["topright"] = [690 * scale - autocamx, autocamy - 40];
distances["bottomleft"] = [autocamx - 40, 460 * scale - autocamy];
distances["bottomright"] = [690 * scale - autocamx, 460 * scale - autocamy];
var lowestD = [-1, -1];
var keys2 = Object.keys(distances);
for (var i = 0; i < keys2.length; i++) {
if (Math.abs(distances[keys2[i]][0] / scale) > lowestD[0]) {
lowestD[0] = Math.abs(distances[keys2[i]][0] / scale);
}
if (Math.abs(distances[keys2[i]][1] / scale) > lowestD[1]) {
lowestD[1] = Math.abs(distances[keys2[i]][1] / scale);
}
}
var horizontal = (lowestD[0]) / 345;
var vertical = (lowestD[1]) / 230;
return Math.min(Math.abs(1 / Math.max(horizontal, vertical)), 1);
}
return 1;
};
scope.runBots = function (keys, now) {
if (aimbot || heavybot || staystill) {
var targetid = -1;
var distances = {};
if (Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden") {
if (playerids[myid].playerData.transform) {
var teamok = true;
if (playerids[myid].team > 1) {
teamok = false;
}
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i] != myid) {
if (playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)) {
distances[keys[i]] = Math.sqrt((playerids[keys[i]].playerData.transform.position.x - playerids[myid].playerData.transform.position.x) ** 2 + (playerids[keys[i]].playerData.transform.position.y - playerids[myid].playerData.transform.position.y) ** 2);
}
}
}
}
}
var lowestD = [-1, -1];
var keys2 = Object.keys(distances);
for (var i = 0; i < keys2.length; i++) {
if (myid != keys2[i]) {
if (lowestD[1] == -1) {
lowestD[1] = distances[keys2[i]];
lowestD[0] = keys2[i];
}
else if (distances[keys2[i]] < lowestD[1]) {
lowestD[1] = distances[keys2[i]];
lowestD[0] = keys2[i];
}
}
}
targetid = lowestD[0];
if (playerids[myid].playerData?.transform && playerids[myid].playerData2) {
if (staystill & staystillpos[0] != null) {
var playerpos = playerids[myid].playerData.transform.position;
if (Math.abs(staystillpos[0] - playerpos.x / scale) < 3) {
if (playerids[myid].playerData2.xvel / scale > 0) {
pressKey(leftRight[0]);
releaseKey(leftRight[1]);
}
else if (playerids[myid].playerData2.xvel / scale < 0) {
releaseKey(leftRight[0]);
pressKey(leftRight[1]);
}
else {
releaseKey(leftRight[0]);
releaseKey(leftRight[1]);
}
}
else {
if (staystillpos[0] > playerpos.x / scale) {
if (playerids[myid].playerData2.xvel / scale > 10) {
pressKey(leftRight[0]);
releaseKey(leftRight[1]);
}
else {
releaseKey(leftRight[0]);
pressKey(leftRight[1]);
}
}
else if (staystillpos[0] < playerpos.x / scale) {
if (playerids[myid].playerData2.xvel / scale < -10) {
releaseKey(leftRight[0]);
pressKey(leftRight[1]);
}
else {
pressKey(leftRight[0]);
releaseKey(leftRight[1]);
}
}
}
}
}
if (targetid != -1 && playerids[myid].playerData?.transform) {
if (playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot) {
var indexE = -1;
for (var i = 0; i < playerids[myid].playerData.children.length; i++) {
if (playerids[myid].playerData.children[i].constructor.name == "e") {
indexE = i;
break;
}
}
if (indexE != -1 && playerids[myid].playerData.children[indexE].visible) {
if (started == 0) {
started = now;
}
var v = arrowSpeed(now - started);
var g = gravity;
var mypos = playerids[myid].playerData.transform.position;
var targetpos = playerids[targetid].playerData.transform.position;
var rot = positive(playerids[myid].playerData.children[indexE].transform.rotation);
var k = 1 / pixelsPerMeter();
var rx = (targetpos.x - mypos.x) * k;
var ry = -(targetpos.y - mypos.y) * k;
var tvx = playerids[targetid].playerData2.xvel * 1000 * k;
var tvy = -playerids[targetid].playerData2.yvel * 1000 * k;
var tax = playerids[targetid].playerData2.axs * 1000 * k;
var tay = -playerids[targetid].playerData2.ays * 1000 * k;
function arrowMiss(theta) {
var dt = 1 / 30;
var px = Math.cos(theta), py = Math.sin(theta);
var vx = v * Math.cos(theta), vy = v * Math.sin(theta);
var best = Infinity;
for (var i = 0; i < 150; i++) {
var t = i * dt;
var qx = rx + tvx * t + 0.5 * tax * t * t;
var qy = ry + tvy * t + 0.5 * tay * t * t
var dx = px - qx, dy = py - qy, d = dx * dx + dy * dy;
if (d < best) best = d;
vy -= g * dt;
var sp = Math.sqrt(vx * vx + vy * vy);
if (sp > 60) { var r = 60 / sp; vx *= r; vy *= r; }
px += vx * dt; py += vy * dt;
}
return best;
}
var v2 = v * v;
var seed = Math.atan2(ry, rx);
var t = Math.hypot(rx, ry) / v;
for (var it = 0; it < 5; it++) {
var alpha = rx + tvx * t + 0.5 * tax * t * t;
var beta = ry + tvy * t + 0.5 * tay * t * t;
var D = v2 * v2 - g * (g * alpha * alpha + 2 * beta * v2);
if (D < 0) break;
var s = Math.sqrt(D);
seed = Math.atan2(v2 - s, g * alpha);
var vx0 = v * Math.cos(seed);
if (Math.abs(vx0) < 1e-6) break;
var tNew = alpha / vx0;
if (tNew <= 0 || !isFinite(tNew)) break;
if (Math.abs(tNew - t) < 1e-4) break;
t = tNew;
}
var bestTheta = seed, bestMiss = arrowMiss(seed);
function scan(center, half, n) {
for (var j = -n; j <= n; j++) {
var cand = center + (j / n) * half;
var m = arrowMiss(cand);
if (m < bestMiss) { bestMiss = m; bestTheta = cand; }
}
}
scan(seed, 0.50, 15);
scan(bestTheta, 0.05, 10);
var angle = positive(-bestTheta);
var min = angle_between(angle, rot);
if (angle_between2(angle, rot) < 0) {
pressKey(leftRight[0]);
releaseKey(leftRight[1]);
} else {
releaseKey(leftRight[0]);
pressKey(leftRight[1]);
}
if (min < 0.05) {
releaseKey(leftRight[0]);
releaseKey(leftRight[1]);
}
}
else if (started > 0) {
started = 0;
releaseKey(leftRight[0]);
releaseKey(leftRight[1]);
}
}
}
if (playerids[myid].playerData?.transform && heavybot && mode != "f" && mode != "bs") {
var myradius = playerids[myid].playerData2.radius / scale;
var mypos = playerids[myid].playerData.transform.position;
var breakout = false;
for (var i = 0; i < keys2.length; i++) {
var targetradius = playerids[keys2[i]].playerData2.radius / scale;
var targetpos = playerids[keys2[i]].playerData.transform.position;
var deltapos = [(targetpos.x - mypos.x) / scale, (targetpos.y - mypos.y) / scale];
for (var i2 = 0; i2 < 200; i2++) {
deltapos2 = [...deltapos];
var i3 = i2 * 0.5;
deltapos2[0] += ((playerids[keys2[i]].playerData2.xvel - playerids[myid].playerData2.xvel) / scale * i3);
deltapos2[1] += ((playerids[keys2[i]].playerData2.yvel - playerids[myid].playerData2.yvel) / scale * i3);
var dis = Math.sqrt(deltapos2[0] ** 2 + deltapos2[1] ** 2);
if (dis < myradius + targetradius) {
breakout = true;
holdheavy = 20;
break;
}
}
if (breakout) {
break;
}
}
if (holdheavy > 0) {
if (!heavyheld2) {
heavyheld = playerids[myid].playerData.children[heavyid].alpha > 0;
}
pressKey(heavy);
heavyheld2 = true;
if (mode == "sp") {
if (!grappleheld2) {
grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length > 0;
}
if (grappleheld) {
releaseKey(special);
}
grappleheld2 = true;
}
}
else if (holdheavy < 0) {
holdheavy = 0;
heavyheld2 = false;
grappleheld2 = false;
if (!heavyheld) {
heavyheld = false;
releaseKey(heavy);
}
if (grappleheld && mode == "sp") {
grappleheld = false;
pressKey(special);
}
}
else {
heavyheld2 = false;
heavyheld = false;
grappleheld2 = false;
grappleheld = false;
}
}
}
};
scope.drawTrajectory = function () {
if (!trajLine) { return; }
trajLine.clear();
if (!trajectory || (mode != "ar" && mode != "ard")) { trajChargeStart = 0; return; }
var me = playerids[myid];
if (!me || !me.playerData || !me.playerData.transform || !me.playerData2) { trajChargeStart = 0; return; }
var indexE = arrowHolderIndex(me.playerData);
if (indexE == -1 || !me.playerData.children[indexE].visible) { trajChargeStart = 0; return; }
var now = Date.now();
if (trajChargeStart == 0) { trajChargeStart = now; }
var v = arrowSpeed(now - trajChargeStart);
var g = gravity;
var ppmPix = pixelsPerMeter();
var mypos = me.playerData.transform.position;
var theta = -positive(me.playerData.children[indexE].transform.rotation);
var cos = Math.cos(theta), sin = Math.sin(theta);
var dt = 1 / 30;
var N = trajSteps;
var apx = new Array(N), apy = new Array(N);
var px = cos, py = sin;
var vx = v * cos, vy = v * sin;
for (var i = 0; i < N; i++) {
apx[i] = px; apy[i] = py;
vy -= g * dt;
var sp = Math.sqrt(vx * vx + vy * vy);
if (sp > 60) { var rr = 60 / sp; vx *= rr; vy *= rr; }
px += vx * dt; py += vy * dt;
}
function toX(m) { return mypos.x + m * ppmPix; }
function toY(m) { return mypos.y - m * ppmPix; }
trajLine.lineStyle(trajWidth, trajColor, trajOpacity);
trajLine.moveTo(toX(apx[0]), toY(apy[0]));
for (var s = 1; s < N; s++) { trajLine.lineTo(toX(apx[s]), toY(apy[s])); }
if (trajIntercepts) {
var k = 1 / ppmPix;
for (var id in playerids) {
if (id == myid) { continue; }
var p = playerids[id];
if (!p.playerData || !p.playerData.transform || !p.playerData2) { continue; }
var tp = p.playerData.transform.position;
var rx = (tp.x - mypos.x) * k, ry = -(tp.y - mypos.y) * k;
var tvx = p.playerData2.xvel * 1000 * k, tvy = -p.playerData2.yvel * 1000 * k;
var tax = p.playerData2.axs * 1000 * k, tay = -p.playerData2.ays * 1000 * k;
var bestD = Infinity, bqx = rx, bqy = ry;
for (var j = 0; j < N; j++) {
var t = j * dt;
var qx = rx + tvx * t + 0.5 * tax * t * t;
var qy = ry + tvy * t + 0.5 * tay * t * t;
var dx = apx[j] - qx, dy = apy[j] - qy, d = dx * dx + dy * dy;
if (d < bestD) { bestD = d; bqx = qx; bqy = qy; }
}
trajLine.lineStyle(2, trajMarkerColor, 0.9);
trajLine.drawCircle(toX(bqx), toY(bqy), p.playerData2.radius);
}
}
};
Gwindow.requestAnimationFrame = function (...args) {
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
while (parentDraw.parent) {
parentDraw = parentDraw.parent;
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
scale = (parseInt(canv.style["width"]) / 730);
var now = Date.now();
var keys = Object.keys(playerids);
addto = { "children": [] };
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
applyPan();
var panx = 0;
var pany = 0;
if (pan) {
panx = pan.x;
pany = pan.y;
}
newzoom = computeAutocamZoom(keys);
newzoom2 = newzoom2 + 0.15 * (newzoom - newzoom2);
zoom2 = zoom2 + 0.15 * (zoom - zoom2);
addto.scale.x = newzoom2 * zoom2;
addto.scale.y = newzoom2 * zoom2;
if (holdheavy > 0) {
if (holdheavy == 1) {
holdheavy = -1;
}
else {
holdheavy -= 1;
}
}
if (playerids[myid].playerData?.children) {
for (var i = 0; i < playerids[myid].playerData.children.length; i++) {
if (playerids[myid].playerData.children[i].alpha != 1) {
heavyid = i;
}
if (playerids[myid].playerData.children[i].vertexData) {
if (playerids[myid].playerData.children[i].vertexData.length == 0) {
specialid = i;
}
}
}
}
applyPlayerStyles(keys);
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (canvasWidth != width) {
canvasWidth = width;
pixiCircle.clear();
pixiCircle.x = parseInt(canv.style["width"]) / 2;
pixiCircle.y = parseInt(canv.style["height"]) / 2;
pixiCircle.lineStyle(3, 0x8B8000);
pixiCircle.drawRect(-parseInt(canv.style["width"]) / 2, -parseInt(canv.style["height"]) / 2, parseInt(canv.style["width"]), parseInt(canv.style["height"]));
pixiCircle.lineStyle(3, 0xFF0000);
pixiCircle.arc(0, 0, 850 * scale, Math.atan2(250, -100 * Math.sqrt(66)), Math.atan2(250, 100 * Math.sqrt(66)));
pixiCircle.lineTo(-100 * Math.sqrt(66) * scale, 250 * scale);
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
}
if (!addto.children.includes(container)) {
addto.addChild(container);
}
drawTrajectory();
if (keys.length > 0) {
if (playerids[myid].playerData && playerids[myid].playerData2) {
runBots(keys, now);
}
}
if (FollowCam) {
var ftId = (playerids[followTarget] && playerids[followTarget].playerData) ? followTarget : myid;
var ftp = playerids[ftId] ? playerids[ftId].playerData : null;
if (ftp?.transform) {
pixiCircle.visible = true;
parentDraw.x = -ftp.x * addto.scale.x + parseInt(width) / 2;
parentDraw.y = -ftp.y * addto.scale.y + parseInt(height) / 2;
parentDraw.children[0].x = ftp.x * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = ftp.y * addto.scale.y - parseInt(height) / 2;
}
else {
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
}
}
if (!FollowCam) {
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999 && !pan_enabled) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
}
parentDraw.x += panx * scale * addto.scale.x;
parentDraw.y += pany * scale * addto.scale.y;
parentDraw.children[0].x -= panx * scale * addto.scale.x;
parentDraw.children[0].y -= pany * scale * addto.scale.y;
}
if (maxfps) {
return setTimeout(...args);
}
return requestAnimationFrameOriginal.call(this, ...args);
};
scope.SENDFUNCTION = function (args) { return args; };
scope.RECIEVEFUNCTION = function (args) { return args; };
scope.EVENTLOOPFUNCTION = function () { };
Gwindow.WebSocket.prototype.send = function (args) {
if (this.url.includes("socket.io/?EIO=3&transport=websocket&sid=")) {
if (typeof (args) == "string" && !bonkwssextra.includes(this)) {
args = SENDFUNCTION(args);
wsssendlog.push(args);
wsssendrecievelog.push([0, args, Date.now()]);
if (!bonkwss) {
bonkwss = this;
}
if (args.startsWith('42[26,')) {
var jsonargs = JSON.parse(args.substring(2));
if (sandboxon) {
if (typeof (sandboxplayerids[jsonargs[1]["targetID"]]) != 'undefined') {
var packet = '42[18,' + jsonargs[1]["targetID"] + ',' + jsonargs[1]["targetTeam"] + ']';
RECIEVE(packet);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet], to: [-1] }]));
}
}
}
if (args.startsWith('42[9,')) {
var jsonargs = JSON.parse(args.substring(2));
if (sandboxon) {
if (typeof (sandboxplayerids[jsonargs[1]["banshortid"]]) != 'undefined') {
if (Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden") {
var packet = '42[24,' + jsonargs[1]["banshortid"].toString() + ',' + jsonargs[1]["kickonly"] + ']';
var packet2 = '42[5,' + jsonargs[1]["banshortid"].toString() + ',0]';
RECIEVE(packet);
RECIEVE(packet2);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet, packet2], to: [-1] }]));
}
else {
notify("Cannot delete players while ingame.");
}
}
}
}
if (args.startsWith('42[1,')) {
return;
}
if (args.startsWith('42[4,')) {
var jsonargs = JSON.parse(args.substring(2));
if (sandboxcopyme == myid && typeof (jsonargs[1]["i"]) != "undefined") {
var jsonkeys = Object.keys(sandboxplayerids);
var jsonargs2 = jsonargs[1];
for (var i = 0; i < jsonkeys.length; i++) {
jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
var packet = '42[7,' + jsonkeys[i].toString() + ',' + JSON.stringify(jsonargs2) + ']';
RECIEVE(packet);
}
jsonargs2["c"] = "CVALUE";
jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"', "CVALUE");
SEND("42" + JSON.stringify([4, { "type": "customfakerecieve", "from": username, "packet": ['42[7,ID,' + jsonargs2 + ']'], to: [-1] }]));
}
if (typeof (jsonargs[1]["i"]) != "undefined") {
if (playerids[myid].movecount >= jsonargs[1]["c"]) {
jsonargs[1]["c"] = playerids[myid].movecount;
playerids[myid].movecount += 1;
}
else {
playerids[myid].movecount = parseInt(jsonargs[1]["c"]) + 1;
}
}
if (recording && typeof (jsonargs[1]["i"]) != "undefined") {
if (myid.toString() == recordingid) {
if (recordingdata.length == 0) {
recordingdata.push([jsonargs[1]["i"], jsonargs[1]["f"]]);
}
else {
recordingdata.push([jsonargs[1]["i"], jsonargs[1]["f"] - recordingdata[0][1]]);
}
}
}
playerids[myid].lastmove = Date.now();
if (ishost && typeof (jsonargs[1]["i"]) != "undefined") {
for (var i = 0; i < disabledkeys.length; i++) {
if (GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]) {
if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && !killedids.includes(myid)) {
killedids.push(myid);
currentFrame = Math.floor((Date.now() - gameStartTimeStamp) / 1000 * 30);
SEND('42[25,{"a":{"playersLeft":[' + myid.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
RECIEVE('42[31,{"a":{"playersLeft":[' + myid.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
break;
}
}
}
}
args = "42" + JSON.stringify(jsonargs);
}
if (args.startsWith('42[29,')) {
var jsonargs = JSON.parse(args.substring(2));
setBalance(jsonargs[1]["sid"], jsonargs[1]["bal"]);
if (sandboxon) {
if (typeof (sandboxplayerids[jsonargs[1]["sid"]]) != 'undefined') {
var packet = '42[36,' + jsonargs[1]["sid"] + ',' + jsonargs[1]["bal"] + ']';
RECIEVE(packet);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet], to: [-1] }]));
}
}
}
if (args.startsWith('42[11,')) {
var jsonargs = JSON.parse(args.substring(2));
var id = jsonargs[1].sid;
if (playerids[id]) {
if (crashbanned.includes(playerids[id].userName)) {
SEND('42' + JSON.stringify([9, { "banshortid": id, "kickonly": true }]));
notify("Crashbanned " + playerids[id].userName + ".");
}
}
args = '42' + JSON.stringify(jsonargs);
}
if (args.startsWith('42[40,')) {
var jsonargs = JSON.parse(args.substring(2));
var id = jsonargs[1].sid;
if (playerids[id]) {
if (crashbanned.includes(playerids[id].userName)) {
var allData = jsonargs[1].allData;
var state = decodeIS(allData.state);
allData.state = encodeIS(state);
allData.stateID = allData.fc - 9999999999;
notify("Crashbanned " + playerids[id].userName + ".");
}
}
args = '42' + JSON.stringify(jsonargs);
}
if (args.startsWith('42[12,')) {
playerids = {};
var jsonargs2 = JSON.parse(args.substring(2));
var jsonargs = jsonargs2[1];
if (createqproominput.value != "custom") {
jsonargs["quick"] = true;
jsonargs["mode"] = createqproominput.value;
}
playerids["0"] = makePlayer({ "peerID": jsonargs["peerID"], "userName": username, "level": Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)), "guest": typeof (jsonargs.token) == "undefined", "team": 1, "avatar": jsonargs["avatar"], "commands": true });
allstyles[username] = [0, 0, 0];
myid = 0;
bonkwss = this;
hostid = 0;
inroom = true;
if (savedrooms.length > 0) {
Gdocument.getElementById("roomlistrefreshbutton").click();
}
if (overideSkin) {
jsonargs.avatar = typeof (overideSkin) == "string" ? JSON.parse(overideSkin) : overideSkin;
}
args = "42" + JSON.stringify(jsonargs2);
}
if (args.startsWith('42[13,')) {
var jsonargs2 = JSON.parse(args.substring(2));
var jsonargs = jsonargs2[1];
if (overideSkin) {
jsonargs.avatar = typeof (overideSkin) == "string" ? JSON.parse(overideSkin) : overideSkin;
}
args = "42" + JSON.stringify(jsonargs2);
}
if (args.startsWith('42[10,')) {
var jsonargs = JSON.parse(args.substring(2));
if (!jsonargs[2]) { recordChat(jsonargs[1]["message"]); }
if (jsonargs[2]) {
args = "42" + JSON.stringify([10, jsonargs[1]]);
}
else if (translating2[0]) {
text = translate(jsonargs[1]["message"], "auto", translating2[1]).then(function (r) { SEND("42" + JSON.stringify([10, { "message": r }, true])) });
return;
}
}
if (args.startsWith('42[23,')) {
var jsonargs = JSON.parse(args.substring(2));
var map = decodeFromDatabase(jsonargs[1]["m"]);
currentmap.push(map);
}
if (args.startsWith('42[23,') && recteams) {
var jsonargs = JSON.parse(args.substring(2));
var spawns = map["spawns"];
var teamsneeded = true;
var excludedindexes = [];
var ffaspawns = false;
var ffaforsure = false;
for (var i = 0; i < spawns.length; i++) {
var currentSpawn = spawns[i];
if (Math.sqrt(currentSpawn.x ** 2 + currentSpawn.y ** 2) >= 850 || currentSpawn.y > 250) {
excludedindexes.push(i);
}
else if (!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)) {
excludedindexes.push(i);
}
else if (currentSpawn.f) {
ffaspawns = true;
if (!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)) {
excludedindexes.push(i);
ffaforsure = true
}
}
}
if (!ffaspawns && !ffaforsure) {
teamsneeded = true;
}
else {
teamsneeded = false;
}
if (teamsneeded) {
var newspawns = [];
for (var i = 0; i < spawns.length; i++) {
if (!excludedindexes.includes(i)) {
newspawns.push({ "r": spawns[i]["r"], "g": spawns[i]["gr"], "b": spawns[i]["b"], "y": spawns[i]["ye"], "total": spawns[i]["r"] + spawns[i]["ye"] + spawns[i]["gr"] + spawns[i]["b"], "priority": spawns[i]["priority"] });
}
}
if (newspawns.length > 0) {
var teamletters = ["r", "g", "b", "y"];
var ratios = { "r": 0, "g": 0, "b": 0, "y": 0 };
for (var i = 0; i < newspawns.length; i++) {
for (var i2 = 0; i2 < teamletters.length; i2++) {
var ct = teamletters[i2];
if (newspawns[i]["priority"] != 0) {
ratios[ct] += (newspawns[i][ct]) / newspawns[i]["total"] * newspawns[i]["priority"];
}
}
}
var highest = ["", 0];
for (var i = 0; i < teamletters.length; i++) {
var ct = teamletters[i];
if (ratios[ct] > 0 && highest[1] < ratios[ct]) {
highest = [ct, ratios[ct]];
}
}
if (highest[0] != "") {
for (var i = 0; i < teamletters.length; i++) {
var ct = teamletters[i];
ratios[ct] = ratios[ct] / highest[1];
}
}
var playerids3 = Object.keys(playerids);
var playerids2 = [];
for (var i = 0; i < playerids3.length; i++) {
if (playerids[playerids3[i]].team > 0) {
playerids2.push(playerids3[i]);
}
}
var pi2l = playerids2.length;
var ratios2 = { "r": 0, "r1": 0, "g": 0, "g1": 0, "b": 0, "b1": 0, "y": 0, "y1": 0 };
var items = Object.entries(ratios);
items.sort(function (a, b) { return a[1] - b[1]; });
var items = items.map(function (e) { return e[0]; });
var highest2 = ["", 0];
while (pi2l > 0) {
var done = false;
for (var i2 = 0; i2 < items.length; i2++) {
var ci = items[i2];
var ci2 = items[i2] + "1";
for (var i = 0; i < teamletters.length; i++) {
var ct = teamletters[i];
if (ratios2[ct] > 0 && highest2[1] < ratios2[ct]) {
highest2 = [ct, ratios2[ct]];
}
}
if (highest2[0] != "") {
for (var i = 0; i < teamletters.length; i++) {
var ct = teamletters[i];
ratios2[ct + "1"] = ratios2[ct] / highest2[1];
}
}
if (ratios[ci] > 0 && ratios[ci] >= ratios2[ci2] && pi2l > 0) {
ratios2[ci] += 1;
pi2l--;
done = true;
}
}
if (pi2l > 0 && !done) {
ratios2[highest2[0]] += 1;
pi2l--;
}
}
SEND('42[32,{"t":true}]');
RECIEVE('42[39,true]');
for (var i = 0; i < ratios2["r"]; i++) {
var pid = playerids2.splice(Math.floor(Math.random() * playerids2.length), 1)[0];
SEND('42[26,{"targetID":' + pid + ',"targetTeam":2}]');
if (playerids[pid].peerID != "sandbox") {
RECIEVE('42[18,' + pid + ',2]');
}
}
for (var i = 0; i < ratios2["g"]; i++) {
var pid = playerids2.splice(Math.floor(Math.random() * playerids2.length), 1)[0];
SEND('42[26,{"targetID":' + pid + ',"targetTeam":4}]');
if (playerids[pid].peerID != "sandbox") {
RECIEVE('42[18,' + pid + ',4]');
}
}
for (var i = 0; i < ratios2["b"]; i++) {
var pid = playerids2.splice(Math.floor(Math.random() * playerids2.length), 1)[0];
SEND('42[26,{"targetID":' + pid + ',"targetTeam":3}]');
if (playerids[pid].peerID != "sandbox") {
RECIEVE('42[18,' + pid + ',3]');
}
}
for (var i = 0; i < ratios2["y"]; i++) {
var pid = playerids2.splice(Math.floor(Math.random() * playerids2.length), 1)[0];
SEND('42[26,{"targetID":' + pid + ',"targetTeam":5}]');
if (playerids[pid].peerID != "sandbox") {
RECIEVE('42[18,' + pid + ',5]');
}
}
}
}
else {
SEND('42[32,{"t":false}]');
RECIEVE('42[39,false]');
}
}
if (args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused) {
roundsperqp2++;
if (roundsperqp2 >= roundsperqp) {
quicki = pickNextMap(true);
}
canceled = false;
startedinqp = true;
window.map(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length), 0);
}
if (args.startsWith('42[32,')) {
var jsonargs = JSON.parse(args.substring(2));
var keys = Object.keys(playerids);
if (!jsonargs[1]["t"]) {
FFA = true;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].team != 0) {
playerids[keys[i]].team = 1;
}
}
}
else {
FFA = false;
}
}
if (args.startsWith('42[5,')) {
var jsonargs = JSON.parse(args.substring(2));
if (stopquickplay != 1 && startedinqp) {
startedinqp = false;
jsonargs[1]["gs"]["wl"] = 999;
if (!instaqp) {
var jsonargs2 = decodeIS(jsonargs[1]["is"]);
jsonargs2["ftu"] = 60;
if (jsonargs2["mm"]["rxa"] != "") {
jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
}
jsonargs2 = encodeIS(jsonargs2);
jsonargs[1]["is"] = jsonargs2;
var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
if (jsonargs3["m"]["rxa"] != "") {
jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
}
jsonargs3 = encodeToDatabase(jsonargs3);
jsonargs[1]["gs"]["map"] = jsonargs3;
}
}
args = "42" + JSON.stringify(jsonargs);
}
}
}
else {
}
if (this.url.includes("socket.io/?EIO=3&transport=websocket&sid=") && !this.injected) {
this.injected = true;
var originalRecieve = this.onmessage;
this.onmessage = function (args) {
if (!bonkwssextra.includes(this)) {
if (typeof (args.data) == "string" && args.data.startsWith("42[")) {
args = { "data": args.data };
var args2 = JSON.parse(args.data.substring(2));
args2[0] = parseInt(args2[0]);
args.data = "42" + JSON.stringify(args2);
}
wssrecievelog.push(args.data);
wsssendrecievelog.push([1, args.data, Date.now()]);
if (typeof (args.data) == "string") {
args = { "data": RECIEVEFUNCTION(args.data) };
if (args.data.startsWith('42[1,')) {
var jsonargs = JSON.parse(args.data.substring(2));
originalSend.call(this, '42[1,{"id":' + jsonargs[2] + '}]');
}
if (args.data.startsWith('42[36,')) {
var jsonargs = JSON.parse(args.data.substring(2));
setBalance(jsonargs[1], jsonargs[2]);
}
if (args.data.startsWith('42[24,')) {
beenKickedTimeStamp = Date.now();
var jsonargs = JSON.parse(args.data.substring(2));
onlykicked = jsonargs[2];
if (myid == jsonargs[1]) {
if (onlykicked) {
SHOW_MESSAGE("You were kicked by " + playerids[hostid].userName);
}
else {
SHOW_MESSAGE("You were banned by " + playerids[hostid].userName);
}
}
}
if (args.data.startsWith('42[21,')) {
recievedinitdata = true;
var jsonargs = JSON.parse(args.data.substring(2));
currentmap.push(jsonargs[1]["map"]);
applyBalArray(jsonargs[1]["bal"]);
}
if (args.data.startsWith('42[48,')) {
recievedinitdata = true;
var jsonargs = JSON.parse(args.data.substring(2));
currentmap.push(decodeFromDatabase(jsonargs[1]["gs"]["map"]));
currentIS = decodeIS(jsonargs[1]["state"]);
applyBalArray(jsonargs[1]["bal"] || jsonargs[1]["gs"]["bal"]);
}
if (args.data.startsWith('42[23,')) {
var jsonargs = JSON.parse(args.data.substring(2));
if (causelag) {
jsonargs[1]["result"] -= causelag2;
}
args.data = '42' + JSON.stringify(jsonargs);
}
if (args.data.startsWith('42[16,')) {
var jsonargs = JSON.parse(args.data.substring(2));
var now = Date.now();
if (jsonargs[1] == "chat_rate_limit") {
if (pollactive[1] + 100 > now) {
pollactive = [false, 0, 0, []];
notify("Your poll failed due to chat rate limit.");
notify("Please try again.");
}
}
else if (jsonargs[1] == "room_full") {
if (!savedrooms.includes(currentroomaddress)) {
savedroombutton.className = "brownButton brownButton_classic buttonShadow";
}
}
}
if (args.data.startsWith('42[6,')) {
var jsonargs = JSON.parse(args.data.substring(2));
if (typeof (playerids[jsonargs[1]]) != 'undefined') {
delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
delete playerids[jsonargs[1]];
}
hostid = jsonargs[2];
}
if (args.data.startsWith('42[39,')) {
var jsonargs = JSON.parse(args.data.substring(2));
var keys = Object.keys(playerids);
if (!jsonargs[1]) {
FFA = true;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].team != 0) {
playerids[keys[i]].team = 1;
}
}
}
else {
FFA = false;
}
}
if (args.data.startsWith("42[2")) {
var jsonargs = JSON.parse(args.data.substring(2));
if (createqproominput.value == "bonkquick") {
jsonargs[3] = null;
}
args.data = "42" + JSON.stringify(jsonargs);
}
if (args.data.startsWith('42[41,')) {
var jsonargs = JSON.parse(args.data.substring(2));
hostid = jsonargs[1]["newHost"];
}
if (args.data.startsWith('42[29,')) {
var jsonargs = JSON.parse(args.data.substring(2));
currentmap.push(decodeFromDatabase(jsonargs[1]));
}
if (args.data.startsWith('42[20,')) {
var jsonargs = JSON.parse(args.data.substring(2));
if (translating[0]) {
translate(jsonargs[2], "auto", translating[1]).then(function (r) { if (r == jsonargs[2]) { return } displayInChat(playerids[jsonargs[1]].userName + ": " + r, "#DA0808", "#1EBCC1") });
}
if (echo_list.includes(playerids[jsonargs[1]].userName)) {
chat(flag_manage(echotext.replaceAll("username", playerids[jsonargs[1]].userName).replaceAll("message", jsonargs[2])));
}
if (randomchat) {
var isin = false;
for (var i = 0; i < randomchatpriority[1].length; i++) {
if (randomchatpriority[1][i][0] == jsonargs[2]) {
isin = true;
if (myid != jsonargs[1]) {
randomchatpriority[1][i][1] += 2;
randomchatpriority[0] += 2;
}
break;
}
}
if (!isin) {
randomchatpriority[1].push([jsonargs[2], Math.max(35 - Math.abs(35 - jsonargs[2].length), 1)]);
randomchatpriority[0] += Math.max(35 - Math.abs(35 - jsonargs[2].length), 1);
}
}
if (pollactive[0] || pollactive2[0]) {
var chatmessage = jsonargs[2].toUpperCase().trim().replace(")", "");
var lettersindex = letters.indexOf(chatmessage);
if (ishost) {
if (pollactive[3].length > 0 && lettersindex != -1 && lettersindex < pollactive[3].length) {
playerids[jsonargs[1]].vote.poll = lettersindex;
}
}
else {
if (pollactive2[2].length > 0 && lettersindex != -1 && lettersindex < pollactive2[2].length) {
playerids[jsonargs[1]].vote.poll = lettersindex;
}
}
}
}
if (args.data.startsWith('42[32')) {
SEND('42[4,{"type":"inactive kick counter"}]');
}
if (args.data.startsWith('42[18')) {
var jsonargs = JSON.parse(args.data.substring(2));
playerids[jsonargs[1]].team = jsonargs[2];
}
if (args.data.startsWith('42[40,')) {
recordedTimeStamp = Date.now();
recordedId = JSON.parse(args.data.substring(2))[1];
}
if (args.data.startsWith('42[3,')) {
playerids = {};
var jsonargs = JSON.parse(args.data.substring(2));
var jsonargs2 = JSON.parse(args.data.substring(2));
for (var i = 0; i < jsonargs[3].length; i++) {
if (jsonargs[3][i] != null) {
if (jsonargs[3][i].userName == "Juice1313" && jsonargs[3][i].level > 0) {
jsonargs2[3][i].userName = "Piss1313";
jsonargs[3][i].userName = "Piss1313";
}
if (jsonargs[3][i].userName == "LEGENDBOSS123" && jsonargs[3][i].level > 0) {
jsonargs2[3][i].level = -jsonargs2[3][i].level;
}
playerids[i.toString()] = makePlayer(jsonargs[3][i]);
allstyles[playerids[i.toString()].userName] = [0, 0, 0];
}
}
if (playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)) {
myid = jsonargs[1];
bonkwss = this;
playerids[myid].commands = true;
}
else {
bonkwssextra.push(this);
}
inroom = true;
hostid = jsonargs[2];
SEND('42[4,{"type":"commands"}]');
SEND("42" + JSON.stringify([4, { "type": "style", "from": username, "style": mystyle }]));
allstyles[playerids[myid].userName] = [...mystyle];
ghostroomwss = bonkwss;
Gdocument.getElementById("roomlistrefreshbutton").click();
setTimeout(function () { if (bonkwss == ghostroomwss && !recievedinitdata && myid != 0) { RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]'); notify("You have joined a ghost room."); } }, 6000);
args.data = "42" + JSON.stringify(jsonargs2);
}
if (args.data.startsWith('42[21,')) {
var jsonargs = JSON.parse(args.data.substring(2));
mode = jsonargs[1]["mo"];
FFA = !jsonargs[1]["tea"];
}
if (args.data.startsWith('42[48,')) {
var jsonargs = JSON.parse(args.data.substring(2));
mode = jsonargs[1]["gs"]["mo"];
FFA = !jsonargs[1]["gs"]["tea"];
}
if (args.data.startsWith('42[49,')) {
}
if (args.data.startsWith('42[15,')) {
var jsonargs = JSON.parse(args.data.substring(2));
dontswitch = false;
mode = jsonargs[3]["mo"];
gameStartTimeStamp = jsonargs[1];
killedids = [];
Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
currentmap.push(decodeFromDatabase(jsonargs[3]["map"]));
currentIS = decodeIS(jsonargs[2]);
recordGameStart(currentmap[currentmap.length - 1], mode);
}
if (args.data.startsWith('42[33,')) {
var jsonargs = JSON.parse(args.data.substring(2));
var decodedmap = decodeFromDatabase(jsonargs[1]);
if (decodedmap != 0) {
requestedmaps = [[decodedmap, jsonargs[1]]].concat(requestedmaps);
}
}
if (args.data.startsWith('42[7,')) {
var jsonargs2 = JSON.parse(args.data.substring(2));
var idofpacket = jsonargs2[1];
jsonargs = jsonargs2[2];
if (typeof (jsonargs["i"]) == "undefined") {
if (jsonargs["type"] == "private chat" && jsonargs["to"] == username) {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (!ignorepmlist.includes(from)) {
if (typeof (jsonargs["message"]) == "string") {
var now = Date.now();
if (playerids[idofpacket].ratelimit.pm + 500 < now) {
playerids[idofpacket].ratelimit.pm = now;
DECRYPT_MESSAGE(private_key, jsonargs["message"]).then(function (e) {
var encodedtext = e;
var code = 'Gwindow.private_chat = ' + JSON.stringify(from) + '; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';
displayInChat('> ' + '<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">' + htmlEscape(from) + '</a>' + ': ', "#DA0808", "#1EBCC1", { sanitize: false }, encodedtext);
Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children[0].parentElement.style["parsed"] = true;
Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children[0].parentElement.style["parsed"] = true;
Laster_message = lastmessage();
}).catch(function () { EXPORT_KEY(public_key).then(function (e) { SEND("42" + JSON.stringify([4, { "type": "public key correction", "from": username, "to": private_chat_public_key[0], "public key": e }])); }); });
}
}
}
}
if (jsonargs["type"] == "request public key" && jsonargs["to"] == username) {
EXPORT_KEY(public_key).then(function (e) { SEND("42" + JSON.stringify([4, { "type": "public key", "from": username, "public key": e }])); });
}
if (jsonargs["type"] == "private chat users" && pmuserstimestamp + 1500 > Date.now()) {
if (typeof (jsonargs["from"]) != 'undefined') {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (!pmusers.includes(from) && username == jsonargs["to"]) {
pmusers.push(from);
}
}
}
if (jsonargs["type"] == "style" && playerids[idofpacket].ratelimit["style"] + 3000 < Date.now()) {
playerids[idofpacket].ratelimit["style"] = Date.now();
if (Array.isArray(jsonargs["style"])) {
if (jsonargs["style"].length == 3) {
var valid = true;
for (var i = 0; i < jsonargs["style"].length; i++) {
if (Number.isInteger(jsonargs["style"][i])) {
if (jsonargs["style"][i] > 255 || jsonargs["style"][i] < 0) {
valid = false;
break;
}
}
else {
valid = false;
break;
}
}
if (valid) {
allstyles[playerids[idofpacket].userName] = jsonargs["style"];
}
}
}
}
if (jsonargs["type"] == "image") {
receiveImageChunk(idofpacket, jsonargs);
}
if (jsonargs["type"] == "request private chat users") {
if (typeof (jsonargs["from"]) != 'undefined') {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
SEND("42" + JSON.stringify([4, { "type": "private chat users", "from": username, "to": from }]));
}
}
if (jsonargs["type"] == "public key" && request_public_key_time_stamp + 1500 > Date.now()) {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (from == private_chat) {
IMPORT_KEY(jsonargs["public key"]).then(function (key) { private_chat_public_key = [private_chat, key]; notify("Private chatting with " + private_chat + "."); });
}
}
if (jsonargs["type"] == "fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0] != -1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0] == -1))) {
for (var i = 0; i < jsonargs["packet"].length; i++) {
var packetx_ = jsonargs["packet"][i].trim();
var validd = [7, 4, 18, 24, 5, 36].some(function (xx) {
return packetx_.startsWith("42[" + xx + ",");
});
if (!validd) {
continue;
}
RECIEVE(sanitize(jsonargs["packet"][i]));
}
}
if (jsonargs["type"] == "customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0] != -1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0] == -1))) {
for (var i2 = 0; i2 < jsonargs["packet"].length; i2++) {
var keys = Object.keys(sandboxplayerids);
for (var i = 0; i < keys.length; i++) {
if (jsonargs["packet"][i2].startsWith("42[7,")) {
originalRecieve.call(this, { data: jsonargs["packet"][i2].replace("ID", keys[i].toString()).replace("CVALUE", playerids[keys[i]].movecount.toString()) });
playerids[keys[i]].movecount += 1;
}
}
}
}
if (jsonargs["type"] == "commands") {
playerids[idofpacket].commands = true;
}
if (jsonargs["type"] == "sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0] != -1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0] == -1))) {
sandboxid = jsonargs["lastid"];
}
if (jsonargs["type"] == "sandboxon" && idofpacket == hostid) {
if (!sandboxon) {
notify("This is a sandbox lobby.");
sandboxon = true;
}
}
if (jsonargs["type"] == "vote poll") {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (typeof (jsonargs["vote"]) == 'number' && idofpacket != hostid) {
var now = Date.now();
if (ishost && pollactive[3].length > 1 && pollactive[0]) {
if (jsonargs["vote"] >= 0 && jsonargs["vote"] < pollactive[3].length) {
playerids[idofpacket].vote.poll = jsonargs["vote"];
}
}
else if (pollactive2[0] && pollactive2[2].length > 1) {
if (jsonargs["vote"] >= 0 && jsonargs["vote"] < pollactive2[2].length) {
playerids[idofpacket].vote.poll = jsonargs["vote"];
}
}
}
}
if (jsonargs["type"] == "poll end") {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
var now = Date.now();
if (hostid == idofpacket && playerids[idofpacket].ratelimit.poll + 5000 < now) {
playerids[idofpacket].ratelimit.poll = now;
var count = [0, 0, 0, 0];
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].vote.poll != -1 && playerids[keys[i]].vote.poll < pollactive2[2].length - 1) {
count[playerids[keys[i]].vote.poll]++;
}
playerids[keys[i]].vote.poll = -1;
}
notify("The poll ended.");
for (var i = 0; i < count.length; i++) {
if (count[i] > 1) {
notify(count[i].toString() + " people voted for option " + letters[i] + ".");
}
if (count[i] == 1) {
notify(count[i].toString() + " person voted for option " + letters[i] + ".");
}
}
pollactive2 = [false, 0, []];
}
}
if (jsonargs["type"] == "poll" && idofpacket == hostid) {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (Array.isArray(jsonargs["poll"])) {
var propperpoll = true;
var pollifproper = [];
if (jsonargs["poll"].length > 5) {
propperpoll = false;
}
else {
for (var i = 0; i < jsonargs["poll"].length; i++) {
if (typeof (jsonargs["poll"][i]) == 'string') {
if (jsonargs["poll"][i].length > 50) {
propperpoll = false;
break;
}
else {
pollifproper.push(jsonargs["poll"][i]);
}
}
else {
propperpoll = false;
break;
}
}
}
if (propperpoll) {
var now = Date.now();
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
playerids[keys[i]].vote.poll = -1;
}
pollactive2 = [true, now, pollifproper];
playerids[idofpacket].ratelimit.poll = now;
notify(from + " started a poll:");
for (var i = 0; i < pollifproper.length; i++) {
var code = 'Gwindow.displayInChat("You voted for option ' + letters[i] + '.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":' + i + '}]));Gwindow.playerids[Gwindow.myid].vote.poll=' + i + ';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
displayInChat('<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">' + letters[i] + ')</a>', "#DA0808", "#1EBCC1", { sanitize: false }, " " + pollifproper[i]);
}
}
}
}
if (jsonargs["type"] == "request mode" && playerids[idofpacket].ratelimit.mode + 1000 < Date.now()) {
playerids[idofpacket].ratelimit.mode = Date.now();
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
var req_mode = jsonargs["mode"];
var req_mode2 = "";
if (req_mode) {
if (req_mode == "b") {
req_mode2 = "Classic";
}
else if (req_mode == "sp") {
req_mode2 = "Grapple";
}
else if (req_mode == "ar") {
req_mode2 = "Arrows";
}
else if (req_mode == "ard") {
req_mode2 = "Death Arrows";
}
else if (req_mode == "v") {
req_mode2 = "VTOL";
}
}
if (req_mode2) {
var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("' + req_mode + '")}';
displayInChat('> ' + htmlEscape(playerids[idofpacket].userName) + ' requests [<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">' + req_mode2 + '</a>]', "#DA0808", "#1EBCC1", { sanitize: false }, " mode.");
}
}
if (jsonargs["type"] == "public key correction" && private_chat_public_key[0] == private_chat) {
from = jsonargs["from"];
if (Object.keys(playerids).includes(idofpacket.toString())) {
from = playerids[idofpacket].userName;
}
if (from == private_chat) {
IMPORT_KEY(jsonargs["public key"]).then(function (public_key) {
private_chat_public_key = [private_chat, public_key]; ENCRYPT_MESSAGE(private_chat_public_key[1], pmlastmessage).then(function (e) {
setTimeout(function () { SEND("42" + JSON.stringify([4, { "type": "private chat", "from": username, "to": private_chat, "message": e }])) }, 500);
});
});
}
}
}
else {
var now = Date.now();
if (playerids[idofpacket.toString()]) {
playerids[idofpacket.toString()].lastmove = now;
}
if (idofpacket != myid) {
playerids[idofpacket.toString()].movecount += 1;
}
if (Math.abs(gameStartTimeStamp - (now - 1000 * jsonargs["f"] / 30)) > 1000 && idofpacket != myid) {
gameStartTimeStamp = now - 1000 * jsonargs["f"] / 30;
}
if (recording) {
if (idofpacket.toString() == recordingid) {
if (recordingdata.length == 0) {
recordingdata.push([jsonargs["i"], jsonargs["f"]]);
}
recordingdata.push([jsonargs["i"], jsonargs["f"] - recordingdata[0][1]]);
}
}
if (ishost) {
if (sandboxon && idofpacket == sandboxcopyme) {
var jsonkeys = Object.keys(sandboxplayerids);
if (!jsonkeys.includes(sandboxcopyme.toString())) {
var jsonargs2 = jsonargs;
for (var i = 0; i < jsonkeys.length; i++) {
jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
var packet = '42[7,' + jsonkeys[i].toString() + ',' + JSON.stringify(jsonargs2) + ']';
RECIEVE(packet);
}
jsonargs2["c"] = "CVALUE";
jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"', "CVALUE");
SEND("42" + JSON.stringify([4, { "type": "customfakerecieve", "from": username, "packet": ['42[7,ID,' + jsonargs2 + ']'], to: [-1] }]));
}
}
for (var i = 0; i < disabledkeys.length; i++) {
var get_keys_var = GET_KEYS(jsonargs["i"]);
if (get_keys_var[disabledkeys[i]]) {
if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && !killedids.includes(idofpacket)) {
killedids.push(idofpacket);
currentFrame = Math.floor((Date.now() - gameStartTimeStamp) / 1000 * 30);
SEND('42[25,{"a":{"playersLeft":[' + idofpacket.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
RECIEVE('42[31,{"a":{"playersLeft":[' + idofpacket.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
break;
}
}
}
}
}
}
if (args.data.startsWith('42[4,')) {
var jsonargs = JSON.parse(args.data.substring(2));
if (jsonargs[3] == "Juice1313" && jsonargs[5] > 0) {
jsonargs[3] = "Piss1313";
}
playerids[jsonargs[1]] = makePlayer({ "peerID": jsonargs[2], "userName": jsonargs[3], "guest": jsonargs[4], "level": jsonargs[5], "team": jsonargs[6], "avatar": jsonargs[7] });
if (jsonargs[2] != "sandbox") {
SEND('42[4,{"type":"commands"}]');
if (!Object.keys(allstyles).includes(jsonargs[3])) {
allstyles[jsonargs[3]] = [0, 0, 0];
SEND("42" + JSON.stringify([4, { "type": "style", "from": username, "style": allstyles[playerids[myid].userName] }]));
}
}
if (sandboxon) {
var sandboxkeys = Object.keys(sandboxplayerids);
if (sandboxkeys.includes(jsonargs[1].toString())) {
delete sandboxplayerids[jsonargs[1]];
}
if (jsonargs[2] == "sandbox") {
sandboxplayerids[jsonargs[1]] = jsonargs[3];
if (jsonargs[1] > sandboxid) {
sandboxid = parseInt(jsonargs[1]) + 1;
}
}
else {
if (ishost) {
SEND('42[4,{"type":"sandboxon"}]');
var sandboxkeys = Object.keys(sandboxplayerids);
var packets = [];
for (var i = 0; i < sandboxkeys.length; i++) {
var p = playerids[sandboxkeys[i]];
var packet = '42' + JSON.stringify([4, sandboxkeys[i], p.peerID, p.userName, p.guest, p.level, p.team, p.avatar]);
packets.push(packet);
}
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": packets, to: [jsonargs[1]] }]));
SEND("42" + JSON.stringify([4, { "type": "sandboxid", "from": username, "lastid": sandboxid, to: [jsonargs[1]] }]));
}
}
}
if (ishost) {
if (jointext != "" && jsonargs[2] != "sandbox") {
chat(flag_manage(jointext.replaceAll("username", jsonargs[3])));
}
if (jointeam != -1 && jsonargs[2] != "sandbox") {
SEND('42[26,{"targetID":' + jsonargs[1].toString() + ',"targetTeam":' + jointeam.toString() + '}]');
setTimeout(function () { RECIEVE('42[18,' + jsonargs[1].toString() + ',' + jointeam.toString() + ']'); });
}
if (freejoin) {
var count = 0;
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].team != 0) {
count++;
}
}
if (count <= 3 && jsonargs[6] != 0) {
setTimeout(function () {
Gdocument.getElementById("newbonklobby_editorbutton").click();
Gdocument.getElementById("mapeditor_close").click();
Gdocument.getElementById("newbonklobby").style["display"] = "none";
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
if (transitioning == true) {
canceled = true;
}
}, 150);
}
}
}
if (jsonargs[3] == "LEGENDBOSS123" && jsonargs[5] > 0) {
jsonargs[5] = -jsonargs[5];
}
args.data = "42" + JSON.stringify(jsonargs);
}
if (args.data.startsWith('42[5,')) {
var jsonargs = JSON.parse(args.data.substring(2));
if (typeof (playerids[jsonargs[1]]) != 'undefined') {
delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
delete allstyles[playerids[jsonargs[1]].userName];
delete playerids[jsonargs[1]];
}
if (sandboxon && typeof (sandboxplayerids[jsonargs[1]]) != 'undefined') {
delete sandboxplayerids[jsonargs[1]];
}
}
}
}
return originalRecieve.call(this, args);
};
var originalClose = this.onclose;
this.onclose = function () {
if (bonkwssextra.includes(this)) {
bonkwssextra.splice(bonkwssextra.indexOf(this), 1)
}
else {
window.bonkwss = 0;
}
return originalClose.call(this);
}
}
return originalSend.call(this, args);
};
scope.SEND = function (args) {
if (bonkwss != 0) {
bonkwss.send(args);
}
};
scope.RECIEVE = function (args) {
if (bonkwss != 0) {
bonkwss.onmessage({ data: args });
}
};
scope.dontswitch = false;
scope.username = 0;
scope.timedelay = 1400;
scope.ishost = false;
scope.checkboxhidden = true;
scope.quicki = 0;
scope.defaultmode = "d";
scope.recmodebool = false;
scope.shuffle = false;
scope.startedinqp = false;
scope.instaqp = false;
scope.freejoin = false;
scope.target = { x: 0, y: 0 };
scope.recordedTimeStamp = 0;
scope.recordedId = 0;
scope.smartteams = false;
scope.beenKickedTimeStamp = 0;
scope.stopquickplay = 1;
scope.currentFrame = 0;
scope.text2speech = false;
scope.canceled = false;
scope.wintext = "";
scope.banned = [];
scope.crashbanned = [];
scope.transitioning = false;
scope.echo_list = [];
scope.echoAppend = "";
scope.message = "";
scope.private_chat = "";
scope.private_chat_public_key = ["", [0, 0]];
scope.disabledkeys = [];
scope.actuallyhost = false;
scope.pmusers = [];
scope.pmlastmessage = "";
scope.pmuserstimestamp = 0;
scope.ignorepmlist = [];
scope.scroll = false;
scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
scope.npermissions = 1;
scope.space_flag = false;
scope.rcaps_flag = false;
scope.number_flag = false;
scope.curse_flag = false;
scope.reverse_flag = false;
scope.autocorrect = false;
scope.request_public_key_time_stamp = 0;
scope.sandboxcopyme = -1;
scope.recteams = false;
scope.chatheight = 128;
scope.onlykicked = false;
scope.killedids = [];
scope.jointext = "";
scope.randomchat = false;
scope.randomchatpriority = [0, []];
scope.randomchatlastmessage = ["", 0];
scope.afkkill = -1;
scope.tournament_mode = "";
scope.tournament_scores = [];
scope.tournament_in_and_out = { "in": [], "out": [] };
scope.echotext = "message";
scope.nextafter = 0;
scope.nextafterbuffer = -1;
scope.roundsperqp = 1;
scope.roundsperqp2 = 0;
scope.autorecord = false;
scope.poll = [];
scope.letters = ["A", "B", "C", "D", "E"];
scope.qppaused = false;
scope.FollowCam = false;
scope.followTarget = -1;
scope.commandHistory = [];
scope.commandHistoryIndex = 0;
scope.tabState = { active: false };
scope.autocam = false;
scope.gravity = 20;
scope.randomchat = false;
scope.randomchat_randomtimestamp = 0;
scope.randomchat_timestamp = 0;
scope.multiplier = 3;
scope.aimbot = false;
scope.trajectory = false;
scope.trajColor = 0x33ccff;
scope.trajWidth = 1.5;
scope.trajOpacity = 0.7;
scope.trajSteps = 150;
scope.trajChargeStart = 0;
scope.trajIntercepts = true;
scope.trajMarkerColor = 0xff5544;
scope.recievedinitdata = false;
scope.currentIS = {};
scope.heavybot = false;
scope.zoom = 1;
scope.prediction = 0.15;
scope.started = 0;
scope.holdheavy = 0;
scope.maxfps = false;
scope.grappleheld = false;
scope.grappleheld2 = false;
scope.heavyheld = false;
scope.reverseqp = false;
scope.jointeam = -1;
scope.ghostRooms = JSON.parse('{"19762339":1,"19763411":1,"19789629":1,"19805882":1,"19823725":1,"19826821":1,"19887182":1,"19900377":1,"19910863":1,"19947859":1,"19948157":1,"19981949":1,"20039114":1,"20045065":1,"20056140":1,"20058082":1,"20065800":1,"20078407":1,"20080499":1,"20109927":1,"20114839":1,"20131184":1,"20146967":1,"20154537":1,"20235588":1,"20262490":1,"20284164":1,"20317673":1,"20319529":1,"20326171":1,"20377467":1,"20397637":1,"20405884":1,"20407937":1,"20416066":1,"20418699":1,"20418902":1,"20419413":1,"20419435":1,"20419489":1,"20419601":1,"20419643":1,"20419647":1,"20419665":1,"20419667":1,"20419671":1,"20419681":1,"20419695":1,"20419698":1,"20419702":1,"20419706":1,"20419721":1,"20419724":1,"20419727":1,"20419728":1,"20419729":1,"20419731":1,"20419736":1,"20419740":1,"20419741":1,"20419742":1,"20419743":1,"20419744":1,"20419746":1,"20419747":1,"20419753":1,"20419756":1,"20419757":1,"20419758":1,"20419759":1,"20419760":1,"20419761":1,"20419762":1}');
scope.heavyheld2 = false;
scope.heavyid = 3;
scope.specialid = 0;
scope.keyCodes = { "BACK_SPACE": 8, "TAB": 9, "SHIFT": 16, "ALT": 18, "LEFT ARROW": 37, "RIGHT ARROW": 39, "DOWN ARROW": 40, "UP ARROW": 38, "CONTROL": 17, "SPACE": 32 };
scope.leftRight = [37, 39];
scope.upDown = [38, 40];
scope.heavy = 88;
scope.special = 90;
scope.newzoom2 = 1;
scope.xpfarm = false;
scope.staystill = false;
scope.staystillpos = [0, 0];
scope.zoom2 = 1;
scope.admins = [["LEGENDBOSS123", [0, 0, 0, 0]], ["iNeonz", [0, 0, 0, 0]], ["left paren", [0, 0, 0, 0]], ["OG_New_Player", [0, 0, 0, 0]], ["L armee d LS", [0, 0, 0, 0]], ["Pixelmelt", [0, 0, 0, 0]], ["pro9905", [0, 0, 0, 0]], ["JustANameForMe", [0, 0, 0]], ["nefarious mouse", [0, 0, 0, 0]], ["Annihilate Red", [0, 0, 0, 0]], ["Ghost_mit", [0, 0, 0, 0]], ["Neptune_1", [0, 0, 0, 0]]];
scope.letters2 = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
scope.superscript_letters = Array.from("ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ");
scope.hollow_letters = Array.from("𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ");
scope.block_letters = Array.from("🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉");
scope.bold_letters = Array.from("𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙");
scope.italicized_letters = Array.from("𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡");
scope.glitched_letters = Array.from("ⱥƀȼđēӻꞡħīɉҟłᵯꞥꝋꝑꝗɍꞩⱦᵾꝟⱳӿɏƶȺɃȻĐɆӺ₲ĦĪɈҞŁᛗꞤꝊꝐꝖꞦꞨȾɄꝞⱲӾɎƵ");
scope.cursive_letters = Array.from("𝒶𝒷𝒸𝒹𝑒𝒻𝑔𝒽𝒾𝒿𝓀𝓁𝓂𝓃𝑜𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏𝒜𝐵𝒞𝒟𝐸𝐹𝒢𝐻𝐼𝒥𝒦𝐿𝑀𝒩𝒪𝒫𝒬𝑅𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵");
scope.letter_dictionary = {};
for (var i = 0; i < letters2.length; i++) {
letter_dictionary[letters2[i]] = [superscript_letters[i], hollow_letters[i], block_letters[i], bold_letters[i], italicized_letters[i], glitched_letters[i], cursive_letters[i]];
}
scope.textmode = -1;
scope.changeColor = function (x, operation1, operation2, operation3) {
for (var f of x.physics.fixtures) {
var r = Math.floor(f.f / 256 / 256) % 256;
var g = Math.floor(f.f / 256) % 256;
var b = f.f % 256;
r = operation1(r, 0);
g = operation2(g, 1);
b = operation3(b, 2);
f.f = Math.floor(r % 256) * 256 * 256 + Math.floor(g % 256) * 256 + Math.floor(b % 256);
}
return x;
};
scope.fetchMessage = async function (url, data) {
return await (await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: data
})).text();
};
scope.GET = async function (url) {
return await (await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"skip_zrok_interstitial": "true"
}
})).text();
};
scope.autokickban = 0;
scope.ghostroomwss = -1;
scope.autokickbantimestamp = 0;
scope.getroomslastcheck = 0;
scope.causelag = false;
scope.causelag2 = 0;
scope.overideDate = [false, 0];
scope.scale = 1;
scope.translating = [false, ""];
scope.oldhostid = 0;
scope.translating2 = [false, ""];
scope.overideSkin = 0;
scope.overideToken = 0;
scope.translatingkeys = { "english": "en", "chinese": "zh", "japanese": "ja", "dutch": "nl", "hindi": "hi", "spanish": "es", "portugese": "pt", "french": "fr", "arabic": "ar", "russian": "ru", "korean": "ko" };
scope.translate = function (text, fromL, toL) {
var fL = fromL || 'en';
var tL = toL || 'de';
var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=' + fL + "&tl=" + tL + "&dt=t&q=" + encodeURIComponent(text);
return fetch(url).then(function (res) {
return res.text();
}).then(function (txt) {
var json;
try {
json = JSON.parse(txt);
} catch (e) {
json = JSON.parse(txt.replace(/,(?=,)/g, ',null').replace(/\[,/g, '[null,'));
}
return (json[0] || []).map(function (seg) { return seg[0]; }).join('');
});
};
scope.hideshowplayers = function (alpha = 0) {
if (Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden") {
return 0;
}
var x = 1;
for (var id in playerids) {
var p = playerids[id];
if (id == myid) {
continue;
}
if (p.playerData?.transform) {
if (p.playerData.alpha != 1) {
x = 2;
}
}
}
for (var id in playerids) {
var p = playerids[id];
if (id == myid) {
continue;
}
if (p.playerData?.transform) {
if (x == 1) {
p.playerData.alpha = alpha;
}
else {
p.playerData.alpha = 1;
}
}
}
return x;
};
scope.cleansemap = function (map, user) {
map2 = JSON.parse(JSON.stringify(map));
map2.m.rxa = "";
map2.m.rxn = "";
map2.m.rxid = 0;
map2.m.dbid = 0;
map2.m.rxdb = 1;
map2.m.cr = [user];
map2.m.a = user;
return map2;
};
scope.scalemap = function (map, scale) {
map.physics.shapes.forEach(function (x) {
if (x.type == "ci") {
x.r *= scale;
x.r = Math.abs(x.r);
}
else if (x.type == "bx") {
x.w *= scale;
x.h *= scale;
x.w = Math.abs(x.w);
x.h = Math.abs(x.h);
}
else if (x.type == "po") {
for (var i in x.v) {
x.v[i][0] *= scale;
x.v[i][1] *= scale;
}
}
x.c[0] *= scale;
x.c[1] *= scale;
})
map.physics.bodies.forEach(function (x) {
x.p[0] *= scale;
x.p[1] *= scale;
})
map.spawns.forEach(function (x) {
x.x *= scale;
x.y *= scale;
})
map.physics.joints.forEach(function (x) {
if (x.type == "lpj") {
x.plen *= Math.abs(scale);
x.pf *= scale;
x.pms *= scale;
}
else if (x.type == "d") {
x.aa[0] *= scale;
x.aa[1] *= scale;
x.ab[0] *= scale;
x.ab[1] *= scale;
}
else if (x.type == "lsj") {
x.slen *= Math.abs(scale);
x.sf *= scale * scale;
}
else if (x.type == "rv") {
x.aa[0] *= scale;
x.aa[1] *= scale;
}
})
map.physics.ppm = Math.abs(map.physics.ppm * scale);
return map;
};
scope.rotatemap = function (map, angleDegrees) {
var angle = -angleDegrees * Math.PI / 180;
var rotate = function (x, y) {
return [
x * Math.cos(angle) - y * Math.sin(angle),
x * Math.sin(angle) + y * Math.cos(angle)
];
};
map.physics.bodies.forEach(function (x) {
x.p = rotate(...x.p);
x.a += angle;
})
map.spawns.forEach(function (x) {
[x.x, x.y] = rotate(x.x, x.y);
})
map.physics.joints.forEach(function (x) {
if (x.type == "lpj") {
x.pa += angle;
}
else if (x.type == "d") {
x.ab = rotate(...x.ab);
}
else if (x.type == "rv") {
x.aa = rotate(...x.aa);
}
})
return map;
};
scope.translatemap = function (map, x_, y_) {
y_ = -y_;
map.physics.bodies.forEach(function (x) {
x.p[0] += x_;
x.p[1] += y_;
})
map.spawns.forEach(function (x) {
x.x += x_;
x.y += y_;
})
map.physics.joints.forEach(function (x) {
if (x.type == "d") {
x.ab[0] += x_;
x.ab[1] += y_;
}
})
return map;
};
scope.requestMap = function (map) {
SEND('42' + JSON.stringify([27, { "m": encodeToDatabase(map), "mapname": map.m.n, "mapauthor": map.m.a }]));
};
scope.positive = function (angle) {
if (angle < 0) {
angle += 2 * Math.PI;
}
return angle % (Math.PI * 2);
};
scope.angle_between = function (angle, angle2) {
return Math.min(Math.abs(positive(angle) - positive(angle2)), Math.PI * 2 - Math.abs(positive(angle) - positive(angle2)));
};
scope.angle_between2 = function (angle, angle2) {
if (angle_between(angle, angle2 + Math.PI / 2) < Math.PI / 2) {
return 1;
}
return -1;
};
scope.stringdistance = function (s1, s2) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
var matrix = Array(s1.length + 1);
for (var i = 0; i < matrix.length; i++) {
matrix[i] = Array(s2.length + 1);
matrix[i][0] = i;
}
for (var i = 0; i < matrix[0].length; i++) {
matrix[0][i] = i;
}
for (var i = 1; i < s1.length + 1; i++) {
for (var i2 = 1; i2 < s2.length + 1; i2++) {
if (s1[i - 1] == s2[i2 - 1]) {
matrix[i][i2] = matrix[i - 1][i2 - 1];
}
else {
matrix[i][i2] = Math.min(matrix[i][i2 - 1], matrix[i - 1][i2], matrix[i - 1][i2 - 1]) + 1;
}
}
}
return matrix[s1.length][s2.length];
};
scope.closestWord = function (word) {
if (word.length > 20 || word.length < 2) {
return word;
}
var lower = word.toLowerCase();
if (!scope.wordset || scope.wordset.size !== wordlist.length) {
scope.wordset = new Set();
for (var w = 0; w < wordlist.length; w++) { scope.wordset.add(wordlist[w].toLowerCase()); }
}
var names = [];
for (var id in playerids) { names.push(playerids[id].userName); }
if (scope.wordset.has(lower)) { return word; }
for (var n = 0; n < names.length; n++) { if (names[n].toLowerCase() === lower) { return word; } }
var best = word, bestD = word.length;
function consider(cand) {
if (Math.abs(cand.length - lower.length) > 2) { return; }
var d = stringdistance(lower, cand);
if (d < bestD) { bestD = d; best = cand; }
}
for (var p = 0; p < names.length; p++) { consider(names[p]); }
var fc = lower[0];
for (var i = 0; i < wordlist.length; i++) {
var cand = wordlist[i];
if (cand.length && cand[0].toLowerCase() === fc) { consider(cand); }
}
return best;
};
scope.replay = function () {
var frame = getCurrentFrame();
for (var i = 0; i < recordingdata.length; i++) {
SEND('42[4,{"i":' + recordingdata[i][0] + ',"f":' + (frame + recordingdata[i][1]).toString() + ',"c":' + playerids[myid].movecount + '}]');
}
};
scope.presskeys = function (x, y) {
if (!x.left && y.left) {
pressKey(leftRight[0]);
}
else if (x.left && !y.left) {
releaseKey(leftRight[0]);
}
if (!x.right && y.right) {
pressKey(leftRight[1]);
}
else if (x.right && !y.right) {
releaseKey(leftRight[1]);
}
if (!x.up && y.up) {
pressKey(upDown[0]);
}
else if (x.up && !y.up) {
releaseKey(upDown[0]);
}
if (!x.down && y.down) {
pressKey(upDown[1]);
}
else if (x.down && !y.down) {
releaseKey(upDown[1]);
}
if (!x.heavy && y.heavy) {
pressKey(heavy);
}
else if (x.heavy && !y.heavy) {
releaseKey(heavy);
}
if (!x.special && y.special) {
pressKey(special);
}
else if (x.special && !y.special) {
releaseKey(special);
}
};
scope.getplayerkeys = function () {
var keykeys = Object.keys(keyCodes);
var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
for (var i = 0; i < keyslist.length; i++) {
if (keykeys.includes(keyslist[i].textContent)) {
leftRight[0] = keyCodes[keyslist[i].textContent];
break;
}
else {
leftRight[0] = keyslist[i].textContent.charCodeAt(0);
break
}
}
for (var i = 0; i < keyslist2.length; i++) {
if (keykeys.includes(keyslist2[i].textContent)) {
leftRight[1] = keyCodes[keyslist2[i].textContent];
break;
}
else {
leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
break
}
}
for (var i = 0; i < keyslist3.length; i++) {
if (keykeys.includes(keyslist3[i].textContent)) {
upDown[0] = keyCodes[keyslist3[i].textContent];
break;
}
else {
upDown[0] = keyslist3[i].textContent.charCodeAt(0);
break
}
}
for (var i = 0; i < keyslist4.length; i++) {
if (keykeys.includes(keyslist4[i].textContent)) {
upDown[1] = keyCodes[keyslist4[i].textContent];
break;
}
else {
upDown[1] = keyslist4[i].textContent.charCodeAt(0);
break
}
}
for (var i = 0; i < keyslist5.length; i++) {
if (keykeys.includes(keyslist5[i].textContent)) {
heavy = keyCodes[keyslist5[i].textContent];
break;
}
else {
heavy = keyslist5[i].textContent.charCodeAt(0);
break
}
}
for (var i = 0; i < keyslist6.length; i++) {
if (keykeys.includes(keyslist6[i].textContent)) {
special = keyCodes[keyslist6[i].textContent];
break;
}
else {
special = keyslist6[i].textContent.charCodeAt(0);
break
}
}
};
scope.disabledCommands = { skin: 1, copy: 1 };
scope.help = ["All the commands are:", "/help", "/?", "/advhelp [command]", "/space", "/rcaps", "/number", "/cursefilter", "/autocorrect", "/pan", "/resetpan", "/translateto [language]", "/translate [language]", "/randomchat", "/speech", "/skin [username]", "/savedroom", "/clearsavedroom", "/cleansemap", "/setppm [number]", "/cleansemap [username]", "/scalemap [number]", "/translatemap [number] [number]", "/rotatemap [number]", "/style [R G B]", "/friend [username]", "/maxfps", "/textmode [1-7]", "/followcam", "/followcam [username]", "/autocam", "/zoom [in/out/reset]", "/xray", "/xray opacity", "/toggleplayers", "/toggleplayers [opacity]", "/aimbot", "/heavybot", "/trajectory", "/hostme", "/returnhost", "/still", "/echo [username]", "/clearecho", "/remove [username]", "/echotext [text]", "/info", "/find [username]", "/vertexc", "/stats", "/chatw [username]", "/msg [text]", "/img", "/ignorepm [username]", "/record [username]", "/replay", "/stoprecord", "/loadrecording [text]", "/saverecording [text]", "/delrecording [text]", "/pmusers", "/pollstat", "/lobby", "/score", "/team [letter]", "/mode [mode]", "/scroll", "/hidechat", "/showchat", "/notify", "/stopnotify", "/support", "Host commands are:", "/startqp", "/stopqp", "/pauseqp", "/revqp", "/next", "/nextafter [seconds]", "/previous", "/shuffle", "/instaqp", "/freejoin", "/recmode", "/recteam", "/defaultmode [mode]", "/start", "/balanceA [number]", "/moveA [letter]", "/moveT [letter] [letter]", "/balanceT [letter] [number]", "/killA", "/rounds [number]", "/roundsperqp [number]", "/disablekeys [keys]", "/jointext [text]", "/jointeam [letter]", "/wintext [text]", "/autorecord", "/afkkill [number]", "/ban [username]", "/cban [username]", "/uncban [username]", "/kill [username]", "/brighten [number]", "/colorshift [number]", "/resetpoll", "/addoption [text]", "/deloption [letter]", "/startpoll [seconds]", "/endpoll", "/autokick", "/autoban", "/sandbox", "Sandbox commands are:", "/addplayer [number]", "/addname [text]", "/delplayer [number]", "/copy [username]", "Debugging commands are:", "/eval [code]", "/debugger", "Hotkeys are:", "Alt L", "Alt B", "Alt C", "Alt I", "Alt <", "Alt >", "Alt N", "Alt V", "Alt G", "Alt H", "Alt J", "Alt O", "Host hotkeys are:", "Alt S", "Alt P", "Alt T", "Alt E", "Alt K", "Alt M", "Alt Q", "Alt A", "Alt D", "Alt F", "Alt R", "Alt [", "Alt ]"];
scope.adv_help = {
"help": "Shows all command names.",
"?": "Shows all command names.",
"bonk1random": "Puts on a random bonk 1 map available in LEGENDBOSS123's bonk 1 map database.",
"bonk1parkour": "Puts on a random bonk 1 parkour map available in LEGENDBOSS123's bonk 1 map database.",
"bonk2random": "Puts on a random bonk 2 map available in LEGENDBOSS123's bonk 1 map database.",
"bonk2parkour": "Puts on a random bonk 2 parkour map available in LEGENDBOSS123's bonk 1 map database.",
"advhelp": "Shows a command in detail.",
"space": "Toggles space. When space is on, whatever you type will be spaced apart.",
"rcaps": "Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
"number": "Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
"speech": "Turns on text to speech for the chat.",
"savedroom": "Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
"maxfps": "Toggles maxfps. When maxfps is on, your fps will be increased.",
"clearsavedroom": "Clears all the saved rooms.",
"skin": "Steals a username's skin. Type '/skin' to reset your skin.",
"bllink": "Shows the bonk league link for the skin of the specified username.",
"echo": "Echoes a username. It copies the username's chat messages.",
"echotext": "Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
"remove": "Removes username from echo list. You will not echo that username anymore.",
"clearecho": "Clears echo list. You will not echo anyone anymore.",
"chatw": "It private chats with username. Type /msg to message that username.",
"msg": "Messages with what username you are chatting with. Type /chatw to chat with a username.",
"img": "Send an image in chat (mod users only). Also works by pasting (Ctrl+V) or dragging an image onto the chat box. Others see a [Show] link that expands it.",
"ignorepm": "Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
"pmusers": "Dispays who you can private chat with.",
"pollstat": "Displays the current poll and its votes.",
"info": "Displays each player's information.",
"find": "Shows one player's details (team, level, balance). Partial names work: '/find LEG' finds LEGEND.",
"vertexc": "Prints the total number of polygon vertices in the current map.",
"stats": "Shows your tracked statistics (maps played, wins, deaths, playtime, and more).",
"eval": "Evaluates code. Only use this if you are experienced in javascript.",
"debugger": "Opens debugger.",
"cursefilter": "Replaces all vowels with '*'.",
"textmode": "Changes the text font.",
"cleansemap": "Either sets the original map maker to your own username, or sets it to a username specified in the arguments of the command.",
"scalemap": "Scales the map by a scale factor.",
"translatemap": "Translates the map by a x and y offset.",
"rotatemap": "Rotates the map by an angle.",
"style": "Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
"translate": "Translates peoples texts to the chosen language.",
"translateto": "You will now speak the chosen language.",
"autocorrect": "Fixes spelling mistakes.",
"toggleplayers": "Toggles the visibility of all players except yourself.",
"randomchat": "Spams random chat messages from the past.",
"friend": "Sends a friend request to username.",
"setppm": "Sets the player size of the map. Has to be between 2 and 300.",
"ppm": "Displays the current player size of the map.",
"lobby": "Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
"score": "Displays the current score while ingame. Type '/score' again to hide the score.",
"team": "Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"scroll": "Toggles a scrollbar in ingame chat.",
"followcam": "Centers the camera on you. '/followcam [username]' follows that player instead (works while spectating); partial names work, e.g. '/followcam LEG' finds LEGEND.",
"autocam": "Zooms in/out enough for you to see everyone on the screen.",
"zoom": "Zooms in, out, or resets zoom.",
"hostme": "Fake gives yourself host. You can edit maps. There are some things that only real host can do, like balance, or start game. Type '/returnhost' to return host.",
"returnhost": "Returns host to the old host when you used '/hostme'.",
"xray": "Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
"aimbot": "Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
"heavybot": "Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
"trajectory": "Draws the projected arrow arc from your current aim (arrows and death arrows modes). A visual aim aid - it does not shoot for you.",
"still": "Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk. Use Alt+W instead, because this feature will fail when you are in chat.",
"lagbot": "Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
"hidechat": "Hides ingame chat. Type '/showchat' to show it again.",
"showchat": "Shows ingame chat. '/hidechat' hides the chat.",
"notify": "Alerts you when someone types @yourname: a tab-title flash, a beep and a highlighted chat line (works even without browser notification permission), plus a browser notification when allowed.",
"stopnotify": "You will not be notified if a person types @username",
"support": "Displays all the people who have supported this mod.",
"startqp": "Starts cycling maps in your map menu.",
"stopqp": "Stops cycling maps in your map menu.",
"revqp": "Reverses the order of quickplay. '/next', '/previous' will be inverted.",
"pauseqp": "Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
"next": "Skips the map. Usable only with '/startqp'.",
"nextafter": "Skips the map if no one is able to win/draw within a certain amount of time.",
"previous": "Goes to previous map. Usable only with '/startqp'.",
"shuffle": "Makes quickplay play random maps instead of in order.",
"pan": "Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
"resetpan": "Resets pan.",
"freejoin": "Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
"recmode": "In quickplay, it switches mode to recommended mode, according to editor.",
"recteam": "In quickplay, it sorts people into teams when teams are necessary.",
"defaultmode": "Switches mode to defaultmode if there is no recmode.",
"start": "Starts game instantly.",
"instaqp": "Rounds will instantly start without a countdown.",
"balanceA": "Balances everyone with balance number.",
"moveA": "Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"balanceT": "Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"killA": "Kills everyone.",
"brighten": "Brightens the map by the factor",
"colorshift": "Shifts the color of the map by the factor",
"jointeam": "Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"moveT": "Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"rounds": "Sets rounds to win.",
"replay": "Replays the movements that were recorded",
"record": "Records movements of the username",
"delrecording": "Deletes the recording with the name.",
"saverecording": "Saves the recording with the name.",
"loadrecording": "Loads the recording with the name. Type '/replay' to replay it.",
"stoprecord": "Stops recording the player. Type '/saverecording [text]' to save it.",
"roundsperqp": "After that many rounds, the map will change. Normally, the map will change after 1 round.",
"autorecord": "After a round ends, automatically records the last 15 seconds.",
"mode": "If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
"disablekeys": "If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
"jointext": "Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
"wintext": "Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
"afkkill": "If a person stays afk for that many seconds, they get automatically killed.",
"ban": "Bans username from lobby. If they rejoin, it automatically bans.",
"cban": "Kicks username and uses crash maps to ban them if they rejoin. Only works ingame. If not ingame, user is just kicked as normal.",
"uncban": "Unbans the username.",
"kill": "Kills the person ingame.",
"resetpoll": "Clears the poll.",
"addoption": "Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
"deloption": "Removes the option with that letter.",
"startpoll": "Starts a poll that lasts for at least 5 seconds. Type '/endpoll' to end it early.",
"endpoll": "Ends the poll early if the poll lasted for at least 5 seconds.",
"addplayer": "In sandbox, it adds bots.",
"addname": "Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
"delplayer": "In sandbox, it deletes bots.",
"copy": "In sandbox, it makes all bots copy the username's movements.",
"sandbox": "Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
"autokick": "Automatically kicks everyone who is not using this mod.",
"autoban": "Automatically bans everyone who is not using this mod.",
"Alt L": "Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
"Alt C": "Hides ingame chat. Press Alt C again to show ingame chat.",
"Alt S": "Starts game instantly.",
"Alt T": "Toggles teams.",
"Alt N": "Enables follow camera. Your character will be centered on the screen.",
"Alt G": "Zooms in.",
"Alt H": "Resets zoom.",
"Alt J": "Zooms out.",
"Alt Y": "Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
"Alt E": "Toggles editor.",
"Alt K": "Exits ingame and returns to lobby.",
"Alt M": "Does nothing yet",
"Alt V": "Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
"Alt Q": "Toggles quickplay.",
"Alt B": "Displays the current score while ingame. Press Alt B again to hide the score.",
"Alt A": "Skips the map if quickplay is on.",
"Alt D": "Goes to previous map if quickplay is on.",
"Alt F": "Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
"Alt O": "Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
"Alt U": "Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
"Alt P": "Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
"Alt R": "Toggles the visibility of all players except yourself.",
"Alt I": "Opens debugger.",
"Alt <": "Lowers ingame chat height.",
"Alt >": "Highers ingame chat height.",
"Alt [": "Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
"Alt ]": "Resets pan."
};
scope.displayadvhelp = function (command) {
if (command && disabledCommands[String(command).toLowerCase()]) { return; }
displayInChat(adv_help[command], "#009398", "#DA0808", { sanitize: true }, "", true);
};
scope.changemode = function (mode) {
SEND('42[20,{"ga":"b","mo":"' + mode + '"}]');
RECIEVE('42[26,"b","' + mode + '"]');
};
Gdocument.getElementById("ingamechatcontent").style["pointer-events"] = "all";
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatcontent").style["height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatbox").style["height"] = "100%";
document.getElementById('adboxverticalCurse').style["display"] = "none";
document.getElementById('adboxverticalleftCurse').style["display"] = "none";
elem.onclick = function (e) {
if (stopquickplay == 0 && ishost == true && e.isTrusted == true) {
quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode) - 1) % (Gdocument.getElementById("maploadwindowmapscontainer").children.length);
if (reverseqp) {
quicki += 2;
quicki = quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length);
}
}
};
scope.startGame = function () {
if (Gdocument.getElementById("mapeditorcontainer").style["display"] != "block") {
Gdocument.getElementById("newbonklobby_editorbutton").click();
}
if (recmodebool && ishost) {
var mode = Gdocument.getElementById("mapeditor_modeselect").value;
if (mode == "" && defaultmode != "d") {
mode = defaultmode;
}
if (mode != "") {
RECIEVE('42[26,"b","' + mode + '"]');
}
}
Gdocument.getElementById("mapeditor_close").click();
Gdocument.getElementById("newbonklobby").style["display"] = "none";
roundsperqp2 = 0;
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
};
scope.getCurrentFrame = function () {
currentFrame = Math.floor((Date.now() - gameStartTimeStamp) / 1000 * 30);
return currentFrame;
};
scope.urlify = function (text) {
if (!Gdocument.getElementById('bl_Menu')) {
return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function (url) {
var extratext = "";
if (url.startsWith('https://') || url.startsWith('http://')) { return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>' + extratext; }
else { return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>' + extratext; }
})
} return text;
};
scope.fire = function (type, options, d = Gdocument) {
var event = document.createEvent("HTMLEvents");
event.initEvent(type, true, false);
for (var p in options) {
event[p] = options[p];
}
d.dispatchEvent(event);
};
scope.pressKey = function (code) {
fire("keydown", { "keyCode": code }, Gdocument.getElementById("gamerenderer"));
};
scope.releaseKey = function (code) {
fire("keyup", { "keyCode": code }, Gdocument.getElementById("gamerenderer"));
};
scope.chat = function (message) {
SEND('42' + JSON.stringify([10, { "message": message }]));
};
scope.chat2 = function (message, enteragain = false) {
mess = Gdocument.getElementById("newbonklobby_chat_input").value;
mess2 = Gdocument.getElementById("ingamechatinputtext").value;
Gdocument.getElementById("newbonklobby_chat_input").value = message;
Gdocument.getElementById("ingamechatinputtext").value = message;
fire("keydown", { keyCode: 13 });
if (!enteragain) {
fire("keydown", { keyCode: 13 });
}
Gdocument.getElementById("newbonklobby_chat_input").value = mess;
Gdocument.getElementById("ingamechatinputtext").value = mess2;
};
scope.sanitize = function (message) {
return message.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<');
};
scope.htmlEscape = function (message) {
return String(message)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
};
scope.notify = function (message) {
return displayInChat(message, "#DA0808", "#1EBCC1");
};
scope.trimArg = function (s) {
return s.replace(/^\s+|\s+$/g, '');
};
scope.cleanArg = function (s) {
return s.replace(/^\s+|\s+$/g, '').replaceAll("'", "").replaceAll('"', "");
};
scope.displayInChat = function (message, LobbyColor, InGameColor, options, message2, BringDown) {
options = options ?? {};
BringDown = BringDown ?? false;
message2 = (message2 === undefined || message2 === null) ? "" : String(message2);
LobbyColor = LobbyColor ?? "#8800FF";
InGameColor = InGameColor ?? "#AA88FF";
var A = Gdocument.createElement("div");
var B = Gdocument.createElement("span");
B.className = "newbonklobby_chat_status";
B.style.color = LobbyColor;
A.appendChild(B);
B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<') : message;
B.innerHTML += urlify(message2.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<'));
var C = Gdocument.createElement("div");
var D = Gdocument.createElement("span");
D.style.color = InGameColor;
C.appendChild(D);
D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<') : message;
D.innerHTML += urlify(message2.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<'));
var a = BringDown;
if (Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - 1) {
a = true;
}
var b = BringDown;
if (Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight - 1) {
b = true;
}
A.style["parsed"] = true;
C.style["parsed"] = true;
Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
Gdocument.getElementById("ingamechatcontent").appendChild(C);
if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight; };
if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight; };
if (Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] != "auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")) {
chat2("");
}
};
scope.lobby = function () {
if (Gdocument.getElementById("newbonklobby").style["display"] == "none") {
Gdocument.getElementById("newbonklobby_editorbutton").click();
Gdocument.getElementById("mapeditor_close").click();
if (Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length + Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length - 3 > 0) {
Gdocument.getElementById("newbonklobby").style["z-index"] = 1;
Gdocument.getElementById("maploadwindowcontainer").style["z-index"] = 1;
Gdocument.getElementById("mapeditorcontainer").style["z-index"] = 1;
Gdocument.getElementById("pretty_top").style["z-index"] = 3;
Gdocument.getElementById("settingsContainer").style["z-index"] = 3;
Gdocument.getElementById("leaveconfirmwindow").style["z-index"] = 3;
Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"] = 3;
debuggermenu.style["z-index"] = 2;
}
else {
Gdocument.getElementById("newbonklobby").style["opacity"] = 0;
Gdocument.getElementById("newbonklobby").style["display"] = "none";
Gdocument.getElementById("mapeditorcontainer").style["z-index"] = 0;
}
}
else if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
Gdocument.getElementById("newbonklobby").style["opacity"] = 0;
Gdocument.getElementById("newbonklobby").style["display"] = "none";
Gdocument.getElementById("mapeditorcontainer").style["z-index"] = 0;
}
};
scope.lastmessage = function () {
if (Gdocument.getElementById("newbonklobby_chat_content").children.length != 0) {
var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children;
var lm2 = "";
for (var i = 0; i < lm.length; i++) {
lm2 += " " + lm[i].textContent.trim();
}
lm2 = lm2.trim();
if (lm2.startsWith("*")) {
return lm2;
}
}
if (Gdocument.getElementById("ingamechatcontent").children.length != 0) {
var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children;
var lm2 = "";
for (var i = 0; i < lm.length; i++) {
lm2 += " " + lm[i].textContent.trim();
}
return lm2.trim();
}
return "";
};
scope.map = function (e, t = timedelay) {
if (e < 0) {
notify("There is no previous map.");
quicki = 0;
return;
}
if (Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined) {
notify("Click the maps button.");
return;
}
setTimeout(function () {
if (!canceled) {
startedinqp = true;
if (roundsperqp2 >= roundsperqp) {
roundsperqp2 = 0;
}
Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
Gdocument.getElementById("newbonklobby_editorbutton").click();
if (recmodebool && ishost) {
var mode = Gdocument.getElementById("mapeditor_modeselect").value;
if (mode == "" && defaultmode != "d") {
mode = defaultmode;
}
if (mode != "") {
RECIEVE('42[26,"b","' + mode + '"]');
}
}
var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
Gdocument.getElementById("newbonklobby").style["display"] = "none";
if (displayblock) {
Gdocument.getElementById("newbonklobby").style["display"] = "block";
}
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
}
canceled = false;
transitioning = false;
}, t);
};
scope.gotonextmap = function (e) {
if (e < 0) {
notify("There is no previous map.");
quicki = 0;
return;
}
if (Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined) {
notify("Click the maps button.");
return;
}
Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
Gdocument.getElementById("newbonklobby_editorbutton").click();
if (recmodebool && ishost) {
var mode = Gdocument.getElementById("mapeditor_modeselect").value;
if (mode == "" && defaultmode != "d") {
mode = defaultmode;
}
if (mode != "") {
RECIEVE('42[26,"b","' + mode + '"]');
}
}
startedinqp = true;
if (roundsperqp2 >= roundsperqp) {
roundsperqp2 = 0;
}
var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
Gdocument.getElementById("newbonklobby").style["display"] = "none";
if (displayblock) {
Gdocument.getElementById("newbonklobby").style["display"] = "block";
}
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
};
scope.commands = scope.commands || {};
scope.registerCommand = function (names, opts, run) {
if (typeof opts === "function") { run = opts; opts = {}; }
opts = opts || {};
opts.run = run;
(Array.isArray(names) ? names : [names]).forEach(function (n) { commands[n] = opts; });
};
scope.parseCommand = function (chat_val) {
var m = chat_val.slice(1).match(/^(\S+)\s*([\s\S]*)$/);
if (!m) { return null; }
var rest = m[2].replace(/\s+$/, "");
return { name: m[1], rest: rest, args: rest.length ? rest.split(/\s+/) : [], raw: chat_val };
};
scope.commandhandle = function (chat_val) {
var parsed = parseCommand(chat_val);
if (parsed) {
if (disabledCommands[parsed.name.toLowerCase()]) { return chat_val; }
var cmd = commands[parsed.name];
if (cmd) {
if (cmd.host && !ishost) { return chat_val; }
if (cmd.sandbox && !sandboxon) { return chat_val; }
if (cmd.minArgs && parsed.args.length < cmd.minArgs) { return chat_val; }
var out = cmd.run(parsed);
return out === undefined ? "" : out;
}
}
return legacyCommandHandle(chat_val);
};
scope.TEAM_IDS = { s: 0, f: 1, r: 2, b: 3, g: 4, y: 5 };
scope.teamFromLetter = function (ch) {
var t = TEAM_IDS[String(ch).toLowerCase()];
return t === undefined ? -1 : t;
};
scope.setTeam = function (id, team) {
SEND('42[26,{"targetID":' + id + ',"targetTeam":' + team + '}]');
if (playerids[id] && playerids[id].peerID != "sandbox") {
RECIEVE('42[18,' + id + ',' + team + ']');
}
};
scope.MODE_CODES = { classic: "b", grapple: "sp", arrows: "ar", "death arrows": "ard", vtol: "v", football: "f"};
scope.MODE_LABELS = { b: "Classic", sp: "Grapple", ar: "Arrows", ard: "Death Arrows", v: "VTOL", f: "Football"};
scope.modeFromName = function (name) { return MODE_CODES[String(name).toLowerCase()] || ""; };
scope.modeLabel = function (code) { return MODE_LABELS[code] || ""; };
scope.chatLink = function (label, code) {
return '<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">' + label + '</a>';
};
scope.imageBuffers = {};
scope.receivedImages = {};
scope.imageToDataURL = function (file, maxDim, quality) {
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onerror = reject;
reader.onload = function () {
var img = new Image();
img.onerror = reject;
img.onload = function () {
var s = Math.min(1, maxDim / Math.max(img.width, img.height));
var cw = Math.max(1, Math.round(img.width * s)), ch = Math.max(1, Math.round(img.height * s));
var canvas = Gdocument.createElement("canvas");
canvas.width = cw; canvas.height = ch;
canvas.getContext("2d").drawImage(img, 0, 0, cw, ch);
resolve(canvas.toDataURL("image/jpeg", quality));
};
img.src = reader.result;
};
reader.readAsDataURL(file);
});
};
scope.isSafeImageSrc = function (src) {
return typeof src === "string" &&
(/^data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=\s]+$/.test(src) || /^https:\/\/[^\s"'<>]+$/.test(src));
};
scope.embedImage = function (from, src, showNow) {
if (!isSafeImageSrc(src)) { return; }
var safeFrom = htmlEscape(String(from || "?"));
var imgTag = '<img src="' + htmlEscape(src) + '" style="max-width:260px;max-height:260px;border-radius:6px;display:block;margin-top:4px;">';
if (showNow) {
displayInChat(safeFrom + ' sent an image:<br>' + imgTag, "#DA0808", "#1EBCC1", { sanitize: false });
return;
}
var imgId = "img_" + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
receivedImages[imgId] = src;
displayInChat(safeFrom + ' sent an image: ' + chatLink("[Show]", 'Gwindow.showChatImage("' + imgId + '", this)'), "#DA0808", "#1EBCC1", { sanitize: false });
};
scope.showChatImage = function (imgId, linkEl) {
var src = receivedImages[imgId];
if (!src || !linkEl || !linkEl.replaceWith || !isSafeImageSrc(src)) { return; }
var box = linkEl.closest ? linkEl.closest("#newbonklobby_chat_content, #ingamechatcontent") : null;
var atBottom = box ? (box.clientHeight + box.scrollTop >= box.scrollHeight - 2) : false;
var img = Gdocument.createElement("img");
img.src = src;
img.style.cssText = "max-width:260px;max-height:260px;border-radius:6px;display:block;margin-top:4px;";
if (box && atBottom) { img.onload = function () { box.scrollTop = box.scrollHeight; }; }
linkEl.replaceWith(img);
if (box && atBottom) { box.scrollTop = box.scrollHeight; }
};
scope.sendImage = async function (file) {
if (!file || !/^image\//.test(file.type || "")) { notify("That is not an image."); return; }
var dataUrl;
try { dataUrl = await imageToDataURL(file, 300, 0.6); } catch (e) { notify("Could not read that image."); return; }
if (dataUrl.length > 60000) { try { dataUrl = await imageToDataURL(file, 220, 0.45); } catch (e) { } }
if (dataUrl.length > 110000) { notify("Image is too detailed to send. Try a smaller one."); return; }
embedImage(username, dataUrl, true);
var id = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
var chunk = 3000, total = Math.ceil(dataUrl.length / chunk);
for (var i = 0; i < total; i++) {
SEND("42" + JSON.stringify([4, { type: "image", from: username, id: id, ci: i, n: total, d: dataUrl.slice(i * chunk, (i + 1) * chunk) }]));
await new Promise(function (r) { setTimeout(r, 45); });
}
};
scope.receiveImageChunk = function (senderId, msg) {
if (!msg || typeof msg.id != "string" || typeof msg.ci != "number" || typeof msg.n != "number" || typeof msg.d != "string") { return; }
if (msg.n < 1 || msg.n > 60 || msg.d.length > 4000) { return; }
var now = Date.now();
for (var k in imageBuffers) { if (now - imageBuffers[k].ts > 15000) { delete imageBuffers[k]; } }
var b = imageBuffers[msg.id];
if (!b) {
if (playerids[senderId] && !rateOK(playerids[senderId], "image", 2000)) { return; }
b = imageBuffers[msg.id] = { from: playerids[senderId] ? playerids[senderId].userName : msg.from, n: msg.n, parts: [], count: 0, ts: now, size: 0 };
}
if (msg.ci < 0 || msg.ci >= b.n || b.parts[msg.ci] !== undefined) { return; }
b.parts[msg.ci] = msg.d; b.count++; b.size += msg.d.length; b.ts = now;
if (b.size > 130000) { delete imageBuffers[msg.id]; return; }
if (b.count >= b.n) {
var full = b.parts.join("");
delete imageBuffers[msg.id];
embedImage(b.from, full, false);
}
};
scope.mentionFlashTimer = null;
scope.flashTitle = function (text) {
try {
if (typeof scope.realTitle != "string") { scope.realTitle = document.title; }
if (mentionFlashTimer) { clearInterval(mentionFlashTimer); }
var on = false, count = 0;
mentionFlashTimer = setInterval(function () {
document.title = on ? scope.realTitle : text; on = !on;
if (++count >= 12) { clearInterval(mentionFlashTimer); mentionFlashTimer = null; document.title = scope.realTitle; }
}, 600);
} catch (e) { }
};
scope.mentionBeep = function () {
try {
var Ctx = window.AudioContext || window.webkitAudioContext;
if (!Ctx) { return; }
var ctx = new Ctx(), o = ctx.createOscillator(), g = ctx.createGain();
o.type = "sine"; o.frequency.value = 880; g.gain.value = 0.06;
o.connect(g); g.connect(ctx.destination);
o.start(); o.stop(ctx.currentTime + 0.15);
setTimeout(function () { try { ctx.close(); } catch (e) { } }, 400);
} catch (e) { }
};
if (!scope.mentionFocusHooked) {
scope.mentionFocusHooked = true;
window.addEventListener("focus", function () {
if (mentionFlashTimer) { clearInterval(mentionFlashTimer); mentionFlashTimer = null; if (typeof scope.realTitle == "string") { document.title = scope.realTitle; } }
});
}
scope.onMentioned = function (message) {
flashTitle("You were mentioned");
mentionBeep();
displayInChat("You were mentioned.", "#CC6600", "#CC6600");
if (typeof Notification !== "undefined") {
if (Notification.permission === "granted") {
try { var n = new Notification("Bonk - you were mentioned", { body: String(message) }); n.onclick = function () { window.focus(); n.close(); }; } catch (e) { }
} else if (Notification.permission !== "denied") {
try { Notification.requestPermission(); } catch (e) { }
}
}
};
scope.defaultStats = function () {
return { mapsPlayed: 0, totalWins: 0, totalDeaths: 0, chatSent: 0, slurs: 0,
playtimeMs: 0, gamesFinished: 0, modeCounts: {}, perMap: {} };
};
if (!scope.stats) { scope.stats = defaultStats(); }
scope.statsState = { currentHash: null, currentMapRef: null, gameCounted: false, lastDeathMs: 0, lastStartMs: 0, lastPlayMs: 0, lastSaveMs: 0, lastPos: null, recent: [] };
scope.slurList = ["nigger", "nigga", "faggot", "retard", "fuck", "shit"];
scope.countSlurs = function (text) {
if (typeof text != "string") { return 0; }
var t = text.toLowerCase(), n = 0;
for (var i = 0; i < slurList.length; i++) {
var re = new RegExp("\\b" + slurList[i].replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\b", "g");
var m = t.match(re); if (m) { n += m.length; }
}
return n;
};
scope.hashString = function (s) {
var h = 5381;
for (var i = 0; i < s.length; i++) { h = ((h << 5) + h + s.charCodeAt(i)) | 0; }
return (h >>> 0).toString(36);
};
scope.mapHash = function (map) { try { return hashString(JSON.stringify(map.physics)); } catch (e) { return null; } };
scope.mapCounter = function (hash) {
if (!stats.perMap[hash]) { stats.perMap[hash] = { deaths: 0, wins: 0, plays: 0 }; }
return stats.perMap[hash];
};
scope.openStatsDB = function () {
return new Promise(function (resolve) {
try {
var req = indexedDB.open("BonkCommandsStats", 1);
req.onupgradeneeded = function () { req.result.createObjectStore("kv"); };
req.onsuccess = function () { resolve(req.result); };
req.onerror = function () { resolve(null); };
} catch (e) { resolve(null); }
});
};
scope.loadStats = function () {
openStatsDB().then(function (db) {
if (!db) { return; }
try {
var g = db.transaction("kv", "readonly").objectStore("kv").get("stats");
g.onsuccess = function () { if (g.result) { scope.stats = Object.assign(defaultStats(), g.result); } };
} catch (e) { }
});
};
scope.saveStatsTimer = null;
scope.saveStats = function () {
if (saveStatsTimer) { return; }
saveStatsTimer = setTimeout(function () {
saveStatsTimer = null;
openStatsDB().then(function (db) {
if (!db) { return; }
try { db.transaction("kv", "readwrite").objectStore("kv").put(scope.stats, "stats"); } catch (e) { }
});
}, 1500);
};
scope.loadPlaylists = function () {
openStatsDB().then(function (db) {
if (!db) { return; }
try {
var g = db.transaction("kv", "readonly").objectStore("kv").get("playlists");
g.onsuccess = function () { if (g.result && typeof g.result == "object") { scope.playlists = g.result; } };
} catch (e) { }
});
};
scope.savePlaylistsTimer = null;
scope.savePlaylists = function () {
if (savePlaylistsTimer) { return; }
savePlaylistsTimer = setTimeout(function () {
savePlaylistsTimer = null;
openStatsDB().then(function (db) {
if (!db) { return; }
try { db.transaction("kv", "readwrite").objectStore("kv").put(scope.playlists, "playlists"); } catch (e) { }
});
}, 800);
};
scope.PLAYLIST_CODE_TAG = "BONKPL1:";
scope.encodePlaylistsCode = function (obj) {
return scope.PLAYLIST_CODE_TAG + btoa(unescape(encodeURIComponent(JSON.stringify(obj))));
};
scope.decodePlaylistsCode = function (code) {
code = String(code || "").replace(/^\s+|\s+$/g, "");
var idx = code.indexOf(scope.PLAYLIST_CODE_TAG);
if (idx != -1) { code = code.slice(idx + scope.PLAYLIST_CODE_TAG.length); }
code = code.replace(/\s+/g, "");
var obj = JSON.parse(decodeURIComponent(escape(atob(code))));
if (!obj || typeof obj != "object" || Array.isArray(obj)) { throw new Error("not a playlist object"); }
for (var k in obj) {
if (!Array.isArray(obj[k])) { throw new Error("playlist \"" + k + "\" is not a list"); }
for (var j = 0; j < obj[k].length; j++) {
if (typeof obj[k][j] != "string") { throw new Error("playlist \"" + k + "\" has a non-string map"); }
}
}
return obj;
};
scope.importPlaylistsFromCode = function (code) {
var obj;
try { obj = decodePlaylistsCode(code); }
catch (e) { notify("Invalid playlist code" + (e && e.message ? " (" + e.message + ")." : ".")); return null; }
var newPlaylists = 0, newMaps = 0;
for (var name in obj) {
if (!playlists[name]) { playlists[name] = []; newPlaylists++; }
var existing = playlists[name];
var seen = {};
for (var a = 0; a < existing.length; a++) { seen[existing[a]] = 1; }
for (var b = 0; b < obj[name].length; b++) {
var enc = obj[name][b];
if (!seen[enc]) { existing.push(enc); seen[enc] = 1; newMaps++; }
}
}
savePlaylists();
return { playlists: newPlaylists, maps: newMaps };
};
scope.copyToClipboard = function (text) {
try {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).catch(function () { });
return true;
}
} catch (e) { }
try {
var ta = Gdocument.createElement("textarea");
ta.value = text;
ta.style["position"] = "fixed";
ta.style["opacity"] = "0";
Gdocument.body.appendChild(ta);
ta.select();
Gdocument.execCommand("copy");
Gdocument.body.removeChild(ta);
return true;
} catch (e2) { return false; }
};
scope.currentMapObj = function () { return currentmap && currentmap.length ? currentmap[currentmap.length - 1] : null; };
scope.playlistAddCurrent = function (name) {
name = (name || "").trim();
if (!name) { notify("Usage: /addmap <playlist name>"); return; }
var m = currentMapObj();
if (!m) { notify("No map is loaded."); return; }
if (!playlists[name]) { playlists[name] = []; }
var h = mapHash(m);
for (var i = 0; i < playlists[name].length; i++) {
try { if (mapHash(decodeFromDatabase(playlists[name][i])) == h) { notify("That map is already in \"" + name + "\"."); return; } } catch (e) { }
}
try { playlists[name].push(encodeToDatabase(m)); } catch (e) { notify("Failed to add map: " + e.message); return; }
savePlaylists();
notify("Added map to \"" + name + "\" (" + playlists[name].length + " maps).");
};
scope.playlistDelCurrent = function (name) {
name = (name || "").trim();
if (!name) { notify("Usage: /delmap <playlist name>"); return; }
var m = currentMapObj();
if (!m) { notify("No map is loaded."); return; }
if (!playlists[name]) { notify("No playlist named \"" + name + "\"."); return; }
var h = mapHash(m);
var before = playlists[name].length;
playlists[name] = playlists[name].filter(function (enc) {
try { return mapHash(decodeFromDatabase(enc)) != h; } catch (e) { return true; }
});
savePlaylists();
if (playlists[name].length < before) { notify("Removed map from \"" + name + "\" (" + playlists[name].length + " left)."); }
else { notify("Current map is not in \"" + name + "\"."); }
};
scope.resolvePlaylistName = function (query) {
var names = Object.keys(playlists);
if (!names.length) { return { name: "", reason: "none" }; }
var q = String(query || "").replace(/^\s+|\s+$/g, "").toLowerCase();
if (!q) { return { name: "", reason: "nomatch" }; }
var byLen = function (a, b) { return a.length - b.length; };
for (var i = 0; i < names.length; i++) { if (names[i].toLowerCase() === q) { return { name: names[i] }; } }
var pref = names.filter(function (n) { return n.toLowerCase().indexOf(q) === 0; });
if (pref.length === 1) { return { name: pref[0] }; }
if (pref.length > 1) { return { name: "", reason: "ambiguous", options: pref.sort(byLen) }; }
var sub = names.filter(function (n) { return n.toLowerCase().indexOf(q) !== -1; });
if (sub.length === 1) { return { name: sub[0] }; }
if (sub.length > 1) { return { name: "", reason: "ambiguous", options: sub.sort(byLen) }; }
var best = "", bestD = Infinity;
for (var j = 0; j < names.length; j++) { var d = stringdistance(q, names[j].toLowerCase()); if (d < bestD) { bestD = d; best = names[j]; } }
if (best && bestD <= Math.max(2, Math.floor(q.length / 2))) { return { name: best }; }
return { name: "", reason: "nomatch" };
};
scope.decodeMapInput = function (input) {
input = (input || "").replace(/^\s+|\s+$/g, "");
if (!input) { return null; }
try { var j = JSON.parse(input); if (j && j.physics) { return j; } } catch (e) { }
var s = input;
if (s.length >= 2 && ((s.charAt(0) == '"' && s.charAt(s.length - 1) == '"') || (s.charAt(0) == "'" && s.charAt(s.length - 1) == "'"))) {
s = s.substring(1, s.length - 1);
}
try { var d = decodeFromDatabase(s); if (d && d.physics) { return d; } } catch (e) { }
try { var d2 = decodeFromDatabase(input); if (d2 && d2.physics) { return d2; } } catch (e) { }
return null;
};
scope.downloadTextFile = function (filename, content) {
try {
var a = Gdocument.createElement("a");
a.href = "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content);
a.download = filename;
Gdocument.body.appendChild(a);
a.click();
setTimeout(function () { try { Gdocument.body.removeChild(a); } catch (e) { } }, 100);
return true;
} catch (e) { return false; }
};
scope.copyTextToClipboard = function (text) {
try { return (Gwindow.navigator.clipboard || navigator.clipboard).writeText(text); }
catch (e) { return Promise.reject(e); }
};
scope.serializeCurrentMap = function (fmt) {
var m = currentMapObj();
if (!m) { return null; }
return (fmt == "json") ? JSON.stringify(m) : encodeToDatabase(m);
};
scope.recordChat = function (message) { stats.chatSent++; stats.slurs += countSlurs(message); saveStats(); };
scope.gameActive = function () {
var gr = Gdocument.getElementById("gamerenderer");
if (!gr || gr.style["visibility"] == "hidden") { return false; }
var cd = Gdocument.getElementById("ingamecountdown");
if (cd && cd.style["visibility"] != "hidden") { return false; }
var w = Gdocument.getElementById("ingamewinner");
if (w && w.style["visibility"] == "inherit") { return false; }
return true;
};
scope.recordDeath = function () {
if (!gameActive()) { return; }
var now = Date.now();
if (now - (statsState.lastStartMs || 0) < 2500) { return; }
if (now - (statsState.lastDeathMs || 0) < 1000) { return; }
statsState.lastDeathMs = now;
stats.totalDeaths++;
if (statsState.currentHash) { mapCounter(statsState.currentHash).deaths++; }
saveStats();
};
scope.recordGameStart = function (map, modeCode) {
if (modeCode) { stats.modeCounts[modeCode] = (stats.modeCounts[modeCode] || 0) + 1; }
var h = mapHash(map);
if (h) {
var mc = mapCounter(h);
if (mc.plays === 0) { stats.mapsPlayed++; }
mc.plays++;
statsState.currentHash = h;
statsState.currentMapRef = map;
}
statsState.gameCounted = false;
statsState.lastStartMs = Date.now();
statsState.lastPos = null; statsState.recent = [];
saveStats();
};
scope.didIWin = function (topText) {
if (!topText) { return false; }
if (topText === username) { return true; }
var word = { 2: "red", 3: "blue", 4: "green", 5: "yellow" }[playerids[myid] ? playerids[myid].team : -1];
return !!word && topText.toLowerCase().indexOf(word) !== -1;
};
scope.statsTick = function () {
try {
var now = Date.now();
var m = currentmap[currentmap.length - 1];
if (m && m !== statsState.currentMapRef) {
statsState.currentMapRef = m;
statsState.currentHash = mapHash(m);
}
if (gameActive()) {
if (statsState.lastPlayMs) { stats.playtimeMs += now - statsState.lastPlayMs; }
statsState.lastPlayMs = now;
} else {
statsState.lastPlayMs = 0;
}
if (now - (statsState.lastSaveMs || 0) > 15000) { statsState.lastSaveMs = now; saveStats(); }
var winEl = Gdocument.getElementById("ingamewinner");
if (winEl && winEl.style["visibility"] == "inherit") {
if (!statsState.gameCounted) {
statsState.gameCounted = true;
stats.gamesFinished++;
var topEl = Gdocument.getElementById("ingamewinner_top");
var botEl = Gdocument.getElementById("ingamewinner_bottom");
var topT = topEl ? topEl.textContent : "";
if ((botEl ? botEl.textContent : "") != "DRAW" && didIWin(topT)) {
stats.totalWins++;
if (statsState.currentHash) { mapCounter(statsState.currentHash).wins++; }
}
saveStats();
}
} else {
statsState.gameCounted = false;
}
var p = playerids[myid];
if (gameActive() && p && p.playerData && p.playerData.transform && p.playerData2 && p.playerData2.alive) {
var pos = p.playerData.transform.position;
if (statsState.lastPos) {
var dx = pos.x - statsState.lastPos[0], dy = pos.y - statsState.lastPos[1];
var dist = Math.sqrt(dx * dx + dy * dy);
var normal = 0, recent = statsState.recent;
for (var i = 0; i < recent.length; i++) { if (recent[i] > normal) { normal = recent[i]; } }
if (dist > Math.max(normal * 3, 25 * (scale || 1))) { recordDeath(); }
else { recent.push(dist); if (recent.length > 40) { recent.shift(); } }
}
statsState.lastPos = [pos.x, pos.y];
} else {
statsState.lastPos = null;
}
} catch (e) { }
};
scope.formatDuration = function (ms) {
var s = Math.floor(ms / 1000), h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60);
var sec = s % 60;
return h ? (h + "h " + m + "m") : (m ? (m + "m " + sec + "s") : (sec + "s"));
};
loadStats();
loadPlaylists();
scope.rateOK = function (player, key, ms) {
if (!player || !player.ratelimit) { return true; }
if ((player.ratelimit[key] || 0) + ms < Date.now()) { player.ratelimit[key] = Date.now(); return true; }
return false;
};
scope.getAvailableMaps = function () {
var kids = Gdocument.getElementById("maploadwindowmapscontainer").children;
var available = [], availableindexes = [], notempty = false;
for (var i = 0; i < kids.length; i++) {
var on = false;
[...kids[i].children].forEach(function (el) {
if (el.className == "quickplaycheckbox quickplaychecked") { on = el.checked; }
});
available.push(on);
if (on) { availableindexes.push(i); notempty = true; }
}
return { available: available, availableindexes: availableindexes, notempty: notempty };
};
scope.pickNextMap = function (forward) {
var count = Gdocument.getElementById("maploadwindowmapscontainer").children.length;
var avail = getAvailableMaps().availableindexes;
if (avail.length == 0) { return quicki; }
if (shuffle) {
var pool = avail.slice();
if (pool.length != 1) {
var idx = pool.indexOf(quicki % count);
if (idx != -1) { pool.splice(idx, 1); }
}
return pool[Math.floor(Math.random() * pool.length)];
}
var goHigher = forward ? !reverseqp : reverseqp;
var cands = avail.filter(function (i) { return goHigher ? i > quicki : i < quicki; });
if (cands.length > 0) {
return goHigher ? cands[0] : cands[cands.length - 1];
}
return goHigher ? avail[0] : avail[avail.length - 1];
};
scope.registerToggle = function (cmdName, stateVar, noun, opts) {
opts = opts || {};
registerCommand(cmdName, { host: opts.host }, function () {
scope[stateVar] = !scope[stateVar];
notify(noun + (scope[stateVar] ? " is now on." : " is now off."));
if (opts.after) { opts.after(scope[stateVar]); }
return "";
});
};
registerToggle("space", "space_flag", "Space");
registerToggle("rcaps", "rcaps_flag", "Rcaps");
registerToggle("number", "number_flag", "Number");
registerToggle("cursefilter", "curse_flag", "Curse Filter");
registerToggle("autocorrect", "autocorrect", "Autocorrect");
registerToggle("randomchat", "randomchat", "Random chat");
registerToggle("speech", "text2speech", "Text to speech");
registerToggle("maxfps", "maxfps", "Max FPS");
registerToggle("aimbot", "aimbot", "Aimbot", { after: function (on) { if (on) { getplayerkeys(); } } });
registerToggle("heavybot", "heavybot", "Heavy bot", { after: function (on) { if (on) { getplayerkeys(); } } });
registerToggle("trajectory", "trajectory", "Trajectory line", { after: function (on) { if (!on && trajLine) { trajLine.clear(); } } });
registerCommand("stats", function (ctx) {
if (ctx.rest && ctx.rest.toLowerCase() === "reset") {
scope.stats = defaultStats();
saveStats();
notify("Statistics reset.");
return "";
}
var cur = statsState.currentHash ? mapCounter(statsState.currentHash) : { deaths: 0, wins: 0 };
var avg = stats.gamesFinished ? (stats.playtimeMs / stats.gamesFinished / 1000) : 0;
var modeStr = Object.keys(stats.modeCounts).map(function (m) { return (modeLabel(m) || m) + " " + stats.modeCounts[m]; }).join(", ") || "none";
notify("=== Your Bonk Stats ===");
notify("Maps played: " + stats.mapsPlayed);
notify("Wins: " + stats.totalWins + " | Deaths: " + stats.totalDeaths);
notify("On this map: Wins: " + cur.wins + " | Deaths: " + cur.deaths);
notify("Playtime: " + formatDuration(stats.playtimeMs) + ", Avg game: " + avg.toFixed(1) + "s");
notify("Chat messages sent: " + stats.chatSent);
notify("Modes played: " + modeStr);
notify("Slurs sent: " + stats.slurs);
return "";
});
registerCommand("vertexc", function () {
var m = currentmap[currentmap.length - 1];
if (!m || !m.physics || !m.physics.shapes) { notify("No map is loaded."); return ""; }
var count = m.physics.shapes.reduce(function (x, y) { return x + (y.v ? y.v.length : 0); }, 0);
notify("Number of Vertices in map: " + count);
return "";
});
scope.resolvePlaylistOrNotify = function (query) {
var res = resolvePlaylistName(query);
if (res.name) { return res.name; }
if (res.reason === "none") { notify("You have no playlists yet. Create one in the map window (PLAYLISTS > ADD)."); }
else if (res.reason === "ambiguous") { notify("\"" + query + "\" matches multiple playlists: " + res.options.join(", ") + ". Be more specific."); }
else { notify("No playlist close to \"" + query + "\". Your playlists: " + (Object.keys(playlists).join(", ") || "(none)") + "."); }
return "";
};
scope.suggestPlaylistNames = function () { return Object.keys(playlists); };
registerCommand("addmap", { minArgs: 1, suggest: suggestPlaylistNames }, function (ctx) {
var name = resolvePlaylistOrNotify(ctx.rest);
if (name) { playlistAddCurrent(name); }
return "";
});
registerCommand("delmap", { minArgs: 1, suggest: suggestPlaylistNames }, function (ctx) {
var name = resolvePlaylistOrNotify(ctx.rest);
if (name) { playlistDelCurrent(name); }
return "";
});
registerCommand("loadmap", function () {
var input;
try { input = Gwindow.prompt("Paste a map (database string or JSON):"); } catch (e) { input = prompt("Paste a map (database string or JSON):"); }
if (input == null) { return ""; }
var map = decodeMapInput(input);
if (!map) { notify("Could not load map: the pasted data was not a valid map."); return ""; }
if (ishost) { loadMap(map); notify("Map loaded."); }
else { requestMap(map); notify("Map requested."); }
return "";
});
registerCommand("savemap", function (ctx) {
var m = currentMapObj();
if (!m) { notify("No map is loaded."); return ""; }
var fmt = (ctx.rest || "string").toLowerCase();
if (fmt != "json") { fmt = "string"; }
var base = (m.m && m.m.n ? m.m.n : "map").replace(/[^a-z0-9_\-]+/gi, "_") || "map";
var out;
try { out = serializeCurrentMap(fmt); } catch (e) { notify("Failed to encode map: " + e.message); return ""; }
if (out == null) { notify("No map is loaded."); return ""; }
var ok = downloadTextFile(base + (fmt == "json" ? ".json" : ".txt"), out);
notify(ok ? ("Saved map as " + fmt + ".") : "Failed to save map.");
return "";
});
registerCommand("copymap", function (ctx) {
var m = currentMapObj();
if (!m) { notify("No map is loaded."); return ""; }
var fmt = (ctx.rest || "string").toLowerCase();
if (fmt != "json") { fmt = "string"; }
var out;
try { out = serializeCurrentMap(fmt); } catch (e) { notify("Failed to encode map: " + e.message); return ""; }
if (out == null) { notify("No map is loaded."); return ""; }
copyTextToClipboard(out).then(
function () { notify("Copied map (" + fmt + ") to clipboard."); },
function () { notify("Clipboard blocked; could not copy the map."); }
);
return "";
});
registerCommand("img", function () {
var input = Gdocument.createElement("input");
input.type = "file";
input.accept = "image/*";
input.onchange = function () { if (input.files && input.files[0]) { sendImage(input.files[0]); } };
input.click();
return "";
});
registerCommand("team", { minArgs: 1 }, function (ctx) {
var btn = { r: "redbutton", g: "greenbutton", y: "yellowbutton", b: "bluebutton", s: "specbutton", f: "ffabutton" }[ctx.args[0]];
if (btn) { Gdocument.getElementById("newbonklobby_" + btn).click(); }
return "";
});
registerCommand("mode", { minArgs: 1, suggest: function () { return Object.keys(MODE_CODES); } }, function (ctx) {
var name = ctx.rest.toLowerCase();
var code = modeFromName(name);
if (!code) {
notify("Mode options:");
["classic", "arrows", "death arrows", "grapple", "vtol"].forEach(function (m) { notify(m); });
return "";
}
if (ishost) {
SEND('42[20,{"ga":"b","mo":"' + code + '"}]');
RECIEVE('42[26,"b","' + code + '"]');
notify("Changed mode to " + name + ".");
} else if (rateOK(playerids[myid], "mode", 1000)) {
SEND("42" + JSON.stringify([4, { "type": "request mode", "from": username, "mode": code }]));
var js = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("' + code + '")}';
displayInChat('> ' + htmlEscape(username) + ' requests [' + chatLink(modeLabel(code), js) + ']', "#DA0808", "#1EBCC1", { sanitize: false }, " mode.");
} else {
notify("You are requesting modes too quickly.");
}
return "";
});
registerCommand("moveA", { host: true, minArgs: 1 }, function (ctx) {
var t = teamFromLetter(ctx.args[0]);
if (t == -1) {
notify("The format for this command is:");
notify("/moveA [letter]");
notify("For example: '/moveA r' would move everyone to red team.");
return "";
}
Object.keys(playerids).forEach(function (id) { setTeam(id, t); });
return "";
});
registerCommand("moveT", { host: true }, function (ctx) {
var from = teamFromLetter(ctx.args[0]);
var to = teamFromLetter(ctx.args[1]);
if (ctx.args.length < 2 || from == -1 || to == -1) {
notify("The format for this command is:");
notify("/moveT [letter] [letter]");
notify("For example: '/moveT s r' would move everyone in spectate to red team.");
return "";
}
Object.keys(playerids).forEach(function (id) {
if (playerids[id].team == from) { setTeam(id, to); }
});
return "";
});
scope.legacyCommandHandle = function (chat_val) {
if (chat_val.substring(1, 6) == "echo " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var eu = cleanArg(chat_val.substring(6));
eu = resolveUserName(eu) || eu;
if (eu == username) {
notify("You cannot echo yourself.");
return "";
}
else if (echo_list.indexOf(eu) === -1) {
echo_list.push(eu);
notify(eu + " is being echoed.");
return "";
}
else {
notify(eu + " is already being echoed.");
return "";
}
}
else if (chat_val.substring(1, 8) == "remove " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var ru = cleanArg(chat_val.substring(7));
ru = resolveUserName(ru) || ru;
if (echo_list.indexOf(ru) !== -1) {
echo_list.splice(echo_list.indexOf(ru), 1);
notify(ru + " is not being echoed.");
return "";
}
else {
notify("You cannot remove someone that you didn't echo.");
return "";
}
}
else if (chat_val.substring(1, 10) == "echotext " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
notify("Set echotext as: " + echotext);
notify("Type '/echotext' to reset echotext.");
return "";
}
else if (chat_val.substring(1, 9) == "echotext") {
echotext = "message";
notify("Reset echotext.");
return "";
}
else if (chat_val.substring(1, 10) == "clearecho") {
echo_list = [];
notify("Cleared the echo list.");
return "";
}
else if (chat_val.substring(1, 11) == "randomchat") {
if (randomchat == true) {
notify("Random chat is now off.");
randomchat = false;
}
else {
notify("Random chat is now on.");
randomchat = true;
}
return "";
}
else if (chat_val.substring(1, 12) == "autocorrect") {
if (autocorrect == true) {
notify("Autocorrect is now off.");
autocorrect = false;
}
else {
notify("Autocorrect is now on.");
autocorrect = true;
}
return "";
}
else if (chat_val.substring(1, 12) == "bonk1random") {
notify("Fetching random bonk 1 map...");
GET("https://legendboss123.com/bonk1-random").then(function (leveldata) {
if (leveldata == "1") {
notify("Ratelimited, please wait a bit.");
return;
}
leveldata = JSON.parse(leveldata)
if (ishost) {
loadMap(fromOldString(leveldata))
notify("Loaded random bonk 1 map...");
}
else {
requestMap(fromOldString(leveldata));
notify("Requested random bonk 1 map...");
}
});
return "";
}
else if (chat_val.substring(1, 12) == "bonk2random") {
notify("Fetching random bonk 2 map...");
GET("https://legendboss123.com/bonk2-random").then(function (leveldata) {
if (leveldata == "1") {
notify("Ratelimited, please wait a bit.");
return;
}
leveldata = JSON.parse(leveldata)
if (ishost) {
loadMap(decodeFromDatabase(leveldata))
notify("Loaded random bonk 2 map...");
}
else {
requestMap(decodeFromDatabase(leveldata));
notify("Requested random bonk 2 map...");
}
});
return "";
}
else if (chat_val.substring(1, 13) == "bonk1parkour") {
notify("Fetching random bonk 1 parkour map...");
GET("https://legendboss123.com/bonk1-parkour").then(function (leveldata) {
if (leveldata == "1") {
notify("Ratelimited, please wait a bit.");
return;
}
leveldata = JSON.parse(leveldata);
if (ishost) {
loadMap(fromOldString(leveldata))
notify("Loaded random bonk 1 parkour map...");
}
else {
requestMap(fromOldString(leveldata));
notify("Requested random bonk 1 parkour map...");
}
});
return "";
}
else if (chat_val.substring(1, 13) == "bonk2parkour") {
notify("Fetching random bonk 2 parkour map...");
GET("https://legendboss123.com/bonk2-parkour").then(function (leveldata) {
if (leveldata == "1") {
notify("Ratelimited, please wait a bit.");
return;
}
leveldata = JSON.parse(leveldata)
if (ishost) {
loadMap(decodeFromDatabase(leveldata))
notify("Loaded random bonk 2 parkour map...");
}
else {
requestMap(decodeFromDatabase(leveldata));
notify("Requested random bonk 2 parkour map...");
}
});
return "";
}
else if (chat_val.substring(1, 10) == "scalemap " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = cleanArg(chat_val.substring(10));
var scale = Number(text);
if (isNaN(scale)) {
notify("Please enter a valid number.");
return "";
}
if (!ishost) {
requestMap(scalemap(currentmap[currentmap.length - 1], scale));
return "";
}
loadMap(scalemap(currentmap[currentmap.length - 1], scale));
return "";
}
else if (chat_val.substring(1, 8) == "setppm " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = cleanArg(chat_val.substring(8));
var ppm = Number(text);
if (isNaN(ppm) || ppm < 2 || ppm > 300) {
notify("Please enter a valid number.");
return "";
}
currentmap[currentmap.length - 1].physics.ppm = ppm;
if (!ishost) {
requestMap(currentmap[currentmap.length - 1]);
return "";
}
loadMap(currentmap[currentmap.length - 1]);
return "";
}
else if (chat_val.substring(1, 4) == "ppm") {
if (currentmap[currentmap.length - 1]?.physics?.ppm) {
notify("PPM: " + currentmap[currentmap.length - 1].physics.ppm);
}
return "";
}
else if (chat_val.substring(1, 14) == "translatemap " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
var text = cleanArg(chat_val.substring(14));
var text2 = text.split(" ");
var array = [];
for (var i = 0; i < text2.length; i++) {
var parsed = Number(text2[i]);
if (!isNaN(parsed)) {
array.push(parsed);
}
}
if (array.length != 2) {
notify("Please enter 2 valid numbers.");
return "";
}
if (!ishost) {
requestMap(translatemap(currentmap[currentmap.length - 1], array[0], array[1]));
return "";
}
loadMap(translatemap(currentmap[currentmap.length - 1], array[0], array[1]));
return "";
}
else if (chat_val.substring(1, 11) == "rotatemap " && chat_val.replace(/^\s+|\s+$/g, '').length >= 10) {
var text = cleanArg(chat_val.substring(11));
var angle = Number(text);
if (isNaN(angle)) {
notify("Please enter a valid number.");
return "";
}
if (!ishost) {
requestMap(rotatemap(currentmap[currentmap.length - 1], angle));
return "";
}
loadMap(rotatemap(currentmap[currentmap.length - 1], angle));
return "";
}
else if (chat_val.substring(1, 13) == "translateto " && chat_val.replace(/^\s+|\s+$/g, '').length >= 14) {
var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
var keys = Object.keys(translatingkeys);
if (keys.includes(text)) {
translating2 = [true, translatingkeys[text]];
notify("You will now speak the " + text + " language.");
}
else {
notify("Invalid language. Here are the current language options:");
for (var i = 0; i < keys.length; i++) {
notify(keys[i]);
}
}
return "";
}
else if (chat_val.substring(1, 12) == "translateto") {
translating2 = [false, ""];
notify("You will not speak another language anymore.");
return "";
}
else if (chat_val.substring(1, 11) == "translate " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
var keys = Object.keys(translatingkeys);
if (keys.includes(text)) {
translating = [true, translatingkeys[text]];
notify("Translator has been set to the " + text + " language.");
}
else {
notify("Invalid language. Here are the current language options:");
for (var i = 0; i < keys.length; i++) {
notify(keys[i]);
}
}
return "";
}
else if (chat_val.substring(1, 10) == "translate") {
translating = [false, ""];
notify("Translator has been turned off.");
return "";
}
else if (chat_val.substring(1, 6) == "space") {
if (space_flag == true) {
notify("Space is now off.");
space_flag = false;
}
else {
notify("Space is now on.");
space_flag = true;
}
return "";
}
else if (chat_val.substring(1, 6) == "rcaps") {
if (rcaps_flag == true) {
notify("Rcaps is now off.");
rcaps_flag = false;
}
else {
notify("Rcaps is now on.");
rcaps_flag = true;
}
return "";
}
else if (chat_val.substring(1, 7) == "number") {
if (number_flag == true) {
notify("Number is now off.");
number_flag = false;
}
else {
notify("Number is now on.");
number_flag = true;
}
return "";
}
else if (chat_val.substring(1, 12) == "cursefilter") {
if (curse_flag == true) {
notify("Curse Filter is now off.");
curse_flag = false;
}
else {
notify("Curse Filter is now on.");
curse_flag = true;
}
return "";
}
else if (chat_val.substring(1, 8) == "reverse") {
if (reverse_flag == true) {
notify("Reverse is now off.");
reverse_flag = false;
}
else {
notify("Reverse is now on.");
reverse_flag = true;
}
return "";
}
else if (chat_val.substring(1, 7) == "speech") {
if (text2speech == true) {
notify("Text to speech is now off.");
text2speech = false;
}
else {
notify("Text to speech is now on.");
text2speech = true;
}
return "";
}
else if (chat_val.substring(1, 7) == "maxfps") {
if (maxfps) {
notify("Max FPS is now off.");
maxfps = false;
}
else {
notify("Max FPS is now on.");
maxfps = true;
}
return "";
}
else if (chat_val.substring(1, 6) == "eval " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var ev = "";
try {
ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
}
catch (e) {
notify(e.message);
}
try {
notify(ev.toString());
}
catch {
}
return "";
}
else if (chat_val.substring(1, 10) == "textmode " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
var parsed = parseInt(text);
if (!isNaN(parsed)) {
if (parsed <= 7 && parsed >= 1) {
textmode = parsed - 1;
notify("Type '/textmode' to reset textmode.");
}
else {
notify("Please enter a integer from 1-7 inclusive.");
}
}
else {
notify("Please enter a integer from 1-7 inclusive.");
}
return "";
}
else if (chat_val.substring(1, 9) == "textmode") {
textmode = -1;
notify("Reset textmode.");
return "";
}
else if (chat_val.substring(1, 10) == "savedroom") {
if (savedrooms.length == 0) {
notify("You do not have any saved rooms.");
return "";
}
else {
var keys = Object.keys(savedroomsdata);
for (var i = 0; i < keys.length; i++) {
var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["' + keys[i] + '"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf(' + keys[i] + '),1);';
displayInChat('<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">Remove</a>' + ' - ', "#DA0808", "#1EBCC1", { sanitize: false }, JSON.stringify(savedroomsdata[keys[i]].roomname) + " - " + savedroomsdata[keys[i]].players + "/" + savedroomsdata[keys[i]].maxplayers + " players.");
Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children[0].parentElement.style["parsed"] = true;
Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children[0].parentElement.style["parsed"] = true;
Laster_message = lastmessage();
}
}
return "";
}
else if (chat_val.substring(1, 15) == "clearsavedroom") {
if (savedrooms.length == 0) {
notify("You do not have any saved rooms.");
return "";
}
else {
var keys = Object.keys(savedroomsdata);
for (var i = 0; i < keys.length; i++) {
savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])), 1);
delete savedroomsdata[keys[i]];
}
}
return "";
}
else if (chat_val.substring(1, 10) == "followcam") {
var fcArg = trimArg(chat_val.substring(10));
if (fcArg) {
var fcId = resolveUserId(fcArg);
if (fcId === -1) { notify('Could not find a player matching "' + fcArg + '".'); return ""; }
FollowCam = true;
followTarget = fcId;
notify("Follow Camera is now following " + playerids[fcId].userName + ".");
return "";
}
if (FollowCam == true) {
notify("Follow Camera is now off.");
FollowCam = false;
followTarget = -1;
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
var addto = { "children": [] };
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
}
}
else {
notify("Follow Camera is now on.");
FollowCam = true;
followTarget = myid;
}
return "";
}
else if (chat_val.substring(1, 8) == "autocam") {
if (autocam == true) {
notify("Auto Cam is now off.");
autocam = false
}
else {
notify("Auto Cam is now on.");
autocam = true;
}
return "";
}
else if (chat_val.substring(1, 4) == "pan") {
if (pan_enabled == true) {
notify("Pan is now off.");
pan_enabled = false;
pan = { "x": 0, "y": 0 };
}
else {
notify("Pan is now on. Shift + Arrow Keys to pan.");
pan_enabled = true;
}
return "";
}
else if (chat_val.substring(1, 9) == "resetpan") {
pan = { "x": 0, "y": 0 };
notify("Reset pan.");
return "";
}
else if (chat_val.substring(1, 7) == "aimbot") {
if (aimbot == true) {
notify("Aimbot is now off.");
aimbot = false;
}
else {
notify("Aimbot is now on.");
aimbot = true;
getplayerkeys();
}
return "";
}
else if (chat_val.substring(1, 6) == "still") {
if (staystill == true) {
notify("Still is now off.");
staystill = false;
staystillpos = [0, 0];
releaseKey(leftRight[0]);
releaseKey(leftRight[1]);
}
else {
if (playerids[myid].playerData?.transform) {
notify("Still is now on.");
staystill = true;
staystillpos = [playerids[myid].playerData.transform.position.x / scale, playerids[myid].playerData.transform.position.y / scale];
getplayerkeys();
releaseKey(leftRight[0]);
releaseKey(leftRight[1]);
}
else {
notify("You have to be alive to use this command.");
}
}
return "";
}
else if (chat_val.substring(1, 9) == "heavybot") {
if (heavybot == true) {
notify("Heavy bot is now off.");
heavybot = false;
}
else {
notify("Heavy bot is now on.");
heavybot = true;
getplayerkeys();
}
return "";
}
else if (chat_val.substring(1, 5) == "info") {
for (var id in playerids) {
var str = `${id == hostid ? "[HOST] " : ""}${playerids[id].userName}: ${id}; LVL ${playerids[id].level}`;
notify(str);
}
return "";
}
else if (chat_val.substring(1, 6) == "find " && trimArg(chat_val.substring(5)).length) {
var findId = resolveUserId(trimArg(chat_val.substring(5)));
if (findId === -1) {
notify("No player found matching \"" + trimArg(chat_val.substring(5)) + "\".");
return "";
}
var fp = playerids[findId];
var teamName = { 0: "Spectator", 1: "FFA", 2: "Red", 3: "Blue", 4: "Green", 5: "Yellow" }[fp.team] ?? ("Team " + fp.team);
notify(`${findId == hostid ? "[HOST] " : ""}${fp.userName} - id ${findId}; ${teamName}; LVL ${fp.level}; bal ${fp.bal ?? 0}${fp.guest ? "; guest" : ""}${fp.commands ? "; has mod" : ""}`);
return "";
}
else if (chat_val.substring(1, 14) == "toggleplayers") {
var alpha = 0;
if (chat_val.substring(15).length > 0) {
alpha = Number(chat_val.substring(15));
if (isNaN(alpha) || alpha > 1 || alpha < 0) {
notify("Alpha must be a number between 0 and 1.");
return "";
}
notify("Alpha set to: " + alpha.toString());
}
var x = hideshowplayers(alpha);
switch (x) {
case 0:
notify("Cannot hide/show players in lobby.");
break;
case 1:
notify("Players hidden.");
break;
case 2:
notify("Players unhidden.");
break;
}
return "";
}
else if (chat_val.substring(1, 5) == "xray") {
var alpha = 0.5;
if (chat_val.substring(6).length > 0) {
alpha = Number(chat_val.substring(6));
if (isNaN(alpha) || alpha > 1 || alpha < 0) {
notify("Alpha must be a number between 0 and 1.");
return "";
}
notify("Alpha set to: " + alpha.toString());
}
Gdocument.getElementById("pretty_top_settings").click();
Gdocument.getElementById("settings_close").click();
if (Gdocument.getElementById("settings_graphicsquality").value == 1) {
notify("You must have medium or high quality enabled to use this feature.");
return "";
}
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
var addto = { "children": [] };
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var addto2 = { "children": [] };
for (var i = 0; i < addto.children.length; i++) {
if (addto.children[i].constructor.name == "e") {
addto2 = addto.children[i];
break;
}
}
var checkxray = addto2.children[0];
var addto3 = addto2.children[0].children;
if (addto3.length == 1) {
checkxray = checkxray.children[0];
addto3 = addto3[0].children;
}
var xrayon = false;
if (checkxray.xrayon) {
checkxray.xrayon = false;
xrayon = false;
}
else {
checkxray.xrayon = true;
xrayon = true;
}
if (xrayon) {
notify("Xray is now on.");
for (var i = 0; i < addto3.length; i++) {
if (addto3[i].children.length > 0) {
var ids = [];
var ids2 = [];
for (var i3 = 0; i3 < addto3[i].children.length; i3++) {
addto3[i].children[i3].visible = false;
if (addto3[i].children[i3].children.length > 0) {
for (var i4 = 0; i4 < addto3[i].children[i3].children.length; i4++) {
if (addto3[i].children[i3].children[i4].geometry?.id) {
ids.push(addto3[i].children[i3].children[i4].geometry.id);
}
else if (addto3[i].children[i3].children[i4].texture?.baseTexture?.uid) {
ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
}
}
}
}
for (var i3 = 0; i3 < addto3[i].children.length; i3++) {
if (addto3[i].children[i3].children.length == 0) {
if (addto3[i].children[i3].geometry?.id) {
if (ids.includes(addto3[i].children[i3].geometry.id + 1)) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = alpha;
}
}
else if (addto3[i].children[i3].texture?.baseTexture?.uid) {
if (ids2.includes(addto3[i].children[i3].texture.baseTexture.uid + 1)) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = alpha;
}
}
if (addto3[i].children[i3].batchDirty) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = 0.5;
if (addto3[i].children[i3 + 1]) {
addto3[i].children[i3 + 1].visible = true;
addto3[i].children[i3 + 1].alpha = alpha;
}
}
}
}
}
}
}
else {
notify("Xray is now off.");
for (var i = 0; i < addto3.length; i++) {
for (var i2 = 0; i2 < addto3[i].children.length; i2++) {
addto3[i].children[i2].visible = true;
addto3[i].children[i2].alpha = 1;
}
}
}
}
return "";
}
else if (chat_val.substring(1, 6) == "zoom ") {
var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
var addto = 0;
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
if (addto) {
if (text == "in") {
zoom *= 1.1;
}
else if (text == "out") {
zoom /= 1.1;
}
else if (text == "reset") {
zoom = 1;
}
else {
notify("Options for zooming:");
notify("in");
notify("out");
notify("reset");
return "";
}
addto.scale.x = zoom;
addto.scale.y = zoom;
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999 && !FollowCam) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
}
}
return "";
}
else if (chat_val.substring(1, 9) == "hidechat") {
Gdocument.getElementById("ingamechatcontent").style["max-height"] = "0px";
return "";
}
else if (chat_val.substring(1, 9) == "showchat") {
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
return "";
}
else if (chat_val.substring(1, 6) == "score") {
var element = Gdocument.getElementById("ingamewinner_scores");
if (element.style["opacity"] < 1) {
element.style["opacity"] = 1;
element.style["visibility"] = "visible";
}
else {
element.style["opacity"] = 0;
element.style["visibility"] = "unset";
}
return "";
}
else if (chat_val.substring(1, 7) == "scroll") {
if (scroll == false) {
scroll = true;
Gdocument.getElementById("ingamechatcontent").style["overflow-y"] = "scroll";
Gdocument.getElementById("ingamechatcontent").style["overflow-x"] = "hidden";
}
else if (scroll == true) {
scroll = false;
Gdocument.getElementById("ingamechatcontent").style["overflow-y"] = "hidden";
Gdocument.getElementById("ingamechatcontent").style["overflow-x"] = "hidden";
}
return "";
}
else if (chat_val.substring(1, 7) == "hostme") {
oldhostid = hostid;
RECIEVE('42[41,{"oldHost":' + hostid + ',"newHost":' + myid + '}]');
return "";
}
else if (chat_val.substring(1, 11) == "returnhost") {
if (myid == hostid && oldhostid != -1) {
RECIEVE('42[41,{"oldHost":' + myid + ',"newHost":' + oldhostid + '}]');
}
return "";
}
else if (chat_val.substring(1, 6) == "skin " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var user = cleanArg(chat_val.substring(6));
user = resolveUserName(user) || user;
var id = GETIDBYUSER(user);
if (id != -1 && playerids[id]) {
overideSkin = playerids[id].avatar;
notify("Skin from " + user + " has been stolen.");
}
else {
notify("Player " + user + " not found.");
}
return "";
}
else if (chat_val.substring(1, 5) == "skin") {
overideSkin = null;
notify("Skin has been reset.");
return "";
}
else if (chat_val.substring(1, 8) == "bllink " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
var user = cleanArg(chat_val.substring(8));
user = resolveUserName(user) || user;
var id = GETIDBYUSER(user);
if (id != -1 && playerids[id]) {
overideSkin = playerids[id].avatar;
avatarToBonkLeagueLink(playerids[id].avatar, playerids[id].userName + "'s skin", playerids[id].userName).then(function (link) {
notify("Bonk League link for " + playerids[id].userName + "'s skin:");
displayInChat(urlify(link), "#DA0808", "#1EBCC1", { sanitize: false });
});
}
else {
notify("Player " + user + " not found.");
}
return "";
}
else if (chat_val.substring(1, 7) == "chatw ") {
var text = cleanArg(chat_val.substring(7));
text = resolveUserName(text) || text;
if (username == text) {
notify("You cannot private chat with yourself.");
return "";
}
private_chat = text;
SEND("42" + JSON.stringify([4, { "type": "request public key", "from": username, "to": private_chat }]));
request_public_key_time_stamp = Date.now();
setTimeout(function () { if (private_chat_public_key[0] != private_chat) { notify("Failed to connect to " + private_chat + "."); private_chat = private_chat_public_key[0]; } }, 1600);
return "";
}
else if (chat_val.substring(1, 8) == "lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
if (!isNaN(parseInt(text))) {
int_text = parseInt(text);
if (int_text == 0) {
causelag = false;
causelag2 = 0;
notify("Lagbot is now off.");
notify("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.");
}
else if (int_text > 0 && int_text <= 10) {
causelag = true;
causelag2 = 45 * int_text;
notify("Lagbot is now on with a lag setting of " + int_text.toString() + " (~" + (45 * int_text).toString() + "MS).");
notify("Type '/lagbot 0' to turn off lagbot.");
}
else {
notify("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.");
notify("Type '/lagbot 0' to turn off lagbot.");
}
return "";
}
}
else if (chat_val.substring(1, 8) == "record " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
var text = cleanArg(chat_val.substring(8));
text = resolveUserName(text) || text;
var keys = Object.keys(playerids);
var recordingid2 = -1;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == text) {
recordingid2 = keys[i];
}
}
if (recordingid2 == -1) {
notify("Player not found. Please type a valid username.");
return "";
}
else {
recording = true;
recordingid = recordingid2;
notify(playerids[recordingid].userName + " is now being recorded.");
if (recordingdata.length > 0) {
notify("Any unsaved recording data is now cleared.");
}
recordingdata = [];
}
return "";
}
else if (chat_val.substring(1, 11) == "stoprecord") {
if (recording) {
notify(playerids[recordingid].userName + " is not being recorded anymore.");
notify("Type '/saverecording [text]' to save this recording.");
recording = false;
recordingid = -1;
recordingdata[0][1] = 0;
}
else {
notify("No one is being recorded.");
}
return "";
}
else if (chat_val.substring(1, 15) == "saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length >= 16) {
var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
if (Object.keys(recorddata).includes(text)) {
notify("This recording already exists. Please use a different name or type '/delrecording " + text + "'.");
}
else if (recordingdata.length > 0) {
recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
notify("Recording saved as: " + text);
}
else {
notify("There is no recording data to save. Please record data using '/record [username]'");
}
return "";
}
else if (chat_val.substring(1, 14) == "delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length >= 15) {
var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
if (Object.keys(recorddata).includes(text)) {
notify("Recording deleted.");
delete recorddata[text];
}
else {
notify("This recording does not exist.");
}
return "";
}
else if (chat_val.substring(1, 15) == "loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length >= 16) {
var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
if (!Object.keys(recorddata).includes(text)) {
notify("This recording does not exist.");
}
else {
if (recordingdata.length > 0) {
notify("Any unsaved recording data is now cleared.");
}
recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
notify("Recording data is now loaded.");
}
return "";
}
else if (chat_val.substring(1, 7) == "replay") {
if (recording) {
notify(playerids[recordingid].userName + " is not being recorded anymore.");
notify("Type '/saverecording [text]' to save this recording.");
recordingid = -1;
recording = false;
recordingdata[0][1] = 0;
}
replay();
return "";
}
else if (chat_val.substring(1, 5) == "msg " && chat_val.replace(/^\s+|\s+$/g, '').length >= 6) {
if (private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat) {
var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
pmlastmessage = text.slice(0, 400);
ENCRYPT_MESSAGE(private_chat_public_key[1], text).then(function (e) {
SEND("42" + JSON.stringify([4, { "type": "private chat", "from": username, "to": private_chat, "message": e }]));
});
displayInChat("> " + username + ": ", "#DA0808", "#1EBCC1", { sanitize: false }, text, false);
Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children[0].parentElement.style["parsed"] = true;
Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children[0].parentElement.style["parsed"] = true;
Laster_message = lastmessage();
}
return "";
}
else if (chat_val.substring(1, 10) == "ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = cleanArg(chat_val.substring(10));
text = resolveUserName(text) || text;
if (ignorepmlist.includes(text)) {
var index = ignorepmlist.indexOf(text);
ignorepmlist.splice(index, 1);
notify("You are not ignoring private messages from " + text + ".");
}
else {
ignorepmlist.push(text);
notify("You are now ignoring private messages from " + text + ".");
}
return "";
}
else if (chat_val.substring(1, 8) == "pmusers") {
pmusers = [];
SEND("42" + JSON.stringify([4, { "type": "request private chat users", "from": username }]));
pmuserstimestamp = Date.now();
setTimeout(function () {
if (pmusers.length == 0) {
notify("You cannot private chat with anyone.");
} else { displayInChat("You can private chat with:", "#DA0808", "#1EBCC1"); for (var i = 0; i < pmusers.length; i++) { var code = 'Gwindow.private_chat = ' + JSON.stringify(pmusers[i]) + '; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);'; displayInChat('<a onclick = \'' + htmlEscape(code) + '\' href = "javascript:void(0);" style = "color:green">' + htmlEscape(pmusers[i]) + '</a>', "#DA0808", "#1EBCC1", { sanitize: false }); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); } }
}, 1600);
return "";
}
else if (chat_val.substring(1, 12) == "cleansemap " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
var text = cleanArg(chat_val.substring(12));
if (!ishost) {
requestMap(cleansemap(currentmap[currentmap.length - 1], text));
return "";
}
Gdocument.getElementById("newbonklobby_editorbutton").click();
Gdocument.getElementById("mapeditor_close").click();
loadMap(cleansemap(currentmap[currentmap.length - 1], text));
return "";
}
else if (chat_val.substring(1, 11) == "cleansemap") {
if (!ishost) {
requestMap(cleansemap(currentmap[currentmap.length - 1], username));
return "";
}
Gdocument.getElementById("newbonklobby_editorbutton").click();
Gdocument.getElementById("mapeditor_close").click();
loadMap(cleansemap(currentmap[currentmap.length - 1], username));
return "";
}
else if (chat_val.substring(1, 7) == "style " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
var text2 = text.split(" ");
var array = [];
for (var i = 0; i < text2.length; i++) {
var parsed = parseInt(text2[i]);
if (!isNaN(parsed)) {
array.push(parsed);
}
}
if (array[0] + array[1] + array[2] == 0) {
array = [1, 1, 1];
}
if (array.length == 3) {
SEND("42" + JSON.stringify([4, { "type": "style", "from": username, "style": array }]));
allstyles[username] = array;
mystyle = [...array];
notify("Set style to (" + array.toString() + "). Type '/style' to reset style.");
}
else {
notify("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.");
}
return "";
}
else if (chat_val.substring(1, 6) == "style") {
SEND("42" + JSON.stringify([4, { "type": "style", "from": username, "style": [0, 0, 0] }]));
allstyles[username] = [0, 0, 0];
mystyle = [0, 0, 0];
notify("Reset style.");
return "";
}
else if (chat_val.substring(1, 8) == "friend " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = cleanArg(chat_val.substring(8));
text = resolveUserName(text) || text;
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == text) {
SEND('42[35,{"id":' + keys[i] + '}]');
notify("Sent fake friend request to " + text + ".");
}
}
return "";
}
else if (chat_val.substring(1, 6) == "lobby") {
lobby();
return "";
}
else if (chat_val.substring(1, 9) == "debugger") {
toggleDebugger();
return "";
}
else if (chat_val.substring(1, 6) == "team " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
if (text == "r") { Gdocument.getElementById("newbonklobby_redbutton").click(); }
else if (text == "g") { Gdocument.getElementById("newbonklobby_greenbutton").click(); }
else if (text == "y") { Gdocument.getElementById("newbonklobby_yellowbutton").click(); }
else if (text == "b") { Gdocument.getElementById("newbonklobby_bluebutton").click(); }
else if (text == "s") { Gdocument.getElementById("newbonklobby_specbutton").click(); }
else if (text == "f") { Gdocument.getElementById("newbonklobby_ffabutton").click(); }
return "";
}
else if (chat_val.substring(1, 7) == "notify") {
npermissions = 1;
return "";
}
else if (chat_val.substring(1, 11) == "stopnotify") {
npermissions = 0;
return "";
}
else if (chat_val.substring(1, 8) == "support") {
displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123", "#0000FF", "#FFFFFF");
displayInChat("mastery3", "#0000FF", "#FFFFFF");
displayInChat("UnmatchedBracket aka Left Paren", "#0000FF", "#FFFFFF");
displayInChat("iNeonz", "#0000FF", "#FFFFFF");
return "";
}
else if (chat_val.substring(1, 9) == "pollstat") {
if (pollactive[0] || pollactive2[0]) {
var count = [0, 0, 0, 0];
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (ishost) {
if (playerids[keys[i]].vote.poll != -1 && playerids[keys[i]].vote.poll < pollactive[3].length - 1) {
count[playerids[keys[i]].vote.poll]++;
}
}
else {
if (playerids[keys[i]].vote.poll != -1 && playerids[keys[i]].vote.poll < pollactive2[2].length - 1) {
count[playerids[keys[i]].vote.poll]++;
}
}
}
for (var i = 0; i < count.length; i++) {
if (count[i] > 1) {
notify(count[i].toString() + " people voted for option " + letters[i] + ".");
}
if (count[i] == 1) {
notify(count[i].toString() + " person voted for option " + letters[i] + ".");
}
}
if (ishost) {
notify("The poll will end in: " + ((pollactive[2] - Date.now()) / 1000).toString() + " seconds.");
}
notify("The poll is:");
if (ishost) {
for (var i = 0; i < pollactive[3].length; i++) {
notify(letters[i] + ") " + pollactive[3][i]);
}
}
else {
for (var i = 0; i < pollactive2[2].length; i++) {
notify(letters[i] + ") " + pollactive2[2][i]);
}
}
}
else {
notify("No poll has been started.");
if (ishost) {
notify("Type '/startpoll [seconds]' to start a poll.");
if (poll.length > 0) {
notify("The poll is:");
for (var i = 0; i < poll.length; i++) {
notify(letters[i] + ") " + poll[i]);
}
}
}
}
return "";
}
else if (chat_val.substring(1, 5) == "help" || chat_val.substring(1, 2) == "?") {
var hquery = (chat_val.charAt(1) == "?" ? chat_val.substring(2) : chat_val.substring(5)).replace(/^\s+|\s+$/g, "").toLowerCase();
var renderHelpCmd = function (command, restText, withDesc) {
var descHtml = (withDesc && adv_help[command]) ? '<span style="color:#7a8a8c;"> - ' + htmlEscape(adv_help[command]) + '</span>' : '';
displayInChat("/" + '<a onclick = \'Gwindow.displayadvhelp("' + htmlEscape(command) + '");\' style = "color:green;" href = "javascript:void(0);">' + htmlEscape(command) + '</a>' + restText + descHtml, "#DA0808", "#1EBCC1", { sanitize: false }, "", false);
};
if (hquery) {
var shown = 0;
for (var i = 0; i < help.length; i++) {
if (help[i].charAt(0) != "/") { continue; }
var splitted = help[i].substring(1).split(" ");
var command = splitted[0];
if (disabledCommands[command.toLowerCase()]) { continue; }
var restText = splitted.length > 1 ? " " + splitted.slice(1).join(" ") : "";
var desc = adv_help[command] || "";
if (command.toLowerCase().indexOf(hquery) == -1 && desc.toLowerCase().indexOf(hquery) == -1) { continue; }
renderHelpCmd(command, restText, true);
shown++;
}
if (shown == 0) { notify('No commands match "' + hquery + '".'); }
else { notify(shown + ' command' + (shown == 1 ? '' : 's') + ' matching "' + hquery + '". Click a name for details.'); }
return "";
}
notify('Tip: type "/help word" to search (e.g. /help arrow, /help map).');
for (var i = 0; i < help.length; i++) {
if (help[i].startsWith("/")) {
var splitted = help[i].substring(1).split(" ");
var command = splitted[0];
if (disabledCommands[command.toLowerCase()]) { continue; }
var restText = splitted.length > 1 ? " " + splitted.slice(1).join(" ") : "";
renderHelpCmd(command, restText, false);
}
else if (help[i].startsWith("Alt ")) {
displayInChat('<a onclick = \'Gwindow.displayadvhelp("' + htmlEscape(help[i]) + '");\' style = "color:green;" href = "javascript:void(0);">' + htmlEscape(help[i]) + '</a>', "#DA0808", "#1EBCC1", { sanitize: false }, "", false);
}
else {
notify(help[i]);
}
}
return "";
}
else if (chat_val.substring(1, 9) == "advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length >= 10) {
var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
if (typeof (adv_help[text]) != 'undefined' && !disabledCommands[text.toLowerCase()]) {
notify(adv_help[text]);
}
return "";
}
else if (chat_val.substring(1, 6) == "mode " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
var mode = "";
var text2 = text;
if (text == "arrows") {
text2 = "Arrows";
mode = "ar";
}
else if (text == "death arrows") {
mode = "ard";
text2 = "Death Arrows";
}
else if (text == "grapple") {
mode = "sp";
text2 = "Grapple";
}
else if (text == "classic") {
mode = "b";
text2 = "Classic";
}
else if (text == "vtol") {
mode = "v";
text2 = "VTOL";
}
else {
notify("Mode options:");
notify("classic");
notify("arrows");
notify("death arrows");
notify("grapple");
notify("vtol");
}
if (mode != "") {
if (ishost) {
SEND('42[20,{"ga":"b","mo":"' + mode + '"}]');
RECIEVE('42[26,"b","' + mode + '"]');
notify("Changed mode to " + text + ".");
}
else {
if (playerids[myid].ratelimit.mode + 1000 < Date.now()) {
playerids[myid].ratelimit.mode = Date.now();
SEND("42" + JSON.stringify([4, { "type": "request mode", "from": username, "mode": mode }]));
var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("' + mode + '")}';
displayInChat('> ' + htmlEscape(username) + ' requests [<a onclick = \'' + htmlEscape(code) + '\' style = "color:green;" href = "javascript:void(0);">' + text2 + '</a>]', "#DA0808", "#1EBCC1", { sanitize: false }, " mode.");
}
else {
notify("You are requesting modes too quickly.");
}
}
}
return "";
}
else if (ishost) {
if (chat_val.substring(1, 11) == "nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = Number(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
if (isNaN(text)) {
notify("Type a positive number.");
return "";
}
else if (text <= 0) {
notify("Type a positive number.");
return "";
}
nextafter = text;
notify("Set next after to: " + text.toString() + " seconds.");
notify("Type '/nextafter' to reset next after.");
return "";
}
else if (chat_val.substring(1, 10) == "nextafter") {
nextafter = 0;
notify("Reset next after.");
return "";
}
else if (chat_val.substring(1, 5) == "next" && stopquickplay == 0) {
roundsperqp2 = 0;
quicki = pickNextMap(true);
gotonextmap(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
notify("Switched to next map.");
return "";
}
else if (chat_val.substring(1, 9) == "freejoin") {
if (freejoin == false) {
freejoin = true;
notify("Freejoin is now on.");
}
else {
freejoin = false;
notify("Freejoin is now off.");
}
return "";
}
else if (chat_val.substring(1, 8) == "instaqp") {
if (instaqp == false) {
instaqp = true;
notify("Instaqp is now on.");
}
else {
instaqp = false;
notify("Instaqp is now off.");
}
return "";
}
else if (chat_val.substring(1, 9) == "previous" && stopquickplay == 0) {
roundsperqp2 = 0;
quicki = pickNextMap(false);
gotonextmap(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
notify("Switched to previous map.");
return "";
}
else if (chat_val.substring(1, 6) == "start" && chat_val.length == 6) {
if (Gdocument.getElementById("mapeditorcontainer").style["display"] != "block") {
Gdocument.getElementById("newbonklobby_editorbutton").click();
}
if (recmodebool && ishost) {
var mode = Gdocument.getElementById("mapeditor_modeselect").value;
if (mode == "" && defaultmode != "d") {
mode = defaultmode;
}
if (mode != "") {
RECIEVE('42[26,"b","' + mode + '"]');
}
}
Gdocument.getElementById("mapeditor_close").click();
Gdocument.getElementById("newbonklobby").style["display"] = "none";
roundsperqp2 = 0;
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
return "";
}
else if (chat_val.substring(1, 8) == "startqp" && stopquickplay == 1) {
stopquickplay = 0;
quicki = 0;
qppaused = false;
notify("Enabled quickplay.");
return "";
}
else if (chat_val.substring(1, 7) == "stopqp" && stopquickplay == 0) {
stopquickplay = 1;
quicki = 0;
qppaused = false;
notify("Disabled quickplay.");
return "";
}
else if (chat_val.substring(1, 8) == "pauseqp" && stopquickplay == 0) {
if (qppaused == false) {
qppaused = true;
notify("Paused quickplay.");
}
else {
qppaused = false;
notify("Unpaused quickplay.");
}
return "";
}
else if (chat_val.substring(1, 6) == "revqp" && stopquickplay == 0) {
if (reverseqp == false) {
reverseqp = true;
notify("Reverseqp is now on..");
}
else {
reverseqp = false;
notify("Reverseqp is now off.");
}
return "";
}
else if (chat_val.substring(1, 5) == "ban " && chat_val.replace(/^\s+|\s+$/g, '').length >= 6) {
banned.push(cleanArg(chat_val.substring(5)));
notify("Banned " + cleanArg(chat_val.substring(5)) + ".");
return "/kick '" + cleanArg(chat_val.substring(5)) + "'";
}
else if (chat_val.substring(1, 6) == "kill " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = cleanArg(chat_val.substring(6));
text = resolveUserName(text) || text;
var keys = Object.keys(playerids);
var killid = undefined;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == text) {
killid = keys[i];
}
}
if (typeof (killid) != "undefined" && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && !killedids.includes(killid)) {
currentFrame = Math.floor((Date.now() - gameStartTimeStamp) / 1000 * 30);
killedids.push(killid);
SEND('42[25,{"a":{"playersLeft":[' + killid.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
RECIEVE('42[31,{"a":{"playersLeft":[' + killid.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
}
return "";
}
else if (chat_val.substring(1, 6) == "killA") {
var keys = Object.keys(playerids);
if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
currentFrame = Math.floor((Date.now() - gameStartTimeStamp) / 1000 * 30);
SEND('42[25,{"a":{"playersLeft":[' + keys.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
RECIEVE('42[31,{"a":{"playersLeft":[' + keys.toString() + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
}
return "";
}
else if (chat_val.substring(1, 10) == "balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
if (!isNaN(parseInt(text))) {
if (parseInt(text) >= -100 && parseInt(text) <= 100) {
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
SEND('42[29,{"sid":' + keys[i] + ',"bal":' + text + '}]');
RECIEVE('42[36,' + keys[i] + ',' + text + ']');
}
}
}
return "";
}
else if (chat_val.substring(1, 10) == "brighten " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
if (!isNaN(Number(text))) {
var intText = Number(text);
var f = function (x) {
return x * intText;
};
loadMap(changeColor(currentmap[currentmap.length - 1], f, f, f));
}
return "";
}
else if (chat_val.substring(1, 12) == "colorshift " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
var text = chat_val.substring(12).replace(/^\s+|\s+$/g, '');
if (!isNaN(Number(text))) {
var intText = Number(text);
var seed = [Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5];
var f = function (x, ind) {
return x * 1 + seed[ind] * intText;
};
loadMap(changeColor(currentmap[currentmap.length - 1], f, f, f));
}
return "";
}
else if (chat_val.substring(1, 6) == "cban " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = cleanArg(chat_val.substring(6));;
text = resolveUserName(text) || text;
var user = GETIDBYUSER(text);
if (user != -1) {
SEND('42' + JSON.stringify([9, { "banshortid": user, "kickonly": true }]));
}
if (crashbanned.includes(text)) {
notify("Already crashbanned " + text + ".");
return "";
}
crashbanned.push(text);
notify("Crashbanned " + text + ".");
return "";
}
else if (chat_val.substring(1, 8) == "uncban " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
var text = cleanArg(chat_val.substring(8));;
text = resolveUserName(text) || text;
if (crashbanned.includes(text)) {
crashbanned.splice(crashbanned.indexOf(text), 1);
notify("Un crashbanned " + text + ".");
return "";
}
notify(text + " was never crashbanned.");
return "";
}
else if (chat_val.substring(1, 10) == "balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
var text2 = text.split(" ").filter(function (e) { if (e != "") { return true; } return false; });
if (text2.length != 2 || isNaN(parseInt(text2[1])) || !["s", "r", "b", "y", "g", "f"].includes(text2[0])) {
notify("Please enter a team letter and a number to balance.");
return "";
}
var teamdict = { "s": 0, "f": 1, "r": 2, "b": 3, "g": 4, "y": 5 };
if (parseInt(text2[1]) >= -100 && parseInt(text2[1]) <= 100) {
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].team == teamdict[text2[0]]) {
SEND('42[29,{"sid":' + keys[i] + ',"bal":' + text2[1] + '}]');
RECIEVE('42[36,' + keys[i] + ',' + text2[1] + ']');
}
}
}
return "";
}
else if (chat_val.substring(1, 10) == "resetpoll") {
poll = [];
notify("The poll has been reset.");
return "";
}
else if (chat_val.substring(1, 11) == "addoption " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
if (text.length > 50) {
notify("Your option is greater than 50 characters.");
return "";
}
if (poll.includes(text)) {
notify("This option already exists.");
}
else if (poll.length >= 4) {
notify("Your poll already has the max 4 amounts of options.");
notify("Type '/deloption [letter]' to remove a option.");
notify("The poll is:");
for (var i = 0; i < poll.length; i++) {
notify(letters[i] + ") " + poll[i]);
}
}
else {
poll.push(text);
notify("The poll is now:");
for (var i = 0; i < poll.length; i++) {
notify(letters[i] + ") " + poll[i]);
}
}
return "";
}
else if (chat_val.substring(1, 11) == "deloption " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
if (text == -1 || text >= poll.length) {
if (poll.length > 0) {
notify("Available options are:");
for (var i = 0; i < poll.length; i++) {
notify(letters[i]);
}
}
else {
notify("Your poll is empty.");
notify("Type '/addoption [text]' to add an option.");
}
}
else {
poll.splice(text, 1);
notify("The poll is now:");
for (var i = 0; i < poll.length; i++) {
notify(letters[i] + ") " + poll[i]);
}
}
return "";
}
else if (chat_val.substring(1, 11) == "startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = Number(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
if (isNaN(text)) {
notify("Type a positive number.");
return "";
}
else if (text <= 0) {
notify("Type a positive number.");
return "";
}
else if (text < 5) {
notify("Your poll has to last for at least 5 seconds.");
return "";
}
if (pollactive[0]) {
notify("There is already an ongoing poll.");
notify("Type '/endpoll' to end the poll.");
return "";
}
if (poll.length < 2) {
notify("Your poll needs at least 2 options.");
notify("Type '/addoption' to add to the poll.");
return "";
}
var now = Date.now();
pollactive = [true, now, now + text * 1000, [...poll]];
playerids[myid].ratelimit.poll = now;
var chatpoll = [...poll];
chatpoll.push("Cancel vote.");
pollactive[3].push("Cancel vote.");
for (var i = 0; i < chatpoll.length; i++) {
chatpoll[i] = letters[i] + ") " + chatpoll[i];
}
chat(chatpoll.join(" "));
setTimeout(function () {
if (pollactive[0]) {
SEND("42" + JSON.stringify([4, { "type": "poll", "from": username, "poll": pollactive[3] }]));
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
playerids[keys[i]].vote.poll = -1;
}
notify("The poll will end in: " + text.toString() + " seconds.");
notify("Type '/endpoll' to end the poll early.");
}
}, 200);
return "";
}
else if (chat_val.substring(1, 8) == "endpoll") {
if (pollactive[0]) {
if (playerids[myid].ratelimit.poll + 5000 > Date.now()) {
notify("Your poll has to be at least 5 seconds.");
notify("There are " + ((playerids[myid].ratelimit.poll + 5000 - Date.now()) / 1000).toString() + " seconds left until you can end the poll early.");
return "";
}
playerids[myid].ratelimit.poll = Date.now();
SEND("42" + JSON.stringify([4, { "type": "poll end", "from": username }]));
notify("The poll ended.");
var count = [0, 0, 0, 0];
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].vote.poll != -1 && playerids[keys[i]].vote.poll < pollactive[3].length - 1) {
count[playerids[keys[i]].vote.poll]++;
}
playerids[keys[i]].vote.poll = -1;
}
for (var i = 0; i < count.length; i++) {
if (count[i] > 1) {
notify(count[i].toString() + " people voted for option " + letters[i] + ".");
}
if (count[i] == 1) {
notify(count[i].toString() + " person voted for option " + letters[i] + ".");
}
}
notify("The poll was:");
for (var i = 0; i < pollactive[3].length; i++) {
notify(letters[i] + ") " + pollactive[3][i]);
}
pollactive = [false, 0, 0, []];
}
else {
notify("No poll has been started");
notify("Type '/startpoll [seconds]' to start a poll.");
}
return "";
}
else if (chat_val.substring(1, 7) == "moveA " && chat_val.replace(/^\s+|\s+$/g, '').length >= 8) {
var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
var keys = Object.keys(playerids);
var t = -1;
if (text == "f") {
t = 1;
}
else if (text == "b") {
t = 3;
}
else if (text == "g") {
t = 4;
}
else if (text == "r") {
t = 2;
}
else if (text == "y") {
t = 5;
}
else if (text == "s") {
t = 0;
}
if (t == -1) {
notify("The format for this command is:");
notify("/moveA [letter]");
notify("For example: '/moveA r' would move everyone to red team.");
return "";
}
for (var i = 0; i < keys.length; i++) {
SEND('42[26,{"targetID":' + keys[i].toString() + ',"targetTeam":' + t.toString() + '}]');
if (playerids[keys[i]].peerID != "sandbox") {
RECIEVE('42[18,' + keys[i].toString() + ',' + t.toString() + ']');
}
}
return "";
}
else if (chat_val.substring(1, 7) == "moveT " && chat_val.replace(/^\s+|\s+$/g, '').length >= 8) {
var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function (i) { if (i == "") { return false } else { return true } });
if (text.length == 2) {
var firstteam = -1;
var secondteam = -1;
for (var i = 0; i < 2; i++) {
var t = -1;
if (text[i] == "f") {
t = 1;
}
else if (text[i] == "b") {
t = 3;
}
else if (text[i] == "g") {
t = 4;
}
else if (text[i] == "r") {
t = 2;
}
else if (text[i] == "y") {
t = 5;
}
else if (text[i] == "s") {
t = 0;
}
if (t == -1) {
notify("The format for this command is:");
notify("/moveT [letter] [letter]");
notify("For example: '/moveT s r' would move everyone in spectate to red team.");
return "";
}
else {
if (i == 0) {
firstteam = t;
}
else {
secondteam = t;
}
}
}
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].team == firstteam) {
SEND('42[26,{"targetID":' + keys[i].toString() + ',"targetTeam":' + secondteam.toString() + '}]');
if (playerids[keys[i]].peerID != "sandbox") {
RECIEVE('42[18,' + keys[i].toString() + ',' + secondteam.toString() + ']');
}
}
}
}
else {
notify("The format for this command is:");
notify("/moveT [team] [team]");
notify("For example: '/moveT s r' would move everyone in spectate to red team.");
return "";
}
return "";
}
if (chat_val.substring(1, 13) == "roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length >= 14) {
var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
if (isNaN(text)) {
notify("Type a positive number.");
return "";
}
else if (text <= 0) {
notify("Type a positive number.");
return "";
}
roundsperqp = text;
roundsperqp2 = 0;
notify("Set rounds per quickplay to: " + text.toString());
notify("Type '/roundsperqp' to reset rounds per quickplay.");
return "";
}
else if (chat_val.substring(1, 12) == "roundsperqp") {
roundsperqp = 1;
roundsperqp2 = 0;
notify("Reset rounds per quickplay.");
return "";
}
else if (chat_val.substring(1, 8) == "rounds " && chat_val.replace(/^\s+|\s+$/g, '').length >= 9) {
var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
if (!isNaN(parseInt(text))) {
text = parseInt(text).toString();
SEND('42[21,{"w":' + text + '}]');
RECIEVE('42[27,' + text + ']');
}
return "";
}
else if (chat_val.substring(1, 13) == "disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length >= 14) {
var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
var keys = text.split(" ");
var disabledkeys2 = [];
var possiblekeys = ["left", "right", "up", "down", "heavy", "special"];
for (var i = 0; i < keys.length; i++) {
if (keys[i] != "" && !disabledkeys2.includes(keys[i])) {
if (possiblekeys.includes(keys[i])) {
disabledkeys2.push(keys[i]);
}
else {
notify("Key options: " + possiblekeys.join(" ") + ".");
return "";
}
}
}
disabledkeys = disabledkeys2;
notify("Set disabled keys to: " + disabledkeys.join(" ") + ".");
notify("Type '/disablekeys' to reset disabled keys.");
return "";
}
else if (chat_val.substring(1, 12) == "disablekeys") {
notify("Reset disabled keys.");
disabledkeys = [];
return "";
}
else if (chat_val.substring(1, 10) == "jointext " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
notify("Set jointext to: " + jointext);
notify("Type '/jointext' to reset jointext.");
return "";
}
else if (chat_val.substring(1, 9) == "jointext") {
jointext = "";
notify("Reset jointext.");
return "";
}
else if (chat_val.substring(1, 10) == "jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
var keys = Object.keys(playerids);
var t = -1;
if (text == "f") {
t = 1;
notify("Set jointeam to FFA.");
}
else if (text == "b") {
t = 3;
notify("Set jointeam to blue team.");
}
else if (text == "g") {
t = 4;
notify("Set jointeam to green team.");
}
else if (text == "r") {
t = 2;
notify("Set jointeam to red team.");
}
else if (text == "y") {
t = 5;
notify("Set jointeam to yellow team.");
}
else if (text == "s") {
t = 0;
notify("Set jointeam to spectate.");
}
if (t == -1) {
notify("The format for this command is:");
notify("/jointeam [letter]");
notify("For example: '/jointeam r' would move every joined person to red team.");
return "";
}
notify("Type '/jointeam' to reset jointeam.");
jointeam = t;
return "";
}
else if (chat_val.substring(1, 9) == "jointeam") {
jointeam = -1;
notify("Reset jointeam.");
return "";
}
else if (chat_val.substring(1, 9) == "wintext " && chat_val.replace(/^\s+|\s+$/g, '').length >= 10) {
wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
notify("Set wintext to: " + wintext);
notify("Type '/wintext' to reset wintext.");
return "";
}
else if (chat_val.substring(1, 8) == "wintext") {
wintext = "";
notify("Reset wintext.");
return "";
}
else if (chat_val.substring(1, 11) == "autorecord") {
if (autorecord) {
autorecord = false;
notify("Autorecord is now off.");
}
else {
autorecord = true;
notify("Autorecord is now on.");
}
return "";
}
else if (chat_val.substring(1, 9) == "afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length >= 10) {
var text = Number(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
if (!isNaN(text)) {
if (text > 0) {
notify("Set afk kill to: " + text.toString() + " seconds.");
notify("Type '/afkkill' to reset afk kill.");
var keys = Object.keys(playerids);
var now = Date.now();
for (var i = 0; i < keys.length; i++) {
playerids[keys[i]].lastmove = now;
}
afkkill = text;
}
else {
notify("Type a positive number.");
}
}
else {
notify("Type a positive number.");
}
return "";
}
else if (chat_val.substring(1, 9) == "afkkill") {
afkkill = -1;
notify("Reset afk kill.");
return "";
}
else if (chat_val.substring(1, 13) == "defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length >= 14) {
var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
if (text == "default") {
defaultmode = "";
notify("Changed default mode to default.");
}
else if (text == "arrows") {
defaultmode = "ar";
notify("Changed default mode to arrows.");
}
else if (text == "death arrows") {
defaultmode = "ard";
notify("Changed default mode to death arrows.");
}
else if (text == "grapple") {
defaultmode = "sp";
notify("Changed default mode to grapple.");
}
else if (text == "vtol") {
defaultmode = "v";
notify("Changed default mode to vtol.");
}
else if (text == "classic") {
defaultmode = "b";
notify("Changed default mode to classic.");
}
else {
notify("Default mode options:");
notify("default");
notify("classic");
notify("arrows");
notify("death arrows");
notify("grapple");
notify("vtol");
}
return "";
}
else if (chat_val.substring(1, 8) == "recmode") {
if (recmodebool == true) {
recmodebool = false;
notify("Recmode is now off.");
}
else {
recmodebool = true;
notify("Recmode is now on.");
}
return "";
}
else if (chat_val.substring(1, 8) == "recteam") {
if (recteams == true) {
recteams = false;
notify("Recteam is now off.");
}
else {
recteams = true;
notify("Recteam is now on.");
}
return "";
}
else if (chat_val.substring(1, 8) == "shuffle") {
if (shuffle == true) {
shuffle = false;
notify("Shuffle is now off.");
}
else {
shuffle = true;
notify("Shuffle is now on.");
}
return "";
}
else if (chat_val.substring(1, 9) == "autokick") {
if (autokickban == 0) {
notify("Autokick is now on.");
autokickban = 1;
}
else if (autokickban == 1) {
autokickban = 0;
notify("Autokick is now off.");
}
else {
autokickban = 1;
notify("Autokick is now on, and Autoban is now off.");
}
return "";
}
else if (chat_val.substring(1, 8) == "autoban") {
if (autokickban == 0) {
notify("Autoban is now on.");
autokickban = 2;
}
else if (autokickban == 2) {
autokickban = 0;
notify("Autoban is now off.");
}
else {
autokickban = 2;
notify("Autoban is now on, and Autokick is now off.");
}
return "";
}
else if (chat_val.substring(1, 8) == "sandbox") {
if (sandboxon == false) {
notify("This room is now a sandbox room.");
sandboxon = true;
SEND('42[4,{"type":"sandboxon"}]');
var sandboxkeys = Object.keys(sandboxplayerids);
var packets = [];
for (var i = 0; i < sandboxkeys.length; i++) {
var p = playerids[sandboxkeys[i]];
var packet = '42' + JSON.stringify([4, sandboxkeys[i], p.peerID, p.userName, p.guest, p.level, p.team, p.avatar]);
packets.push(packet);
}
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": packets, to: [-1] }]));
SEND("42" + JSON.stringify([4, { "type": "sandboxid", "from": username, "lastid": sandboxid, to: [-1] }]));
}
else {
notify("You cannot turn a sandbox room back into a normal room.");
}
return "";
}
else if (sandboxon) {
if (chat_val.substring(1, 11) == "addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
if (!isNaN(parseInt(text))) {
var text2 = parseInt(text);
if (text2 > 0) {
for (var i = 0; i < text2; i++) {
while (playerids[sandboxid]) {
sandboxid += 1;
}
var color = Math.floor(Math.random() * 16777215).toString();
var packet = '42' + JSON.stringify([4, sandboxid, "sandbox", sandboxid.toString(), true, 0, 0, { "layers": [], "bc": color }]);
RECIEVE(packet);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet], to: [-1] }]));
sandboxplayerids[sandboxid] = sandboxid.toString();
sandboxid += 1;
}
}
}
return "";
}
if (chat_val.substring(1, 9) == "addname " && chat_val.replace(/^\s+|\s+$/g, '').length >= 10) {
var text = cleanArg(chat_val.substring(9));
while (playerids[sandboxid]) {
sandboxid += 1;
}
var keys = Object.keys(playerids);
var addon = "";
var escape = false;
var keysi = -1;
while (!escape) {
escape = true;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == text + addon) {
addon += "";
var escape = false;
}
if (playerids[keys[i]].userName == text) {
keysi = keys[i];
}
}
}
if (keysi != -1) {
var packet = '42' + JSON.stringify([4, sandboxid, "sandbox", text + addon, playerids[keysi].guest, playerids[keysi].level, 0, playerids[keysi].avatar]);
RECIEVE(packet);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet], to: [-1] }]));
}
else {
var color = Math.floor(Math.random() * 16777215).toString();
var packet = '42' + JSON.stringify([4, sandboxid, "sandbox", text + addon, true, 0, 0, { "layers": [], "bc": color }]);
RECIEVE(packet);
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": [packet], to: [-1] }]));
}
sandboxplayerids[sandboxid] = sandboxid.toString();
sandboxid += 1;
return "";
}
else if (chat_val.substring(1, 11) == "delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length >= 12) {
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
if (!isNaN(parseInt(text))) {
var text2 = parseInt(text);
if (text2 > 0) {
if (Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden") {
var jsonkeys = Object.keys(sandboxplayerids).reverse();
var packets = [];
for (var i = 0; i < text2 && i < jsonkeys.length; i++) {
var packet = '42[5,' + jsonkeys[i] + ',0]';
RECIEVE(packet);
packets.push(packet);
delete sandboxplayerids[jsonkeys[i]];
}
SEND("42" + JSON.stringify([4, { "type": "fakerecieve", "from": username, "packet": packets, to: [-1] }]));
}
else {
notify("Cannot delete players while ingame.");
}
}
}
return "";
}
else if (chat_val.substring(1, 6) == "copy " && chat_val.replace(/^\s+|\s+$/g, '').length >= 7) {
var text = cleanArg(chat_val.substring(6));
text = resolveUserName(text) || text;
var keys = Object.keys(playerids);
var keys2 = Object.keys(sandboxplayerids);
var copiedperson = -1;
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].userName == text) {
copiedperson = keys[i];
}
}
if (copiedperson == -1) {
notify(playerids[copiedperson].userName + " was not found in this room.");
return "";
}
if (keys2.includes(copiedperson.toString())) {
notify("Bots cannot copy a bot.");
return "";
}
notify("All bots will now copy " + playerids[copiedperson].userName + ".");
notify("To reset copy, type '/copy'.");
sandboxcopyme = copiedperson;
return "";
}
else if (chat_val.substring(1, 5) == "copy") {
sandboxcopyme = -1;
notify("Copy is now off.");
return "";
}
}
}
return chat_val;
};
scope.flag_manage = function (t) {
var text = t;
if (autocorrect == true) {
var text2 = text.split(" ");
for (var i = 0; i < text2.length; i++) {
text2[i] = closestWord(text2[i]);
}
text = text2.join(" ");
}
if (reverse_flag == true) {
text = text.split("").reverse().join("")
}
if (rcaps_flag == true) {
text = text.split('');
for (var i = 0; i < text.length; i++) {
if (Math.floor(Math.random() * 2)) {
text[i] = text[i].toUpperCase();
}
else {
text[i] = text[i].toLowerCase();
}
}
text = text.join('');
}
if (space_flag == true) {
text = text.split('').join(' ')
}
if (textmode != -1) {
newtext = "";
for (var i = 0; i < text.length; i++) {
if (letter_dictionary[text[i]]) {
newtext += letter_dictionary[text[i]][textmode];
}
else {
newtext += text[i];
}
}
text = newtext;
}
if (curse_flag == true) {
text = text.replace(/[a|A]/g, "*");
text = text.replace(/[e|E]/g, "*");
text = text.replace(/[i|I]/g, "*");
text = text.replace(/[o|O]/g, "*");
text = text.replace(/[u|U]/g, "*");
text = text.replace(/[y|Y]/g, "*");
}
if (number_flag == true) {
text = text.replace(/[t|T][Oo]+/g, "2");
text = text.replace(/[f|F][o|O][r|R]/g, "4");
text = text.replace(/[a|A][t|T][e|E]/g, "8");
text = text.replace(/[e|E]/g, "3");
text = text.replace(/[a|A]/g, "4");
text = text.replace(/[o|O]/g, "0");
text = text.replace(/[s|S]/g, "5");
text = text.replace(/[i|I|l|L]/g, "1");
}
return text;
};
scope.commandNames = function () {
if (!scope._cmdNames) {
var set = {};
for (var i = 0; i < help.length; i++) {
if (help[i][0] === "/") { set[help[i].slice(1).split(" ")[0]] = 1; }
}
for (var k in commands) { set[k] = 1; }
for (var k2 in set) { if (disabledCommands[k2.toLowerCase()]) { delete set[k2]; } }
scope._cmdNames = Object.keys(set);
}
return scope._cmdNames;
};
scope.suggestUsernames = function () { return Object.keys(playerids).map(function (id) { return playerids[id].userName; }); };
scope.suggestTeamLetters = function () { return ["r", "g", "b", "y", "s", "f"]; };
scope.suggestModeNames = function () { return Object.keys(MODE_CODES); };
scope.suggestLanguages = function () { try { return Object.keys(translatingkeys); } catch (e) { return []; } };
scope.suggestZoomDirections = function () { return ["in", "out", "reset"]; };
scope.suggestTextModes = function () { return ["1", "2", "3", "4", "5", "6", "7"]; };
scope.suggestAllCommands = function () { return commandNames().slice().sort(); };
scope.argSuggests = {
skin: suggestUsernames, cleansemap: suggestUsernames, friend: suggestUsernames,
followcam: suggestUsernames, echo: suggestUsernames, remove: suggestUsernames,
find: suggestUsernames, chatw: suggestUsernames, ignorepm: suggestUsernames,
record: suggestUsernames, ban: suggestUsernames, cban: suggestUsernames,
uncban: suggestUsernames, kill: suggestUsernames, copy: suggestUsernames,
team: suggestTeamLetters, movea: suggestTeamLetters, movet: suggestTeamLetters,
balancet: suggestTeamLetters, jointeam: suggestTeamLetters,
defaultmode: suggestModeNames,
translate: suggestLanguages, translateto: suggestLanguages,
zoom: suggestZoomDirections, textmode: suggestTextModes,
advhelp: suggestAllCommands
};
scope.commandSuggestList = function (val) {
try {
if (!val || val[0] !== "/") { return null; }
var firstSpace = val.indexOf(" ");
if (firstSpace === -1) { return null; }
var name = val.slice(1, firstSpace).toLowerCase();
var provider = (commands[name] && typeof commands[name].suggest === "function") ? commands[name].suggest : (argSuggests[name] || null);
if (typeof provider === "function") {
var arr = provider();
return Array.isArray(arr) ? arr : null;
}
} catch (e) { }
return null;
};
scope.emojiMap = {
skull: "💀", skull_crossbones: "☠️", fire: "🔥", "100": "💯", eyes: "👀", tongue: "👅",
heart: "❤️", broken_heart: "💔", heartbroken: "💔", heart_broken: "💔", sparkling_heart: "💖",
two_hearts: "💕", orange_heart: "🧡", yellow_heart: "💛", green_heart: "💚", blue_heart: "💙",
purple_heart: "💜", black_heart: "🖤", white_heart: "🤍", heart_eyes: "😍", kissing_heart: "😘",
joy: "😂", rofl: "🤣", sob: "😭", cry: "😢", pleading: "🥺", smile: "😄", smiley: "😃", grin: "😁",
laughing: "😆", sweat_smile: "😅", wink: "😉", blush: "😊", yum: "😋", sunglasses: "😎", cool: "😎",
thinking: "🤔", neutral_face: "😐", expressionless: "😑", unamused: "😒", roll_eyes: "🙄",
smirk: "😏", grimacing: "😬", relieved: "😌", sleeping: "😴", sleepy: "😪", drooling: "🤤",
mask: "😷", nauseated: "🤢", vomiting: "🤮", sneezing: "🤧", hot: "🥵", cold: "🥶",
dizzy_face: "😵", exploding_head: "🤯", cowboy: "🤠", partying_face: "🥳", disguise: "🥸",
worried: "😟", fearful: "😨", cold_sweat: "😰", weary: "😩", tired_face: "😫", triumph: "😤",
angry: "😠", rage: "😡", cursing: "🤬", scream: "😱", flushed: "😳", hugging: "🤗",
shushing: "🤫", hand_over_mouth: "🤭", lying: "🤥", clown: "🤡", poop: "💩", ghost: "👻",
alien: "👽", robot: "🤖", thumbsup: "👍", "+1": "👍", thumbsdown: "👎", "-1": "👎", ok_hand: "👌",
clap: "👏", raised_hands: "🙌", pray: "🙏", muscle: "💪", wave: "👋", fingers_crossed: "🤞",
v: "✌️", metal: "🤘", call_me: "🤙", point_up: "☝️", crown: "👑", gem: "💎", moneybag: "💰",
tada: "🎉", party: "🎉", confetti: "🎊", sparkles: "✨", star: "⭐", star2: "🌟", boom: "💥",
zzz: "💤", dash: "💨", sweat_drops: "💦", rocket: "🚀", zap: "⚡", snowflake: "❄️", sunny: "☀️",
rainbow: "🌈", check: "✅", white_check_mark: "✅", x: "❌", cross: "❌", warning: "⚠️",
question: "❓", exclamation: "❗", no_entry: "⛔", gift: "🎁", balloon: "🎈", cake: "🎂",
pizza: "🍕", burger: "🍔", coffee: "☕", beer: "🍺", cat: "🐱", dog: "🐶", fox: "🦊",
monkey: "🐵", snake: "🐍", pig: "🐷", frog: "🐸", unicorn: "🦄", bear: "🐻", goat: "🐐"
};
scope.chatAutocomplete = function (inputEl) {
try {
var val = inputEl.value;
if (tabState.active && val === tabState.lastValue && tabState.matches && tabState.matches.length) {
tabState.idx = (tabState.idx + 1) % tabState.matches.length;
var cv = tabState.base + tabState.matches[tabState.idx];
inputEl.value = cv; tabState.lastValue = cv; return;
}
var em = val.match(/:([a-zA-Z0-9_+\-]*):?$/);
if (em) {
var q = em[1].toLowerCase(), seen = {}, emojis = [], enames = Object.keys(emojiMap);
for (var ei = 0; ei < enames.length; ei++) {
if (enames[ei].indexOf(q) === 0) {
var ch = emojiMap[enames[ei]];
if (!seen[ch]) { seen[ch] = 1; emojis.push(ch); }
}
}
if (emojis.length) {
var ebase = val.slice(0, em.index);
scope.tabState = { active: true, base: ebase, matches: emojis, idx: 0, lastValue: "" };
var ev = ebase + emojis[0];
inputEl.value = ev; tabState.lastValue = ev; return;
}
}
var at = val.match(/@([^@]*)$/);
if (at) {
var aq = at[1].toLowerCase();
var users = Object.keys(playerids).map(function (id) { return playerids[id].userName; })
.filter(function (u) { return u.toLowerCase().indexOf(aq) === 0; });
if (users.length) {
var abase = val.slice(0, at.index) + "@";
scope.tabState = { active: true, base: abase, matches: users, idx: 0, lastValue: "" };
var av = abase + users[0];
inputEl.value = av; tabState.lastValue = av; return;
}
}
var lastSpace = val.lastIndexOf(" ");
var token = val.slice(lastSpace + 1);
var base = val.slice(0, lastSpace + 1);
var matches;
if (val[0] === "/" && lastSpace === -1) {
var qc = token.slice(1).toLowerCase();
matches = commandNames().filter(function (n) { return n.toLowerCase().indexOf(qc) === 0; }).sort().map(function (n) { return "/" + n; });
} else {
var cmdSug = val[0] === "/" ? commandSuggestList(val) : null;
if (cmdSug) {
var firstSpace = val.indexOf(" ");
var restStr = val.slice(firstSpace + 1), rq = restStr.toLowerCase();
base = val.slice(0, firstSpace + 1);
matches = cmdSug.filter(function (c) { return c.toLowerCase().indexOf(rq) === 0; }).sort();
} else {
var qu = token.toLowerCase();
matches = Object.keys(playerids).map(function (id) { return playerids[id].userName; })
.filter(function (u) { return u.toLowerCase().indexOf(qu) === 0; });
}
}
if (!matches.length) { scope.tabState = { active: false }; return; }
scope.tabState = { active: true, base: base, matches: matches, idx: 0, lastValue: "" };
var nv = base + matches[0];
inputEl.value = nv; tabState.lastValue = nv;
} catch (err) { scope.tabState = { active: false }; }
};
scope.suggestSuffix = function (val) {
try {
if (!val) { return ""; }
var at = val.match(/@([^@]*)$/);
if (at) {
var aq = at[1].toLowerCase();
if (aq === "") { return ""; }
var au = Object.keys(playerids).map(function (id) { return playerids[id].userName; })
.filter(function (u) { return u.toLowerCase().indexOf(aq) === 0; })
.sort(function (a, b) { return a.length - b.length; });
if (au.length) { return au[0].slice(at[1].length); }
return "";
}
if (val[0] !== "/") { return ""; }
var lastSpace = val.lastIndexOf(" ");
var token = val.slice(lastSpace + 1);
if (lastSpace === -1) {
var qc = token.slice(1).toLowerCase();
if (qc === "") { return ""; }
var cm = commandNames().filter(function (n) { return n.toLowerCase().indexOf(qc) === 0; }).sort();
if (cm.length) { return cm[0].slice(qc.length); }
return "";
}
var cmdSug = commandSuggestList(val);
if (cmdSug) {
var firstSpace = val.indexOf(" ");
var restStr = val.slice(firstSpace + 1);
if (restStr === "") { return ""; }
var rq = restStr.toLowerCase();
var sm = cmdSug.filter(function (c) { return c.toLowerCase().indexOf(rq) === 0; }).sort();
if (sm.length) { return sm[0].slice(restStr.length); }
return "";
}
if (token === "") { return ""; }
var qu = token.toLowerCase();
var us = Object.keys(playerids).map(function (id) { return playerids[id].userName; })
.filter(function (u) { return u.toLowerCase().indexOf(qu) === 0; })
.sort(function (a, b) { return a.length - b.length; });
if (us.length) { return us[0].slice(token.length); }
return "";
} catch (e) { return ""; }
};
scope.chatGhosts = scope.chatGhosts || {};
scope.makeChatGhost = function (input) {
var ghost = Gdocument.createElement("div");
ghost.className = "bcChatGhost";
ghost.style["position"] = "absolute";
ghost.style["pointerEvents"] = "none";
ghost.style["overflow"] = "hidden";
ghost.style["whiteSpace"] = "pre";
ghost.style["background"] = "transparent";
ghost.style["color"] = "transparent";
ghost.style["zIndex"] = "6";
(input.offsetParent || input.parentElement).appendChild(ghost);
return ghost;
};
scope.updateChatGhost = function (input) {
try {
var ghost = chatGhosts[input.id] || (chatGhosts[input.id] = makeChatGhost(input));
var atEnd = input.selectionStart === input.value.length && input.selectionEnd === input.value.length;
if (Gdocument.activeElement !== input || !atEnd) { ghost.textContent = ""; return; }
var suffix = suggestSuffix(input.value);
if (!suffix) { ghost.textContent = ""; return; }
var cs = Gwindow.getComputedStyle(input);
ghost.style["left"] = input.offsetLeft + "px";
ghost.style["top"] = input.offsetTop + "px";
ghost.style["width"] = input.offsetWidth + "px";
ghost.style["height"] = input.offsetHeight + "px";
ghost.style["boxSizing"] = "border-box";
["fontFamily", "fontSize", "fontWeight", "fontStyle", "letterSpacing", "textTransform", "textIndent", "lineHeight", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderStyle"].forEach(function (p) { ghost.style[p] = cs[p]; });
ghost.style["borderColor"] = "transparent";
ghost.textContent = input.value;
var span = Gdocument.createElement("span");
span.textContent = suffix;
span.style["color"] = "#999999";
ghost.appendChild(span);
ghost.scrollLeft = input.scrollLeft;
} catch (e) { }
};
scope.chatInputKeydown = function (inputEl, e) {
if (e.keyCode == 13) {
var chat_val = inputEl.value;
if (chat_val != "" && chat_val[0] == "/") {
if (commandHistory[commandHistory.length - 1] !== chat_val) { commandHistory.push(chat_val); }
if (commandHistory.length > 50) { commandHistory.shift(); }
commandHistoryIndex = commandHistory.length;
inputEl.value = "";
chat2(commandhandle(chat_val));
} else {
inputEl.value = "";
chat2(flag_manage(chat_val));
}
tabState.active = false;
} else if (e.keyCode == 9) {
e.preventDefault();
chatAutocomplete(inputEl);
} else if (e.keyCode == 38) {
if (commandHistory.length) {
e.preventDefault();
commandHistoryIndex = Math.max(0, commandHistoryIndex - 1);
inputEl.value = commandHistory[commandHistoryIndex];
}
tabState.active = false;
} else if (e.keyCode == 40) {
if (commandHistory.length) {
e.preventDefault();
commandHistoryIndex = Math.min(commandHistory.length, commandHistoryIndex + 1);
inputEl.value = commandHistoryIndex === commandHistory.length ? "" : commandHistory[commandHistoryIndex];
}
tabState.active = false;
}
};
Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function (e) { chatInputKeydown(this, e); };
Gdocument.getElementById("ingamechatinputtext").onkeydown = function (e) { chatInputKeydown(this, e); };
Gwindow.addEventListener("keydown", function (e) {
var t = e.target;
if (!t || (t.id !== "newbonklobby_chat_input" && t.id !== "ingamechatinputtext")) { return; }
if (e.keyCode == 9) {
e.preventDefault();
e.stopImmediatePropagation();
chatAutocomplete(t);
updateChatGhost(t);
}
}, true);
["newbonklobby_chat_input", "ingamechatinputtext"].forEach(function (cid) {
var el = Gdocument.getElementById(cid);
if (!el) { return; }
["input", "keyup", "click", "focus"].forEach(function (ev) { el.addEventListener(ev, function () { updateChatGhost(el); }); });
el.addEventListener("blur", function () { var g = chatGhosts[el.id]; if (g) { g.textContent = ""; } });
});
["newbonklobby_chat_input", "ingamechatinputtext"].forEach(function (cid) {
var el = Gdocument.getElementById(cid);
if (!el) { return; }
el.addEventListener("paste", function (e) {
var items = (e.clipboardData && e.clipboardData.items) || [];
for (var i = 0; i < items.length; i++) {
if (items[i].type && items[i].type.indexOf("image/") === 0) {
var f = items[i].getAsFile();
if (f) { e.preventDefault(); sendImage(f); return; }
}
}
});
el.addEventListener("dragover", function (e) { e.preventDefault(); });
el.addEventListener("drop", function (e) {
if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files[0]) {
e.preventDefault();
sendImage(e.dataTransfer.files[0]);
}
});
});
if (!scope.bonkCommandsMenuHooked) {
scope.bonkCommandsMenuHooked = true;
scope.playerMenuTarget = "";
scope.usernameFromRow = function (row) {
var txt = (row && row.textContent) || "", best = "";
for (var id in playerids) {
var u = playerids[id].userName;
if (u && txt.indexOf(u) !== -1 && u.length > best.length) { best = u; }
}
return best;
};
Gdocument.addEventListener("click", function (e) {
var entry = e.target && e.target.closest && e.target.closest(".newbonklobby_playerentry");
if (entry) { var u = usernameFromRow(entry); if (u) { scope.playerMenuTarget = u; } }
}, true);
var makeMenuButton = function (label, fn) {
var b = Gdocument.createElement("div");
b.className = "newbonklobby_playerentry_menu_button brownButton brownButton_classic buttonShadow bcMenuItem";
b.textContent = label;
b.addEventListener("click", function () { fn(playerMenuTarget); });
return b;
};
var ensureMenuItems = function (menu) {
if (!menu || menu.querySelector(".bcMenuItem")) { return; }
menu.appendChild(makeMenuButton("Follow", function (u) {
var id = resolveUserId(u);
if (id !== -1) { FollowCam = true; followTarget = id; notify("Following " + playerids[id].userName + "."); }
}));
menu.appendChild(makeMenuButton("Private chat", function (u) { if (u) { commandhandle("/chatw " + u); } }));
};
var watchMenu = function (menu) {
if (menu.__bcObserved) { return; }
menu.__bcObserved = true;
ensureMenuItems(menu);
new MutationObserver(function () { ensureMenuItems(menu); }).observe(menu, { childList: true });
};
new MutationObserver(function (muts) {
for (var i = 0; i < muts.length; i++) {
var an = muts[i].addedNodes;
for (var j = 0; j < an.length; j++) {
var node = an[j];
if (node.nodeType !== 1) { continue; }
if (node.classList && node.classList.contains("newbonklobby_playerentry_menu")) { watchMenu(node); }
else if (node.querySelector) { var mn = node.querySelector(".newbonklobby_playerentry_menu"); if (mn) { watchMenu(mn); } }
}
}
}).observe(Gdocument.body, { childList: true, subtree: true });
var existing = Gdocument.getElementsByClassName("newbonklobby_playerentry_menu");
for (var xi = 0; xi < existing.length; xi++) { watchMenu(existing[xi]); }
}
scope.Last_message = "";
scope.Laster_message = "";
scope.new_message = false;
scope.changed_chat = false;
scope.injectedBonkCommandsScript = setInterval(timeout123, 60);
scope.pan_enabled = false;
scope.lastXPtimestamp = Date.now();
scope.pan = { "x": 0, "y": 0 };
scope.pan_speed = 5;
scope.keys_being_held = {};
scope.hotkeys_keyup = function (e) {
if (keys_being_held[e.code]) {
keys_being_held[e.code] = false;
}
};
Gdocument.onkeyup = hotkeys_keyup;
scope.hotkeys = function (e) {
var keycode = e.code;
if (!keys_being_held[keycode]) {
keys_being_held[keycode] = true;
}
if (!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey) {
if (pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount > 0) {
if (keycode == "ArrowUp") {
e.stopPropagation();
e.preventDefault();
}
else if (keycode == "ArrowDown") {
e.stopPropagation();
e.preventDefault();
}
else if (keycode == "ArrowLeft") {
e.stopPropagation();
e.preventDefault();
}
else if (keycode == "ArrowRight") {
e.stopPropagation();
e.preventDefault();
}
}
}
if (e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
if (keycode == "Period") {
if (Gdocument.getElementById("ingamechatcontent").style["max-height"] != "0px") {
chatheight += 5;
if (chatheight > 600) { chatheight = 600; }
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatcontent").style["height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatbox").style["height"] = "100%";
}
e.preventDefault();
}
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
if (keycode == "KeyG") {
var addto = 0;
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
if (addto) {
zoom *= 1.1;
}
addto.scale.x = zoom;
addto.scale.y = zoom;
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999 && !FollowCam) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
e.preventDefault();
}
else if (keycode == "KeyR") {
var x = hideshowplayers();
switch (x) {
case 0:
notify("Cannot hide/show players in lobby.");
break;
case 1:
notify("Players hidden.");
break;
case 2:
notify("Players unhidden.");
break;
}
}
if (keycode == "KeyH") {
var addto = 0;
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
if (addto) {
zoom = 1;
}
addto.scale.x = zoom;
addto.scale.y = zoom;
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999 && !FollowCam) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
e.preventDefault();
}
if (keycode == "KeyJ") {
var addto = 0;
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
if (addto) {
zoom /= 1.1;
}
addto.scale.x = zoom;
addto.scale.y = zoom;
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999 && !FollowCam) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
e.preventDefault();
}
}
if (keycode == "Comma") {
if (Gdocument.getElementById("ingamechatcontent").style["max-height"] != "0px") {
chatheight -= 5;
if (chatheight < 100) { chatheight = 100; }
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatcontent").style["height"] = chatheight.toString() + "px";
Gdocument.getElementById("ingamechatbox").style["height"] = "100%";
}
e.preventDefault();
}
}
if (e.repeat) { return; }
if (e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
if (ishost) {
if (keycode == "KeyE") {
if (Gdocument.getElementById("newbonklobby").style["display"] == "block") {
Gdocument.getElementById("newbonklobby_editorbutton").click();
}
else if (Gdocument.getElementById("mapeditorcontainer").style["display"] == "block") {
Gdocument.getElementById("mapeditor_close").click();
}
e.preventDefault();
}
else if (keycode == "KeyT") {
Gdocument.getElementById("newbonklobby_teamsbutton").click();
e.preventDefault();
}
else if (keycode == "KeyK") {
if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
Gdocument.getElementById("pretty_top_exit").click();
}
e.preventDefault();
}
else if (keycode == "KeyS") {
if (Gdocument.getElementById("mapeditorcontainer").style["display"] != "block") {
Gdocument.getElementById("newbonklobby_editorbutton").click();
}
if (recmodebool && ishost) {
var mode = Gdocument.getElementById("mapeditor_modeselect").value;
if (mode == "" && defaultmode != "d") {
mode = defaultmode;
}
if (mode != "") {
RECIEVE('42[26,"b","' + mode + '"]');
}
}
Gdocument.getElementById("mapeditor_close").click();
Gdocument.getElementById("newbonklobby").style["display"] = "none";
roundsperqp2 = 0;
Gdocument.getElementById("mapeditor_midbox_testbutton").click();
e.preventDefault();
}
else if (keycode == "KeyD") {
roundsperqp2 = 0;
if (stopquickplay == 0) {
quicki = pickNextMap(true);
gotonextmap(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
}
e.preventDefault();
}
else if (keycode == "KeyA") {
if (stopquickplay == 0) {
roundsperqp2 = 0;
quicki = pickNextMap(false);
gotonextmap(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
}
e.preventDefault();
}
else if (keycode == "KeyQ") {
if (stopquickplay == 1) {
stopquickplay = 0;
quicki = 0;
qppaused = false;
notify("Enabled quickplay.");
}
else {
stopquickplay = 1;
quicki = 0;
qppaused = false;
notify("Disabled quickplay.");
}
e.preventDefault();
}
else if (keycode == "KeyP" && stopquickplay == 0) {
if (qppaused == true) {
qppaused = false;
notify("Unpaused quickplay.");
}
else {
qppaused = true;
notify("Paused quickplay.");
}
e.preventDefault();
}
else if (keycode == "KeyF") {
if (freejoin == false) {
freejoin = true;
notify("Freejoin is now on.");
}
else {
freejoin = false;
notify("Freejoin is now off.");
}
e.preventDefault();
}
}
else {
if (keycode == "KeyE") {
e.preventDefault();
}
else if (keycode == "KeyT") {
e.preventDefault();
}
else if (keycode == "KeyK") {
e.preventDefault();
}
else if (keycode == "KeyS") {
e.preventDefault();
}
else if (keycode == "KeyD") {
e.preventDefault();
}
else if (keycode == "KeyA") {
e.preventDefault();
}
else if (keycode == "KeyQ") {
e.preventDefault();
}
else if (keycode == "KeyP") {
e.preventDefault();
}
else if (keycode == "KeyF") {
e.preventDefault();
}
else if (keycode == "KeyR") {
e.preventDefault();
}
}
if (keycode == "KeyL") {
lobby();
e.preventDefault();
}
if (keycode == "KeyC") {
if (Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
if (Gdocument.getElementById("ingamechatcontent").style["max-height"] == "0px") {
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
}
else {
Gdocument.getElementById("ingamechatcontent").style["max-height"] = "0px";
}
}
e.preventDefault();
}
if (keycode == "KeyI") {
toggleDebugger();
e.preventDefault();
}
if (keycode == "KeyB") {
var element = Gdocument.getElementById("ingamewinner_scores");
if (element.style["opacity"] < 1) {
element.style["opacity"] = 1;
element.style["visibility"] = "visible";
}
else {
element.style["opacity"] = 0;
element.style["visibility"] = "unset";
}
e.preventDefault();
}
if (keycode == "KeyY") {
Gdocument.getElementById("pretty_top_settings").click();
Gdocument.getElementById("settings_close").click();
if (Gdocument.getElementById("settings_graphicsquality").value == 1) {
notify("You must have medium or high quality enabled to use this feature.");
return "";
}
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
var addto = { "children": [] };
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var addto2 = { "children": [] };
for (var i = 0; i < addto.children.length; i++) {
if (addto.children[i].constructor.name == "e") {
addto2 = addto.children[i];
break;
}
}
var checkxray = addto2.children[0];
var addto3 = addto2.children[0].children;
if (addto3.length == 1) {
checkxray = checkxray.children[0];
addto3 = addto3[0].children;
}
var xrayon = false;
if (checkxray.xrayon) {
checkxray.xrayon = false;
xrayon = false;
}
else {
checkxray.xrayon = true;
xrayon = true;
}
if (xrayon) {
notify("Xray is now on.");
for (var i = 0; i < addto3.length; i++) {
if (addto3[i].children.length > 0) {
var ids = [];
var ids2 = [];
for (var i3 = 0; i3 < addto3[i].children.length; i3++) {
addto3[i].children[i3].visible = false;
if (addto3[i].children[i3].children.length > 0) {
for (var i4 = 0; i4 < addto3[i].children[i3].children.length; i4++) {
if (addto3[i].children[i3].children[i4].geometry?.id) {
ids.push(addto3[i].children[i3].children[i4].geometry.id);
}
else if (addto3[i].children[i3].children[i4].texture?.baseTexture?.uid) {
ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
}
}
}
}
for (var i3 = 0; i3 < addto3[i].children.length; i3++) {
if (addto3[i].children[i3].children.length == 0) {
if (addto3[i].children[i3].geometry?.id) {
if (ids.includes(addto3[i].children[i3].geometry.id + 1)) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = 0.5;
}
}
else if (addto3[i].children[i3].texture?.baseTexture?.uid) {
if (ids2.includes(addto3[i].children[i3].texture.baseTexture.uid + 1)) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = 0.5;
}
}
if (addto3[i].children[i3].batchDirty) {
addto3[i].children[i3].visible = true;
addto3[i].children[i3].alpha = 0.5;
if (addto3[i].children[i3 + 1]) {
addto3[i].children[i3 + 1].visible = true;
addto3[i].children[i3 + 1].alpha = 0.5;
}
}
}
}
}
}
}
else {
notify("Xray is now off.");
for (var i = 0; i < addto3.length; i++) {
for (var i2 = 0; i2 < addto3[i].children.length; i2++) {
addto3[i].children[i2].visible = true;
addto3[i].children[i2].alpha = 1;
}
}
}
}
e.preventDefault();
}
if (keycode == "KeyN") {
if (FollowCam == true) {
notify("Follow Camera is now off.");
FollowCam = false;
if (parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden") {
var addto = { "children": [] };
for (var i = 0; i < parentDraw.children.length; i++) {
if (parentDraw.children[i].constructor.name == "e") {
addto = parentDraw.children[i];
break;
}
}
var canv = 0;
for (var i = 0; i < Gdocument.getElementById("gamerenderer").children.length; i++) {
if (Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement") {
canv = Gdocument.getElementById("gamerenderer").children[i];
break;
}
}
var width = parseInt(canv.style["width"]);
var height = parseInt(canv.style["height"]);
parentDraw.x = -addto.scale.x * parseInt(width) / 2 + parseInt(width) / 2;
parentDraw.y = -addto.scale.y * parseInt(height) / 2 + parseInt(height) / 2;
parentDraw.children[0].x = parseInt(width) / 2 * addto.scale.x - parseInt(width) / 2;
parentDraw.children[0].y = parseInt(height) / 2 * addto.scale.y - parseInt(height) / 2;
if (addto.scale.x >= 0.99999 && addto.scale.y >= 0.99999) {
pixiCircle.visible = false;
}
else {
pixiCircle.visible = true;
}
}
}
else {
notify("Follow Camera is now on.");
FollowCam = true;
}
e.preventDefault();
}
if (keycode == "KeyV") {
if (autocam == true) {
notify("Auto Cam is now off.");
autocam = false
}
else {
notify("Auto Cam is now on.");
autocam = true;
}
e.preventDefault();
}
if (keycode == "BracketLeft") {
if (pan_enabled == true) {
notify("Pan is now off.");
pan = { "x": 0, "y": 0 };
pan_enabled = false;
}
else {
notify("Pan is now on. Shift + Arrow Keys to pan.");
pan_enabled = true;
}
return "";
}
if (keycode == "BracketRight") {
pan = { "x": 0, "y": 0 };
notify("Reset pan.");
return "";
}
if (keycode == "KeyO") {
if (heavybot == true) {
notify("Heavy bot is now off.");
heavybot = false;
}
else {
notify("Heavy bot is now on.");
heavybot = true;
getplayerkeys();
}
e.preventDefault();
}
if (keycode == "KeyU") {
if (aimbot == true) {
notify("Aimbot is now off.");
aimbot = false;
}
else {
notify("Aimbot is now on.");
aimbot = true;
getplayerkeys();
}
e.preventDefault();
}
if (keycode == "KeyM") {
}
}
if (!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
if (keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")) {
if (Gdocument.getElementById("newbonklobby").style["display"] == "block" && Gdocument.getElementById("newbonklobby_chat_input").value == "" && Gdocument.getElementById("maploadwindowcontainer").style["display"] != "block" && Gdocument.getElementById("newbonklobby_chat_input").style["display"] == "") {
Gdocument.getElementById("newbonklobby_chat_input").value = "/";
if (Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none") {
fire("keydown", { keyCode: 13 });
}
else {
Gdocument.getElementById("newbonklobby_chat_input").focus();
}
e.preventDefault();
}
else if (Gdocument.getElementById("ingamechatinputtext").style["visibility"] == "visible" && Gdocument.getElementById("ingamechatinputtext").style["display"] == "" && Gdocument.getElementById("mapeditorcontainer").style["display"] != "block" && Gdocument.getElementById("ingamechatinputtext").value == "") {
Gdocument.getElementById("ingamechatinputtext").value = "/";
if (!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")) {
fire("keydown", { keyCode: 13 });
}
else {
Gdocument.getElementById("ingamechatinputtext").focus();
}
e.preventDefault();
}
}
}
};
Gdocument.onkeydown = hotkeys;
Gwindow.addEventListener('resize', function (e) {
if (typeof debuggermenu == "undefined") { return; }
debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
}, true);
function timeout123() {
updateWssLog();
if (typeof debuggermenu != "undefined" && debuggermenu.style["display"] != "none") {
var dbgLob = Gdocument.getElementById("newbonklobby");
var dbgGr = Gdocument.getElementById("gamerenderer");
var dbgInRoom = (dbgLob && dbgLob.style["display"] == "block") || (dbgGr && dbgGr.style["visibility"] != "hidden");
if (!dbgInRoom) { setDebuggerOpen(false); }
}
if (typeof updatePlaylistChrome != "undefined") { try { updatePlaylistChrome(); } catch (e) { } }
statsTick();
try {
EVENTLOOPFUNCTION();
} catch (e) {
console.log(e);
}
var now = Date.now();
var keys = Object.keys(playerids);
if (xpfarm && inroom && lastXPtimestamp + 8000 < now) {
lastXPtimestamp = now;
SEND('42[38]');
}
if (getroomslastcheck + 3000 < now) {
getroomslastcheck = now;
if (savedrooms.length > 0) {
var xhr = new Gwindow.XMLHttpRequest();
xhr.open("POST", "https://bonk2.io/scripts/getrooms.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("version=49&gl=n&token=");
}
}
var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
for (var i = 0; i < namelist.length; i++) {
var level = 0;
var levelelement = 0;
var pingelement = 0;
var avatarelement = 0;
var children = namelist[i].parentElement.children;
for (var i2 = 0; i2 < children.length; i2++) {
if (children[i2].className == "newbonklobby_playerentry_level") {
levelelement = children[i2];
level = parseInt(children[i2].textContent.slice(6));
}
else if (children[i2].className == "newbonklobby_playerentry_pingtext") {
pingelement = children[i2];
}
else if (children[i2].className == "newbonklobby_playerentry_avatar") {
avatarelement = children[i2];
}
}
var isadmin = [false, 0];
for (var i3 = 0; i3 < admins.length; i3++) {
if (admins[i3][0] == namelist[i].textContent) {
isadmin = [true, i3];
break;
}
}
if (level) {
if (isadmin[0]) {
namelist[i].style["color"] = "rgb(" + admins[isadmin[1]][1].slice(0, -1).toString() + ")";
if (isadmin[1] <= 3) {
var rotatevalue = 0;
if (admins[isadmin[1]][1][3] < 90) {
rotatevalue = admins[isadmin[1]][1][3] / 2;
}
else if (admins[isadmin[1]][1][3] < 270) {
rotatevalue = (180 - admins[isadmin[1]][1][3]) / 2;
}
else if (admins[isadmin[1]][1][3] < 360) {
rotatevalue = (-360 + admins[isadmin[1]][1][3]) / 2;
}
if (isadmin[1] <= 2) {
namelist[i].parentElement.style["filter"] = "hue-rotate(" + rotatevalue.toString() + "deg)";
}
namelist[i].parentElement.style["font-size"] = "17px";
namelist[i].parentElement.style["background"] = "rgb(" + [255 - admins[isadmin[1]][1][0], 255 - admins[isadmin[1]][1][1], 255 - admins[isadmin[1]][1][2]].toString() + ")";
if (levelelement) {
levelelement.style["color"] = "rgb(" + admins[isadmin[1]][1].slice(0, -1).toString() + ")";
}
if (pingelement) {
pingelement.style["color"] = "rgb(" + admins[isadmin[1]][1].slice(0, -1).toString() + ")";
}
if (avatarelement) {
avatarelement.style["filter"] = "hue-rotate(" + rotatevalue.toString() + "deg)";
}
}
}
}
var stylekeys = Object.keys(allstyles);
for (var i3 = 0; i3 < stylekeys.length; i3++) {
if (stylekeys[i3] == namelist[i].textContent) {
if (namelist[i].style["color"] != "rgb(" + allstyles[stylekeys[i3]].toString() + ")" && (allstyles[stylekeys[i3]][0] + allstyles[stylekeys[i3]][1] + allstyles[stylekeys[i3]][2] != 0 || !isadmin[0])) {
var rgbvalue = [allstyles[stylekeys[i3]][0], allstyles[stylekeys[i3]][1], allstyles[stylekeys[i3]][2]];
namelist[i].style["color"] = "rgb(" + rgbvalue.toString() + ")";
if (!isadmin[0]) {
var n = 255;
namelist[i].parentElement.style["background"] = "rgb(" + [(203 + rgbvalue[0]) % n, (212 + rgbvalue[1]) % n, (215 + rgbvalue[2]) % n].toString() + ")";
}
if (levelelement) {
levelelement.style["color"] = "rgb(" + rgbvalue.toString() + ")";
}
if (pingelement) {
pingelement.style["color"] = "rgb(" + rgbvalue.toString() + ")";
}
}
}
}
}
for (var i3 = 0; i3 < admins.length; i3++) {
if (admins[i3][1][0] == 0 && admins[i3][1][1] == 0 && admins[i3][1][2] == 0) {
admins[i3][1][2] = 180;
admins[i3][1][1] = 0;
admins[i3][1][0] = 0;
}
var rate = 5;
var lowest = 0;
var number = 360;
admins[i3][1][3] = (admins[i3][1][3] % number + 4 + number) % number;
if (admins[i3][1][0] > lowest && admins[i3][1][1] == lowest) {
admins[i3][1][0] -= rate;
admins[i3][1][2] += rate;
}
if (admins[i3][1][2] > lowest && admins[i3][1][0] == lowest) {
admins[i3][1][2] -= rate;
admins[i3][1][1] += rate;
}
if (admins[i3][1][1] > lowest && admins[i3][1][2] == lowest) {
admins[i3][1][0] += rate;
admins[i3][1][1] -= rate;
}
for (var i4 = 0; i4 < 3; i4++) {
if (admins[i3][1][i4] < lowest) {
admins[i3][1][i4] = lowest;
}
else if (admins[i3][1][i4] > 255) {
admins[i3][1][i4] = 255;
}
}
}
if (randomchat) {
if (randomchat_timestamp + randomchat_randomtimestamp < now) {
randomchat_timestamp = now;
randomchat_randomtimestamp = 2000 + Math.random() * 2000;
var randnumber = Math.floor(Math.random() * randomchatpriority[0]) - randomchatlastmessage[1];
for (var i = 0; i < randomchatpriority[1].length; i++) {
if (randomchatpriority[1][i][0] != randomchatlastmessage[0]) {
randnumber -= randomchatpriority[1][i][1];
if (randnumber <= 0) {
chat(flag_manage(randomchatpriority[1][i][0]));
randomchatpriority[1][i][1] += 2;
randomchatpriority[0] += 2;
randomchatlastmessage = randomchatpriority[1][i];
break;
}
}
}
}
}
for (var i = 0; i < keys.length; i++) {
if (autokickbantimestamp + 500 < now && keys[i] != myid && !playerids[keys[i]]?.commands && autokickban > 0 && playerids[keys[i]].peerID != "sandbox" && ishost && playerids[keys[i]].ratelimit.join + 750 < now) {
SEND('42[9,{"banshortid":' + keys[i].toString() + ',"kickonly":' + (autokickban == 1).toString() + '}]');
autokickbantimestamp = now;
}
if (playerids[keys[i]].playerData) {
if (playerids[keys[i]].playerData2) {
if (playerids[keys[i]].playerData.transform) {
playerids[keys[i]].playerData2.alive = true;
if (playerids[keys[i]].playerData2.timeStamp == 0) {
playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
playerids[keys[i]].playerData2.pa = playerids[keys[i]].playerData.rotation;
playerids[keys[i]].playerData2.timeStamp = performance.now();
}
else {
playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x) / (playerids[keys[i]].playerData2.timeStamp - performance.now());
playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y) / (playerids[keys[i]].playerData2.timeStamp - performance.now());
var deltaA = positive(positive(playerids[keys[i]].playerData2.pa) - positive(playerids[keys[i]].playerData.rotation));
if (deltaA > Math.PI) {
deltaA -= 2 * Math.PI;
}
playerids[keys[i]].playerData2.avel = deltaA / (playerids[keys[i]].playerData2.timeStamp - performance.now());
playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
playerids[keys[i]].playerData2.pa = playerids[keys[i]].playerData.rotation;
playerids[keys[i]].playerData2.timeStamp = performance.now();
}
if (playerids[keys[i]].playerData2.timeStamp2 == 0) {
playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
playerids[keys[i]].playerData2.timeStamp2 = performance.now();
}
else {
playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel) / ((playerids[keys[i]].playerData2.timeStamp2 - performance.now()));
playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel) / ((playerids[keys[i]].playerData2.timeStamp2 - performance.now()));
playerids[keys[i]].playerData2.axs = (playerids[keys[i]].playerData2.axs || 0) * 0.85 + playerids[keys[i]].playerData2.xacc * 0.15;
playerids[keys[i]].playerData2.ays = (playerids[keys[i]].playerData2.ays || 0) * 0.85 + playerids[keys[i]].playerData2.yacc * 0.15;
playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
playerids[keys[i]].playerData2.timeStamp2 = performance.now();
}
}
else {
if (playerids[keys[i]].playerData2.alive) {
if (keys[i] == myid) { recordDeath(); }
}
playerids[keys[i]].playerData2.alive = false;
}
}
else {
playerids[keys[i]].playerData2 = { alive: true, radius: 12, timeStamp: 0, timeStamp2: 0, px: 0, py: 0, pvx: 0, pvy: 0, xacc: 0, yacc: 0, axs: 0, ays: 0, xvel: 0, yvel: 0, avel: 0, pa: 0, balance: 0 };
}
}
}
for (var i = 0; i < keys.length; i++) {
if (!playerids[keys[i]].playerData2) {
playerids[keys[i]].playerData2 = { alive: true, radius: 12, timeStamp: 0, timeStamp2: 0, px: 0, py: 0, pvx: 0, pvy: 0, xacc: 0, yacc: 0, axs: 0, ays: 0, xvel: 0, yvel: 0, avel: 0, pa: 0, balance: 0 };
}
}
if (Gdocument.getElementById("redefineControls_table").children[0].children.length <= 1 && keys.length > 0) {
Gdocument.getElementById("pretty_top_settings").click();
Gdocument.getElementById("settings_close").click();
}
if (pollactive[0] && pollactive[2] < now && ishost) {
playerids[myid].ratelimit.poll = Date.now();
SEND("42" + JSON.stringify([4, { "type": "poll end", "from": username }]));
var count = [0, 0, 0, 0];
var keys = Object.keys(playerids);
for (var i = 0; i < keys.length; i++) {
if (playerids[keys[i]].vote.poll != -1 && playerids[keys[i]].vote.poll < pollactive[3].length - 1) {
count[playerids[keys[i]].vote.poll]++;
}
playerids[keys[i]].vote.poll = -1;
}
notify("The poll ended due to time.");
for (var i = 0; i < count.length; i++) {
if (count[i] > 1) {
notify(count[i].toString() + " people voted for option " + letters[i] + ".");
}
if (count[i] == 1) {
notify(count[i].toString() + " person voted for option " + letters[i] + ".");
}
}
notify("The poll was:");
for (var i = 0; i < pollactive[3].length; i++) {
notify(letters[i] + ") " + pollactive[3][i]);
}
pollactive = [false, 0, 0, []];
}
if (!ishost && sandboxcopyme != -1) {
sandboxcopyme = -1;
}
if (afkkill > 0 && ishost) {
var keys = Object.keys(playerids);
currentFrame = Math.floor((now - gameStartTimeStamp) / 1000 * 30);
for (var i = 0; i < keys.length; i++) {
if (typeof (playerids[keys[i]].lastmove) == "undefined") {
playerids[keys[i]].lastmove = now;
}
else {
if (playerids[keys[i]].playerData2?.alive && now - playerids[keys[i]].lastmove >= afkkill * 1000 && now - gameStartTimeStamp >= afkkill * 1000 && !killedids.includes(keys[i])) {
killedids.push(keys[i]);
SEND('42[25,{"a":{"playersLeft":[' + keys[i] + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
RECIEVE('42[31,{"a":{"playersLeft":[' + keys[i] + '],"playersJoined":[]},"f":' + currentFrame.toString() + '}]');
break;
}
}
}
}
if ((Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS" || Gdocument.getElementById("maploadtypedropdowntitle").textContent == "HISTORY")) {
clearmaprequests.style["display"] = "block";
refreshmaprequests.style["display"] = "block";
}
else {
clearmaprequests.style["display"] = "none";
refreshmaprequests.style["display"] = "none";
}
if (Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden") {
Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
Gdocument.getElementById("ingamechatcontent").style["max-height"] = chatheight.toString() + "px";
pan = { "x": 0, "y": 0 };
}
if (Gdocument.getElementById("maploadwindowmapscontainer").children.length > 0 && maponclick == 0) {
maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
}
if ((Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden" || Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "") && (Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "hidden" || Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "")) {
var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
while (chatbox.firstChild) {
chatbox.removeChild(chatbox.firstChild);
}
chatbox = Gdocument.getElementById("ingamechatcontent");
while (chatbox.firstChild) {
chatbox.removeChild(chatbox.firstChild);
}
rcaps_flag = false;
space_flag = false;
number_flag = false;
curse_flag = false;
reverse_flag = false;
autocorrect = false;
translating2 = [false, ""];
translating = [false, ""];
echo_list = [];
scroll = false;
FollowCam = false;
followTarget = -1;
autocam = false;
aimbot = false;
recievedinitdata = false;
zoom = 1;
zoom2 = 1;
newzoom = 1;
newzoom2 = 1;
FFA = true;
mode = "b";
ghostroomwss = -1;
heavybot = false;
stopquickplay = 1;
roundsperqp = 1;
roundsperqp2 = 0;
staystill = false;
staystillpos = [0, 0];
recording = false;
recordingid = -1;
reverseqp = false;
jointeam = -1;
currentroomaddress = -1;
checkboxhidden = false;
freejoin = false;
shuffle = false;
defaultmode = "";
recmodebool = false;
recteams = false;
autorecord = false;
pollactive = [false, 0, 0, []];
pollactive2 = [false, 0, []];
afkkill = -1;
textmode = -1;
nextafter = 0;
jointext = "";
ishost = false;
parentDraw = 0;
sandboxplayerids = {};
sandboxcopyme = -1;
wintext = "";
sandboxon = false;
sandboxid = 200;
disabledkeys = [];
myid = -1;
oldhostid = -1;
randomchat = false;
savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
randomchatpriority = [0, []];
randomchatlastmessage = ["", 0];
autokickbantimestamp = 0;
autokickban = 0;
inroom = false;
causelag = false;
causelag2 = 0;
allstyles = {};
pan = { "x": 0, "y": 0 };
createqproominput.selectedIndex = 0;
if (!bonkwss) {
playerids = {};
}
qppaused = false;
nextafterbuffer = -1;
hostid = -1;
if (chatlog[chatlog.length - 1] != "ROOM END") {
chatlog.push("ROOM END");
}
}
else {
if (chatlog[chatlog.length - 1] == "ROOM END") {
chatlog.push("ROOM START");
}
}
if (Gdocument.getElementById("newbonklobby").style["display"] == "block") {
Gdocument.getElementById("ingamechatinputtext").style["visibility"] = "hidden";
}
else {
Gdocument.getElementById("ingamechatinputtext").style["visibility"] = "visible";
}
if ((myid == hostid && myid != -1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0) {
ishost = true;
}
else {
ishost = actuallyhost;
}
if (Gdocument.getElementById("pretty_top_name") != null) {
username = Gdocument.getElementById("pretty_top_name").textContent;
if (myid != -1) {
username = playerids[myid].userName;
}
}
try {
Last_message = lastmessage()
} catch {
Last_message = "";
}
if (Laster_message != Last_message) {
Laster_message = Last_message;
if (changed_chat == false) {
new_message = true;
}
else {
changed_chat = false;
}
}
if (new_message) {
chatlog.push(Last_message);
var lm = "";
try {
lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length - 1].children;
if (typeof (lm[0].parentElement.style["parsed"]) == 'undefined') {
if (lm[0].className == "newbonklobby_chat_msg_colorbox") {
lm[2].innerHTML = urlify(lm[2].innerHTML);
Laster_message = lastmessage();
lm[0].parentElement.style["parsed"] = true;
}
if (lm[0].className == "newbonklobby_chat_status") {
lm[0].innerHTML = urlify(lm[0].innerHTML);
Laster_message = lastmessage();
lm[0].parentElement.style["parsed"] = true;
}
}
}
catch {
lm = "";
}
if (Last_message.indexOf("@" + username) != -1 && npermissions == 1) {
onMentioned(Last_message);
}
try {
lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length - 1].children;
if (typeof (lm[0].parentElement.style["parsed"]) == 'undefined') {
if (lm[0].className == "ingamechatname") {
lm[1].innerHTML = urlify(lm[1].innerHTML);
Laster_message = lastmessage();
lm[0].parentElement.style["parsed"] = true;
}
if (lm[0].className == "") {
lm[0].innerHTML = urlify(lm[0].innerHTML);
Laster_message = lastmessage();
lm[0].parentElement.style["parsed"] = true;
}
}
}
catch {
lm = "";
}
if (text2speech) {
if (!sayer.speaking) {
if (Last_message.includes(": ")) {
speech.text = Last_message.substring(0, Last_message.indexOf(":")).toLowerCase();
speech.rate = 2.25;
sayer.speak(speech);
speech.text = Last_message.substring(Last_message.indexOf(": ") + 3).toLowerCase();
speech.rate = 1.25;
sayer.speak(speech);
}
else {
speech.text = Last_message.toLowerCase();
sayer.speak(speech);
}
}
}
}
if (ishost == true && new_message) {
for (i = 0; i < banned.length; i++) {
if (Last_message.startsWith("* " + banned[i] + " has joined the game")) {
chat2("/kick '" + banned[i] + "'");
}
}
}
if (Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost) {
roundsperqp2 = 0;
}
if (Gdocument.getElementById("ingamewinner").style["visibility"] == "inherit" && ishost) {
if (Gdocument.getElementById("ingamewinner").style["parsed"] != true) {
if (stopquickplay != 1) {
roundsperqp2++;
}
if (autorecord) {
Gdocument.getElementById("pretty_top_replay").click();
}
}
if (Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext != "" && Gdocument.getElementById("ingamewinner_bottom").textContent != "DRAW") {
chat(flag_manage(wintext.replaceAll("username", Gdocument.getElementById("ingamewinner_top").textContent)));
}
Gdocument.getElementById("ingamewinner").style["parsed"] = true;
}
else {
Gdocument.getElementById("ingamewinner").style["parsed"] = false;
}
if (ishost && stopquickplay == 0) {
if (checkboxhidden) {
checkboxhidden = false;
var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
for (var i = 0; i < classes.length; i++) {
classes[i].style["display"] = "block";
classes[i].className = "quickplaycheckbox quickplaychecked";
}
Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
}
if (nextafter > 0 && gameStartTimeStamp + nextafter * 1000 <= now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"] != "inherit" && !qppaused) {
roundsperqp2 = 0;
quicki = pickNextMap(true);
startedinqp = true;
dontswitch = true;
gotonextmap(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
}
if (Gdocument.getElementById("ingamewinner").style["visibility"] == "inherit" && dontswitch == false && !document.hidden && !qppaused) {
if (roundsperqp2 >= roundsperqp) {
quicki = pickNextMap(true);
}
transitioning = true;
startedinqp = true;
map(quicki % (Gdocument.getElementById("maploadwindowmapscontainer").children.length));
dontswitch = true;
setTimeout(function () { Gdocument.getElementById("ingamewinner").style["visibility"] = "hidden"; dontswitch = false; }, timedelay);
}
}
else {
if (!checkboxhidden) {
checkboxhidden = true;
var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
for (var i = 0; i < classes.length; i++) {
classes[i].style["display"] = "none";
classes[i].className = "quickplaycheckbox quickplayunchecked";
}
Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
}
}
new_message = false;
};
});