// ==UserScript==
// @name Auto-Page Refresh
// @version 4.0
// @description Automatically refresh the page if specific errors are detected in specified divs
// @author Misspent & OpenAI
// @namespace https://chatbot.theb.ai
// @icon https://i.imgur.com/xap0lZG.png
// @license MIT
// @include *upcloud.*
// @include *mcloud.*
// @include *fmovies24.*
// @include *mycloud.*
// @include *vidplay.*
// @include *mp4upload.*
// @include *vidcloud.*
// @include *vizcloud.*
// @include *filemoon.*
// @include *moviesapi.*
// @include *vidsrc.*
// @include *rapid-cloud.*
// @include *a9bfed0818.*
// @include *vid142.*
// @include *aniwave.*
// @include *fmoviesz.*
// @include *megaf.*
// @include *.site*
// @grant none
// ==/UserScript==
// Refresh the page if specific errors are detected in specified divs
(function () {
'use strict';
// Define an array of targets with div, text, and optional delay pairs
const targets = [
{ div: '.message', text: 'Something went wrong', delay: 0 },
{ div: '.message', text: 'Unable to load episode, please try again.', delay: 1500 }, // Fmovies?
{ div: '.message', text: 'Unable to load server, please try again.', delay: 1500 }, // Fmovies?
{ div: '.message', text: 'Unable to load the server, please try again.', delay: 1500 }, // Fmovies?
{ div: '.message', text: 'Unable to load episode list, please try again.', delay: 1500 }, // Fmovies?
{ div: '.message', text: 'This video file cannot be played.', delay: 1500 }, // Fmovies?
{ div: '#player', text: 'This video file cannot be played', delay: 0 },
{ div: '#cf-error-details h1', text: 'Bad gateway', delay: 0 },
{ div: '.message > .inner', text: 'Error while fetching chapter, please try again.', delay: 0 },
{ div: '.message', text: 'Unable to load the server, please try again.', delay: 0 },
{ div: '.message2', text: 'Error 2', delay: 0 },
{ div: '.error-page .detail', text: "We can't find the page that you're looking for.", delay: 1500 },
{ div: '#player .loading', delay: 1500 }, // Aniwave | DO NOT go lower than 1000
];
// Function to check if a target is present and trigger a reload
const checkTarget = (target) => {
const targetDiv = document.querySelector(target.div);
if (targetDiv) {
if (target.text) {
if (targetDiv.innerText.includes(target.text)) {
// Refresh the page
location.reload();
}
} else {
// Check if the div is present and has no text
if (!targetDiv.innerText.trim()) {
// Refresh the page
location.reload();
}
}
}
};
// Function to initiate checks with delay
const initiateChecks = () => {
targets.forEach(target => {
if (target.delay === 0) {
checkTarget(target);
} else {
setTimeout(() => {
checkTarget(target);
}, target.delay || 0); // Use 0 if delay is not specified
}
});
};
// Create a MutationObserver
const observer = new MutationObserver(initiateChecks);
// Configure the observer to watch for changes in the body and its descendants
const observerConfig = { childList: true, subtree: true };
// Start observing the target node for configured mutations
observer.observe(document.body, observerConfig);
// Initial check when the script is executed
initiateChecks();
})();