Alerta de Termo gerado

notificar quando o ASI terminar de gerar um relatorio.

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Alerta de Termo gerado
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  notificar quando o ASI terminar de gerar um relatorio.
// @author       ils94
// @match        https://asiweb.tre-rn.jus.br/asi/report?target=dry.infra.reports.web.UserReportsGateway&action=formUserReports
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let audioPlayed = false;

    function playSound() {
        // Create an audio element
        let audio = new Audio('https://github.com/ils94/workoutTimer/raw/main/sound/finish_pt.mp3');
        // Play the audio
        audio.play().then(() => {
            // Set audioPlayed to true after the audio is played
            audioPlayed = true;
        }).catch((error) => {
            console.error('Failed to play audio:', error);
        });
    }

    function checkElement() {
        let element = document.querySelector('a[name="linkRelatFinalizado"]');
        if (element && !audioPlayed) {
            console.log('Element found:', element);
            clearInterval(intervalId);
            playSound();
        } else {
            console.log('Element not found, retrying in 3 seconds...');
        }
    }

    let intervalId = setInterval(checkElement, 3000);

    // Add a click event listener to the document to allow audio playback
    document.addEventListener('click', () => {
        if (!audioPlayed) {
            playSound();
        }
    });

})();