`);
for(let i of settings.uiScaling){
$('#fsfb-sect-uiScale').append(`
${i.title}
`);
$( "#" + i.id).change(function() {
changeSettings(this.id, $(this).val());
});
};
// add event listeners
let mosX, mosY,
keys = {},
keysChanging = false;
$(document).on('click', e => {
for(let i = 0; i < settings.hotkeys.length; i++) checkHotkeyClicked(e, settings.hotkeys[i]);
for(let i = 0; i < settings.fastsplit_hotkeys.length; i++) settings.fastsplit_hotkeys[i].val == null && checkHotkeyClicked(e, settings.fastsplit_hotkeys[i]);
for(let i = 0; i < settings.quickSettings.length; i++) checkHotkeyClicked(e, settings.quickSettings[i]);
checkHotkeyClicked(e, settings.slowFeed[0]);
checkPowerupClicked(e);
})
.on('mousemove', e => {
if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
({clientX: mosX, clientY: mosY} = e);
if (linesplitting) linesplit();
})
.on("keydown", e => {
// if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
for(let i = 0; i < settings.hotkeys.length; i++) checkNewHotkey(e, settings.hotkeys[i]);
for(let i = 0; i < settings.fastsplit_hotkeys.length; i++) checkFsHotkey(e, settings.fastsplit_hotkeys[i]);
for(let i = 0; i < settings.quickSettings.length; i++) checkNewHotkey(e, settings.quickSettings[i]);
checkNewHotkey(e, settings.slowFeed[0]);
if (!(e.keyCode in keys)){
keys[e.keyCode] = !0;
pressed(e);
}
keysChanging = false;
})
.on("keyup", e => {
if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
delete keys[e.keyCode];
released(e.keyCode);
if(e.keyCode == getKey("keyFixedMouse") && cursorLockActivated){
e.stopImmediatePropagation();
e.preventDefault();
}
});
const hashCode = (str, shift) => {
let char, hash = 0;
if (str.length == 0) return hash;
for (let i = 0; i < str.length; i++) hash = (hash << shift) - hash + (char = str.charCodeAt(i)), hash |= 0;
return hash;
};
const RNG = (min, max) => Math.random() * (max - min) + min;
// chat cmds
if(extraChatCommands){
const $chtbox = $('#chtbox');
$chtbox.on('keydown', e => {
if(e.keyCode != 13) return;
let newMsg = '', params, command, firstMatch = $chtbox.val().match(new RegExp(`(?<=((^|(^\/party +)|(^\/pm +\\S+ ))${chatPrefix}))\\S+(\\s+\\S+)*(?=($|\\s+))`, 'gmi'));
if(firstMatch != null) {
[command, ...params] = firstMatch[0].replace(/\s+/g, ' ').split(' ');
} else return;
const originalMsg = $chtbox.val().replace(new RegExp(`(?<=((^|(^\/party +)|(^\/pm +\\S+ ))))${chatPrefix}${firstMatch[0]}(?=($|\\s+))`, 'gmi'), '');
coinsInfo();
xpInfo();
switch(command.toLowerCase()){
case 'help':
$('#fsfb-extra-info')[0].click();
setTimeout(() => $('.fsfb-modal-body').scrollTop(1850), 200);
newMsg = '';
break;
case 'bots': case 'bot': case 'min': case 'mins': case 'minion': case 'minions': {
let minInfo = misc_settings.bots?.[currentUser], minsAmt, minsTimeRem;
$('#infoContent').children().each(function(){
if($(this).text().includes('Minion Time:')) minsTimeRem = $(this).find('span').text();
if($(this).text().includes('Minions:')) minsAmt = $(this).find('span').text()
})
if((minsChatAmt[currentUser] != null && minsChatAmt[currentUser]?.amt && !minsChatAmt[currentUser]?.started) && (minInfo == null || (minInfo && Date.now() > minInfo.currMs + minInfo.rem))){ /* || (minInfo && Date.now() > minInfo.currMs + minInfo.rem) */
newMsg = `${originalMsg}Minion Pack Unstarted: ${minsChatAmt[currentUser].amt}`;
} else if(minsChatAmt[currentUser] != null && minsChatAmt[currentUser]?.started && minsChatAmt[currentUser]?.amt && minInfo == null ){
newMsg = `${originalMsg}Minion Pack Activated: ${minsChatAmt[currentUser].amt}`;
} else if(minsChatAmt[currentUser] != null && minsChatAmt[currentUser].amt && minInfo != null && (minInfo.active || minsChatAmt[currentUser].started) && minInfo.rem - (Date.now() - minInfo.currMs) > 0){
newMsg = `${originalMsg}Minion Pack Activated: ${minsChatAmt[currentUser].amt}, with ${msToTime(minInfo.rem - (Date.now() - minInfo.currMs))} remaining`;
} else if(minsAmt != null && minsTimeRem != null){
let timeArr = minsTimeRem.split(':'), msBotsTime = (3.6e6 * +timeArr[0]) + (6e4 * +timeArr[1]) + (1e3 * +timeArr[2]);
newMsg = `${originalMsg}Minion Pack Activated: ${minsAmt}, with ${msToTime(msBotsTime)} remaining`;
} else {
newMsg = `${originalMsg}Minion Pack Activated: none`;
}
break;
}
case 'pws': case 'pw': case 'powers': case 'power': case 'inv': case 'inventory': {
curserMsg(`It's recommended to use ${chatPrefix}${command}1 and ${chatPrefix}${command}2 instead, so your chat messages aren't cut-off by the chat maxlength`, 'red', 8e3);
updatePwCount();
newMsg = `${originalMsg}Inv: `;
for(let i in pws){ // rly shitty solution but can't think of a way better way to do it rn
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : ' ') + (amt == '' ? '' : (i + ', ')));
}
if(newMsg.length > 100){
newMsg = `${originalMsg}Inv: `;
for(let i in pws){
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : (i + ', ')));
}
if(newMsg.length > 100){
newMsg = `${originalMsg}Inv: `;
for(let i in pws){
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : (i + ',')));
}
if(newMsg.length > 100){
newMsg = `${originalMsg}Inv: `;
for(let i in pws){
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : '') + (amt == '' ? '' : (i[0] + i[1] + i[2]) + ','));
}
if(newMsg.length > 100){
newMsg = `${originalMsg}Inv: `;
for(let i in pws){
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : (i[0] + i[1]) + ','));
}
if(newMsg.length > 100){
newMsg = `${originalMsg}Inv: `;
for(let i in pws){
const amt = pws[i];
newMsg += (amt + (amt == '' ? '' : (i[0] + ',')));
}
}
}
}
}
}
newMsg = newMsg.replace(/,[^,]*$/g, '');
if(newMsg == 'Inv: ') newMsg = 'Inv: no powers';
break;
}
case 'totalpws': case 'totalpw': case 'totalpowers': case 'totalpower': case 'total': case 'totpw':
newMsg = `${originalMsg}Total Powerups: ${$('.inventory-box>p').toArray().map(x => +x.innerText).reduce((a, b) => a + b)}`
break;
case 'xplevel': case 'levelxp': case 'lvlxp': case 'xpcompleted': case 'xp':
newMsg = `${originalMsg}XP Completed: ${currentPercent ? String(Math.round(currentPercent * currentLevel * 1e3, 1)).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "/" + (currentLevel * 1e3).toLocaleString('en-US') : "0/0"}`
break;
case 'level': case 'levels': case 'lvls': case 'lvl': case 'lvlcompleted': case 'lvlscompleted':
newMsg = `${originalMsg}Level: ${currentLevel}, with ${round(currentPercent * 100, 3)}% completed`
break;
case 'coin': case 'coins':
newMsg = `${originalMsg}Coins: ${String(currentCoins).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
break;
case 'hours': case 'hrs': case 'hour': case 'hr': case 'timeplayed':
newMsg = originalMsg + $('.timePlayed>span').text();
break;
case 'rank': case 'lvlrank':
newMsg = `${originalMsg}My Rank: ${$('.ranking.text-left>span').text().match(/(?<=^Your rank: )\d+$/gm)?.[0]}`
break;
case 'ping': case 'delay': case 'ms':
newMsg = `${originalMsg}My Ping: ${$('#ping').text()}`
break;
case 'fps': case 'frames':
newMsg = `${originalMsg}My FPS: ${$('#fps').text()}`
break;
case 'topmass': case 'highscore': case 'highmass': case 'highestmass':
newMsg = `${originalMsg}My Top Mass: ${$('#topMass').text()}`
break;
case 'cells': case 'cellcount': case 'cell':
newMsg = `${originalMsg}My Cell Count: ${$('#cellsAmount').text()}`
break;
case 'pw1': case 'pws1': case 'power1': case 'powers1': case 'inv1': case 'inventory1':
newMsg = getPowerMessage(1, originalMsg);
break;
case 'pw2': case 'pws2': case 'power2': case 'powers2': case 'inv2': case 'inventory2':
newMsg = getPowerMessage(2, originalMsg);
break;
case 'pw3': case 'pws3': case 'power3': case 'powers3': case 'inv3': case 'inventory3':
newMsg = getPowerMessage(3, originalMsg);
break;
case 'friends': case 'friend': case 'friendsonline': case 'friendonline':
newMsg = `${originalMsg}Friends Online: ${$('#friendsLoggedInAmt').text() + $('#friendsTotalAmt').text()}`;
break;
case 'request': case 'requests': case 'friendrequest': case 'friendrequests': case 'friendreq': case 'req':
newMsg = `${originalMsg}Friend Requests: ${$('#friendsRequestsAmt').text() === '' ? 'none' : $('#friendsRequestsAmt').text()}`;
break;
case 'gold': case 'goldmem': case 'goldmember': case 'golddays': case 'gm': {
const obj = accGoldMem[currentUser];
if(obj?.has == null){
newMsg = `${originalMsg}Days of Goldmember Remaining: none`;
break;
}
newMsg = `${originalMsg}Days Of Goldmember Remaining: ${obj.has || obj.days != null ? (obj.days + (obj.days == 1 ? ' Day' : ' Days')) : 'none'}`;
break;
}
case 'alive': case 'alivetime': case 'timealive':
newMsg = `${originalMsg}Time Alive: ${unsafeWindow.playerIsAlive() ? msToTime(Date.now() - timeAlive) : 'not alive'}`;
break;
case 'mass': case 'currentmass':
newMsg = `${originalMsg}Current Mass: ${unsafeWindow.playerIsAlive() ? currentMass.toLocaleString('en-US') : 'none, not alive'}`;
break;
case 'user': case 'username': case 'usr': case 'account': case 'acc':
newMsg = `${originalMsg}My Username: ${currentUser == "Please Login First" ? "logged out" : currentUser}`
break;
case 'custom': case 'customs': case 'customskins': case 'totalcustoms':
if($('#publicSkinsPage').children().length == 0){
curserMsg(`Please load your custom skins before using this command`, 'red', 6e3);
newMsg = '';
break;
}
newMsg = `${originalMsg}My Total Custom Skins: ${$('[id^="skinCustomImg"').length}, worth ${($('[id^="skinCustomImg"').length * 1e6).toLocaleString('en-US')}`
break;
case 'skins': case 'boughtskins': case 'ownedskins': case 'totalskins': {
if($('#skinsBuy [id^="skinContainer"]').length == 0){
curserMsg(`Please load your owned skins from the agma.io skin store`, 'red', 6e3);
newMsg = '';
break;
}
let ownedSkinsArr = [], edSkins = 0, totalValue = 0;
$('#skinsBuy [id^="skinUseBtn"').each(function(){
ownedSkinsArr.push(+$(this)[0].id.match(/\d+$/gm)[0]);
})
for(let i of skinsArr){
if(ownedSkinsArr.indexOf(i.id) != -1){
i.price > 2e6 ? ++edSkins : totalValue += i.price;
}
}
newMsg = `${originalMsg}My Total Bought Skins: ${$('#skinsBuy [id^="skinUseBtn"').length}, worth ${totalValue.toLocaleString('en-US')} (${edSkins} lim. ed.)`
break;
}
case 'ownedwearables': case 'wearables': case 'wears': case 'totalwearables': case 'totalwears': {
if($('#phpWearables li').length <= 55){
curserMsg(`Please load your wearables before using this command`, 'red', 6e3);
newMsg = '';
break;
}
let wearsPrice = [0];
$('[id^="wearableUseBtn"]').each(function(){
wearsPrice.push(+$(this).parents().eq(0).siblings('span.win-price').text().replace(/,/g, ''))
});
newMsg = `${originalMsg}My Total Wearables: ${$('[id^="wearableUseBtn"]').length}, worth ${sigma(wearsPrice).toLocaleString('en-US')} coins`
break;
}
case 'cloak': case 'invis': case 'invisibility': {
let status, time;
$('#infoContent>p').each(function(){
if($(this).text().includes('Cloaked: ')) status = $(this).text().match(/(?<=Cloaked: ).+/gm);
if($(this).text().includes('Cloak Time: ')) time = $(this).text().match(/(?<=Cloak Time: ).+/gm);
})
newMsg = status == null || time == null ? `${originalMsg}Cloak inactive` : `${originalMsg}Cloak ${status}, with ${time} remaining`
break;
}
case 'addfriend': case 'add':
if(params?.length == 0){
curserMsg(`Please add a username after the command, such as: ${chatPrefix}${command} Fishyyy`, 'red', 6e3);
newMsg = '';
break;
}
unsafeWindow.friendAdd(params[0]);
break;
case 'partymembers': case 'partymember':
newMsg = $('#partyContent').children().length - 1 > 0 ? `${originalMsg}In a party, with ${$('#partyContent').children().length - 1} members` : `${originalMsg}Not in a party`;
break;
case 'players': case 'ply': case 'plyrs': case 'serverplayers': case 'totalplayers': case 'online': {
let players = 0, max = 0;
$('[id^="serverPlayers"]').toArray().map(a => a.innerText).forEach( e => {
let [plys, mx] = e.split('/')
players += +plys;
max += +mx;
})
newMsg = `${originalMsg}Server Players: ${$('[id^="serverRow"].active>[id^="serverPlayers"]').text()}, Total Players: ${players.toLocaleString('en-US') + ' / ' + max.toLocaleString('en-US')}`
break;
}
case 'server':
newMsg = `${originalMsg}Currently playing in ${$('[id^="serverRow"].active>*').first().text()}`;
break;
case 'abil': case 'abils': case 'ability': case 'abilities': { // not finished
let arr = [], newStr = '';
$('.checkmark').each(function(){
if($(this).css('display') == 'block') arr.push($(this).siblings().eq(1).attr('item'));
})
if(misc_settings.abil?.[currentUser] != null || arr.length){
const abil = misc_settings.abil?.[currentUser],
map = {
18: 'Freeze',
22: 'Invis Cloak',
20: '2x Spawn',
23: '2x Exp'
}
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}Active Abilities: none`;
break;
}
for(let i of arr) newStr += map[i] + (abil?.[i] != null && 8.64e7 - (Date.now() - abil[i]) > 0 ? (' with ' + msToTime(8.64e7 - (Date.now() - abil[i])) + ' left, ') : ', ');
newMsg = `${originalMsg}Active Abilities: ${newStr == '' ? 'none' : newStr}`;
newMsg = newMsg.replace(/,[^,]*$/g, '');
} else {
newMsg = `${originalMsg}Active Abilities: none`;
}
break;
}
case 'xpproj': case 'xpprojected': case 'projectedxp': case 'projxp': case 'levelprojected': case 'lvlproj': case 'lvlprojected': {
const projectedHr = lastHrXP.length > 0 ? sigma(getProperty(lastHrXP.slice(-5), "gained")) * 12 : 0;
newMsg = `${originalMsg}Next Hour Projected XP: ${xpStatsInPercentages ? round(convertToPerc(projectedHr, currentLevel) * 100, 2) + '%' : round(projectedHr).toLocaleString('en-US')}`;
break;
}
case 'projcoins': case 'projcoin': case 'projectedcoin': case 'projectedcoins': case 'coinsproj': case 'coinproj': case 'coinprojected': case 'coinsprojected': {
const projectedHr = lastHrCoins.length > 5 ? Math.round(sigma(getProperty(lastHrCoins.slice(-5), "gained")) * 12) : 0;
newMsg = `${originalMsg}Next Hour Projected Coins: ${projectedHr.toLocaleString('en-US')}`;
break;
}
case 'xpremaining': case 'xprem': case 'remainingxp': case 'remxp': {
const xpRemaining = currentLevel ? currentLevel * 1e3 - currentPercent * currentLevel * 1e3 : 0,
newMsg = `${originalMsg}XP Remanining: ${xpStatsInPercentages ? round(convertToPerc(xpRemaining, currentLevel) * 100, 2) + '%' : round(xpRemaining).toLocaleString('en-US')}`;
break;
}
case 'coinsremaining': case 'coinsrem': case 'remainingcoins': case 'remcoins': {
const coinsRemaining = currentCoins ? 25e4 - currentCoins % 25e4 : 0;
newMsg = `${originalMsg}Coins Remanining: ${coinsRemaining.toLocaleString('en-US')}`;
break;
}
case 'xplasthour': case 'lasthourxp': case 'hrxp': case 'xphr': case 'hourxp': case 'xphour': {
const lastHr = lastHrXP.length > 0 ? sigma(getProperty(lastHrXP, "gained")) : 0;
newMsg = `${originalMsg}XP Last Hour: ${xpStatsInPercentages ? round(convertToPerc(lastHr, currentLevel) * 100, 2) + '%' : round(lastHr).toLocaleString('en-US')}`;
break;
}
case 'coinslasthour': case 'lasthourcoins': case 'hrcoins': case 'coinshr': case 'hourcoins': case 'coinshour': {
const lastHr = lastHrCoins.length > 0 ? Math.round(sigma(getProperty(lastHrCoins, "gained"))) : 0
newMsg = `${originalMsg}Coins Last Hour: ${lastHr.toLocaleString('en-US')}`;
break;
}
case 'xplastmin': case 'xplastminute': case 'lastminxp': case 'lastminutexp': case 'minxp': case 'minutexp': case 'xpmin': {
const lastMin = lastMinXP.length > 0 ? sigma(getProperty(lastMinXP, "gained")) : 0;
newMsg = `${originalMsg}XP Last Minute: ${xpStatsInPercentages ? round(convertToPerc(lastMin, currentLevel) * 100, 2) + '%' : round(lastMin).toLocaleString('en-US')}`;
break;
}
case 'coinslastmin': case 'coinslastminute': case 'lastmincoins': case 'lastminutecoins': case 'coinsxp': case 'minutecoins': case 'coinsmin': {
const lastMin = lastMinCoins.length > 0 ? Math.round(sigma(getProperty(lastMinCoins, "gained"))) : 0;
newMsg = `${originalMsg}Coins Last Minute: ${lastMin.toLocaleString('en-US')}`;
break;
}
case 'xplast12s': case 'xplast12sec': case 'xplast12seconds': case 'last12secondsxp': case 'lastminutexp': case 'xp12s': case '12sxp': case 'xp12sec': {
const last12sec = lastMinXP.length > 0 ? lastMinXP[lastMinXP.length - 1].gained : 0;
newMsg = `${originalMsg}XP Last 12 Seconds: ${xpStatsInPercentages ? round(convertToPerc(last12sec, currentLevel) * 100, 2) + '%' : round(last12sec).toLocaleString('en-US')}`;
break;
}
case 'xpsession': case 'sessionxp': case 'xpsesh': case 'sesh': case 'session': case 'seshxp': {
const sessionXP = currentCoins && accounts[currentUser] ? Math.round(currentCoins - accounts[currentUser].coins): 0;
newMsg = `${originalMsg}Session XP: ${xpStatsInPercentages ? round(currentLevel && accounts[currentUser] ? ((round(currentPercent, 3) + currentLevel) - accounts[currentUser].lvl) * 100 : 0, 2) + '%' : round(sessionXP).toLocaleString('en-US')}, Session Length: ${msToTime(Date.now() - scriptStartXP)}`;
break;
}
case 'lifetimexp': case 'xplifetime':
newMsg = `${originalMsg}Lifetime XP: ${round(currentXP ?? 0).toLocaleString('en-US')}`;
break;
case 'coinssession': case 'sessioncoins': case 'coinssesh': case 'seshcoins': {
const sessionCoins = currentCoins && accounts[currentUser] ? Math.round(currentCoins - accounts[currentUser].coins): 0;
newMsg = `${originalMsg}Session Coins: ${sessionCoins.toLocaleString('en-US')}, Session Length:${msToTime(Date.now() - scriptStartCoins)}`;
break;
}
case 'ratewaifu': case 'waifu': case 'waifurating': case 'waifurate': case 'howwaifu':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}My Waifu Rating: 0 / 10`;
break;
}
newMsg = `${originalMsg}My Waifu Rating: ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 102.2)).slice(-3, -1) / 10)} / 10`;
break;
}
newMsg = `${originalMsg}${params[0]}'s Waifu Rating: ${Math.round(+String(Math.round(hashCode(params[0], 5) * 102.2)).slice(-3, -1) / 10)} / 10`;
break;
case 'ratepro': case 'pro': case 'prorating': case 'prorate': case 'howpro':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% pro`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 194.3)).slice(-4, -1) / 10)}% pro`;
break;
}
newMsg = `${originalMsg}${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 5) * 194.3)).slice(-4, -1) / 10)}% pro`;
break;
case 'ratedog': case 'dog': case 'dograting': case 'dograte': case 'howdog':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% dog`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 6) * 189.3)).slice(-4, -1) / 10)}% dog`;
break;
}
newMsg = `${originalMsg}${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 6) * 189.3)).slice(-4, -1) / 10)}% dog`;
break;
case 'rateking': case 'king': case 'kingrating': case 'kingrate': case 'howking':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% king`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 389.3)).slice(-4, -1) / 10)}% king`;
break;
}
newMsg = `${originalMsg}${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 5) * 389.3)).slice(-4, -1) / 10)}% king`;
break;
case 'dice': case 'die': case 'roll': case 'rolldice': {
const sides = params?.length == 0 || isNaN(+params[0]) ? 6 : +params[0];
newMsg = `${originalMsg}Rolled a dice with ${sides.toLocaleString('en-US')}, landed on ${Math.round(RNG(1, sides)).toLocaleString('en-US')}`;
break;
}
case 'rng': case 'random': case 'randomnumber': case 'number': case 'num': {
const min = params?.length < 1 || isNaN(+params[0]) ? 0 : +params[0];
const max = params?.length < 2 || isNaN(+params[1]) ? 10 : +params[1];
if(min > max){
curserMsg(`Please make sure your minimum (${min}) is less than your maximum (${max})`, 'red', 5e3);
newMsg = '';
break;
}
newMsg = `${originalMsg}Generated a random number between ${min.toLocaleString('en-US')} and ${max.toLocaleString('en-US')}, chose: ${Math.round(RNG(min, max)).toLocaleString('en-US')}`;
break;
}
case 'ratefriends': case 'friendsrating': case 'friendsrate': case 'howfriends':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% friends with a frog`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 283.7)).slice(-4, -1) / 10)}% friends with a frog`;
break;
}
if(params?.length == 1){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% friends with a ${params[0]}`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 283.7) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-4, -1) / 10)}% friends with a ${params[0]}`;
break;
} else {
newMsg = `${originalMsg}${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 4) * 283.7) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-4, -1) / 10)}% friends with ${params[1]}`;
break;
}
case 'rateenemies': case 'enemiesrating': case 'enemiesrate': case 'howenemies': case 'enemies':
if(params?.length == 0){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% enemies with a frog`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 164.45)).slice(-5, -2) / 10)}% enemies with a frog`;
break;
}
if(params?.length == 1){
if(currentUser == "Please Login First"){
newMsg = `${originalMsg}I am 0% enemies with a ${params[0]}`;
break;
}
newMsg = `${originalMsg}I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 164.45) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-5, -2) / 10)}% enemies with a ${params[0]}`;
break;
} else {
newMsg = `${originalMsg}${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 4) * 164.45) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-5, -2) / 10)}% enemies with ${params[1]}`;
break;
}
case 'flip': case 'coinflip': case 'heads': case 'tails': case 'flipcoin': {
newMsg = `${originalMsg}Coin flipped! Landed on ${Math.round(RNG(0, 1)) ? 'heads' : 'tails'}`;
break;
}
case 'script': case 'version': case 'fsfb':
newMsg = `${originalMsg}Using fsfb script! Version ${version}`
break;
case 'time': case 'localtime': case 'localetime': case 'date':
newMsg = `${originalMsg}My Time: ${new Date().toLocaleString('en-US')}`
break;
case 'leaderboard': case 'leader': case 'lb':
newMsg = `${originalMsg}My leaderboard position: ${!unsafeWindow.playerIsAlive() || leaderboardPos ? leaderboardPos : 'none, not alive'}`
break;
default:
newMsg = $chtbox.val();
break;
}
// (unsafeWindow.kfjsdafl != null) ? $chtbox.val(newMsg) : $chtbox.val(''), console.log(newMsg);;
$chtbox.val(newMsg)
})
}
// check if player is alive
let playerAlive = false, timeAlive;
unsafeWindow.playerIsAlive = () => playerAlive && $('#advert').css('display') != 'none' ? false : playerAlive;
const playerIsAlive = unsafeWindow.playerIsAlive;
const _setNick = unsafeWindow.setNick
unsafeWindow.setNick = function(){
if(arguments[1] || !playerAlive) timeAlive = Date.now();// respawned
playerAlive = true;
setTimeout(() => { svSwitch = true }, 1000);
return _setNick.apply(this, arguments);
}
const _closeAdvert = unsafeWindow.closeAdvert
unsafeWindow.closeAdvert = function(){
playerAlive = false;
return _closeAdvert.apply(this, arguments);
}
const getPowerMessage = (line, firstMsg) => {
let obj = {
string1: firstMsg + 'Inv (1/?): ',
string2: firstMsg + 'Inv (2/?): ',
string3: firstMsg + 'Inv (3/?): '
}
updatePwCount();
const newPws = {
Recombine: pws.rec,
Speed: pws.spd,
Growth: pws.grw,
Virus: pws.vrs,
Mothercell: pws.mtcl,
Portal: pws.prtl,
'Gold Block': pws.gblk,
Freeze: pws.fz,
Push: pws.psh,
Wall: pws.wall,
'Anti-Freeze': pws.afz,
'Anti-Recombine': pws.arc,
Shield: pws.shld,
'Frozen Virus': pws.fzvs
}
for(let i in newPws){
let add = '';
add += newPws[i] == '' ? '' : newPws[i];
add += newPws[i] == '' ? '' : ' ';
add += newPws[i] == '' ? '' : (i + ', ');
if(obj.string1.length + add.length <= 100) obj.string1 += add;
else if(obj.string2.length + add.length <= 100) obj.string2 += add;
else obj.string3 += add;
}
if(obj.string1 == firstMsg + `Inv (1/?): ` && line == 1) return 'Inv (1/1): no powers';
if(obj['string' + line] == firstMsg + `Inv (${line}/?): `){
curserMsg(`This inventory line doesn't exist! Try a smaller number`, 'red', 6e3);
return ''
}
let totalLines = 1;
if(obj.string3 == firstMsg + 'Inv (3/?): ' && obj.string2 != firstMsg + 'Inv (2/?): ') totalLines = 2;
else if(obj.string3 != firstMsg + 'Inv (3/?): ' && obj.string2 != firstMsg + 'Inv (2/?): ') totalLines = 3;
return line == 1 ? obj.string1.replace(/,[^,]*$/g, '').replace(/\?/g, totalLines) : line == 2 ? obj.string2.replace(/,[^,]*$/g, '').replace(/\?/g, totalLines) : obj.string3.replace(/,[^,]*$/g, '').replace(/\?/g, totalLines);
}
let pws = {rec: '', spd: '', grw: '', vrs: '', mtcl: '', prtl: '', gblk: '', fz: '', psh: '', wall: '', afz: '', arc: '', shld: '', fzvs: ''};
const updatePwCount = () => {
$('.inventory-box').each(function(){
const val = $(this).css('display') != 'none' ? $(this).children().eq(0).text() || '1' : '';
const map = {
'invWall' : 'wall',
'invAntiFreeze': 'afz',
'invAntiRecombine': 'arc',
'invShield': 'shld',
'invFrozenVirus': 'fzvs',
'invRecombine': 'rec',
'invSpeed': 'spd',
'invGrowth': 'grw',
'invSpawnVirus': 'vrs',
'invSpawnMothercell': 'mtcl',
'invSpawnPortal': 'prtl',
'invSpawnGoldOre': 'gblk',
'invFreeze': 'fz',
'inv360Shot': 'psh'
}
if(map[$(this)[0].id] != null) pws[map[$(this)[0].id]] = val;
})
}
$('#fsfb-export-btn').on('click', () => {
if(!$('#fsfb-sect-imexport>label>input').is(':checked')) return void(curserMsg('You need to select at least one setting to export!', 'red'));
if($('#fsfb-custom-bg').is(':checked')) curserMsg('Exporting settings with custom background included is likely to increase the file size', 'red', 4e3);
let script_settings = {},
script_themes = {};
for (let i in settings) { // put the settings & themes into different objects
if (i == "theme" || i == "theme_boxes") script_themes[i] = settings[i];
else if (i == "export_import") {}
else script_settings[i] = settings[i];
}
let bgImg = null;
const downloadFile = () => {
let obj = {
selected: {
game_settings: $('#fsfb-game-settings').is(':checked'),
game_controls: $('#fsfb-game-controls').is(':checked'),
game_background: $('#fsfb-custom-bg').is(':checked'),
script_settings: $('#fsfb-script-settings').is(':checked'),
script_theme: $('#fsfb-theme-settings').is(':checked')
},
game_settings: localStorage.settings,
game_controls: localStorage.hotkeys,
game_background: bgImg,
script_settings: script_settings,
script_theme: script_themes
}
// if the setting is turned off, then dont need to export it - set it to null
if(!obj.selected.game_settings) obj.game_settings = null;
if(!obj.selected.game_controls) obj.game_controls = null;
if(!obj.selected.game_background) obj.game_background = null;
if(!obj.selected.script_settings) obj.script_settings = null;
if(!obj.selected.script_theme) obj.script_theme = null;
const a = document.createElement('a'),
file = new Blob([JSON.stringify(obj)], {type: "text/plain"});
a.href = URL.createObjectURL(file), a.download = "fsfb script settings", a.click(), URL.revokeObjectURL(a.href); // download a txt file of exported settings
}
if($('#fsfb-custom-bg').is(':checked')){
let db, req = unsafeWindow.indexedDB.open("AgmaDB", 1);
req.onsuccess = function (x) {
db = req.result;
db.onclose = (c) => { db = null; }
db.onversionchange = (c) => { db.close(), db = null; }
let _ = db.transaction("general", "readonly").objectStore("general").get("cbgDataURL");
_.onsuccess = () => {
bgImg = _.result;
downloadFile();
}
}, req.onupgradeneeded = function (c) {
let req = c.target.result;
if (!req.objectStoreNames.contains("general")) {
req.createObjectStore("general");
}
};
} else {
downloadFile();
}
});
$('#fsfb-import-btn').on('click', () => {
if(!$('#fsfb-sect-imexport>label>input').is(':checked')) return void(curserMsg('You need to select at least one setting to import!', 'red'));
if($('#fsfb-custom-bg').is(':checked')) curserMsg('Pasting in settings that include a background image is likely to cause initial lag', 'red', 0);
swal({
title: "Import Settings",
text: "Add your exported settings below and press OK to continue.",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: "Paste exported settings here"
},
function(inputVal){
if (inputVal == null) return false;
if (inputVal == "") {
swal.showInputError("Please don't leave the input empty!");
return false
}
try {
let val = JSON.parse(inputVal);
if(val.selected.script_settings && $('#fsfb-script-settings').is(':checked')){
for (let i in val.script_settings) {
for (let j in val.script_settings[i]) {
for(let x in settings){
for(let y in settings[x]){
if(val.script_settings[i][j].id == settings[x][y].id) settings[x][y] = val.script_settings[i][j];
}
}
}
}
}
if(val.selected.script_theme && $('#fsfb-theme-settings').is(':checked')){
for (let i in val.script_theme) {
for (let j in val.script_theme[i]) {
for(let x in settings){
for(let y in settings[x]){
if(val.script_theme[i][j].id == settings[x][y].id) settings[x][y] = val.script_theme[i][j];
}
}
}
}
}
if(val.selected.game_settings && $('#fsfb-game-settings').is(':checked')) localStorage.setItem('settings', val.game_settings);
if(val.selected.game_controls && $('#fsfb-game-controls').is(':checked')) localStorage.setItem('hotkeys', val.game_controls);
if(val.selected.game_background && $('#fsfb-custom-bg').is(':checked')){
let db, req = unsafeWindow.indexedDB.open("AgmaDB", 1);
req.onsuccess = function (x) {
db = req.result;
db.onclose = (c) => { db = null; }
db.onversionchange = (c) => { db.close(), db = null; }
let _ = db.transaction("general", "readwrite").objectStore("general").put(val.game_background, "cbgDataURL");
}, req.onupgradeneeded = function (c) {
let req = c.target.result;
if (!req.objectStoreNames.contains("general")) {
req.createObjectStore("general");
}
};
}
// if any agma controls were imported, need to refresh bc it's set using localstorage
if((val.selected.game_settings && $('#fsfb-game-settings').is(':checked')) || (val.selected.game_controls && $('#fsfb-game-controls').is(':checked')) || (val.selected.game_background && $('#fsfb-custom-bg').is(':checked'))){
swal({
title: "Please Refresh!",
text: "Refreshing the page is required for your imported agma settings to take effect",
type: "warning",
});
} else swal({ title: "Settings Successfully Imported!", type: "success" });
saveSettings();
updateScriptSettingsUI();
} catch (error){
swal({
title: "Something went wrong!",
text: "Please make sure you've entered in valid settings",
type: "error"
});
}
});
});
$('#fsfb-settings-right').append(``)
if(hideAds){
localStorage.ad_l_time = "9e99"; // smth like time since last ad
$('[id^="agma-io_"], [id^="adWrapper"], #preroll').addClass("fuckAds"); // move ads way off the screen
} else localStorage.ad_l_time = Date.now();
let width = unsafeWindow.innerWidth, height = unsafeWindow.innerHeight;
$(unsafeWindow).on('resize', function(){
width = unsafeWindow.innerWidth, height = unsafeWindow.innerHeight;
});
let pointMove;
const linesplit = () => {
if(!linesplitting) return;
let closest, points = [{n: "top", x: width / 2, y: 0, nx: width / 2, ny: -10e6}, {n: "bottom", x: width / 2, y: height, nx: width / 2, ny: 10e6}, {n: "left", x: 0, y: height / 2, nx: -10e6, ny: height / 2}, {n: "right", x: width, y: height / 2, nx: 10e6, ny: height / 2}];
if(linesplitClosestSide){
let closestSide = [mosY / height, (height - mosY) / height, mosX / width, (width - mosX) / width]; // top, bottom, left, right
closest = points[closestSide.indexOf(Math.min(...closestSide))];
} else {
let distance = p => Math.sqrt(Math.pow(mosX - p.x, 2) + Math.pow(mosY - p.y, 2)),
closestPoint = points.reduce((a, b) => distance(a) < distance(b) ? a : b);
for (let i = 0; i < points.length; i++) {
if (closestPoint.x == points[i].x && closestPoint.y == points[i].y) closest = points[i]
}
}
pointMove = {x: closest.nx, y: closest.ny};
$('canvas').trigger($.Event('mousemove', { clientX: closest.nx, clientY: closest.ny }));
$("#linesplit-markers div").css('background-color', 'transparent');
$('#linesplit-' + closest.n).css('background-color', '#e25615');
}
let confBtns = document.getElementsByClassName('purchase-btn confirmation');
const btnsArr = Array.from(document.getElementsByClassName('purchase-btn confirmation'));
const changeHTML = (index, price, id, name) => {
setTimeout(() => {
const amtDropdown = document.getElementById('shopAmountDropdown')
document.getElementsByClassName('sweet-alert showSweetAlert')[0].childNodes[7].firstChild.textContent = 'If you click "Buy", you will purchase this item. It will cost ' + price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' in total.';
const dropdownChange = () => {
if (amtDropdown.value == "custom") return buyCstmAmt(price, id, name);
let priceSum = (amtDropdown.value * price).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
document.getElementsByClassName('sweet-alert showSweetAlert')[0].childNodes[7].firstChild.textContent = 'If you click "Buy", you will purchase this item. It will cost ' + priceSum + ' in total.';
};
amtDropdown.addEventListener('change', dropdownChange);
}, 30);
};
const buyCstmAmt = (price, id, name) => {
swal({
title: "Enter Purchase Amount",
text: "How many " + name + " would you like to buy?",
html: true,
type: "input",
showCancelButton: true,
closeOnConfirm: false,
inputPlaceholder: "Input amount here"
},
function(input){
let pwAmt = +input,
priceTotal = pwAmt * price;
if (input == null) return false;
if (input == "") {
swal.showInputError("Please don't leave the input empty!");
return false
}
if(!/^[0-9]+$/.test(input) || !(+input >>> 0 === parseFloat(+input))){
swal.showInputError("Please only enter positive integers!");
return false
}
swal({
title: 'Confirm',
text: '
If you click "Buy", you will purchase this item. It will cost ' + priceTotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' in total. You chose to purchase ' + pwAmt.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' ' + name + '
',
html: true,
type: 'warning',
showCancelButton: true,
closeOnConfirm: false,
confirmButtonColor: '#4CAF50',
confirmButtonText: 'Yes, confirm purchase',
cancelButtonText: 'No, cancel purchase'
}, function(confirmed){
if(confirmed) buyPw(id, pwAmt);
})
});
};
// buy a certain amount of powers including > 255
const buyPw = (shopID, pwAmt) => {
if (pwAmt < 1) return;
if (pwAmt > 255) {
for (let i = 0; i < ~~(pwAmt / 255); i++) setTimeout(() => purchaseItem(shopID, 255), 250 * i + 250);
purchaseItem(shopID, pwAmt % 255);
} else purchaseItem(shopID, pwAmt);
};
if(improvedShop){
// add event listeners to dropdown buttons
for (let i = 0; i < confBtns.length; i++) {
confBtns[i].onclick = function () {
setTimeout(() => {
if (document.getElementById('shopAmountDropdown') != null) document.getElementById('shopAmountDropdown').innerHTML += ' ';
}, 5);
}
}
// add event listeners to shop buttons
for (let i = 0; i < 16; i++) {
if (i != 10 && i != 11){
btnsArr[i].addEventListener('click', () => {
let index = i;
changeHTML(index, btnsArr[index].getAttribute('price'), btnsArr[index].getAttribute('item'), $('.purchase-btn.confirmation[item="' + btnsArr[index].getAttribute('item') + '"]').prev().find('h3').eq(0).text());
});
}
}
}
// add extra bot packs
const newBots = [
{title: "100 Bots", time: "24 HOURS", price: "700,000", id: 9},
{title: "125 Bots", time: "48 HOURS", price: "900,000", id: 10},
{title: "300 Bots", time: "24 HOURS", price: "900,000", id: 7},
{title: "100 MASS Bots", time: "1 HOURS", price: "800,000", id: 8},
{title: "300 Bots", time: "72 HOURS", price: "2,000,000", id: 11},
{title: "100 MASS Bots", time: "24 HOURS", price: "2,600,000", id: 12}
]
const minul = document.getElementsByClassName('tab-container-section minion scroll')[0].children[0].children[0]
$('.confirm-minion[item=7], .confirm-minion[item=8]').parent().hide();
document.getElementById('extraTab').childNodes[0].setAttribute('onclick', '');
function createEl(i) {
const botEl = document.createElement('li');
botEl.setAttribute('class', 'masterTooltip extra-min');
botEl.setAttribute('title', 'Spawns bots/minions which suicide into your playercell to make you big in no time! Minions follow your mouse and split upon your command! Minions start immediately after you buy them.');
minul.appendChild(botEl);
botEl.innerHTML = `
` + i.title + `
` + i.time + `
` + i.price + `
Buy
`;
}
if(extraBotPacks){
for(let i of newBots) createEl(i);
}
function warnBeforeMinion(linkURL, priceK,itemId) {
swal({
title: "Confirm",
text: 'If you click "Buy", you will purchase these minions. They cost ' + priceK,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#4CAF50",
confirmButtonText: "Yes, confirm purchase",
cancelButtonText: "No, cancel purchase"
}, function() {
purchaseMinion(itemId);
});
}
// listen for when a min pack is bought
let minBoughtAmt = {};
if(extraChatCommands){
let lastClickedPrice, currentPrice, lastID;
const confirmClicked = () => {
setTimeout(() => {
if($('.sweet-alert h2').text() != "Success!" || lastClickedPrice != currentPrice) return;
const map = {
1: '10 Bots 1 Hour',
2: '40 Bots 1 Hour',
3: '50 Bots 2 Hours',
4: '80 Bots 1 Hour',
5: '100 Bots 4 Hours',
6: '125 Bots 8 Hours',
7: '300 Bots 24 Hours',
8: '100 MASS Bots 1 Hour',
9: '100 Bots 24 Hours',
10: '125 Bots 48 Hours',
11: '300 Bots 72 Hours',
12: '100 MASS Bots 24 Hours'
}
minBoughtAmt[currentUser] = {...minsChatAmt[currentUser], ... {chatAmt: map[lastID], started: false}};
}, 900);
};
$('.purchase-btn2.confirm-minion[item]').on('click', function () {
lastClickedPrice = this.getAttribute('price').replace(/,/g, '');
lastID = this.getAttribute('item');
$('.confirm').attr('disabled', 'true'); // disable so user doesn't buy early - swal is slow to load text
setTimeout(() => {
$('.confirm').removeAttr('disabled');
currentPrice = $('.sweet-alert.showSweetAlert.visible p').eq(0).text().replace(/\D+/g, '');
}, 750);
setTimeout(() => $('.confirm')[0].addEventListener('click', confirmClicked), 500);
})
}
// context menu: click on skin -> skin ID to clipboard, click on name -> name to clipboard
$('#contextPlayer').on('click', e => {
if(!rightClickCopyInfo) return;
if($('#contextPlayerSkin').width() + $('#contextPlayerSkin').offset().left + 5 > e.pageX){ // bcs #contextMenu event :dog:
// cell was clicked
if($('#contextPlayerSkin').css('background-image') != "none"){
let skinID = $('#contextPlayerSkin').css('background-image').match(/\/skins\/[0-9]+/g)[0].substring(7); // get the skin image, then match only the skin's ID
navigator.clipboard.writeText(skinID).then(function() {
curserMsg('Skin ID of ' + skinID + ' was copied to your clipboard.', 'green');
}, function() {
curserMsg('Something went wrong. Nothing was added to your clipboard.', 'red');
});
} else if($('#contextPlayerSkin').css('background-color') == 'rgb(51, 51, 51)') curserMsg('No player selected. Nothing was added to your clipboard.', 'red');
else curserMsg('No skin equipped. Nothing was added to your clipboard.', 'red');
} else { // name was clicked
if($('#contextPlayerSkin').css('background-color') == 'rgb(51, 51, 51)') curserMsg('No player selected. Nothing was added to your clipboard.', 'red');
else {
navigator.clipboard.writeText($('#contextPlayerName').text()).then(function() {
curserMsg('Nickname: "' + $('#contextPlayerName').text() + '" was copied to your clipboard', 'green');
}, function() {
curserMsg("Something went wrong. Nothing was added to your clipboard.", "red");
});
}
}
});
// little bar at the top of the screen that tells u stuff
const curserMsg = (msg, color, time) => {
if(color == "green") color = "rgb(0, 192, 0)";
if(color == "red") color = "rgb(255, 0, 0)";
if(color == "gray") color = "rgb(153, 153, 153)";
$('#curser').text(msg).show().css('color', color)
if(time != 0) setTimeout(() => $('#curser').fadeOut(400), time ?? 4e3);
}
let minTimeRemaining = 0;
const startMin = unsafeWindow.strMin;
unsafeWindow.strMin = function(){
minsStart();
return startMin.apply(this, arguments);
}
let minsChatAmt = {},
accGoldMem = {};
const minsStart = async() => {
let minAmt, minsStarted = false;
const waitUntil1 = (condition) => new Promise(resolve => {
let interval = setInterval(() => {
$('#infoContent').children().each(function(){
if($(this).text().includes('Minion Time:')) minsStarted = true;
})
condition() && (clearInterval(interval), resolve());
}, 100);
setTimeout(() => { (clearInterval(interval), resolve()) }, 1e4);
});
await waitUntil1(() => minsStarted == true);
if(!minsStarted) return;
$('#infoContent').children().each(function(){
if($(this).text().includes('Minion Time:')) minTimeRemaining = $(this).find('span').text();
if($(this).text().includes('Minions:')) minAmt = $(this).find('span').text()
})
let timeArr = minTimeRemaining.split(':'), msBotsTime = (3.6e6 * +timeArr[0]) + (6e4 * +timeArr[1]) + (1e3 * +timeArr[2]);
misc_settings.bots[currentUser] = {...misc_settings.bots[currentUser], ...{active: true, amt: minAmt, chatAmt: null, rem: msBotsTime, currMs: Date.now()}};
set("fsfb-misc", misc_settings);
}
// ability time remaining
if(showRemainingAbilityTime){
let lastClickedPrice, currentPrice, lastID;
const confirmClicked = () => {
setTimeout(() => {
if($('.sweet-alert h2').text() != "Success!" || lastClickedPrice != currentPrice) return;
misc_settings.abil[currentUser] = {...misc_settings.abil[currentUser], ...{[lastID] : Date.now()}};
set("fsfb-misc", misc_settings);
}, 900);
};
[18, 20, 22, 23].forEach(el => {
let h5 = $(`.purchase-btn.confirmation[item="${el}"]`).parents().eq(0).find('div h5');
h5.clone().insertAfter(h5).addClass('fsfb-fake').hide();
$(`.purchase-btn[item="${el}"]`).on('click', function () {
lastClickedPrice = this.getAttribute('price');
lastID = this.getAttribute('item');
$('.confirm').attr('disabled', 'true'); // disable so user doesn't buy early - swal is slow to load text
setTimeout(() => {
$('.confirm').removeAttr('disabled');
currentPrice = $('.sweet-alert.showSweetAlert.visible p').eq(0).text().replace(/\D+/g, '');
}, 750);
setTimeout(() => $('.confirm')[0].addEventListener('click', confirmClicked), 500);
})
});
}
// sort wearables by owned
const waitUntil = condition => new Promise(resolve => {
let interval = setInterval(() => {
condition() && (clearInterval(interval), resolve());
}, 100);
setTimeout(() => { (clearInterval(interval), resolve()) }, 15e3);
});
if(sortWearablesByOwned){
$('#wearablesTab').on('click', async()=> {
await waitUntil(() => $('#phpWearables li').length > 55);
if($('#phpWearables li').length <= 55) return;
$($('[id^="wearableUseBtn"]').get().reverse()).each(function(){
$($(this).parents().get(2)).insertBefore($("#phpWearables li:eq(0)"));
})
$('#phpWearables').append('');
});
}
// https://stackoverflow.com/questions/2424191/how-do-i-make-an-element-draggable-in-jquery
$.fn.draggable = function(){
var $this = this,
ns = 'draggable_'+(Math.random()+'').replace('.',''),
mm = 'mousemove.'+ns,
mu = 'mouseup.'+ns,
$w = $(window),
isFixed = ($this.css('position') === 'fixed'),
adjX = 0, adjY = 0;
$this.mousedown(function(ev){
var pos = $this.offset();
if (isFixed) {
adjX = $w.scrollLeft(); adjY = $w.scrollTop();
}
var ox = (ev.pageX - pos.left), oy = (ev.pageY - pos.top);
$this.data(ns,{ x : ox, y: oy });
$w.on(mm, function(ev){
ev.preventDefault();
ev.stopPropagation();
if (isFixed) {
adjX = $w.scrollLeft(); adjY = $w.scrollTop();
}
var offset = $this.data(ns);
$this.css({left: ev.pageX - adjX - offset.x, top: ev.pageY - adjY - offset.y});
});
$w.on(mu, function(){
$w.off(mm + ' ' + mu).removeData(ns);
});
});
return this;
};
/* xp/coins statistics */
const updateTimeXP = 12e3; // xp bar updates every 12 seconds, don't change
let lastMinXP = [];
let lastHrXP = [];
let currentPercent, currentLevel, currentXP, currentCoins;
unsafeWindow.logStatsScriptXP = !1;
unsafeWindow.logStatsScriptCoins = !1;
let scriptStartCoins = Date.now();
let scriptStartXP = Date.now();
let accounts = {};
const guiDisplay = "none";
let coinsHTMLactive = false;
const updateTimeCoins = 6e3;
let lastMinCoins = [];
let lastHrCoins = [];
// add stats box html
const statsBody = document.createElement('div');
statsBody.setAttribute('id', 'stats-container');
statsBody.style.display = guiDisplay;
statsBody.innerHTML = `
');
} else {
$('#publicSkinsPage tbody').html('');
for(let i = 0; i < totalRows; i++) $('#publicSkinsPage tbody').append('
');
let currRow = 0, currColumn = 0;
for(let i of skinsSearchedArr){
if(++currColumn > 4) currRow++, currColumn = 1;
$('#publicSkinsPage tr').eq(currRow).append(`
${sanitize(i.name)}
`)
}
}
}, 300);
$('#fsfb-skinsearch').on('keydown', handlePress);
}
currentUser = $('#userCoins2')[0].innerText;
let user_abil = currentUser == 'Please Login First' ? null : misc_settings.abil?.[currentUser];
if(user_abil != undefined && showRemainingAbilityTime){
for(let i in user_abil){
let text = $(`.purchase-btn.confirmation[item="${i}"]`).parents().eq(0).find('div h5'),
active = $('#' + $(`.purchase-btn.confirmation[item="${i}"]`).parents().eq(0)[0].id + ' img').eq(1).css('display') != "none";
// has been 24h+ and the player hasn't logged out since it's expired
if(Date.now() - user_abil[i] > 8.64e7 && active){
text.eq(1).text('EXPIRED IF UNLOG');
text.eq(0).find('div h5').hide();
}
// has been >24h
else if(Date.now() - user_abil[i] < 8.64e7 && active){
text.eq(0).hide();
text.eq(1).text(msToTime(8.64e7 - (Date.now() - user_abil[i]))).show();
}
else { // has been 24h+ & player has logged out
text.eq(0).find('div h5').show();
text.eq(1).find('div h5').hide();
}
}
} else {
$('.white_shopdesc').show();
$('.white_shopdesc.fsfb-fake').hide();
}
if(accounts[currentUser] == null && currentUser !== 'Please Login First'){
xpInfo();
coinsInfo();
accounts = {...accounts, ...{[currentUser] : {coins: currentCoins, xp: currentXP, lvl: round(currentPercent, 3) + currentLevel}}};
}
if(accounts[currentUser] != null && accounts[currentUser].coins == 0) accounts[currentUser].coins = currentCoins;
if(accounts[currentUser] != null && accounts[currentUser].xp == 0) accounts[currentUser].xp = currentXP;
if(coinXPstats && intervalCount % 12 == 0){
setTimeout(() => {
xpInfo();
lastMinXP.push(new record(round(currentXP, 3), round(currentPercent, 3) + currentLevel, currentUser, lastMinXP));
const prevObjXP = lastMinXP[lastMinXP.length - 1];
if(prevObjXP && prevObjXP.id % (6e4 / updateTimeXP) == 0) lastHrXP.push(new record(round(currentXP, 3), round(currentPercent, 3) + currentLevel, currentUser, lastHrXP));
if(lastMinXP.length > 6e4 / updateTimeXP) lastMinXP.shift();
if(lastHrXP.length > 60) lastHrXP.shift();
if(!coinsHTMLactive && $('#stats-container').css('display') == 'block') updateUI();
unsafeWindow.logStatsScriptXP && console.log(lastMinXP, lastHrXP);
}, 500);
}
if(coinXPstats && intervalCount % 6 == 0){
coinsInfo();
lastMinCoins.push(new record(currentCoins, 0, currentUser, lastMinCoins));
const lastObjCoins = lastMinCoins[lastMinCoins.length - 1];
if(lastObjCoins && lastObjCoins.id % (6e4 / updateTimeCoins) == 0) lastHrCoins.push(new record(currentCoins, 0, currentUser, lastHrCoins));
if(lastMinCoins.length > 6e4 / updateTimeCoins) lastMinCoins.shift();
if(lastHrCoins.length > 60) lastHrCoins.shift();
if(coinsHTMLactive && $('#stats-container').css('display') == 'block') updateUI();
unsafeWindow.logStatsScriptCoins && console.log(lastMinCoins, lastHrCoins);
}
if(coinsHTMLactive){
$('#stats-sesh-length').text(msToTime(Date.now() - scriptStartCoins));
} else {
$('#stats-sesh-length').text(msToTime(Date.now() - scriptStartXP));
}
if(intervalCount % 3 == 0 && misc_settings?.statsPos != null){
statsboxPos = {top: $("#stats-container")[0].style.top, left: $("#stats-container")[0].style.left};
misc_settings.statsPos = statsboxPos;
set("fsfb-misc", misc_settings);
}
if(intervalCount % 2 == 0){ // "You have an activated bot pack available: 100 XXL Bots 1 Hours! Restart your bots before they expire!"
if(chatmsgs != null && chatmsgs?.length > 2){ // "You have an activated bot pack available: 100 Bots 24 Hours! Restart your bots before they expire!"
for(let i of chatmsgs){
if(i.name == '' && i.cache != null && i.cache.color2 == '#ff8100'){
if(i.message.match(/(?<=(Welcome back to Agma, )).+/g)?.[0] == currentUser){
const msgBots = $('.memberType').text() == 'GOLD MEMBER' ? chatmsgs?.[chatmsgs.indexOf(i) - 2] : chatmsgs?.[chatmsgs.indexOf(i) - 1],
msgGM = $('.memberType').text() == 'GOLD MEMBER' ? chatmsgs?.[chatmsgs.indexOf(i) - 1] : null;
if(msgBots?.message.includes('Restart your bots before they expire!')){
if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = msgBots.message.match(/\d+.+\d Hours/g)[0];
minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: msgBots.message.match(/\d+.+\d Hours/g)[0], started: true}};
set("fsfb-misc", misc_settings);
} else if(msgBots?.message.match(/(?<=(You have a new bot pack available: )).+(?=(! Start your bots in the minion panel.))/g)?.length){
if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = msgBots.message.match(/\d+.+\d Hours/g)[0];
minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: msgBots.message.match(/\d+.+\d Hours/g)[0], started: false}};
set("fsfb-misc", misc_settings);
}
if(msgGM != null && msgGM.message.match(/(?<=You have )\d+(?= Days left of Gold Member!)/gm)?.length){
accGoldMem[currentUser] = {...accGoldMem[currentUser], ... {days: msgGM.message.match(/(?<=You have )\d+(?= Days left of Gold Member!)/gm)[0], has: true}};
} else {
accGoldMem[currentUser] = {...accGoldMem[currentUser], ... {has: false}};
}
} else if(i.message.match(/(?<=(You have a new bot pack available: )).+(?=(! Start your bots in the minion panel.))/g)?.length){
if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = i.message.match(/\d+.+\d Hours/g)[0];
minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: i.message.match(/\d+.+\d Hours/g)[0], started: false}};
set("fsfb-misc", misc_settings);
}
/* else if(minsChatAmt[currentUser]?.chatAmt && i.message.match(/\d+.+\d Hour/g)?.[0] == minsChatAmt[currentUser].chatAmt.match(/\d+.+\d Hour/g)[0]){
minsChatAmt[currentUser].amt = i.message.match(/\d+.+\d Hour/g)[0];
} */
}
}
}
}
if(currentServerId === 0){
try {
for(let i of JSON.parse(localStorage.gameservers)){
if(i.isCurrent) currentServerId = i.id;
}
svSwitch = true;
} catch {};
}
if(currentUser == 'Please Login First' || $('#level').text() == 0) lastLoggedOut = Date.now();
changeTitle(settings.checkboxes[4].active ? currentUser == 'Please Login First' ? "Agma.io" : "Agma.io - " + currentUser : "Agma.io - A free multiplayer MMO game");
if($('#friendAcceptAll').length > 0 && friendDeclineAll && $('#friendRejectAll').length < 1 && currentUser != 'Please Login First') addFriendDecline();
if($('#friendDialogMessage').text() != 'Login to see your friendlist' && $('#friendDialogMessage').text() == 'Loading...' && $('#friendsRequestsAmt').text() == '' && friendDeclineAll && /* $('#requestList').children().length > 0 && */ currentUser != 'Please Login First'){
$('#btnFriends')[0].click();
$('#btnFriends')[0].click();
}
fpsArr.push(+document.getElementById("fps").innerText);
if(fpsArr.length == 6) fpsArr.shift();
avgFps = mean(fpsArr);
setTimeout(mainInterval, 1e3);
}
setTimeout(mainInterval, 1e3);
// }, 1e3);
if(showXPdecimals){
$('.progress-bar span').each(function(){
$(this).hide().clone().insertAfter($(this)).addClass('fsfb-fakePerc').removeClass('sr-only exp-bar').show(); // show detailed lvl percent (clone to prevent showing the old % before it gets changed)
});
setInterval(() => {
let currPercent = $('.progress-bar[role=progressbar]')[0].style.width.slice(0, -1) / 100;
$('.fsfb-fakePerc').text(currPercent && $('.sr-only.exp-bar')[0].textContent != '0%' ? round(currPercent * 100, 2) + '%' : '0%');
}, 250);
}
const antiAFK = () => {
setTimeout(antiAFK, 3e4);
if(!$('#fsfb-antiAFK').is(':checked'))return; // move mouse every 30sec
if(linesplitting){
$('#canvas').trigger($.Event('mousemove', {clientX: pointMove.x + 1, clientY: pointMove.y})).trigger($.Event('mousemove', {clientX: pointMove.x - 1, clientY: pointMove.y}));
} else {
$('#canvas').trigger($.Event('mousemove', {clientX: mosX + 1, clientY: mosY})).trigger($.Event('mousemove', {clientX: mosX - 1, clientY: mosY}));
}
}
setTimeout(antiAFK, 3e4);
const updateScriptSettingsUI = () => {
for(let i of settings.checkboxes) $('#' + i.id).prop("checked", i.active).trigger("change");
for(let i of settings.hotkeys) $('#' + i.id).text(getName(i.key));
for(let i of settings.fastsplit_hotkeys) $('#' + i.id).text(getName(i.key));
for(let i of settings.quickSettings){
$('#' + i.id1).val(i.set);
$('#' + i.id).text(getName(i.key));
}
$('#' + settings.slowFeed[0].id).text(getName(settings.slowFeed[0].key));
$('#' + settings.slowFeed[1].id).val(settings.slowFeed[1].val);
for(let i of settings.fastsplit_hotkeys){
i.val == null ? $('#' + i.id).text(getName(i.key)) : $('#' + i.id).val(i.val);
}
for(let i of settings.uiScaling) $('#' + i.id).val(i.level).trigger("change");
for(let i of settings.export_import) $('#' + i.id).prop("checked", i.active).trigger("change");
for(let i of settings.theme){
$('#' + i.id).prop("checked", i.active).trigger("change");
$('#' + i.id1).val(i.color).trigger("change");
}
for(let i of settings.theme_boxes) $('#' + i.id).prop("checked", i.active).trigger("change");
for(let i of settings.chat_translate){
'set' in i ? $('#' + i.id).val(i.set) : $('#' + i.id).prop('checked', i.active).trigger('change');
}
}
setTimeout(() => updateScriptSettingsUI(), 1e3);
$('body').append('');
const _replaceCSS = (a,b) => {
document.getElementById(a).innerHTML = b;
}
$('body').append(`
Script Documentation
Chat Copy/Cut/Paste- allows you to use the commands in chat (e.g. Ctrl + V becomes avaiable inside chat)
Anti-AFK- prevents you from automatically disconnecting after 10 minutes
Anti-Invis- shows you players even when they have the invisibility ability active
Linesplit Toggle- enabled means that if you press the linesplit hotkey, it will turn linesplitting on until the key is pressed again (in contrast to stopping the linesplit when key is released)
Change Page Title- changes the tab's title to just "Agma.io" with the current username
Hide Shouts- prevent megaphone shouts from showing up at all
Hold To Spam- while the powerup's hotkey is held, it will continuously use the powerup
Show Portal Mass- displays the predicted amount of times the portals in rooms 1 & 2 have been fed by players (not 100% accurate & doesn't work at all servers)
Power Spawns Overlay- show the locations of where powerups/minion packs spawn with lower opacity (thanks to Light for helping with getting all of the power locations)
Quick Buy- click plus sign (+) next to your powers (only if you set it to true in the code), then click on the powerup you want to buy
Food/Virus/Mothercell Color- changes the color that's filling these to a custom one
Virus/Mothercell Stroke- changes the color of the stroke (border/outline) to a custom one
Spiked Cells- render all cells with the spikes from the infecton gamemode
Show Mass- show the mass of all players' cells
Only My Skin- hide all skins besides the one you're using
Only Party Skin- hide all skins besides the ones people in your party are using
Only My Nick- hide all nicks besides the one you're using
Only Party Nick- hide all nicks besides the ones people in your party are using
Shoot 7 Ejected- press ejected mass hotkey 7 times (useful to prime room 1 or 2 portal when it's been reset
Linesplit Lock- finds which direction your mouse is the closest to & puts mouse way off the map (towards that direction) so you can perform perfect linesplits without zooming out or precisely placing your mouse (feature and design inspired byWynell's script)
Macrosplit Bots- hold this key to macrosplit your bots without switching controls off of yourself
Hide UI- press this key to toggle showing the game UI (intended for recording/screenshots)
Toggle Slow Feed- (toggle) this presses eject mass hotkey at the defined interval (intended for feeding the gold block while AFK)
Slow Feed Speed- the speed at which eject mass is pressed when slow-feeding
Quick Settings- when the hotkey assigned is pressed, it will toggle the setting that is selected
Toggle Cursor Lock- when pressed, this will keep cursor lock active until you press it again (also works when the tab is unfocused)
Fast Onesplit- performs a fast onesplit (Onesplit -> Freeze -> Unfreeze); speed is dependent fps (low fps indicates slow CPU, slow CPU can mess timings up)
Fast Doublesplit- performs a fast Doublesplit (Doublesplit -> Freeze -> Unfreeze); speed is dependent fps (low fps indicates slow CPU, slow CPU can mess timings up)
Chat Size- make the size of chat bigger/smaller
Inventory Size- make the size of powerups inventory bigger/smaller
Statsbox Size- make the size of XP/coins stats bigger/smaller
Export- select the boxes of the settings you wish to export and press the button, a .txt file will be downloaded with your settings inside
Import- select the boxes of the settings you wish to import and insert the exported settings into the input (note: settings will only be changed if they were selected in both export & import
Chat Command
Description
${chatPrefix}help
list all available chat commands
${chatPrefix}bots
show which bot pack you have active and how much time is remaining
${chatPrefix}pws
show the amount of powerups in your inventory (recommended to use ${chatPrefix}pws1, ${chatPrefix}pws2, and ${chatPrefix}pws3)
${chatPrefix}totalpws
show the total amount of powerups you have in your inventory
${chatPrefix}xp
show then amount of xp you've completed for this level
${chatPrefix}lvl
show your level and how much of the level you've completed
${chatPrefix}coins
show the amount of coins you have
${chatPrefix}hours
show the hours you have on your account
${chatPrefix}rank
show your ranking
${chatPrefix}ping
show your current ping
${chatPrefix}fps
show your current FPS
${chatPrefix}topmass
show your highest mass
${chatPrefix}cells
show your cell count
${chatPrefix}pws1
show the first part of your powerup inventory
${chatPrefix}pws2
show the second part of your powerup inventory
${chatPrefix}pws3
show the third part of your powerup inventory
${chatPrefix}friends
show how many friends you have and how many are online
${chatPrefix}requests
show how many friend requests you have
${chatPrefix}gold
show how many days of gold member you have left remaining
${chatPrefix}alive
show the amount of time you've been alive
${chatPrefix}mass
show your current mass
${chatPrefix}user
show your current username
${chatPrefix}customs
show the amount of custom skins you own
${chatPrefix}wearables
show how many wearables you own
${chatPrefix}cloak
show the remaining time of your cloak ability
${chatPrefix}add [user]
type this command to quickly add a friend using chat
${chatPrefix}partymembers
show how many people are in your party
${chatPrefix}players
show how many players are online in your server and are online in all agma servers
${chatPrefix}server
show which server you're currently in
${chatPrefix}abils
show your currently active abilities
${chatPrefix}xpproj
show the predicted amount of XP you will gain in an hour
${chatPrefix}coinsproj
show the predicted amount of coins you will gain in an hour
${chatPrefix}xprem
show the amount of XP remaining for your level
${chatPrefix}xphour
show the amount of xp you've gained in the last hour
${chatPrefix}coinshour
show the amount of coins you've gained in the last hour
${chatPrefix}xpmin
show the amount of XP you've gained in the last minute
${chatPrefix}coinsmin
show the amount of coins you've gained in the last minute
${chatPrefix}xp12s
show the amount of coins you've gained in the last 12 seconds
${chatPrefix}xpsesh
show the amount of XP you've gained in this session
${chatPrefix}lifetimexp
show the total amount of XP you've earned in your account's lifetime
${chatPrefix}seshcoins
show the amount of coins you've gained in this session
${chatPrefix}waifu [user]
rate the waifu of the selected username (leave user blank to rate yourself)
${chatPrefix}pro [user]
show how pro someone is (leave user blank to rate yourself)
${chatPrefix}dog [user]
show how dog someone is (leave user blank to rate yourself)
${chatPrefix}king [user]
show how king someone is (leave user blank to rate yourself)
${chatPrefix}dice [sides]
roll a die with the desired number of sides
${chatPrefix}rng [min] [max]
generate a random number in a range
${chatPrefix}coinflip
flip a coin and see if it lands on heads or tails
${chatPrefix}script
show the current script you're using & which version
${chatPrefix}time
show your current date & time
${chatPrefix}skins
show your bought skins and their worth (limited as well)
${chatPrefix}ratefriends [user1] [user2]
show how what percent friends two usernames are
${chatPrefix}rateenemies [user1] [user2]
show how what percent enemies two usernames are
${chatPrefix}leaderboard
show your leaderboard position
Hide Ads- both video and image ads will be removed from the screen
Skin Search- search through skins by their names/ids
Improved Shop- added larger amounts that can be purchased at a time, can also buy a specified amount at one time
Sort Wearables- wearables are automatically sorted by owned (the ones you own will be before all others)
Extra Bot Packs- added hidden bot packs that can be purchased with coins (originally discovered by firebone)
Context Menu Copy Info- right click on a player, then click on their cell icon to copy their skin ID to clipboard or click on their name to copy their nickname to clipboard
Copy Chat- right click on screen, then click "Copy Chat Messages" to copy the currently visible chat messages to your clipboard
Abilities Remaining Time- shows the remaining time left of abilities (only works if the abilities were purchased in the same browser)
Unlock Free Skins- gives you access to the facebook & youtube free skins
Hover For Skin ID- hovering skins in the skin menu will shop their ID
In Depth XP/Coins Stats- click on coins/xp progress bar in top left to view respective statistics
XP Bar Decimals- show the percentage up to 2 decimal places
White Border For Black Cells- show a white border around black cells (from minion nuker) so they're easier to see with dark backgrounds
Inventory Single Row- put powerups inventory on a single row instead of on 2 seperate rows (inspired by Principito)