Last active
July 7, 2022 10:39
-
-
Save emkis/b8a87d4794e008ce516780153e37407d to your computer and use it in GitHub Desktop.
Memhack easy click automation
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
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