Skip to content

Instantly share code, notes, and snippets.

@cxmcc cxmcc/nuke-branch.js
Created Mar 21, 2017

Embed
What would you like to do?
Nuke all Closed and Merged branches on a github web page.
// Paste into console
// Need to disable Content Security Policy in your browser
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
var branch_actions = $('.branch-actions');
$.each(branch_actions, function() {
var first_child = this.children[0];
if (first_child != undefined && $(first_child).attr('class') == 'pr-details') {
var state = $(first_child.children[1]);
var klass = state.attr('class');
if (klass == "state state-closed" || klass == "state state-merged") {
console.log($(first_child.children[1]).attr('title'))
var form = this.children[1];
var button = form.children[1];
$(button).click();
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.