Dante Auto Task Checker

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();
    }


})();