Last active
December 4, 2024 08:50
-
-
Save Gesugao-san/4b1cf7b20b2c28c6aeeed9aa93c30c4b to your computer and use it in GitHub Desktop.
Playing with http://spacestationidle.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let buttLoot, buttLeave, _debug = Boolean(1); | |
let _store = Array.from(document.querySelectorAll('*')).find(e => e.__vue__).__vue__.$store; | |
// Seach for buttons to click | |
// https://stackoverflow.com/a/67398903/8175291 | |
function querySelectorIncludesText(selector, text) { | |
if ((!selector) || (!text)) return console.error('querySelectorIncludesText error!'); | |
return Array.from(document.querySelectorAll(selector)) | |
.find(el => el.textContent.includes(text)); | |
} | |
// Run away if player can be killed in two successfully hits. | |
// ToDo: Auto run away if low food. | |
function leaveIfLowHP() { | |
if ( | |
(_store.getters["playerMob/health"] - | |
(_store.getters["enemyMob/maxHit"] * 2)) < | |
(_store.getters["playerMob/stats"].maxHealth) | |
) return; | |
buttLeave = querySelectorIncludesText('button', 'Leave') || | |
querySelectorIncludesText('button', 'Yakety sax away'); | |
if (!buttLeave) return console.error('Autobattle: Can\'t click to leave - no button found!'); | |
buttLeave.click(); | |
if (_debug) console.debug('leaving...'); | |
} | |
// Loop for autobattle. | |
// ToDo: Make interval changing more dynamically. | |
setInterval(() => { | |
if (!_store.getters["combat/isActive"]) return; | |
leaveIfLowHP(); | |
buttLoot = querySelectorIncludesText('button', 'Loot all'); | |
if (!buttLoot) return console.error('Autobattle: Can\'t click to loot - no button found!'); | |
buttLoot.click(); | |
if (_debug) console.debug('looting...'); | |
}, _store.getters["playerMob/targetStats"].attackSpeed * 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
function replaceInVuex(key1, key2, value, force_reload = false) { | |
if (!key1) return console.error("Err: no key1."); | |
if (!key2) return console.error("Err: no key2."); | |
var _vuex = JSON.parse(localStorage.vuex); | |
_vuex[key1][key2] = value; | |
localStorage.vuex = JSON.stringify(_vuex); | |
if (force_reload) window.location.reload(); | |
return console.log('replaceInVuex:', _vuex[key1], '- OK'); | |
} | |
const _store = Array.from(document.querySelectorAll('*')).find(e => e.__vue__).__vue__.$store; | |
if (0) replaceInVuex('chrono', 'lastLogoutTime', 1, true); // Gives max hours of chrono | |
// if (0) replaceInVuex('playerMob', 'health', _store.getters["playerMob/stats"].maxHealth); // dispatch("playerMob/addHealth", 123); | |
if (0) replaceInVuex('enemyMob', 'health', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment