Skip to content

Instantly share code, notes, and snippets.

@gusalbukrk
Last active December 19, 2024 02:01
Show Gist options
  • Save gusalbukrk/8b7b55d24189ba17c89d3309f60006a2 to your computer and use it in GitHub Desktop.
Save gusalbukrk/8b7b55d24189ba17c89d3309f60006a2 to your computer and use it in GitHub Desktop.

Automate Trello archived items deletion

Open the panel to show the archived items and run the block of codes below on the console.

Lists

const delay = async (ms) => new Promise((res, rej) => setTimeout(() => res(), ms));
const lists = document.querySelectorAll('.js-delete');

for (const listDeleteBtn of lists) {
  console.log(listDeleteBtn);
  
  listDeleteBtn.click();
  await delay(1000);
  document.querySelector('.js-confirm').click();
}

Cards

const delay = async (ms) => new Promise((res, rej) => setTimeout(() => res(), ms));
var xpath = "//button[text()='Delete']";
var results = document.evaluate(
    xpath,
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null
);

// results.snapshotLength gives the number of matched elements
for (var i = 0; i < results.snapshotLength; i++) {
    var button = results.snapshotItem(i);
    console.log("Found a delete button:", button);
    // You can now manipulate or use the button element as needed
    button.click();
    await delay(1000);
    document.querySelector('button[aria-label="delete-confirm"]').click();
    //break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment