Last active
August 18, 2016 14:34
-
-
Save dvdbng/44f66d6f3ac0aa6389c1b8be46dbfd41 to your computer and use it in GitHub Desktop.
An userscript that shows a desktop notification when the status of a github PR changes
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 PR Notifications | |
// @namespace ghnotifications | |
// @description Show notifications when the status of a PR changes | |
// @include https://github.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
(function(){ | |
if(Notification.permission !== 'denied' && Notification.permission !== 'granted') { | |
Notification.requestPermission(); | |
} | |
function getState() { | |
var elm = document.querySelector('.merge-pr .branch-action'); | |
var match = elm && elm.getAttribute('class').match(/\bbranch-action-state-(\w+)/); | |
return match && match[1]; | |
} | |
var prevState = null; | |
setInterval(function(){ | |
var newState = getState(); | |
if(prevState && newState && prevState != newState) { | |
new Notification("Status changed from " + prevState + ' to ' + newState, { | |
body: document.title, | |
icon: 'https://github.com/apple-touch-icon.png' | |
}); | |
} | |
prevState = newState; | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment