Skip to content

Instantly share code, notes, and snippets.

@emkis
Last active July 7, 2022 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emkis/b8a87d4794e008ce516780153e37407d to your computer and use it in GitHub Desktop.
Save emkis/b8a87d4794e008ce516780153e37407d to your computer and use it in GitHub Desktop.
Memhack easy click automation
let isRateRunning = false
init()
function init() {
removeAnimations()
watchKeyboardShortcut()
}
function watchKeyboardShortcut() {
const { start, stop } = setAutomaticRate()
const isKeyT = (event) => Boolean(event.code === 'KeyT')
window.addEventListener('keydown', (event) => {
isKeyT(event) && toggleRate({ start, stop })
})
}
function toggleRate({ start, stop }) {
const startRate = () => {
isRateRunning = true
start()
console.info('Automatic Rate is running ⏩')
}
const stopRate = () => {
isRateRunning = false
stop()
console.info('Automatic Rate has stopped ⏸')
}
isRateRunning ? stopRate() : startRate()
}
function setAutomaticRate() {
const rateIntervalTime = 5500 // 5 segundos e meio
let currentInterval = null
const getCurrentInterval = () => currentInterval
const clearRateInterval = () => clearInterval(getCurrentInterval())
const startRateInterval = () => {
currentInterval = setInterval(rateAsEasy, rateIntervalTime)
}
return { start: startRateInterval, stop: clearRateInterval }
}
function rateAsEasy() {
const card = document.querySelector(`.sc-hGFGMM.cVHWfC`)
const [easyButton] = document.querySelectorAll(`.sc-jEnjew.fDokeh`)
card.click()
easyButton.click()
}
function removeAnimations() {
const reducedMotionStyles = `
*,:after,:before {
animation-duration: .01ms!important;
animation-iteration-count: 1!important;
scroll-behavior: auto!important;
transition-duration: .01ms!important
}
`
const styleElement = document.createElement('style')
styleElement.textContent = reducedMotionStyles
document.body.append(styleElement)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment