Bye Bye MathsWatch

Say Bye Bye to Mathswatch as now you "no longer have access to it" as the servers are down!

  1. // ==UserScript==
  2. // @name Bye Bye MathsWatch
  3. // @author HyperrGB
  4. // @version 2.2
  5. // @description Say Bye Bye to Mathswatch as now you "no longer have access to it" as the servers are down!
  6. // @match https://vle.mathswatch.co.uk/*
  7. // @license MIT
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/1080178
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to display the error message and loading countdown
  16. function displayError() {
  17. const errorContainer = document.createElement('div');
  18. errorContainer.style.width = '100%';
  19. errorContainer.style.height = '100vh';
  20. errorContainer.style.backgroundColor = '#bf2c15'; // Updated background color
  21. errorContainer.style.color = '#ffffff';
  22. errorContainer.style.fontSize = '24px';
  23. errorContainer.style.fontWeight = 'bold';
  24. errorContainer.style.textAlign = 'center';
  25. errorContainer.style.display = 'flex';
  26. errorContainer.style.flexDirection = 'column';
  27. errorContainer.style.justifyContent = 'center';
  28. errorContainer.style.alignItems = 'center';
  29. errorContainer.style.padding = '0 20%'; // Updated padding on the sides
  30.  
  31. const errorIcon = document.createElement('img');
  32. errorIcon.src = 'https://www.imagehost.at/images/2023/05/17/coolpic.png'; // URL of the error icon
  33. errorIcon.style.width = '15%'; // Adjust the size of the icon if needed
  34. errorIcon.style.height = 'auto';
  35. errorIcon.style.marginBottom = '2%'; // Add spacing between icon and text
  36.  
  37. const errorText = document.createElement('div');
  38. errorText.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.';
  39. errorText.style.marginTop = '2%'; // Add spacing above the error message
  40.  
  41. const loadingContainer = document.createElement('div');
  42. loadingContainer.style.width = '100%';
  43. loadingContainer.style.textAlign = 'center';
  44. loadingContainer.style.position = 'absolute';
  45. loadingContainer.style.bottom = '4%';
  46.  
  47. const loadingText = document.createElement('div');
  48. loadingText.style.fontWeight = 'bold';
  49. loadingText.textContent = 'You are in the queue, approx. 4 hours.';
  50.  
  51. const loadingBar = document.createElement('div');
  52. loadingBar.style.width = '20%';
  53. loadingBar.style.height = '2%';
  54. loadingBar.style.backgroundColor = '#ffffff';
  55. loadingBar.style.margin = '2% auto';
  56. loadingBar.style.borderRadius = '5px';
  57.  
  58. const progressBar = document.createElement('div');
  59. progressBar.style.width = '0%';
  60. progressBar.style.height = '100%';
  61. progressBar.style.backgroundColor = '#4CAF50';
  62. progressBar.style.borderRadius = '5px';
  63. progressBar.style.transition = 'width 1s linear';
  64.  
  65. loadingBar.appendChild(progressBar);
  66. loadingContainer.appendChild(loadingBar);
  67. loadingContainer.appendChild(loadingText);
  68. errorContainer.appendChild(errorIcon); // Add the error icon to the error container
  69. errorContainer.appendChild(errorText);
  70. errorContainer.appendChild(loadingContainer);
  71. document.body.innerHTML = '';
  72. document.body.appendChild(errorContainer);
  73.  
  74. // Start the countdown timer
  75. const duration = 4 * 60 * 60; // 4 hours in seconds
  76. let remainingTime = duration;
  77. const interval = 1000;
  78.  
  79. const timerInterval = setInterval(() => {
  80. remainingTime -= interval / 1000;
  81.  
  82. const progress = (duration - remainingTime) / duration * 100;
  83. progressBar.style.width = progress + '%';
  84.  
  85. if (remainingTime <= 0) {
  86. clearInterval(timerInterval);
  87. // Reload the page after the timer ends
  88. window.location.reload();
  89. }
  90. }, interval);
  91. }
  92.  
  93. // Function to continuously display the error message and loading countdown
  94. function errorLoop() {
  95. displayError();
  96. setTimeout(errorLoop, 1000); // Adjust the delay (in milliseconds) between error messages if needed
  97. }
  98.  
  99. // Start the error loop when the page finishes loading
  100. window.addEventListener('load', errorLoop);
  101. })();