Created
May 10, 2016 07:46
-
-
Save grrowl/df14cbca50f42a5bffea51902033daf0 to your computer and use it in GitHub Desktop.
GitHub: click anywhere on the "merge message" (with disabled button) and it'll wait until the button enables and click it 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 () { | |
function handleLoaded() { | |
var butan = document.querySelector('.merge-message .btn[disabled]') | |
var checkTimer; | |
if (butan) { | |
butan.parentElement.addEventListener('click', function handleClick(event) { | |
if (checkTimer) { | |
// already checking | |
return | |
} | |
checkTimer = setInterval(function () { | |
if (butan.attributes.getNamedItem('disabled')) { | |
// still disabled | |
butan.style.outline = (Math.random() * 10)+ 'px outset orange' | |
} else { | |
// success -- click the button with our previous event | |
butan.style.outline = '2px inset green' | |
butan.dispatchEvent(event) | |
clearInterval(checkTimer) | |
} | |
}, 500) | |
}, false) | |
} | |
} | |
window.addEventListener('load', handleLoaded) | |
document.addEventListener('pjax:success', handleLoaded) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Although we hook on
load
andpjax:success
, there's some additional JS re-rendering the button, so this won't work after new commits are added live, for example.