Skip to content

Instantly share code, notes, and snippets.

@rmnmjw
Created June 24, 2023 15:21
Show Gist options
  • Save rmnmjw/afea5e71540cb197c9b8c7232fdeea7d to your computer and use it in GitHub Desktop.
Save rmnmjw/afea5e71540cb197c9b8c7232fdeea7d to your computer and use it in GitHub Desktop.
Clockify Web App Add Badge
// ==UserScript==
// @name clockify - badge
// @namespace t89sjuvq8x
// @match https://app.clockify.me/*
// @grant none
// @version 1.0
// @author rmnmjw
// @description 2023-06-24, 17:20:00
// ==/UserScript==
(async () => {
const observer = new MutationObserver((mutations) => {
const m = /(?<time>[0-9\:]+)/g.exec(mutations[0].target.innerHTML)?.groups.time;
if (!m) {
navigator.setAppBadge(0);
return;
}
navigator.setAppBadge(m.split(':')[0]);
});
observer.observe(document.querySelector('title'), {
childList: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment