Skip to content

Instantly share code, notes, and snippets.

@raidan00
Last active May 30, 2023 08:54
Show Gist options
  • Save raidan00/70722543c92a5a5ffa50459c5e05b6c7 to your computer and use it in GitHub Desktop.
Save raidan00/70722543c92a5a5ffa50459c5e05b6c7 to your computer and use it in GitHub Desktop.
StarBreak-Bots: Login
// ==UserScript==
// @name StarBreak-Bots: Login
// @version 1.0
// @match https://*.starbreak.com/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
let un = getAccountUsername();
let accsData = getAccsData();
let activeBots = GM_getValue("activeBots") ?? {};
activeBots[un] = true;
GM_setValue("activeBots", activeBots);
for (const key in accsData) {
if(!activeBots[key]){
let button = document.createElement("button");
button.id = "newBotButton";
button.textContent = "+1 Bot";
button.addEventListener('click', function (e) {
e.preventDefault();
localStorage.setItem('LocalStorage.pb', accsData[key]);
document.body.removeChild(button);
window.open("https://www.starbreak.com/", '_blank', "location=yes, height=400, width=800, top=500, left=500");
});
document.body.appendChild(button);
break;
}
}
let playButtonTid = 0;
let createTextureDone = false;
function onLoaded(){
(function (orig) {
RenderEngineWebGL._Z21XDL_CreateTextTextureiPKcijS0_ij = function (textureId, fontName, size, color, text, outlineSize, outlineColor) {
if(createTextureDone) return orig.apply(null, arguments);
var textStr = Pointer_stringify(text);
var font = size + 'px ' + Pointer_stringify(fontName);
var csscolor = TextUtils.loadColorToCSSRGBA(color);
var tid = orig.apply(null, arguments);
if(textStr == "PLAY" && font == "32px HemiHeadBold" && csscolor == "rgba(255,255,255,1)"){
playButtonTid = tid;
createTextureDone = true;
}
return tid;
};
})(RenderEngineWebGL._Z21XDL_CreateTextTextureiPKcijS0_ij);
let loginFinished = false;
let lastTryLogin = 0;
function tryLogin(){
if(lastTryLogin + 250 > Date.now()) return;
lastTryLogin = Date.now();
sendKey("keydown", 13);
sendKey("keyup", 13);
document.title = un;
setTimeout(()=>{
loginFinished = true;
}, 10000);
}
(function (orig) {
RenderEngineWebGL._Z15XDL_DrawTextureiiiiiiiiiiiiij9BlendMode = function(texture, sx, sy, sw, sh, dx, dy, dw, dh, rot, rpx, rpy, flip, cm, blendMode) {
if(loginFinished) return orig.apply(null, arguments);
if(texture == playButtonTid){
tryLogin();
}
return orig.apply(null, arguments);
};
})(RenderEngineWebGL._Z15XDL_DrawTextureiiiiiiiiiiiiij9BlendMode);
}
function waitUntilLoaded () {
if (typeof RenderEngineWebGL == 'undefined' || typeof XDL == 'undefined' || typeof Module === 'undefined') {
setTimeout(waitUntilLoaded, 0);
return;
}
onLoaded();
}
waitUntilLoaded();
function sendKey(type, keyCode) {
let preventDefault = function dummyPreventDefault() {};
let ev = { type, keyCode, preventDefault };
XDL.onKey(ev);
}
function getAccsData() {
return GM_getValue("accsData") ?? {};
}
function setAccsData(d) {
GM_setValue("accsData", d);
}
function readString(b, fieldname) {
let i = b.indexOf(fieldname);
if (i === -1) return null;
return b.substr(i+fieldname.length+2, b.charCodeAt(i+fieldname.length+1));
}
function getAccountUsername() {
let b = atob(localStorage.getItem('LocalStorage.pb'));
let n = readString(b, '\x08username');
return n;
}
function startBots(){
GM_setValue("activeBots", {});
localStorage.botsLead = "";
let botsList = {}
for(let key in accsData){
botsList[key] = true;
}
localStorage.botsList = JSON.stringify(botsList);
document.location.reload();
}
function addAccount() {
var d = getAccsData();
let un = getAccountUsername();
if (un === null) {
alert('you need register');
return;
}
d[un] = localStorage.getItem('LocalStorage.pb');
setAccsData(d);
document.location.reload();
}
let div;
function addButtonInPanel(name, fn, mt) {
let el = document.createElement('a');
el.textContent = name;
el.setAttribute('href', '#');
el.setAttribute('style', `display: block; margin: 3px; ${ mt? "margin-top: 10px;" : "" }`);
el.addEventListener('click', function (e) {
e.preventDefault();
fn();
});
div.appendChild(el);
}
function showBotsPanel(){
div = document.createElement("div");
div.id = "botsPanel";
document.body.appendChild(div);
for (let an of Object.keys(accsData)) {
let innerDiv = document.createElement("div");
div.appendChild(innerDiv);
let acc = document.createElement('a');
acc.textContent = an;
acc.setAttribute('href', '#');
acc.setAttribute('class', 'an');
if(an == un) acc.setAttribute('style', 'color: green');
acc.addEventListener('click', function (e) {
e.preventDefault();
localStorage.setItem('LocalStorage.pb', accsData[an]);
document.location.reload();
});
innerDiv.appendChild(acc);
let remove = document.createElement('a');
remove.textContent = "X";
remove.setAttribute('href', '#');
remove.setAttribute('class', 'remove');
remove.addEventListener('click', function (e) {
e.preventDefault();
let d = getAccsData();
delete d[an];
setAccsData(d);
document.location.reload();
});
innerDiv.appendChild(remove);
}
addButtonInPanel('Add/Update Account', addAccount, true);
addButtonInPanel('Start Bots', startBots);
}
showBotsPanel();
const innerStyle = `
#botsPanel {
position: fixed;
background-color: rgba(16, 16, 16, 0.9);
top: 200px;
left: -190px;
color: #f0f0f0;
font-size: 12pt;
font-family: Consolas, monospace;
padding: 10px;
text-align: center;
border-radius: 5px;
padding-right: 23px;
border: 1px solid #a5a5a5;
transition-duration: 0.35s;
}
#botsPanel:hover{
left: 0px;
}
#botsPanel a:link {
color: #e0e0e0;
}
#botsPanel a:visited {
color: #e0e0e0;
}
#botsPanel a:hover {
color: #f0f0f0;
}
#botsPanel a:active {
color: #e8e8e8;
}
.remove {
color: red !important;
margin-left: 10px;
}
#newBotButton {
position: fixed;
left: 80px;
top: 80px;
font-size: 100px;
padding: 5px 30px;
}
`
let css = document.createElement('style');
css.innerHTML = innerStyle;
document.head.appendChild(css);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment