Last active
March 19, 2021 17:25
-
-
Save bannostookaylo/6d60b69f987a4448cd3c870733cf2a1a to your computer and use it in GitHub Desktop.
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 delMsgs = async () => { | |
const container = document.querySelector('.msg-conversations-container ul'); | |
if (!container) { | |
console.log('no messages - are you on the messages page?'); | |
return; | |
} | |
const loadAllMessages = async () => { | |
return await new Promise((resolve) => { | |
let height = 0; | |
let attempts = 0; | |
if (container) { | |
console.log('loading messages...'); | |
const interval = setInterval(() => { | |
const { scrollHeight } = container; | |
if (scrollHeight > 20000) { | |
console.log( | |
'limited to around 200 messages...' | |
); | |
clearInterval(interval); | |
resolve(); | |
} | |
if (scrollHeight === height) { | |
if (attempts >= 3) { | |
console.log('messages loaded...'); | |
clearInterval(interval); | |
resolve(); | |
} else { | |
console.log('...'); | |
attempts++; | |
} | |
} | |
height = scrollHeight; | |
container.scrollTop = scrollHeight; | |
}, 1000); | |
} else { | |
console.log('no messages'); | |
} | |
}); | |
}; | |
await loadAllMessages(); | |
console.log('attempting to select all messages'); | |
const labels = container.getElementsByTagName('label'); | |
for (let i = 0; i < labels.length; i++) { | |
if (labels[i]) { | |
labels[i].click(); | |
} | |
} | |
console.log('Click the trash can icon at the top to delete all messages.'); | |
console.log('type "delMsgs()" below this and then hit enter to run again.'); | |
}; | |
delMsgs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment