Skip to content

Instantly share code, notes, and snippets.

@dsetzer
dsetzer / ResolveKeyWorkers.js
Last active July 25, 2022 20:10
Partial Private Key Solver
async function resolveKeyWorkers(brokenKey, startIter, numWorkers) {
var updateFrequency = 100000 * Number(numWorkers);
var splitKey = brokenKey.split("?");
var iteratorStart = Number(startIter) || Math.pow(58, (splitKey.length - 2));
var duration = Math.pow(58, (splitKey.length - 1));
var workers = [];
var latestStatus = null, latestUpdate = 0;
var statusUpdate = function (info) {
if (!latestStatus || info[0] > latestStatus[0]) {
latestStatus = info;
@dsetzer
dsetzer / IterativeProb.js
Created October 25, 2021 13:17
Finds the cumulative win probability of a target payout in bustabit/bustadice. Results parameter expects an ordered array of numbers representing the games bust history.
/**
* Calculates current cumulative geometric probability
* @param payout Target payout to calculate for
* @param results Array of ordered results
* @param precision Num decimal places accuracy
* @param debug Output result slice to console
* @returns Cumulative geometric win probability
*/
function getCumulativeProb(payout, results, precision, debug = false) {
let prc = 10 ** Math.max(1, Math.min((precision || 18), 18), 1);
@dsetzer
dsetzer / Pattern-System-v1.4.js
Last active December 19, 2022 11:14
Dynamic Pattern System v1.4 work in progress prototype for bustabit/bustadice scripts.
// ----------------------- V1.4 -------------------------
// This utility function will check an array of game results for a given pattern and return the most recent occurrence of a
// match. The pattern is specified using a regex-style syntax that uses the available tokens defined in the token list. The
// token list is an array of objects containing a token letter and a callback function that is used to check if the game results
// match the specified condition. It returns an array containing the game result objects for the matched results.
function checkPattern(pattern, results, tokens){
let tokenLetters = pattern.match(/\w/g);
let filteredTokens = tokens.filter((token) => tokenLetters.includes(token[0]));
let res = results.map((r, i) => (`[${i}${filteredTokens.filter((e) => e[1](r)).map((e) => (e[0])).join('')}]`)).reverse().join('');
@dsetzer
dsetzer / downloadString.js
Last active August 31, 2021 00:18
Initiates a file download from javascript. No longer works from within sandboxed iframes.
function downloadString(data, fileName = 'download.txt', fileType = 'text/plain') {
var blob = new Blob([data], {type: fileType});
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else{
var e = document.createEvent('MouseEvents'),
a = document.createElement('a');
a.download = fileName;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
@dsetzer
dsetzer / default-martingale-sim.js
Created July 15, 2021 23:07
default martingale script from bustabit converted to bustadice with added sim mode.
var config = {
baseBet: { value: 100, type: 'balance', label: 'Base Bet' },
payout: { value: 2, type: 'multiplier', label: 'Target Payout' },
stop: { value: 1e8, type: 'balance', label: 'Stop if bet >' },
delay: { value: 100, type: 'number', label: 'Bet Speed' },
loss: {
value: 'increase', type: 'radio', label: 'On Loss',
options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Increase bet by' },
@dsetzer
dsetzer / round-prec.js
Last active April 14, 2021 07:58
Rounding with precision
// Arrow functions
const round = (num, prec) => (prec = 10 ** prec, Math.round(num * prec) / prec);
const roundUp = (num, prec) => (prec = 10 ** prec, Math.ceil(num * prec) / prec);
const roundDown = (num, prec) => (prec = 10 ** prec, Math.floor(num * prec) / prec);
// Classic functions
function round(num, prec) {
prec = Math.pow(10, prec);
return Math.round(num * prec) / prec;
}
@dsetzer
dsetzer / bab_to_ether-dice.js
Created March 21, 2021 22:36
Script wrapper for running bustabit scripts on ether-dice. This expects the bustabit script to be standard format where bets are placed at GAME_STARTING event. Scripts with everything in GAME_ENDED will skip endlessly. Also don't expect any Ruzli scripts to work, it's a miracle those run to begin with.
engine.bet=function(e,n){this.nextBet={value:e,target:n}},engine.getState=(()=>{}),engine.cashOut=(()=>{});const gameResultFromHash=()=>{},SHA256=()=>{};engine.history={first(){let e=engine.nextResult;if(e||(e=engine.getLastGamePlayed),e){let n={id:e.id,hash:e.hash,bust:e.crash};return["NOT_PLAYED","SKIPPED"].includes(engine.getLastGamePlay)||(n.wager=e.wager,e.cashout<=e.crash&&(n.cashedAt=e.cashout)),n}return{id:0,hash:"none",bust:0,wager:0,cashedAt:0}}};const log=console.log,stop=engine.stop,userInfo={get uname(){},get balance(){return engine.getBalance}};engine.on("script_started",()=>{setTimeout(async()=>{for(;;)engine.nextBet=null,engine.nextResult=null,await engine.emit("GAME_STARTING"),null!==engine.nextBet?(engine.emit("BET_PLACED",{uname:"temp",wager:engine.nextBet.value,payout:engine.nextBet.target}),engine.nextResult=await engine.placeBet(engine.nextBet.value,engine.nextBet.target)):engine.nextResult=await engine.skip(),engine.emit("GAME_STARTED"),"WON"===engine.getLastGamePlay&&engine.emit("CASHE
@dsetzer
dsetzer / results-verifier.js
Created February 9, 2021 23:09
Result verifier adapted for use inside of a bustadice script.
var config = {};
(function (I) {
function w(c, a, d) {
var l = 0, b = [], g = 0, f, n, k, e, h, q, y, p, m = !1, t = [], r = [], u, z = !1; d = d || {}; f = d.encoding || "UTF8"; u = d.numRounds || 1; if (u !== parseInt(u, 10) || 1 > u) throw Error("numRounds must a integer >= 1"); if (0 === c.lastIndexOf("SHA-", 0)) if (q = function (b, a) { return A(b, a, c) }, y = function (b, a, l, f) {
var g, e; if ("SHA-224" === c || "SHA-256" === c) g = (a + 65 >>> 9 << 4) + 15, e = 16; else throw Error("Unexpected error in SHA-2 implementation"); for (; b.length <= g;)b.push(0); b[ a >>> 5 ] |= 128 << 24 - a % 32; a = a + l; b[ g ] = a & 4294967295;
b[ g - 1 ] = a / 4294967296 | 0; l = b.length; for (a = 0; a < l; a += e)f = A(b.slice(a, a + e), f, c); if ("SHA-224" === c) b = [ f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ], f[ 4 ], f[ 5 ], f[ 6 ] ]; else if ("SHA-256" === c) b = f; else throw Error("Unexpected error in SHA-2 implementation"); return b
}, p = function (b) { return b.slice
@dsetzer
dsetzer / default-bab-mart-bustadice.js
Last active January 11, 2023 13:59
Bustadice's default martingale script is less configurable than bustabit's so I made a bustadice version out of it. (this is for use on bustadice).
var config = {
baseBet: { value: 100, type: 'balance', label: 'base bet' },
stopBet: { value: 1e8, type: 'balance', label: 'stop if bet >' },
basePayout: { value: 2, type: 'multiplier' },
stopPayout: {value: 20,type: 'multiplier',label: 'stop if payout >'},
lossBet: {
value: 'increase', type: 'radio', label: 'Bet On Loss',
options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Multiply bet by' },
@dsetzer
dsetzer / LD2WD4.js
Last active October 29, 2023 15:42
Simple script I made for bustadice. It bets on 2x, doubles the bet amount on a loss and divides the bet by 4 if it's greater than 8 times the base bet otherwise by 2. It's not a set&forget script, it's risky but more profitable than plain martingale and it's manageable at a slow bet speed.
var config = {
baseBet: { type: 'balance', label: 'Base Bet', value: 128},
betSpeed: { type: 'number', label: 'Bet Speed', value: 800},
maxBet: { type: 'balance', label: 'Max Bet', value: 10000 }
}
Object.entries(config).forEach(c => window[c[0]] = c[1].value);
var s = t => new Promise(r => setTimeout(r, t));
for(let b = baseBet; ;b=Math.max(baseBet, b)){
if (b > maxBet) break;
await this.bet(Math.round(b / 100) * 100, 2).then(r => {