Skip to content

Instantly share code, notes, and snippets.

@raidan00
Last active May 30, 2023 13:55
Show Gist options
  • Save raidan00/b46db0e083616b7bc39bd9001c5b54bf to your computer and use it in GitHub Desktop.
Save raidan00/b46db0e083616b7bc39bd9001c5b54bf to your computer and use it in GitHub Desktop.
StarBreak: Sprite Sheet Replacer
// ==UserScript==
// @name StarBreak: Sprite Sheet Replacer
// @version 1.0
// @match https://*.starbreak.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
/*
* Add one entry below for each of the sprite sheets you want to replace (and replace/remove the example one).
* The format of the name is name.index, for example forest.0 or lab.1.
* The URL is the URL to the replacement sprite sheet.
*/
let replacementTextures = {
/* DW
'base.0': 'https://i.imgur.com/pLI3Eg0.png',
'base.1': 'https://i.imgur.com/qnJRHGy.png',
*/
/* Fab
'base.0': 'https://i.imgur.com/ehhcRM0.png',
'base.1': 'https://i.imgur.com/2zPsoQV.png',
*/
/* IC */
'base.0': 'https://i.imgur.com/SdV7oOJ.png',
'base.1': 'https://i.imgur.com/Mylh189.png',
/* WF
'base.0': 'https://i.imgur.com/56TPozR.png',
'base.1': 'https://i.imgur.com/PR97z66.png',
*/
'jungle.0': 'https://i.imgur.com/Emehw6S.png',
'jungle.1': 'https://i.imgur.com/yvxGV7d.png',
'dumb.0': 'https://i.imgur.com/KrNZPjp.png',
'dumb.1': 'https://i.imgur.com/hTaHBJU.png',
'lab.2': 'https://i.imgur.com/xv8zjVL.png',
//'hulk.0': 'https://i.imgur.com/xqzjdG3.png', my gy sprite
'hulk.0': 'https://cdn.discordapp.com/attachments/563381012911095808/563388936467120139/hulk.0.pHTbK-Xql-phUd4ZQPfakw.png',
'hulk.1': 'https://cdn.discordapp.com/attachments/563381012911095808/563389266378489880/hulk.1.nfnRkZIcq50duR3y1mEubA.png',
'hulk.2': 'https://cdn.discordapp.com/attachments/563381012911095808/563389248003244062/hulk.2.7neYZn9tUilLq6ShYaw8IQ.png',
'scboss.0': 'https://i.imgur.com/cIMEU0Y.png',
};
function onLoaded () {
XDL.loadTexture = function (filename, doneCallback, userData) {
let textureName = filename.match(/\w+\.\d/)[0];;
let realFilename = filename;
if (textureName in replacementTextures) {
realFilename = replacementTextures[textureName];
}
var image = new Image();
image.crossOrigin = "Anonymous";
image.src = realFilename;
image.userScriptTextureName = textureName;
image.onload = function() {
var textureId = XDL.renderEngine.addTexture(image);
Runtime.dynCall('vii', doneCallback, [textureId, userData]);
};
image.onerror = function() {
console.error('error trying to load ' + filename + ', retrying');
setTimeout(function() {
XDL.loadTexture(filename, doneCallback, userData);
}, 1000);
};
};
}
function waitUntilLoaded () {
if (typeof XDL == 'undefined') {
setTimeout(waitUntilLoaded, 100);
return;
}
onLoaded();
}
waitUntilLoaded();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment