Last active
November 15, 2023 14:20
-
-
Save AadityaJain-Dev/8f2c07dcf69b2380c7efd1c34c76ec57 to your computer and use it in GitHub Desktop.
Reddit Web Comment Deletion Script
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
/** | |
* Reddit Comment Deletion Script: | |
* This script automates the process of deleting the last 25 comments made by a user on their Reddit profile. | |
* | |
* Instructions: | |
* - Log in to Reddit and visit the comments page (https://www.reddit.com/user/[your_user_name]/comments/). | |
* - Run this script to delete the last 25 comments. | |
* - Refresh the page and run the script again for the next batch of comments. | |
*/ | |
// Array to store unique comment IDs | |
const uniqueCommentsList = []; | |
// Going through all comments block & extracting unique comment IDs | |
document.querySelectorAll("#AppRouter-main-content > div > div > div._3ozFtOe6WpJEMUtxDOIvtU > div._31N0dvxfpsO6Ur5AKx4O5d > div._1OVBBWLtHoSPfGCRaPzpTf._2OVNlZuUd8L9v0yVECZ2iA > div:nth-child(3) > div:nth-child(1) > div > div > div").forEach((element) => { | |
// Filtering out unique comment IDs from junk | |
if (element.classList[1] && element.classList[1].length === 10) { | |
uniqueCommentsList.push(element.classList[1]); | |
} | |
}); | |
// Iterate over the unique comment IDs and delete each comment | |
uniqueCommentsList.forEach((commentId, index) => { | |
// Calculating timeout value to keep wait before deleting the next comment | |
const timeoutFor = index * 1000; | |
// Perform actions for each comment after a defined delay | |
setTimeout(() => { | |
// Click on the overflow menu for the specific comment | |
document.querySelector(`#profileOverviewPageKey--${commentId}-overflow-menu`).click(); | |
// Click on the option to delete the comment | |
document.querySelector("body > div:nth-child(32) > div > button:nth-child(3)").click(); | |
// Confirm the deletion of the comment | |
document.querySelector("#SHORTCUT_FOCUSABLE_DIV > div:nth-child(7) > div > div > section > footer > button._17UyTSs2atqnKg9dIq5ERg.ogOEj4x-0BpDZWeccJwxx._2iuoyPiKHN3kfOoeIQalDT._10BQ7pjWbeYP63SAPNS8Ts.HNozj_dKjQZ59ZsfEegz8._2nelDm85zKKmuD94NequP0").click(); | |
}, timeoutFor); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment