Skip to content

Instantly share code, notes, and snippets.

@corupta
Last active March 11, 2024 03:34
Show Gist options
  • Save corupta/fc2813de9da80f7a3d3a85922bc47f28 to your computer and use it in GitHub Desktop.
Save corupta/fc2813de9da80f7a3d3a85922bc47f28 to your computer and use it in GitHub Desktop.
Simple bot for BiteFight game.
(() => {
// A script I created to automatically play the tavern story in bitefight game.
// Copy the script into any chrome extension, and enable it in tavern page of bitefight game.
// Refresh, and let it level you up.
const desiredOptionsOrder = [
'Continue (3 AP)',
'Complete story',
'Continue',
'Tread the mountain path',
'Enter the cavern',
'Step into the depths',
'Enter forest',
'Enter city',
'Stay here',
'Rob city',
'Ask for more',
'Use chance',
'Look for coins',
'Throw a coin in',
'Party',
'Make some valuable booty',
'Beguile',
'Devour',
'Look for a better path',
'Terrorise',
'Mislead',
'Assassinate',
'Warn of dangers',
'Talk',
'Shadow bones',
'Carry on walking',
'Set everything alight',
'Rob',
'Examine',
'Observe',
'Investigate',
'Hide',
'Jump over it',
'Smash everything',
'Escort',
'Brave',
'Find fortune in misfortune',
'Full attack',
'Accept',
'Confront the enemy',
]
const findOptions = () => {
const optionNodes = Array.from(document.querySelectorAll('.btn-left.center > .btn-right > .btn'));
const optionTexts = optionNodes.map(option => option.innerText);
return [optionTexts, optionNodes];
}
const makeChoice = () => {
const [optionTexts, optionNodes] = findOptions();
let unknownOptions = [];
optionTexts.forEach(option => {
if (!desiredOptionsOrder.includes(option)) {
unknownOptions.push(option);
}
});
if (unknownOptions.length > 0) {
console.log(`Unknown options: `);
console.log(unknownOptions.map(option => `'${option}',`).join('\n'));
console.log();
return;
}
let chosenOptionIndex = -1;
for (let option of desiredOptionsOrder) {
chosenOptionIndex = optionTexts.indexOf(option);
if (chosenOptionIndex !== -1) {
break;
}
}
console.log(`Chosen option: #${chosenOptionIndex}: '${optionTexts[chosenOptionIndex]}'`);
optionNodes[chosenOptionIndex].click();
}
const timeout = 0; // 50 + Math.random()*50;
setTimeout(makeChoice, timeout);
console.log(`Timeout: ${timeout}`);
setTimeout(() => {
const status = document.querySelector('.gold').innerText;
console.log(`Status: ${status}`);
const story = document.querySelector('h2').innerText.split('\n')[1];
console.log(`Story: ${story}`);
}, timeout);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment