-
-
Save EatZeBaby/366082af0778729892c0cafa32fc76e9 to your computer and use it in GitHub Desktop.
Want to be the best at Lucca Faces? Run the game, then execute this code into your console. Let it play until you are the best!
This file contains hidden or 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
(() => { | |
const people = [] | |
let startTimeout | |
let restartTimeout | |
let cheatTimeout | |
let discoverTimeout | |
function mainStartGame () { | |
document.querySelector('.main-container .buttons button').click() | |
startGame(1000) | |
} | |
function startGame (timeout) { | |
clearTimeout(startTimeout) | |
startTimeout = setTimeout(() => { | |
document.querySelector('.main-container .rotation-loader').click() | |
cheat() | |
}, timeout) | |
} | |
function restartGame () { | |
clearTimeout(restartTimeout) | |
restartTimeout = setTimeout(() => { | |
console.log('Restarting game') | |
;[...document.querySelectorAll('.main-container .buttons .button')].find((btn) => btn.textContent === 'Rejouer').click() | |
startGame(1000) | |
}, 1000) | |
} | |
function cheat () { | |
const discoveringOrAnswered = !!document.querySelector('#game .answers .has-answered') | |
const gameEnded = !!document.querySelector('.main-container .results-card') | |
clearTimeout(cheatTimeout) | |
if (!discoveringOrAnswered && !gameEnded) { | |
if (people.length) { | |
findAnswer() | |
} else { | |
discoverAnswer() | |
} | |
} else if (!gameEnded) { | |
cheatTimeout = setTimeout(() => { | |
cheat() | |
}, 100) | |
} else { | |
const score = document.querySelector('.main-container .score b').textContent | |
console.log(`Game has ended, score was ${score}`) | |
restartGame() | |
} | |
} | |
function getCurPersonId () { | |
return document.querySelector('#game app-timer .image').attributes.style.value.match(/id=(.*)&/)[1] | |
} | |
function getPossibleAnswers () { | |
return [...document.querySelectorAll('#game .answers .answer')] | |
} | |
function findAnswer () { | |
console.log(`Trying to find answer based on current known people (${people.length} people known so far)`) | |
const possibleAnswers = getPossibleAnswers() | |
const curPersonId = getCurPersonId() | |
const answer = people.find((person) => person.id === curPersonId) | |
if (!answer) { | |
console.warn('Cannot find answer in known people') | |
discoverAnswer() | |
} else { | |
console.info(`Found answer: ${answer.name}`) | |
possibleAnswers.filter((possibleAnswer) => possibleAnswer.textContent === answer.name)[0].click() | |
cheat() | |
} | |
} | |
function discoverAnswer () { | |
const possibleAnswers = getPossibleAnswers() | |
clearTimeout(discoverTimeout) | |
discoverTimeout = setTimeout(() => { | |
possibleAnswers[0].click() | |
const answer = document.querySelector('#game .answers .is-right') | |
if (!answer) { | |
console.error('Failed to discover answer!') | |
} else { | |
people.push({ | |
id: getCurPersonId(), | |
name: answer.textContent | |
}) | |
console.info(`Answer discovered and added to known people: ${answer.textContent}`) | |
cheat() | |
} | |
}, 500) | |
} | |
mainStartGame() | |
console.log('Cheat started') | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error Uncaught TypeError: Cannot read properties of undefined (reading 'click')
at :89:32
at L. (zone.js:2378:41)
at v.invokeTask (zone.js:406:31)
at M.runTask (zone.js:178:47)
at invokeTask (zone.js:487:34)
at invoke (zone.js:476:48)
at p.args. (zone.js:2358:32)