这是indexloc提供的服务,不要输入任何密码
Skip to content

script is not working - but this snippet deletes a page at a time #84

@augusto

Description

@augusto

Adding this here in case it's of use to anyone. The current script doesn't work (and seems not being supported anymore).

I put together this script that deletes one page at a time. To use it:

  • Go to reddit your overview page: https://old.reddit.com/user/me
  • Open the dev tools (usually F12 on most browsers).
  • Go to the console tab, and paste the script below and press enter.
  • The script deletes a page and reloads the page. Because the focus remains on the console, press the up key and press enter.
(async () => {
  // Get all visible "delete" comment links
  const deleteLinks = Array.from(document.querySelectorAll('div.entry form.del-button a'))
    .filter(a => a.textContent.trim().toLowerCase() === "delete");

  if (deleteLinks.length === 0) {
    alert("No deletable comments found on this page.");
    return;
  }

  for (let i = 0; i < deleteLinks.length; i++) {
    deleteLinks[i].click();
    // Wait for the confirmation dialog
    await new Promise(r => setTimeout(r, 100));
  }
  
  const confirmations = Array.from(document.querySelectorAll('div.entry form.del-button span.active'))
    .filter(s=>s.textContent.trim().toLowerCase() === "are you sure?  yes / no");
  
  for (let i = 0; i < confirmations.length; i++) {
    await new Promise(r => setTimeout(r, 1000));
	confirmations[i].querySelector('a').click();
  }
  

  location.reload();
})();

You might need to play with the sleeps, as it seems reddit not always deletes the posts even after giving a success response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions