Skip to content

Instantly share code, notes, and snippets.

@thevtm
Last active March 28, 2025 02:03
Show Gist options
  • Select an option

  • Save thevtm/cee53cdddd78796ec6060947e2d84aac to your computer and use it in GitHub Desktop.

Select an option

Save thevtm/cee53cdddd78796ec6060947e2d84aac to your computer and use it in GitHub Desktop.
Progress Knight Quest Bot
// Simple bot that executes an action after another that I made for the game Progress Knight Quest
// https://indomit.github.io/progress_knight_2/
// GitHub: https://github.com/indomit/progress_knight_2/
(() => {
try {
window.stop_bot();
} catch (_) {}
/* UTIL */
const formatMs = (milliseconds) => {
const seconds = Math.floor(milliseconds / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
const remainingHours = hours % 24;
const remainingMinutes = minutes % 60;
const remainingSeconds = seconds % 60;
let result = [];
if (days > 0) result.push(`${days} day${days === 1 ? "" : "s"}`);
if (remainingHours > 0) result.push(`${remainingHours} hour${remainingHours === 1 ? "" : "s"}`);
if (remainingMinutes > 0) result.push(`${remainingMinutes} minute${remainingMinutes === 1 ? "" : "s"}`);
if (remainingSeconds > 0 || result.length === 0)
result.push(`${remainingSeconds} second${remainingSeconds === 1 ? "" : "s"}`);
return result.join(", ");
};
/* STOP BOT */
const [stop_bot, stop_bot_promise, STOP_BOT_ERROR_SIGNAL] = (() => {
const STOP_BOT_ERROR_SIGNAL = { message: "Bot has been stopped!" };
let stop_bot_promise_resolve;
const stop_bot_promise = new Promise((resolve) => (stop_bot_promise_resolve = resolve));
const stop_bot = () => stop_bot_promise_resolve();
window.stop_bot = stop_bot;
return [stop_bot, stop_bot_promise, STOP_BOT_ERROR_SIGNAL];
})();
/* ROUND SIGNALS */
const [round_start, round_end, round_promise_wrap, ROUND_END_ERROR_SIGNAL] = (() => {
const ROUND_END_ERROR_SIGNAL = { message: "Round ended!" };
let round_promise_resolve;
const round_promise_wrap = { value: undefined };
const round_start = () => (round_promise_wrap.value = new Promise((resolve) => (round_promise_resolve = resolve)));
const round_end = () => round_promise_resolve();
return [round_start, round_end, round_promise_wrap, ROUND_END_ERROR_SIGNAL];
})();
/* SENSORS */
const sensors = {};
sensors.age = () => gameData.days / 365;
sensors.concentration_level = () => gameData.taskData.Concentration.level;
sensors.concentration_max_level = () => gameData.taskData.Concentration.maxLevel;
sensors.absolute_wish_level = () => gameData.taskData["Absolute Wish"].level;
sensors.absolute_wish_max_level = () => gameData.taskData["Absolute Wish"].maxLevel;
sensors.void_amplification_level = () => gameData.taskData["Void Amplification"].level;
sensors.void_amplification_max_level = () => gameData.taskData["Void Amplification"].maxLevel;
sensors.mind_release_level = () => gameData.taskData["Mind Release"].level;
sensors.mind_release_max_level = () => gameData.taskData["Mind Release"].maxLevel;
sensors.ceaseless_abyss_level = () => gameData.taskData["Ceaseless Abyss"].level;
sensors.ceaseless_abyss_max_level = () => gameData.taskData["Ceaseless Abyss"].maxLevel;
sensors.temporal_dimension_level = () => gameData.taskData["Temporal Dimension"].level;
sensors.temporal_dimension_max_level = () => gameData.taskData["Temporal Dimension"].maxLevel;
sensors.evil = () => gameData.evil;
sensors.evil_gain = () => getEvilGain();
sensors.essence_gain = () => getEssenceGain();
sensors.dark_matter_gain = () => getDarkMatterGain();
sensors.metaverse_gain = () => getMetaversePerkPointsGain();
sensors.can_touch_eye = () => gameData.requirements["Rebirth button 1"].isCompleted();
sensors.can_embrace_evil = () => gameData.requirements["Rebirth button 2"].isCompleted();
sensors.can_transcend = () => gameData.requirements["Rebirth button 3"].isCompleted();
sensors.can_collapse_universe = () => gameData.requirements["Rebirth button 4"].isCompleted();
sensors.can_metaverse = () => gameData.requirements["Rebirth button 5"].isCompleted();
sensors.evil_perk_points = () => gameData.evil_perks_points;
sensors.evil_perk_reduce_eye_age = () => gameData.evil_perks.reduce_eye_requirement;
sensors.evil_perk_reduce_evil_age = () => gameData.evil_perks.reduce_evil_requirement;
sensors.evil_perk_reduce_the_void_age = () => gameData.evil_perks.reduce_the_void_requirement;
sensors.evil_perk_reduce_celestial_age = () => gameData.evil_perks.reduce_celestial_requirement;
sensors.evil_perk_receive_percentage_of_essence = () => gameData.evil_perks.receive_essence;
sensors.can_evil_perk_reduce_eye_age = () => gameData.evil_perks_points >= getEvilPerkCost(1);
sensors.can_evil_perk_reduce_evil_age = () => gameData.evil_perks_points >= getEvilPerkCost(2);
sensors.can_evil_perk_reduce_the_void_age = () => gameData.evil_perks_points >= getEvilPerkCost(3);
sensors.can_evil_perk_reduce_celestial_age = () => gameData.evil_perks_points >= getEvilPerkCost(4);
sensors.can_evil_perk_receive_percentage_of_essence = () => gameData.evil_perks_points >= getEvilPerkCost(5);
sensors.is_in_void_age = () => gameData.requirements["The Void"].isCompleted();
sensors.has_magic_eye = () => gameData.requirements["Magic Eye"].isCompleted();
sensors.is_boost_active = () => gameData.boost_active;
sensors.can_apply_boost = () => canApplyBoost();
sensors.is_perk_instant_evil_active = () => gameData.perks.instant_evil === 1;
/* TASKS */
const tasks = {};
tasks.wait_ms = async (ms, options = { log: true }) => {
if (options.log) console.log(`Waiting ${formatMs(ms)}...`);
let timeout_promise_resolve;
const timeout_promise = new Promise((resolve) => (timeout_promise_resolve = resolve));
const timeout_interval_id = setTimeout(timeout_promise_resolve, ms);
const race_result = await Promise.race([
timeout_promise.then(() => "timeout"),
round_promise_wrap.value.then(() => "round_end"),
stop_bot_promise.then(() => "stop_bot"),
]);
if (race_result === "round_end") {
clearInterval(timeout_interval_id);
throw ROUND_END_ERROR_SIGNAL;
}
if (race_result === "stop_bot") {
clearInterval(timeout_interval_id);
throw STOP_BOT_ERROR_SIGNAL;
}
};
tasks.wait_condition = async (condition_fn, options = { log: true }) => {
while (!condition_fn()) await tasks.wait_ms(100, { log: false });
};
tasks.touch_eye = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_touch_eye());
if (options.log) console.log(`Clicked "Touch eye"`);
return rebirthOne();
};
tasks.embrace_evil = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_embrace_evil());
if (options.log) console.log(`Clicked "Embrace evil"`);
rebirthTwo();
};
tasks.transcend = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_transcend());
if (options.log) console.log(`Clicked "Transcend"`);
rebirthThree();
};
tasks.collapse_universe = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_transcend());
if (options.log) console.log(`Clicked "Collapse Universe"`);
rebirthFour();
};
tasks.metaverse = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_metaverse());
if (options.log) console.log(`Clicked "Metaverse"`);
rebirthFive();
};
tasks.buy_reduce_eye_age = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_evil_perk_reduce_eye_age());
if (options.log) console.log(`Clicked "Reduce Eye Age Requirement"`);
buyEvilPerk(1);
};
tasks.buy_reduce_evil_age = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_evil_perk_reduce_evil_age());
if (options.log) console.log(`Clicked "Reduce Evil Age Requirement"`);
buyEvilPerk(2);
};
tasks.buy_reduce_the_void_age = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_evil_perk_reduce_the_void_age());
if (options.log) console.log(`Clicked "Reduce The Void Age Requirement"`);
buyEvilPerk(3);
};
tasks.buy_reduce_celestial_age = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_evil_perk_reduce_celestial_age());
if (options.log) console.log(`Clicked "Reduce Celestial Age Requirement"`);
buyEvilPerk(4);
};
tasks.buy_receive_percentage_of_essence = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_evil_perk_receive_percentage_of_essence());
if (options.log) console.log(`Clicked "Receive % of Essence"`);
buyEvilPerk(5);
};
tasks.apply_boost = async (options = { log: true }) => {
await tasks.wait_condition(() => sensors.can_apply_boost());
if (options.log) console.log(`Clicked "Boost"`);
applyBoost();
};
/* BOT ROUTINE */
const bot_routines = {};
bot_routines.buy_reduce_eye_age_until = async (times, options = { log: true }) => {
while (sensors.evil_perk_reduce_eye_age() < times) {
await tasks.wait_ms(100, { log: false }); // Otherwise the game freezes
await tasks.buy_reduce_eye_age();
}
};
bot_routines.buy_reduce_the_void_age_until = async (times, options = { log: true }) => {
while (sensors.evil_perk_reduce_the_void_age() < times) {
await tasks.wait_ms(100, { log: false }); // Otherwise the game freezes
await tasks.buy_reduce_the_void_age();
}
};
bot_routines.buy_reduce_celestial_age_until = async (times, options = { log: true }) => {
while (sensors.evil_perk_reduce_celestial_age() < times) {
await tasks.wait_ms(100, { log: false }); // Otherwise the game freezes
await tasks.buy_reduce_celestial_age();
}
};
bot_routines.buy_receive_percentage_of_essence_until = async (times, options = { log: true }) => {
while (sensors.evil_perk_receive_percentage_of_essence() < times) {
await tasks.wait_ms(100, { log: false }); // Otherwise the game freezes
await tasks.buy_receive_percentage_of_essence();
}
};
bot_routines.boost_always = async (options = { log: true }) => {
while (true) {
await tasks.apply_boost({ log: options.log });
}
};
bot_routines.embrace_evil_until = async (amount, options = { log: true }) => {
if (sensors.is_perk_instant_evil_active()) return;
OuterLoop: while (true) {
while (true) {
if (sensors.evil() > amount) break OuterLoop;
if (sensors.evil_gain() / sensors.evil() >= 100) break;
await tasks.wait_ms(0.1 * 1000, { log: false });
}
await tasks.wait_ms(1 * 1000);
await tasks.embrace_evil();
}
};
/* PARALLEL */
const parallel = async (promise) => {
try {
await promise;
} catch (err) {
if (err !== ROUND_END_ERROR_SIGNAL && err !== STOP_BOT_ERROR_SIGNAL) {
stop_bot();
throw err;
}
}
};
/* BOTS */
const bots = {};
bots.evil_age = async (max_eye_reduce_times = 4) => {
console.log("[1/2] Touching eye for max levels!");
while (!sensors.can_touch_eye() && sensors.evil_perk_reduce_eye_age() < max_eye_reduce_times) {
if (sensors.can_evil_perk_reduce_eye_age()) {
await tasks.buy_reduce_eye_age();
}
await tasks.wait_ms(1000, { log: false });
}
await tasks.touch_eye();
console.log("[2/2] Embrace evil!");
while (!sensors.can_embrace_evil()) {
if (sensors.can_evil_perk_reduce_evil_age()) {
await tasks.buy_reduce_evil_age();
}
await tasks.wait_ms(1000, { log: false });
}
await tasks.embrace_evil();
};
bots.void_age = async (max_eye_reduce_times = 5) => {
console.log("[0/4] Reducing Eye Age!");
while (!sensors.can_touch_eye() && sensors.evil_perk_reduce_eye_age() < max_eye_reduce_times) {
if (sensors.can_evil_perk_reduce_eye_age()) {
await tasks.buy_reduce_eye_age();
}
await tasks.wait_ms(1000, { log: false });
}
////////////////////////////////////////////////////////////////////////////
console.log("[1/4] Touching Eye!");
if (sensors.has_magic_eye()) {
console.log("Has Magic Eye, skipping!");
} else {
await tasks.touch_eye();
}
////////////////////////////////////////////////////////////////////////////
console.log("[2/4] Reducing Void Age!");
while (!sensors.is_in_void_age()) {
if (sensors.can_evil_perk_reduce_the_void_age()) {
await tasks.buy_reduce_the_void_age();
}
await tasks.wait_ms(1000, { log: false });
}
////////////////////////////////////////////////////////////////////////////
console.log("[3/4] Embracing Evil!");
await tasks.wait_ms(10 * 1000);
await tasks.embrace_evil();
////////////////////////////////////////////////////////////////////////////
console.log("[4/4] Done!");
};
bots.celestial_age = async () => {
parallel(bot_routines.boost_always());
console.log("Waiting for transcend...");
await bot_routines.embrace_evil_until(2_500_00);
await tasks.wait_condition(() => sensors.can_transcend());
await tasks.wait_ms(2 * 1000);
await tasks.transcend();
console.log("Transcended!!");
};
bots.dark_matter = async () => {
parallel(bot_routines.buy_receive_percentage_of_essence_until(9));
console.log("[0/4] Transcend");
tasks.transcend();
console.log("[1/4] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 1e25);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[2/4] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 1e38);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[3/4] Collapse the Universe");
await tasks.wait_condition(() => sensors.dark_matter_gain() > 1800);
await tasks.wait_ms(3 * 1000);
await tasks.collapse_universe();
console.log("[4/4] Done!");
};
bots.dark_matter_10x = async () => {
parallel(bot_routines.boost_always());
parallel(bot_routines.buy_receive_percentage_of_essence_until(15));
console.log("[0/5] Transcend");
tasks.transcend();
console.log("[1/5] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 50_000_000);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[2/5] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 1e9);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[3/5] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 1e17);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[4/5] Collapse the Universe");
await tasks.wait_condition(() => sensors.dark_matter_gain() > 100);
await tasks.wait_ms(3 * 1000);
await tasks.collapse_universe();
console.log("[5/5] Done!");
};
bots.dark_matter_10x_3x = async () => {
parallel(bot_routines.boost_always());
parallel(bot_routines.buy_receive_percentage_of_essence_until(9));
console.log("[0/3] Transcend");
tasks.transcend();
console.log("[1/3] Transcend");
await tasks.wait_condition(() => sensors.essence_gain() > 1e25);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[2/3] Collapse the Universe");
await tasks.wait_condition(() => sensors.dark_matter_gain() > 500);
await tasks.wait_ms(3 * 1000);
await tasks.collapse_universe();
console.log("[3/3] Done!");
};
bots.dark_matter_10x_3x_2k = async () => {
parallel(bot_routines.boost_always());
parallel(bot_routines.buy_receive_percentage_of_essence_until(15));
console.log("[0/3] Transcend");
tasks.transcend();
await tasks.wait_condition(() => sensors.essence_gain() > 1e25);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
await tasks.wait_condition(() => sensors.essence_gain() > 1e40);
await tasks.wait_ms(1 * 1000);
await tasks.transcend();
console.log("[2/3] Collapse the Universe");
await tasks.wait_condition(() => sensors.dark_matter_gain() > 1500);
await tasks.wait_ms(3 * 1000);
await tasks.collapse_universe();
console.log("[3/3] Done!");
};
bots.metaverse = async (min_points_amount) => {
parallel(bot_routines.buy_receive_percentage_of_essence_until(50));
console.log("[0/1] Metaverse");
await tasks.wait_condition(() => sensors.metaverse_gain() > min_points_amount);
await tasks.wait_ms(2 * 1000);
await tasks.metaverse();
console.log("[1/1] Done!");
};
/* EXECUTION */
(async () => {
console.log("Starting Bot!");
try {
while (true) {
const round_timer_start = new Date();
round_start();
// Evil Age until evil is 5k
// The Void Age until evil is 2.5m
// await bots.evil_age(0);
// await bots.void_age();
// await bots.celestial_age();
// await bots.dark_matter();
// await bots.dark_matter_10x();
// await bots.dark_matter_10x_3x();
// await bots.dark_matter_10x_3x_2k();
await bots.metaverse(3000);
// parallel(bot_routines.buy_receive_percentage_of_essence_until(100));
// await tasks.wait_ms(60 * 1000);
// Give the game some time to update
await tasks.wait_ms(1000, { log: false });
round_end();
const round_timer_end = new Date();
console.log(`Round finished in ${formatMs(round_timer_end - round_timer_start)}`);
// break;
}
} catch (err) {
if (err === STOP_BOT_ERROR_SIGNAL) {
console.log("Bot has been stopped!");
} else {
throw err;
}
}
console.log("Bot Finished!");
})();
})();
/*
ks = Object.keys(gameData.taskData)
ks.map(k => gameData.taskData[k]).filter(r => r instanceof Job)[0]
gameData.requirements['Beggar']
jobCategories['The Void']
skillCategories['Almightiness']
isHeroesUnlocked()
gameData.requirements['Imperator'].requirements => [
{
"task": "All Seeing Eye",
"requirement": 3000,
"herequirement": 650
},
{
"task": "Concentration",
"requirement": 3000
},
{
"task": "Chairman",
"requirement": 666
}
]
isCompleted() {
if (this.completed) return true
for (const requirement of this.requirements) {
if (!this.getCondition(false, requirement)) {
return false
}
}
this.completed = true
return true
}
JSON.stringify(gameData.evil_perks)
{"reduce_eye_requirement":4,"reduce_evil_requirement":0,"reduce_the_void_requirement":4,"reduce_celestial_requirement":0,"receive_essence":0}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment