Alerta de Termo gerado

notificar quando o ASI terminar de gerar um relatorio.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();
        }
    });

})();