Created
February 8, 2019 22:05
-
-
Save mattdeboard/ae609734d6bdabbbd109abdece3d7833 to your computer and use it in GitHub Desktop.
Push PR merge buttons for you
This file contains 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
function justClickIt() { | |
// The web-based minification tools I tried require 'var' instead of 'const' | |
var mergeButton = document.querySelector(".merge-message .select-menu .btn-group-squash button"); | |
var confirmButton = document.querySelector("button.js-merge-commit-button"); | |
// Selector for the "Update Branch" button | |
var updateButton = document.querySelector("form.branch-action-btn button"); | |
console.log("Looking for the right buttons..."); | |
if (!!updateButton && !updateButton.disabled) { | |
console.log("Clicking update branch button..."); | |
updateButton.click(); | |
} else if (mergeButton && !mergeButton.disabled) { | |
console.log("Merge button looks active; clicking it!"); | |
mergeButton.click(); | |
if (confirmButton) { | |
confirmButton.click(); | |
} else { | |
console.log("Looks like the merge button was ready but the confirm button wasn't..."); | |
} | |
} | |
} | |
setInterval(justClickIt, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Warning - Do not test this on open PRs you don't want merged.
This little program will just indiscriminately click merge buttons without checking with you first!
Make sure you read the source & understand what's happening before running this.
What is this?
This is a javascript snippet that eliminates having to race other devs to get your branch merged when it's ready. It accomplishes this via the following algorithm:
It:
setInterval
.Instructions
A couple ways to run this:
To create a bookmarklet (easiest way):
The
javascript:
prefix will tell Chrome to run that code when you click the bookmark. It's minified because there's a length limit to bookmark URLs.