Forked from chenrui333/github-delete-stale-branches.js
Last active
May 16, 2025 00:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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