Bye Bye MathsWatch

Infinitely displays an error message on Mathswatch website with a loading animation and a 4-hour countdown underneath the error text

当前为 2023-05-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bye Bye MathsWatch
  3. // @version 2.0
  4. // @description Infinitely displays an error message on Mathswatch website with a loading animation and a 4-hour countdown underneath the error text
  5. // @match https://vle.mathswatch.co.uk/*
  6. // @license MIT
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/1080178
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to display the error message and loading countdown
  15. function displayError() {
  16. const errorContainer = document.createElement('div');
  17. errorContainer.style.width = '100%';
  18. errorContainer.style.height = '100vh';
  19. errorContainer.style.backgroundColor = '#bf2c15'; // Updated background color
  20. errorContainer.style.color = '#ffffff';
  21. errorContainer.style.fontSize = '24px';
  22. errorContainer.style.fontWeight = 'bold';
  23. errorContainer.style.textAlign = 'center';
  24. errorContainer.style.display = 'flex';
  25. errorContainer.style.flexDirection = 'column';
  26. errorContainer.style.justifyContent = 'center';
  27. errorContainer.style.alignItems = 'center';
  28. errorContainer.style.padding = '0 20%'; // Updated padding on the sides
  29. errorContainer.textContent = 'MathsWatch is currently down due to: Excess Users on Server, we are using a virtual queue to limit the amount of people on MathsWatch, please either try again later or wait in the queue, Thanks';
  30.  
  31. const loadingContainer = document.createElement('div');
  32. loadingContainer.style.width = '100%';
  33. loadingContainer.style.textAlign = 'center';
  34. loadingContainer.style.position = 'absolute';
  35. loadingContainer.style.bottom = '20px';
  36.  
  37. const loadingText = document.createElement('div');
  38. loadingText.style.fontWeight = 'bold';
  39. loadingText.textContent = 'You are in the queue, approx. 4 hours.';
  40.  
  41. const loadingBar = document.createElement('div');
  42. loadingBar.style.width = '200px';
  43. loadingBar.style.height = '10px';
  44. loadingBar.style.backgroundColor = '#ffffff';
  45. loadingBar.style.margin = '10px auto';
  46. loadingBar.style.borderRadius = '5px';
  47.  
  48. const progressBar = document.createElement('div');
  49. progressBar.style.width = '0%';
  50. progressBar.style.height = '100%';
  51. progressBar.style.backgroundColor = '#4CAF50';
  52. progressBar.style.borderRadius = '5px';
  53. progressBar.style.transition = 'width 1s linear';
  54.  
  55. loadingBar.appendChild(progressBar);
  56. loadingContainer.appendChild(loadingBar);
  57. loadingContainer.appendChild(loadingText);
  58. errorContainer.appendChild(loadingContainer);
  59. document.body.innerHTML = '';
  60. document.body.appendChild(errorContainer);
  61.  
  62. // Start the countdown timer
  63. const duration = 4 * 60 * 60; // 4 hours in seconds
  64. let remainingTime = duration;
  65. const interval = 1000;
  66.  
  67. const timerInterval = setInterval(() => {
  68. remainingTime -= interval / 1000;
  69.  
  70. const progress = (duration - remainingTime) / duration * 100;
  71. progressBar.style.width = progress + '%';
  72.  
  73. if (remainingTime <= 0) {
  74. clearInterval(timerInterval);
  75. // Reload the page after the timer ends
  76. window.location.reload();
  77. }
  78. }, interval);
  79. }
  80.  
  81. // Function to continuously display the error message and loading countdown
  82. function errorLoop() {
  83. displayError();
  84. setTimeout(errorLoop, 1000); // Adjust the delay (in milliseconds) between error messages if needed
  85. }
  86.  
  87. // Start the error loop when the page finishes loading
  88. window.addEventListener('load', errorLoop);
  89. })();