Skip to content

Instantly share code, notes, and snippets.

@leftdevel
Last active February 10, 2020 15:06
Show Gist options
  • Save leftdevel/c1b3508041226e27cda1084483536126 to your computer and use it in GitHub Desktop.
Save leftdevel/c1b3508041226e27cda1084483536126 to your computer and use it in GitHub Desktop.
delete github branches on screen
// Using this for branches displayed on the "stale branches" page, under https://github.com/yourOrg/yourProject/branches/stale
// Meant to be copy & paste into the browser console.
var i = 0;
function deleteOne() {
// Idempotent selector, should select only Delete buttons that are not already clicked. When clicked, the UI
// updates and replaces Details class with Details--on.
var deleteButton = document.querySelectorAll('li.Details form button.text-red.js-branch-delete-target')[i];
if (typeof deleteButton === 'undefined') {
return false;
}
deleteButton.click();
return true;
}
var id = setInterval(function() {
try {
if (!deleteOne()) {
clearInterval(id);
}
i += 1;
} catch (e) {
clearInterval(id);
throw e;
}
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment