Created
June 4, 2025 18:45
-
-
Save ryanwilsonperkin/87bdd99c3a4a1ab2c4dce54bb9571619 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 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