Created
October 21, 2019 01:18
-
-
Save rap0so/9b30a1abcfe3600d039662fea5a30867 to your computer and use it in GitHub Desktop.
Totally functional method to get rage click
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
const saveMousePosition = totalClicks => event => { | |
if (!event) return totalClicks; | |
totalClicks.push(`${event.clientX}-${event.clientY}`); | |
return []; | |
}; | |
const addNewClick = saveMousePosition([]); | |
const _setRage = () => { | |
document.addEventListener('click', event => { | |
addNewClick(event); | |
}); | |
document.addEventListener('mousemove', saveMousePosition([])); | |
setInterval(() => { | |
saveMousePosition([]); | |
}, 500); | |
}; | |
const getRage = () => | |
new Promise(resolve => | |
resolve({ | |
rage_clicks: [...new Set(addNewClick())] | |
}) | |
); | |
export { _setRage, getRage }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment