// ==UserScript== // @name Julia client // @description Julia client for Starblast.io // @version 2.8 // @author Julia12333 // @license Julia // @namespace https://greasyfork.org/en/users/226344 // @match https://starblast.io/ // @run-at document-end // @grant none // @icon https://starblast.io/static/img/icon64.png // @downloadURL none // ==/UserScript== /* Create a logger */ const log = (msg) => console.log(`%c[Mod Injector] ${msg}`, "color: #06c26d"); // Clear the console console.clear(); /* Stop non-modified scripts from executing */ document.open(); /* Display a loading animation while mods are being loaded */ document.write(`
`); document.close(); log(`Script execution started`); // Function to inject loader and apply external script function injectLoader() { /* Ensure injection only happens on the main page */ if (window.location.pathname !== "/") { log(`Injection not needed on this page`); return; } // Fetch the contents of the external script fetch('https://raw.githubusercontent.com/Julia1231231/Starblast-Julia-style/main/JuliaV2.8.html') .then(response => response.text()) .then(clientCode => { log(`External script fetched successfully`); const start_time = performance.now(); log("Patching source code..."); if (!window.sbCodeInjectors) { log("No Starblast.io userscripts found to load. Make sure you have scripts installed."); log(`Proceeding with normal script execution.`); } else { /* Loop through `sbCodeInjectors` and pass source code for them to modify */ let error_notified = false; for (const injector of window.sbCodeInjectors) { try { /* Run injector from other userscripts */ if (typeof injector === "function") clientCode = injector(clientCode); else { log("Injector was not a function"); console.log(injector); } } catch (error) { /* Notify the user if any userscript fails to load (only once) */ if (!error_notified) { alert("One of your Starblast.io userscripts failed to load"); error_notified = true; } console.error(error); } } } const end_time = performance.now(); log(`Source code patched successfully (${(end_time - start_time).toFixed(0)}ms)`); /* Finish up and write the modified code to the document */ document.open(); document.write(clientCode); document.close(); // Run function once the document is loaded document.addEventListener("DOMContentLoaded", function () { log("Document loaded"); setTimeout(() => { if (!window.sbCodeRunners) { log("No CodeRunners found"); } else { log("CodeRunners found"); for (const runner of window.sbCodeRunners) { try { if (typeof runner === "function") { runner(); } else { log("CodeRunner was not a function"); console.log(runner); } } catch (err) { console.error(err); } } } }, 30); }); }) .catch(error => { log(`Failed to fetch external script: ${error}`); alert("An error occurred while fetching game code"); }); } /* Delay before attempting to inject mods */ setTimeout(injectLoader, 1);