Delete all reddit comments

Delete all your comments in reddit, navigate to https://www.reddit.com/user/{YOUR USERNAME}/comments, and reload. Only compatible with old reddit interface. Switch to old interface before using.

当前为 2022-12-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Delete all reddit comments
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.reddit.com/user/*/comments
  5. // @match https://old.reddit.com/user/*/comments
  6. // @grant none
  7. // @version 1.1
  8. // @author -
  9. // @license MIT
  10. // @description Delete all your comments in reddit, navigate to https://www.reddit.com/user/{YOUR USERNAME}/comments, and reload. Only compatible with old reddit interface. Switch to old interface before using.
  11. // ==/UserScript==
  12.  
  13. async function del_comments_curr_page() {
  14. let tab = document.getElementById('siteTable');
  15. let top_list = tab.getElementsByClassName('thing');
  16.  
  17. // Add random interval to avoid bot detection.
  18. function sleep(ms) {
  19. return new Promise(resolve => setTimeout(resolve, ms));
  20. }
  21.  
  22. async function remove() {
  23. for (let i = 0;i < top_list.length;i++){
  24. let del_form = top_list[i].getElementsByClassName('toggle del-button')[0];
  25. let del_but = del_form.getElementsByClassName('togglebutton')[0];
  26. console.log(i)
  27. console.log(del_but)
  28. del_but.click();
  29. await sleep(Math.floor(Math.random()*300 + 300));
  30. let yes_but = del_form.getElementsByClassName('yes')[0];
  31. console.log(yes_but);
  32. yes_but.click()
  33. await sleep(Math.floor(Math.random()*300 + 300));
  34. }
  35. }
  36.  
  37. await remove();
  38. //reload page to load new comments to delete
  39. window.location.reload();
  40. }
  41.  
  42. window.addEventListener('load', function () {
  43. del_comments_curr_page();
  44. }, false)