Infinitely displays an error message on Mathswatch website with a loading animation and a 4-hour countdown underneath the error text
当前为
// ==UserScript==
// @name Bye Bye MathsWatch
// @version 1.0
// @description Infinitely displays an error message on Mathswatch website with a loading animation and a 4-hour countdown underneath the error text
// @match https://vle.mathswatch.co.uk/*
// @grant none
// @license MIT
// @namespace https://greasyfork.org/users/1080178
// ==/UserScript==
(function() {
'use strict';
// Function to display the error message and loading countdown
function displayError() {
const errorContainer = document.createElement('div');
errorContainer.style.width = '100%';
errorContainer.style.height = '100vh';
errorContainer.style.backgroundColor = '#f44336';
errorContainer.style.color = '#ffffff';
errorContainer.style.fontSize = '24px';
errorContainer.style.fontWeight = 'bold';
errorContainer.style.textAlign = 'center';
errorContainer.style.paddingTop = '30vh';
errorContainer.textContent = 'Hello! Sorry for the delays, but MathsWatch Servers are overloaded due to excess revising students as they currently have priority, this is a on and off thing and you may be able to gain access later. Sorry for the inconvenience caused. Please refer this message to your teacher if you had due homework. Regards, The MathsWatch Team.';
const loadingContainer = document.createElement('div');
loadingContainer.style.width = '100%';
loadingContainer.style.textAlign = 'center';
loadingContainer.style.position = 'absolute';
loadingContainer.style.bottom = '20px';
const loadingText = document.createElement('div');
loadingText.style.fontWeight = 'bold';
loadingText.textContent = 'You are in the queue, aprox. 4 hours.';
const loadingBar = document.createElement('div');
loadingBar.style.width = '200px';
loadingBar.style.height = '10px';
loadingBar.style.backgroundColor = '#ffffff';
loadingBar.style.margin = '10px auto';
loadingBar.style.borderRadius = '5px';
const progressBar = document.createElement('div');
progressBar.style.width = '0%';
progressBar.style.height = '100%';
progressBar.style.backgroundColor = '#4CAF50';
progressBar.style.borderRadius = '5px';
progressBar.style.transition = 'width 1s linear';
loadingBar.appendChild(progressBar);
loadingContainer.appendChild(loadingText);
loadingContainer.appendChild(loadingBar);
errorContainer.appendChild(loadingContainer);
document.body.innerHTML = '';
document.body.appendChild(errorContainer);
// Start the countdown timer
const duration = 4 * 60 * 60; // 4 hours in seconds
let remainingTime = duration;
const interval = 1000;
const timerInterval = setInterval(() => {
remainingTime -= interval / 1000;
const progress = (duration - remainingTime) / duration * 100;
progressBar.style.width = progress + '%';
if (remainingTime <= 0) {
clearInterval(timerInterval);
// Reload the page after the timer ends
window.location.reload();
}
}, interval);
}
// Function to continuously display the error message and loading countdown
function errorLoop() {
displayError();
setTimeout(errorLoop, 1000); // Adjust the delay (in milliseconds) between error messages if needed
}
// Start the error loop when the page finishes loading
window.addEventListener('load', errorLoop);
})();