Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinwestern/069dc781d520d5218f799f1241779978 to your computer and use it in GitHub Desktop.
Save kevinwestern/069dc781d520d5218f799f1241779978 to your computer and use it in GitHub Desktop.
Delete reddit comments shown on your profile, from your profile page
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