Greasy Fork is available in English.

Check for Element Loop with Sound

notificar quando o ASI terminar de gerar um relatorio.

От 10.05.2024. Виж последната версия.

  1. // ==UserScript==
  2. // @name Check for Element Loop with Sound
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description notificar quando o ASI terminar de gerar um relatorio.
  6. // @author ils94
  7. // @match https://asiweb.tre-rn.jus.br/asi/report?target=dry.infra.reports.web.UserReportsGateway&action=formUserReports
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let audioPlayed = false;
  15.  
  16. function playSound() {
  17. // Create an audio element
  18. let audio = new Audio('https://github.com/ils94/workoutTimer/raw/main/sound/finish_pt.mp3');
  19. // Play the audio
  20. audio.play().then(() => {
  21. // Set audioPlayed to true after the audio is played
  22. audioPlayed = true;
  23. }).catch((error) => {
  24. console.error('Failed to play audio:', error);
  25. });
  26. }
  27.  
  28. function checkElement() {
  29. let element = document.querySelector('a[name="linkRelatFinalizado"]');
  30. if (element && !audioPlayed) {
  31. console.log('Element found:', element);
  32. clearInterval(intervalId);
  33. playSound();
  34. } else {
  35. console.log('Element not found, retrying in 3 seconds...');
  36. }
  37. }
  38.  
  39. let intervalId = setInterval(checkElement, 3000);
  40.  
  41. // Add a click event listener to the document to allow audio playback
  42. document.addEventListener('click', () => {
  43. if (!audioPlayed) {
  44. playSound();
  45. }
  46. });
  47.  
  48. })();