Created
October 17, 2023 18:17
-
-
Save prakhar897/20206c8a564b971a3d54caa6f6aeaa8e to your computer and use it in GitHub Desktop.
Console Script to delete all comments and posts from Reddit
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
/* | |
** 1. Go to https://old.reddit.com/user/<your_username> | |
** 2. Insert this script in console. | |
** 3. works in both comments and submitted section. | |
*/ | |
function clickElement(selector) { | |
const element = document.querySelector(selector); | |
if (element) { | |
element.click(); | |
return true; | |
} | |
return false; | |
} | |
function deleteButtonClick() { | |
const deleteButtons = document.querySelectorAll('a.togglebutton[data-event-action="delete"]'); | |
if (deleteButtons.length === 0) { | |
clearInterval(interval); | |
const nextButton = document.querySelector('.next-button > a'); | |
if (nextButton) { | |
nextButton.click(); | |
alert('Restart script.'); | |
} | |
} else { | |
deleteButtons[0].click(); | |
setTimeout(() => { | |
const yesButton = document.querySelector('span.option.error.active > a.yes'); | |
if (yesButton) { | |
yesButton.click(); | |
} | |
}, 300); | |
} | |
} | |
const interval = setInterval(deleteButtonClick, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment