Skip to content

Instantly share code, notes, and snippets.

@timmc
Last active June 16, 2023 18:20
Show Gist options
  • Save timmc/fb2f482886d67c22cf03e2793f1309b5 to your computer and use it in GitHub Desktop.
Save timmc/fb2f482886d67c22cf03e2793f1309b5 to your computer and use it in GitHub Desktop.
Script to delete all reddit comments on the *current page* when viewing own comment history. Quick and dirty approach if you don't have more than a few hundred comments.
function deleteAllOnPage(comments, index) {
var id = comments[index]
if (!id) return
console.debug('wiping ' + id)
$.ajax({
type: 'POST',
url: '/api/editusertext',
data: {
thing_id: id,
text: ' ',
id: 'any',
uh: r.config.modhash,
renderstyle: 'html'
},
success: function successEdit() {
console.debug('deleting ' + id)
$.ajax({
type: 'POST',
url: '/api/del',
data: {
executed: 'deleted',
id: id,
renderstyle: 'html',
uh: r.config.modhash
},
success: function successDel() {
deleteAllOnPage(comments, index + 1)
},
error: function errorDel() {
console.error('Failed to delete ' + id, arguments)
}
})
},
error: function errorEdit() {
console.error('Failed to delete ' + id, arguments)
}
})
}
deleteAllOnPage($('.comment').map(function(){ return $(this).data('fullname') }), 0)
@timmc
Copy link
Author

timmc commented Jun 16, 2023

Unhiding everything on the page:

unhide_links = [...document.querySelectorAll('a[data-event-action=unhide]')]

automate = setInterval(() => { if (unhide_links.length) unhide_links.pop().click(); else clearInterval(automate); }, 1000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment