• Before registering an account on PlayerSquared you must first agree that you are at least 13 years of age & have read & agree to our Terms & rules & our Privacy policy.

Admin JS Remove Your YouTube Comments In One Click

OfficialJesseP's iconOfficialJesseP

Community Admin
ADMIN
December 10, 2018
549
1,314
11
1. Go to: YouTube Comment History
2. Scroll down to load as many comments as you want to remove.
3. Press F12 to Open Developer Tools (F12 or Ctrl+Shift+I on Windows/Linux, Cmd+Option+I on Mac).
4. Copy & paste the code below into the Developer Tools console & hit Enter.
JavaScript:
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function scrollToBottom() {
  window.scrollTo(0, document.body.scrollHeight);
  await sleep(1000); // wait for new content to load
}

async function deleteVisibleItems() {
  let deleteButtons = document.querySelectorAll('button[aria-label^="Delete activity item"]');

  for (let i = 0; i < deleteButtons.length; i++) {
    console.log(`Deleting item ${i + 1} of ${deleteButtons.length}...`);

    const button = deleteButtons[i];
    button.scrollIntoView({ behavior: "smooth" });
    button.click();

    await sleep(300);

    let confirmBtn = document.querySelector('button[aria-label^="Delete"]');
    if (confirmBtn) {
      confirmBtn.click();
    } else {
      console.warn("Confirm button not found. Skipping this item.");
    }

    await sleep(500);
  }
}

async function nukeAll() {
  let previousCount = -1;
  let runCount = 0;

  while (true) {
    runCount++;
    console.log(`Pass ${runCount}...`);

    await deleteVisibleItems();

    await scrollToBottom();

    // Wait briefly for more items to load
    await sleep(1000);

    const currentCount = document.querySelectorAll('button[aria-label^="Delete activity item"]').length;

    if (currentCount === 0 || currentCount === previousCount) {
      console.log("No new delete buttons found. Finished.");
      break;
    }

    previousCount = currentCount;
  }

  console.log("All done!");
}

nukeAll();
5. Done :)

Use at your own risk: Automating interactions may violate terms of service.

Seal Of Quality.png