Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iotashan/53a78c99395bc0b16e8eef944f6f3b9f to your computer and use it in GitHub Desktop.
Save iotashan/53a78c99395bc0b16e8eef944f6f3b9f to your computer and use it in GitHub Desktop.
Delete stale branches from the GitHub repo's stale branches page (github.com/user/repo/branches/stale). Originally from https://stackoverflow.com/a/69089905
async function deleteStaleBranches(delay=75) {
var stale_branches = document.getElementsByClassName('prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj');
for (var i = 0; i < stale_branches.length; i++) {
stale_branches.item(i).click();
await new Promise(r => setTimeout(r, delay));
}
const next = document.querySelector('[aria-label="Next Page"]');
if(next) {
next.click();
setTimeout(() => deleteStaleBranches(delay), delay);
}
} (() => { deleteStaleBranches(75); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment