Created
March 11, 2024 02:48
-
-
Save kevinwestern/069dc781d520d5218f799f1241779978 to your computer and use it in GitHub Desktop.
Delete reddit comments shown on your profile, from your profile page
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
window.getCSRF = () => document.cookie.split('; ').find(s => s.indexOf('csrf_token') === 0).substring('csrf_token='.length) | |
function deleteComment(id) { | |
fetch("https://www.reddit.com/svc/shreddit/graphql", { | |
"method": "POST", | |
"headers": { | |
"accept": "application/json", | |
"content-type": "application/json", | |
}, | |
"body": JSON.stringify({ | |
"operation":"DeleteComment", | |
"variables": { | |
"input": { | |
"commentId":`${id}` | |
} | |
}, | |
"csrf_token":`${window.getCSRF())}` | |
}), | |
}); | |
} | |
new Set(Array.from(document.querySelectorAll('[comment-id]')).map(e => e.getAttribute('comment-id'))).forEach(deleteComment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment