Greasy Fork is available in English.

Show random verification time

show random verification time

  1. // ==UserScript==
  2. // @name Show random verification time
  3. // @namespace https://greatest.deepsurf.us/users/821661
  4. // @match https://*.superau.la/*
  5. // @grant none
  6. // @version 1.0
  7. // @require https://update.greatest.deepsurf.us/scripts/526417/1540623/USToolkit.js
  8. // @author hdyzen
  9. // @description show random verification time
  10. // @license GPL-3.0-only
  11. // ==/UserScript==
  12.  
  13. function waitElement(selector) {
  14. return new Promise((resolve, reject) => {
  15. const callback = () => {
  16. const target = document.querySelector(selector);
  17. if (target) resolve(target);
  18. };
  19.  
  20. const observer = new MutationObserver(callback);
  21.  
  22. observer.observe(document.body, {
  23. childList: true,
  24. subtree: true,
  25. });
  26. });
  27. }
  28.  
  29. async function init() {
  30. try {
  31. const dataFutura = new Date(JSON.parse(localStorage.getItem("db-v6")).CurrentSession.AulaEmAndamento.ValidacaoAleatoria.CandidatoConvocacoes[0].HoraConvocacaoAleatoria);
  32. const restante = await waitElement(".chat__header__title:has(> :nth-child(2))");
  33. const aleatoria = document.createElement("span");
  34. aleatoria.style.marginLeft = "6px";
  35. restante.appendChild(aleatoria);
  36.  
  37. const intervalo = setInterval(() => {
  38. const agora = new Date();
  39. const tempoRestante = dataFutura - agora;
  40.  
  41. if (tempoRestante <= 0) {
  42. clearInterval(intervalo);
  43. console.log("A data futura foi alcançada!");
  44. } else {
  45. const segundos = Math.floor((tempoRestante / 1000) % 60);
  46. const minutos = Math.floor((tempoRestante / (1000 * 60)) % 60);
  47. const horas = Math.floor((tempoRestante / (1000 * 60 * 60)) % 24);
  48.  
  49. aleatoria.textContent = `• ${horas}h${minutos}m${segundos}s`;
  50. // console.log(`${horas}h${minutos}m${segundos}s`);
  51. }
  52. }, 1000);
  53. } catch (error) {
  54. console.error("Error: ", error);
  55. }
  56. }
  57. init();