Last active
March 25, 2024 13:41
-
-
Save Fedcomp/07a8cf7ddbac97547184a035156593d2 to your computer and use it in GitHub Desktop.
Example of mass deletion of telegram join messages in telegram web (https://web.telegram.org/a/)
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 timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; | |
const contextMenuClick = (element) => element.dispatchEvent(new MouseEvent('contextmenu', { | |
bubbles: true, | |
cancelable: true, | |
view: window, | |
})) | |
const messages = () => [...document.querySelectorAll('[id^=message].ActionMessage')] | |
.filter(e => e.textContent.includes(' joined the group')); | |
const deleteMessage = async (e) => { | |
contextMenuClick(e); | |
await timeout(randomInteger(500,800)); | |
const deleteContextButton = document.querySelector('.MenuItem.destructive.compact') | |
if (!deleteContextButton) return; | |
deleteContextButton.click(); | |
await timeout(randomInteger(500,800)); | |
const deletePopupButton = document.querySelector('button.Button.confirm-dialog-button.default.danger.text') | |
if (!deletePopupButton) return; | |
deletePopupButton.click(); | |
} | |
const wipeMessages = async () => { | |
while(true) { | |
const msgs = messages().reverse() | |
for (obj of msgs) { | |
await timeout(randomInteger(1000,1500)) | |
await deleteMessage(obj) | |
} | |
} | |
} | |
await wipeMessages() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment