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-05-18 提交的版本。查看 最新版本

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