// ==UserScript== // @name SB-AUI // @namespace http://tampermonkey.net/ // @version 1.1.0 // @description Advanced UI for Starblast with extra features // @author Halcyon // @license All rights reserved, this code may not be reproduced or used in any way without the express written consent of the author. // @match https://starblast.io/ // @icon https://www.google.com/s2/favicons?sz=64&domain=starblast.io // @grant none // @downloadURL none // ==/UserScript== 'use strict'; const API_LINK = "https://starblast.dankdmitron.dev/api/simstatus.json"; const applyBaseStyles = (element, includeFont = true) => { element.style.boxShadow = "black 0px 0px 0px"; element.style.textShadow = "black 0px 0px 0px"; if (includeFont) { element.style.fontFamily = `"DM Sans", sans-serif`; } element.style.fontWeight = "400"; element.style.background = "#0b0b0b"; element.style.border = "1px solid #1a1a1a" element.style.color = "#FFF"; element.style.borderRadius = "10px"; } const applyStyles = (styles, element) => { if (!element) { return; } if (!styles) { return; } for (let key of Object.keys(styles)) { try { element.style[key] = styles[key] } catch (ex) {console.error(`applyStyles: Cannot apply style '${key}' to ${element}`)} } return; } try { var styleElement = document.createElement('style'); var importRule = ` @import url('https://fonts.googleapis.com/css2?family=Abel&family=DM+Sans:wght@400;500;700&display=swap'); `; styleElement.textContent = importRule; document.head.appendChild(styleElement); document.addEventListener("DOMContentLoaded", function() { var elementsToStyle = document.querySelectorAll("body"); elementsToStyle.forEach(function(element) { element.style.fontFamily = '"DM Sans", sans-serif'; }); }); } catch (ex) {} try { var style = document.createElement('style'); var fontFaceRule = ` @font-face { font-family: 'Ships'; /* Name your font */ src: url('https://starblast.dankdmitron.dev/fonts/Starblast/starblast-vanilla-ships.ttf') format('truetype'); } `; style.textContent = fontFaceRule; document.head.appendChild(style); } catch (ex) {} for (let el of document.querySelectorAll('button')) { applyBaseStyles(el) } document.documentElement.style.scrollbarWidth = 'thin'; // Internet Explorer and Microsoft Edge (legacy) document.documentElement.style.msOverflowStyle = 'none'; // For Microsoft Edge (Chromium-based) and modern browsers with standard scrollbar support var style = document.createElement('style'); var css = ` /* Webkit and Blink */ ::-webkit-scrollbar { width: 0.2em; } ::-webkit-scrollbar-thumb { background-color: #1a1a1a; border: none; border-radius: 0.1em; } ::-webkit-scrollbar-track { background-color: transparent; border: none; } /* Firefox */ scrollbar-width: thin; scrollbar-color: transparent transparent; `; style.appendChild(document.createTextNode(css)); document.head.appendChild(style); //document.querySelector("body").style.backgroundImage = "url(https://www.wallpaperflare.com/static/760/797/225/galaxy-space-stars-universe-wallpaper.jpg)"; document.querySelector("body").style.backgroundColor = "#0b0b0b"; let overlayStyles = { backgroundColor: "#1a1a1a", background: "repeating-linear-gradient(45deg, #1a1a1a 0, #131313 1px, #0b0b0b 0, #0b0b0b 50%)", backgroundSize: "10px 10px", maxWidth: "calc(100% - 60px)", maxHeight: "calc(100% - 60px)", margin: "auto auto", boxSizing: "content-box", boxShadow: "black 0px 0px 0px", border: "6px solid #131313", outline: "54px solid #0b0b0b", }; applyStyles(overlayStyles, document.querySelector("#overlay")); try { document.querySelector("#logo > img").src = "https://i.ibb.co/t25sFmR/SBAUI.png"; } catch (ex) { try { setTimeout(() => { document.querySelector("#logo > img").src = "https://i.ibb.co/t25sFmR/SBAUI.png"; }, 500) } catch (ex) { setTimeout(() => { document.querySelector("#logo > img").src = "https://i.ibb.co/t25sFmR/SBAUI.png"; }, 1000) } } document.querySelector("body").style.height = "100dvh"; document.querySelector("body").style.width = "100vw"; document.querySelector("#play").style.fontFamily = `"DM Sans", sans-serif`; document.querySelector("#play").style.letterSpacing = "4px" document.querySelector("#play").style.fontSize = "2.2rem" document.querySelector("#play").style.fontWeight = "600"; document.querySelector("#game_modes").style.background = `transparent`; document.querySelector("#game_modes").style.textShadow = `black 0px 0px 0px`; document.querySelector("#game_modes").style.fontFamily = `'Abel', sans-serif`; document.querySelector("#game_modes").style.fontSize = `1rem`; document.querySelector("#game_modes").style.letterSpacing = `0px`; document.querySelector("#game_modes").style.marginTop = `5px`; document.querySelector("#game_modes").style.marginLeft = `auto`; document.querySelector("#game_modes").style.marginRight = `auto`; document.querySelector("#game_modes").style.width = `80%`; document.querySelector("#game_modes").style.borderTop = `1px solid #1a1a1a`; document.querySelector("#game_modes").style.color = `gray`; document.querySelector(".changelog-new").style.fontFamily = `"DM Sans", sans-serif`; let removalQueries = ['[data-translate-base="music"]','[data-translate-base="community"]']; for (let query of removalQueries) { for (let el of document.querySelectorAll(query)) { el.style.display = "none" } } //followtools bottom-left document.querySelector('.followtools').style.left = '0'; document.querySelector('.followtools').style.width = 'max-content'; document.querySelector('.followtools').style.zIndex = '500'; document.querySelector('.bottom-left').style.top = '0'; document.querySelector('.bottom-left').style.height = 'max-content'; document.querySelector('.inputwrapper').style.background = '#0b0b0b'; document.querySelector('.inputwrapper').style.border = '1px solid #1a1a1a'; document.querySelector('.inputwrapper').style.fontFamily = 'DM Sans'; document.querySelector('.inputwrapper').style.boxShadow = 'black 0px 0px 0px'; document.querySelector('.inputwrapper').style.borderRadius = '10px'; const leftRight = [document.querySelector('#prevMode'),document.querySelector('#nextMode')]; for (let el of leftRight) { el.style.color = '#FFFFFF'; el.style.textShadow = 'black 0px 0px 0px'; } const baseStyleQueries = ['.changelog-new', '#moddingspace', "#donate", "#rankings", "#training"]; for (let query of baseStyleQueries) { applyBaseStyles(document.querySelector(query)); } const ml = ['#moddingspace', "#donate", "#rankings", "#training"] for (let query of ml) { let item = document.querySelector(query); item.style.paddingBottom = "0.5rem"; let icon = document.querySelector(`${query} > i`); icon.style.margin = "0.5rem auto 0.5rem auto"; icon.style.paddingBottom = '0.5rem'; icon.style.width = '80%'; icon.style.borderBottom = '1px solid #1a1a1a'; let span = document.querySelector(`${query} > span`); span.style.color = "#FFF"; span.style.letterSpacing = '1px'; span.style.textShadow = 'black 0px 0px 0px'; span.style.fontWeight = '500'; } for (let el of document.querySelectorAll('.modal')) { applyBaseStyles(el); } for (let el of document.querySelectorAll('.social i')) { applyBaseStyles(el, false); } var J = document.createElement("div"); J.id = "SL_INTEGRATION"; document.querySelector('#overlay').appendChild(J); const SL_INTEGRATION = document.querySelector('#SL_INTEGRATION'); let styles = { position: 'absolute', height: '100%', width: '25%', top: '0', right: '0', display: 'flex', flexDirection: 'column' } for (let key of Object.keys(styles)) { SL_INTEGRATION.style[key] = styles[key] } let options = { activePanel: "listing", activeRegion: "europe", modes: { team: true, survival: false, deathmatch: false, modded: false, invasion: false } }; let filteredSystems = []; let statusReportActive = false; let statusReportData = { name: "", id: "", team_1: { hue: null, gems: 0, level: 0, potentialOutput: 0, PBS: 0, PPBS: 0, players: [] }, team_2: { hue: null, gems: 0, level: 0, potentialOutput: 0, PBS: 0, PPBS: 0, players: [] }, team_3: { hue: null, gems: 0, level: 0, potentialOutput: 0, PBS: 0, PPBS: 0, players: [] } }; const templateStatusData = () => ({name: "",team_1: {hue: null,players: []},team_2: {hue: null,players: []},team_3: {hue: null,players: []}}) window.switchActivePanel = (panel) => { options.activePanel = panel; refreshSL(); } window.switchActiveRegion = (region) => { options.activeRegion = region; refreshSL(); } window.toggleMode = (mode) => { options.modes[mode] = !options.modes[mode]; refreshSL(); } let API_TIMER = setInterval(async () => { if (options.activePanel !== 'listing') { return; } let raw = await(await fetch(API_LINK)).json(); let allSystems = []; for (let item of raw) { if (item.hasOwnProperty("modding") && item.modding) { if (!options.modes.modding) { continue; } } if (item.location.toLowerCase() !== options.activeRegion) { continue; } for (let system of item.systems) { if (options.modes[system.mode]) { allSystems.push({ ...system, IP_ADDR: item.address }); } } } filteredSystems = allSystems.sort((a, b) => a.time - b.time); refreshSL(); }, 3000) const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1); let STATUS_TIMER = null; window.statusReport = async (query) => { if (STATUS_TIMER) {return}; STATUS_TIMER = setInterval(async () => { statusReportActive = true; refreshSL(); let raw = await (await fetch(`https://starblast.dankdmitron.dev/api/status/${query}`)).json(); statusReportData = templateStatusData(); statusReportData.name = raw.name; statusReportData.id = query.split('@')[0]; for (let key of Object.keys(raw.players)) { let player = raw.players[key]; statusReportData[`team_${player.friendly + 1}`].players.push({ name: player.player_name, ecp: !!player.custom, score: player.score, type: player.type, PBS: calculatePlayerScore(player.type, !!player.custom) }) statusReportData[`team_${player.friendly + 1}`].hue = player.hue; } for (let team of raw.mode.teams) { for (let num of ["team_1", "team_2", "team_3"]) { if (team.hue === statusReportData[num].hue) { statusReportData[num].gems = team.crystals statusReportData[num].level = team.level break } } } for (let team of ["team_1", "team_2", "team_3"]) { let sPBS = 0, sPPBS = 0, potentialOutput = 0; for (let i = 0; i < statusReportData[team].players.length; i++) { sPBS += Number(statusReportData[team].players[i].PBS.currentScore); sPPBS += Number(statusReportData[team].players[i].PBS.potentialScore); potentialOutput += statusReportData[team].players[i].PBS.energyOutput; } statusReportData[team].PBS = sPBS.toFixed(2); statusReportData[team].PPBS = sPPBS.toFixed(2); statusReportData[team].potentialOutput = potentialOutput; } statusReportData.team_1.players = statusReportData.team_1.players.sort((a, b) => a.score - b.score).reverse(); statusReportData.team_2.players = statusReportData.team_2.players.sort((a, b) => a.score - b.score).reverse(); statusReportData.team_3.players = statusReportData.team_3.players.sort((a, b) => a.score - b.score).reverse(); }, 2000) } window.closeStatusReport = () => { statusReportActive = false; clearInterval(STATUS_TIMER); STATUS_TIMER = null; refreshSL(); } document.querySelector('#play').addEventListener('click', () => { clearInterval(API_TIMER); clearInterval(STATUS_TIMER); SL_INTEGRATION.style.display = 'none'; }); const refreshSL = () => { SL_INTEGRATION.innerHTML = ` ${ !statusReportActive ? "" : `