Last active
August 12, 2021 04:06
-
-
Save ryanml/dbb95a3382150072852b8ade401fc40b to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Release Merge Sanity Checker | |
// @version 1.0 | |
// @description :^) | |
// @author ryanml | |
// @match https://github.com/MetaMask/metamask-extension/pull/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
// The final merge button isn't present in the initial DOM content, rather | |
// loaded in shortly after, so we have to wait for it | |
const findMergeButton = async () => { | |
return new Promise((resolve, _reject) => { | |
let retries = 0 | |
const findButtonInterval = setInterval(() => { | |
const mergeButton = document.querySelector('.hx_create-pr-button:enabled') | |
if (mergeButton || retries === 500) { | |
clearInterval(findButtonInterval) | |
resolve(mergeButton) | |
} | |
retries++ | |
}, 10) | |
}) | |
} | |
const init = async () => { | |
const branchName = document.querySelector('.head-ref')?.textContent | |
if (branchName !== 'master-sync' && | |
!branchName?.match(/Version-v[0-9\.]{1,}/)) { | |
return | |
} | |
const mergeButton = await findMergeButton() | |
if (mergeButton?.classList.contains('btn-group-squash')) { | |
mergeButton.onclick = (event) => { | |
window.alert( | |
'This looks like a release related PR, should you be merging this instead?' | |
) | |
} | |
} | |
} | |
window.onload = () => { | |
init() | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment