Dante Auto Task Checker

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

  1. // ==UserScript==
  2. // @name Dante Auto Task Checker
  3. // @name:pl Dante Auto Task Checker
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.2
  6. // @description Script auto refreshes Dante page after posting a task and inform if it's failed or completed.
  7. // @description:pl Skrypt automatycznie odświeża stronę Dante po udostępnieniu zadania i informuje, czy zadanie zostało zaliczone.
  8. // @author DaveIT
  9. // @match https://dante.iis.p.lodz.pl/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var oldTitle = document.title;
  17. var spinner = document.querySelector('.fa-spinner.fa-spin');
  18. var failed = document.querySelector('.fa-times-circle.text-danger');
  19. var sounds = {
  20. success: new Audio('https://free-sounds.ct8.pl/success.mp3'),
  21. fail: new Audio('https://free-sounds.ct8.pl/fail.mp3')
  22. }
  23.  
  24. var button = document.querySelector('.btn.btn-warning.btn-block.font-weight-bold');
  25.  
  26. if(button !== null) {
  27. button.onclick = function() {
  28. setTimeout(()=> {
  29. document.querySelector('.fa.fa-book.fa-fw').click();
  30. window.location.reload(true);
  31. }, 1000);
  32. }
  33. }
  34.  
  35. document.onfocus = function() {
  36. document.title = oldTitle;
  37. }
  38.  
  39. if(spinner != null && failed == null) {
  40. setTimeout(()=> {
  41. window.location.reload(true);
  42. }, 1000);
  43. } else if(failed != null) {
  44. document.title = 'Niezaliczono zadania';
  45. sounds.fail.play();
  46. } else {
  47. document.title = 'Zaliczono zadanie';
  48. sounds.success.play();
  49. }
  50.  
  51.  
  52. })();