// ==UserScript==
// @name Sploop++
// @version 0.4
// @description simple visuals
// @author nyannez
// @match *://sploop.io/*
// @run-at document-start
// @icon https://www.google.com/s2/favicons?sz=64&domain=sploop.io
// @grant none
// @namespace https://greasyfork.org/users/960747
// @downloadURL none
// ==/UserScript==
const serverInfo = document.createElement("span");
const servers = {
SFRA: "EU#1 Sand",
SFRA2: "EU#2",
SFRA2BIS: "EU#2 Sand",
SCA: "USA#1 Sand",
SCA2: "USA#2 Sand",
SGP: 'AS#1 Sand',
SGP2: 'AS#2 Sand',
SGP3BIS: "AS#3 Sand",
FRA1FFA: "EU Classic",
CA1FFA: "USA Classic",
SGP1FFA: "AS Classic",
};
window.addEventListener('DOMContentLoaded', event => {
const Comfortaa = document.createElement('style');
Comfortaa.innerHTML = `@import "https://fonts.googleapis.com/css2?family=Comfortaa&display=swap";`;
document.head.appendChild(Comfortaa);
serverInfo.style = `
position: absolute;
font-size: 120%;
z-index: 888;
top: 15px;
color: white;
left: 1%;
font-weight: 100;
pointer-events: none;
font-family: Comfortaa;
text-shadow: 1px 1px 5px black, 3px 3px 5px black;
`;
const pingCount = document.createElement("span");
pingCount.id = "pingCount";
pingCount.style = "position: absolute;z-index: 10;left: 1%;font-family: Comfortaa;pointer-events:none;top: 50px;font-size: 120%;color: white;font-weight: 100;text-shadow: 1px 1px 5px black, 3px 3px 5px black;"
pingCount.textContent = "Ping: unknown";
serverInfo.textContent = "Loading...";
document.body.append(serverInfo, pingCount);
setInterval(() => {
getSploopServers();
const serverName = currentServerUrl.toUpperCase();
const server = sploopServers.find(i => i.r === serverName);
serverInfo.textContent = `${servers[serverName]}: ${server.d[1]}`;
}, 1500)
})
let sploopServers, currentServerUrl, ws;
const getSploopServers = async () => {
await fetch("https://sploop.io/servers").then(e => e.text()).then(e => (sploopServers = JSON.parse(e)));
};
const entities = {
0: { health: 100 },
14: { health: 380 },
23: { health: 380 },
24: { health: 380 },
25: { health: 1000 },
27: { health: 5000 },
28: { health: 5000 },
36: { health: 380 },
};
const packetsID = {
item: 0,
move: 1,
hat: 5,
chat: 7,
place: 8,
joinGame: 11,
angle: 13,
upgrade: 14,
stopMove: 15,
clanAcc: 17,
stopAttack: 18,
hit: 19,
joinClan: 21,
clan: 22,
EAttack: 23,
clanLeave: 24
};
let myID, placing = true, copyMove = 0, onHand = 0, placed = false, isAlive = false;
const sendPacket = (packetID, ...values) => ws.send(new Uint8Array([packetID, ...values]));
const getAngle = (angle) => {
const vec = {
x: 0,
y: 0
};
if (angle & 1) vec.y--;
if (angle & 2) vec.y++;
if (angle & 4) vec.x--;
if (angle & 8) vec.x++;
vec.x *= -1;
vec.y *= -1;
return Math.atan2(vec.y, vec.x);
}
const checkChat = () => document.getElementById('chat-wrapper').style.display === "" || document.getElementById('chat-wrapper').style.display === "none";
window.addEventListener("keydown", event => {
const pressedKey = event.code;
if (pressedKey === "Digit1") {
onHand = 0;
} else if (pressedKey === "Digit2") onHand = 1;
if (checkChat() && ["KeyW", "KeyA", "KeyS", "KeyD"].includes(pressedKey)) {
if (pressedKey === "KeyW") copyMove |= 1;
if (pressedKey === "KeyA") copyMove |= 4;
if (pressedKey === "KeyS") copyMove |= 2;
if (pressedKey === "KeyD") copyMove |= 8;
}
})
window.addEventListener("keyup", event => {
const pressedKey = event.code;
if (checkChat() && ["KeyW", "KeyA", "KeyS", "KeyD"].includes(pressedKey)) {
if (pressedKey === "KeyW") copyMove &= -2;
if (pressedKey === "KeyA") copyMove &= -5;
if (pressedKey === "KeyS") copyMove &= -3;
if (pressedKey === "KeyD") copyMove &= -9;
}
})
const sound = new Audio("https://cdn.discordapp.com/attachments/911689086903918602/1203401888792318023/uK3Ujie.mp3?ex=65d0f658&is=65be8158&hm=35e255836bc58ddc434aedc81ddbb149a1cde594ed6ae13a197212b865ef581e&");
window.getKill = (data) => {
}
window.receiveMsg = (msg) => {
const data = msg.data;
const decoded = typeof data === "string" ? JSON.parse(data) : new Uint8Array(data);
if (!ws) {
currentServerUrl = msg.target.url.split('//')[1].split('.')[0];
ws = msg.target;
ws.onclose = () => (ws = undefined);
};
switch (decoded[0]) {
case 20: {
if (copyMove !== 0 && isAlive && serverInfo.textContent.includes("Sand") && !placed && window.stats[Sploop.objCount][5] < 8 && placing) {
placing = false;
sendPacket(packetsID.item, 5);
const angle = getAngle(copyMove);
const transformedAngle = 65535 * (angle + Math.PI) / (2 * Math.PI);
sendPacket(packetsID.hit, 255 & transformedAngle, transformedAngle >> 8 & 255);
sendPacket(packetsID.stopAttack);
sendPacket(packetsID.item, onHand);
setTimeout(() => {
placing = true;
}, 100)
} else if (window.stats[Sploop.objCount][5] === 8) placed = true;
break;
}
case 15:
document.getElementById("pingCount").textContent = `Ping: ${decoded[1]}`;
break;
case 35:
isAlive = true;
break;
case 19:
onHand = 0;
isAlive = false;
placed = false;
break;
case 33: (myID = decoded[1]);
}
};
let gameEntity;
let chests = [], queue = [];
window.attackAnimation = (type, id, weapon, isObject, entity) => {
if (entity.type === 30 && chests.some(chest => chest[Sploop.id2] === id)) {
queue.push(id);
} else if (entity.type === 0) {
const chests = queue.map(id => gameEntity.get(id));
queue = [];
if (!chests.length) return;
const hatAdditional = entity[Sploop.hat] === 11 ? 1.4 : (entity[Sploop.hat] === 2 ? 1.25 : 1);
const damage = (window.weapons[weapon][Sploop.weaponDamage2] || window.weapons[weapon][Sploop.weaponDamage]) * hatAdditional;
chests.forEach(entity => {
entity.health = ((entity.health -= damage) % 1 === 0) ? entity.health.toFixed(0) : entity.health.toFixed(1)
});
}
};
window.drawChestHP = (target, id, ctx, step) => {
if (target.type === 30 && target.health === undefined) target.health = 380;
if (!chests.some(chest => chest[Sploop.id2] === target[Sploop.id2]) && target.type === 30) chests.push(target);
};
window.removeEntity = (entity) => {
//second
if (!entity.health) return;
if ([12].includes(entity.type)) {
const player = [...gameEntity].filter(([key, value]) => Sploop.id in value && value[Sploop.id] === entity[Sploop.id] && value.type === 0)[0][1];
const spike = queue.map(id => gameEntity.get(id));
queue = [];
spike.forEach(obj => {
obj.health -= player[Sploop.currentWeapon]; // 27 : 30; ih, Kh, Lh
});
};
delete entity.health;
const index = chests.findIndex(chest => chest[Sploop.id2] === entity[Sploop.id2]);
if (index !== -1) {
chests.splice(index, 1);
}
};
window.draw = true;
window.getEntityData = async (entity, ctx, isTeammate, map) => {
gameEntity = map;
const entityX = entity[Sploop.x],
entityY = entity[Sploop.y];
const maxHealth = entities[entity.type].health;
const entityHealth = ((entity[Sploop.health] * maxHealth / 100) / 255 * 100).toFixed(0);
if (window.draw) {
ctx.font = "100 20px MV Boli";
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.shadowColor = "#000000";
ctx.shadowBlur = 5;
ctx.fillStyle = (entity[Sploop.id] === myID || isTeammate) ? window.myHPColor : "#802641";
ctx.fillText(`${entityHealth}/${maxHealth}`, entityX - 50, entityY + window.sprites[entity.type][Sploop.size] + 70);
ctx.shadowBlur = 0;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
};
if (chests.length) {
chests.forEach(target => {
ctx.save();
ctx.beginPath();
ctx.textAlign = "center";
ctx.font = "600 20px Comfortaa";
ctx.fillStyle = "#fff";
ctx.strokeStyle = "#000";
ctx.lineWidth = 3;
ctx.strokeText(target.health, target[Sploop.x], target[Sploop.y] + 5);
ctx.fillText(target.health, target[Sploop.x], target[Sploop.y] + 5);
ctx.fillRect
ctx.closePath();
ctx.restore();
});
}
}
window.requestAnimationFrame = (t) => setTimeout(t, 0);
const TYPEOF = value => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
const NumberSystem = [
{ radix: 2, prefix: "0b0*" },
{ radix: 8, prefix: "0+" },
{ radix: 10, prefix: "" },
{ radix: 16, prefix: "0x0*" }
];
class Regex {
constructor(code, unicode) {
this.code = this.COPY_CODE = code;
this.unicode = unicode || false;
this.hooks = {};
}
static parseValue = value => {
try { return Function(`return (${value})`)(); }
catch (err) { return null; }
};
isRegexp = value => TYPEOF(value) === "regexp";
generateNumberSystem = int => `(?:${NumberSystem.map(({ prefix, radix }) => prefix + int.toString(radix)).join("|")})`;
parseVariables = regex => regex.replace(/\{VAR\}/g, "(?:let|var|const)")
.replace(/\{QUOTE\}/g, "['\"`]")
.replace(/ARGS\{(\d+)\}/g, (_, count) => (Array(Number(count)).fill("\\w+")).join("\\s*,\\s*"))
.replace(/NUMBER\{(\d+)\}/g, (_, int) => this.generateNumberSystem(Number(int)));
format = (name, inputRegex, flags) => {
const regex = Array.isArray(inputRegex) ? inputRegex.map(exp => this.isRegexp(exp) ? exp.source : exp).join("\\s*") : this.isRegexp(inputRegex) ? inputRegex.source : "";
let parsedRegex = this.parseVariables(regex);
if (this.unicode) {
parsedRegex = parsedRegex.replace(/\\w/g, "(?:[^\\x00-\\x7F-]|\\$|\\w)");
}
const expression = new RegExp(parsedRegex.replace(/\{INSERT\}/, ""), flags);
return parsedRegex.includes("{INSERT}") ? new RegExp(parsedRegex, flags) : expression;
};
template = (type, name, regex, substr) => {
const expression = new RegExp(`(${this.format(name, regex).source})`);
const match = this.code.match(expression) || [];
this.code = this.code.replace(expression, type === 0 ? "$1" + substr : substr + "$1");
return match;
};
match = (name, regex, flags, debug = false) => {
const expression = this.format(name, regex, flags);
const match = this.code.match(expression) || [];
this.hooks[name] = { expression, match };
return match;
};
matchAll = (name, regex, debug = false) => {
const expression = this.format(name, regex, "g");
const matches = [...this.code.matchAll(expression)];
this.hooks[name] = { expression, match: matches };
return matches;
};
replace = (name, regex, substr, flags) => {
const expression = this.format(name, regex, flags);
this.code = this.code.replace(expression, substr);
return this.code.match(expression) || [];
};
replaceAll = (name, regex, substr, flags) => {
const expression = this.format(name, regex, "g");
this.code = this.code.replaceAll(expression, substr);
return this.code.match(expression) || [];
};
append = (name, regex, substr) => this.template(0, name, regex, substr);
prepend = (name, regex, substr) => this.template(1, name, regex, substr);
insert = (name, regex, substr) => {
const { source } = this.format(name, regex);
if (!source.includes("{INSERT}")) throw new Error("Your regexp must contain {INSERT} keyword");
const findExpression = new RegExp(source.replace(/^(.*)\{INSERT\}(.*)$/, "($1)($2)"));
this.code = this.code.replace(findExpression, `$1${substr}$2`);
return this.code.match(findExpression);
};
};
window.convertToEmoji = (text) => {
const emojiRegex = /:(\w+):/g;
const convertedText = text.replace(emojiRegex, (match, p1) => {
const emojiMap = {
smile: '๐',
grin: '๐',
joy: '๐',
laughing: '๐',
sweat_smile: '๐
',
wink: '๐',
blush: '๐',
yum: '๐',
sunglasses: '๐',
heart_eyes: '๐',
kissing_heart: '๐',
kissing_closed_eyes: '๐',
stuck_out_tongue_winking_eye: '๐',
stuck_out_tongue_closed_eyes: '๐',
flushed: '๐ณ',
relieved: '๐',
unamused: '๐',
sweat: '๐',
pensive: '๐',
sleep: '๐ด',
mask: '๐ท',
thermometer_face: '๐ค',
head_bandage: '๐ค',
sleeping: '๐ด',
zzz: '๐ค',
poop: '๐ฉ',
clap: '๐',
thumbs_up: '๐',
thumbs_down: '๐',
heart: 'โค๏ธ',
broken_heart: '๐',
sparkling_heart: '๐',
star: 'โญ',
fire: '๐ฅ',
rainbow: '๐',
rocket: '๐',
hourglass: 'โ',
gift: '๐',
tada: '๐',
umbrella: 'โ',
snowflake: 'โ๏ธ',
sun: 'โ๏ธ',
moon: '๐',
beer: '๐บ',
coffee: 'โ',
cake: '๐ฐ',
money_bag: '๐ฐ',
bomb: '๐ฃ',
airplane: 'โ๏ธ',
anchor: 'โ',
guitar: '๐ธ',
alien: '๐ฝ',
skull: '๐',
ghost: '๐ป',
pumpkin: '๐',
christmas_tree: '๐',
santa: '๐
',
gift_box: '๐',
bell: '๐',
crossed_swords: 'โ๏ธ',
wizard: '๐ง',
clinking_glasses: '๐ฅ',
thinking_face: '๐ค',
detective: '๐ต๏ธโโ๏ธ',
scientist: '๐จโ๐ฌ',
astronaut: '๐จโ๐',
artist: '๐ฉโ๐จ',
pilot: '๐จโโ๏ธ',
bride_with_veil: '๐ฐ',
angel: '๐ผ',
baby: '๐ถ',
family: '๐ช',
thumbs_up: '๐',
thumbs_down: '๐',
};
return emojiMap[p1] || match;
});
return convertedText;
}
document.addEventListener("wheel", (event) => {
document.getElementById("hat_menu_content").scrollBy(0, event.deltaY < 0 ? -900 : 900);
});
window.rainb = true;
window.hue = 0;
let defaultHPColor = "#FEB8C5";
setInterval(() => {
if (window.rainb) {
window.myHPColor = `hsl(${window.hue}, 80%, 50%)`;
window.hue += 0.2;
window.hue >= 360 && (window.hue = 0);
} else {
window.myHPColor = defaultHPColor;
}
}, 20)
window.abbreviateNumber = (number) => {
const suffixes = {
't': 1e12,
'b': 1e9,
'm': 1e6,
'k': 1e3,
};
for (const [letter, value] of Object.entries(suffixes)) {
if (number >= value) {
const abbreviated = (number / value).toFixed(1).replace(/\.0$/, '');
return `${abbreviated}${letter}`;
}
}
return number.toString();
}
window.nameGold = false;
let Sploop;
const applyHooks = code => {
const Hook = new Regex(code, true);
window.COPY_CODE = (Hook.COPY_CODE.match(/^(\(function \w+\(\w+\)\{.+)\(.+?\);$/) || [])[1];
Hook.append("EXTERNAL fix", /\(function (\w+)\(\w+\)\{/, "let $2 = eval(`(() => ${COPY_CODE})()`);delete window.COPY_CODE;");
const ID = Hook.match('ID', /&&\w{2}===\w\.(\w{2})\){/)[1];
const map = Hook.match("objects", /\(\);(\w).get\(\w{2}\)&&/)[1];
const myData = Hook.match('myPlayer', /=(\w.get\(\w{2}\));\w&&\w\(\)/)[1];
const X = Hook.match('playerX', /\{this\.(\w{2})=\w\|\|0/)[1];
const Y = Hook.match('playerY', /,this\.(\w{2})=\w\|\|0\}/)[1];
const ID2 = Hook.match('ID2', /-1!==\w+\.(\w+)&&/)[1];
const currentWeapon = Hook.match("crntWeapon", /,\w.(\w{2})===/)[1];
const angle = Hook.match("angle", /;\w.(\w{2})=\w\(\)/)[1];
const weaponName = Hook.match("wpnName", /(\w{2}):"XX/)[1];
const health = Hook.match("health", /(\w{2})<<8;/)[1];
const weaponDamage = Hook.match("wpnDamage", /(\w{2}):32,reload:300/)[1];
const weaponDamage2 = Hook.match("wpnDamage", /\w{2}:25,.{6}:300,(\w{2}):30/)[1];
const teamID = Hook.match('test', /,\w=\w.(\w{2})\|.+?\<\<8/)[1];
const radius = Hook.match("radius", /(\w{2}):220/)[1];
const [, currentItem, hat] = Hook.match("hat", /\(\w+\.(\w+)\|\w+\.(\w+)<