Last active
July 17, 2017 23:33
-
-
Save birkholz/61f04cf3397a9464a108e9246380dfbe to your computer and use it in GitHub Desktop.
A userscript for adding a 1-click approve button to PRs
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
// ==UserScript== | |
// @name GitHub 1-click PR Approve | |
// @namespace https://gist.github.com/birkholz | |
// @description Adds a 1-click approve button to Pull Requests | |
// @version 3 | |
// @author https://github.com/birkholz | |
// @match https://github.com/*/*/pull/*/files | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function AddButton() { | |
var reviewMenu = document.querySelector('.pull-request-review-menu'); | |
if (reviewMenu.querySelector('input[value=approve]').disabled) return; | |
var approveButton = document.createElement('button'); | |
approveButton.innerText = 'Approve'; | |
approveButton.classList.add('btn', 'btn-sm', 'btn-primary'); | |
approveButton.type = 'button'; | |
approveButton.style = 'margin-left:20px;'; | |
approveButton.onclick = function(e) { | |
e.preventDefault(); | |
reviewMenu.querySelector('input[value=approve]').checked = true; | |
reviewMenu.querySelector('button[type=submit]').click(); | |
return false; | |
}; | |
document.querySelector('.pr-review-tools').append(approveButton); | |
var reviewButton = document.querySelector('.js-reviews-container > button'); | |
reviewButton.classList.remove('btn-primary'); | |
} | |
window.setTimeout(AddButton, 300); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The button has been moved to the Files Changed tab: