Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryanwilsonperkin/87bdd99c3a4a1ab2c4dce54bb9571619 to your computer and use it in GitHub Desktop.
Save ryanwilsonperkin/87bdd99c3a4a1ab2c4dce54bb9571619 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Buildkite build completion notifications
// @namespace Violentmonkey Scripts
// @match https://buildkite.com/*/builds/*
// @grant none
// @version 1.0
// @author Ryan Wilson-Perkin
// @description 6/4/2025, 2:09:56 PM
// ==/UserScript==
// Setup notification permissions
if (!("Notification" in window)) return;
if (Notification.permission !== "granted" && Notification.permission !== "denied") {
// Only ask until user explicitly grants / denies
Notification.requestPermission();
}
function notify(message, options) {
const notification = new Notification(message, options);
notification.addEventListener("click", () => {
window.focus();
notification.close();
});
}
const interval = setInterval(() => {
function clear() {clearInterval(interval)}
const elem = document.querySelector('div.build-panel');
const title = document.querySelector('div.build-header .panel-title')?.innerText ?? '';
if (!elem) {
return clear();
} else if (elem.classList.contains('build-state-failed')) {
notify('❌ Build failed', {body: title});
return clear();
} else if (elem.classList.contains('build-state-passed')) {
notify('✅ Build succeeded', {body: title});
return clear();
} else if (elem.classList.contains('build-state-canceled')) {
notify('🛑 Build canceled', {body: title});
return clear();
}
}, 5_000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment