Dante Auto Task Checker

Script auto refreshes Dante page after posting a task and inform if it's failed or completed.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Dante Auto Task Checker
// @name:pl        Dante Auto Task Checker
// @namespace      http://tampermonkey.net/
// @version        0.2
// @description    Script auto refreshes Dante page after posting a task and inform if it's failed or completed.
// @description:pl Skrypt automatycznie odświeża stronę Dante po udostępnieniu zadania i informuje, czy zadanie zostało zaliczone.
// @author         DaveIT
// @match          https://dante.iis.p.lodz.pl/*
// @grant          none
// ==/UserScript==

(function() {
    'use strict';

    var oldTitle = document.title;
    var spinner = document.querySelector('.fa-spinner.fa-spin');
    var failed = document.querySelector('.fa-times-circle.text-danger');
    var sounds = {
        success: new Audio('https://free-sounds.ct8.pl/success.mp3'),
        fail: new Audio('https://free-sounds.ct8.pl/fail.mp3')
    }

    var button = document.querySelector('.btn.btn-warning.btn-block.font-weight-bold');

    if(button !== null) {
        button.onclick = function() {
            setTimeout(()=> {
                document.querySelector('.fa.fa-book.fa-fw').click();
                window.location.reload(true);
            }, 1000);
        }
    }

    document.onfocus = function() {
        document.title = oldTitle;
    }

    if(spinner != null && failed == null) {
        setTimeout(()=> {
            window.location.reload(true);
        }, 1000);
    } else if(failed != null) {
        document.title = 'Niezaliczono zadania';
        sounds.fail.play();
    } else {
        document.title = 'Zaliczono zadanie';
        sounds.success.play();
    }


})();