Domino Tracker Notification

Get notified when the pizza tracker updates!

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Domino Tracker Notification
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Get notified when the pizza tracker updates!
// @author       Therrom
// @include      /https://.*\.dominos\.[\w]+/.*/
// @grant        GM_notification
// ==/UserScript==

(function() {
    'use strict';

    setInterval(function() {checkTracker();}, 1000);
})();

let currentText = undefined;
let utter = undefined;

function checkTracker() {
    const tempText = document.querySelector("div p[role=status]")?.innerHTML
    if (tempText) {
        if (tempText != currentText) {
            currentText = tempText;
            GM_notification({title: 'Tracker Update', text: currentText, timeout: 1000});
            speak(currentText);
        }
    }
}

function speak(text) {
    if(window.speechSynthesis.getVoices().length == 0) {
        window.speechSynthesis.addEventListener('voiceschanged', function() {
            speak(text);
        });
    } else {
        if (utter === undefined) {
            detectVoice();
        }
        utter.text = text;
        window.speechSynthesis.speak(utter);
    }
}

function detectVoice() {
    let available_voices = window.speechSynthesis.getVoices();

    let voice = undefined;
    let defaultVoice = undefined;
    let language = window.navigator.userLanguage || window.navigator.language;

    for (let i=0; i<available_voices.length; i++) {
        if(available_voices[i].default) {
            defaultVoice = available_voices[i];
        }
        if (available_voices[i].lang == language) {
            voice = available_voices[i];
            break;
        }
    }

    if (voice === undefined) {
        voice = defaultVoice;
    }
    if (voice === undefined) {
        voice = available_voices[0]
    }

    utter = new SpeechSynthesisUtterance();
    utter.rate = 1;
    utter.pitch = 0.5;
    utter.voice = voice;
}