Jump to content

[$800] PD Weekly Heroes Wk24

Recommended Posts




This was a bit of a challenge without Seuntjie's dicebot! But luckily, I was able to whip up a bit of JavaScript that should allow people to continue programming bets from the browser. Not as neat is Seuntjie's dicebot, but at least it works!

If you'd like to use it, read through the code carefully! It's good practice to make sure nobody sneaks in an auto-withdrawal script and robs you. You'll need to use this in the console of your browser (usually F12) after you've signed into Primedice:

// ==========================================
// Copy from here...

let stopContinousBetting = false;

function placeBet(rollUntilStop, betVariables){
	let token = localStorage["session"].replaceAll("\"", "");
	let query = {
		"variables": betVariables,
		"query":"mutation PrimediceRoll($amount: Float!, $target: Float!, $condition: CasinoGamePrimediceConditionEnum!, $currency: CurrencyEnum!) {\n  primediceRoll(amount: $amount, target: $target, condition: $condition, currency: $currency) {\n    ...CasinoBetFragment\n    state {\n      ...PrimediceStateFragment\n      __typename\n    }\n    __typename\n  }\n}\n\nfragment CasinoBetFragment on CasinoBet {\n  id\n  active\n  payoutMultiplier\n  amountMultiplier\n  amount\n  payout\n  updatedAt\n  currency\n  game\n  user {\n    id\n    name\n    __typename\n  }\n  __typename\n}\n\nfragment PrimediceStateFragment on CasinoGamePrimedice {\n  result\n  target\n  condition\n  __typename\n}\n"

	fetch("https://primedice.com/_api/graphql", {
		method: "POST",
		headers: {
			"x-access-token": token,
			"x-language": "en",
			"x-lockdown-token": "",
			"content-type": "application/json",
			"content-length": query.length
		body: JSON.stringify(query)
	}).then(response => {
		if (response.ok){
			return response.json();
			console.log("Request failed!", response);
	}).then((jsonBody) => {
		if (jsonBody.data.primediceRoll){
			let roll = jsonBody.data.primediceRoll;
			let condition = roll.state.condition;
			let target = roll.state.target;
			let rollNumber = +roll.state.result.toFixed(2);
			let won = condition === "above"
				? rollNumber > target
				: rollNumber < target;

			console.log (
				won ? "Win" : "Loss",

			if (rollUntilStop && !shouldStopBetting(won, rollNumber)){
				placeBet(rollUntilStop, betVariables);
			console.log("No roll returned!", jsonBody);

function shouldStopBetting(won, rollNumber){
	if (stopContinousBetting){
		console.log("Betting manually stopped!");
		stopContinousBetting = false;
		return true;

	let winningNumbers = [33.33, 44.44, 55.55, 66.66, 77.77];
	if (won && (winningNumbers.includes(rollNumber))) {
		console.log("Stop condition met!");
		return true;
	return false;

function stopBetting(){
	stopContinousBetting = true;

// ...To here.
// ==========================================

// Run this only after you've input the exact bet parameters you want

// Run this if you want to interrupt betting


Share this post

Link to post
Share on other sites
This topic is now closed to further replies.