Domino Tracker Notification

Get notified when the pizza tracker updates!

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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;
}