Auto-Page Refresh

When certain text is displayed, the website will refresh. This will refresh the page for you whenever it needs to.

目前为 2024-01-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Auto-Page Refresh
// @version      1.0
// @description  When certain text is displayed, the website will refresh. This will refresh the page for you whenever it needs to.
// @author       Misspent & OpenAI
// @namespace    https://chatbot.theb.ai
// @icon         https://i.imgur.com/xap0lZG.png
// @license      MIT
// @match        https://flixtor.video/*
// @match        https://fmoviesz.to/*
// @match        https://flixtor.video/*
// @match        https://sflix.to/*
// @match        https://yesmoviez.to/*
// @match        https://www2.solarmovie.cr/*
// @match        https://actvid.rs/*
// @match        https://123moviesgoto.com/*
// @match        https://aniwave.to/*
// @match        https://9animetv.to/*
// @match        https://animension.to/*
// @match        https://gogoanime3.net/*
// @match        https://vidplay.site/*
// @include      https://aniwave.*/*
// @include      https://vidstream.*/*
// @include      https://filemoon.*/*
// @include      https://vizcloud.*/*
// @include      https://mcloud.to/*
// @include      https://mcloud2.to/*
// @include      https://movies7.to/*
// @include      https://*.mp4upload.*/*
// @include      https://vidplex.*/*
// @include      https://rapid-cloud.*/*
// @include      https://*.bunnycdn.*/*
// @include      *video*
// @include      *flix*
// @include      *movie*
// @include      *tv*
// @include      *invidious*
// @grant        none
// ==/UserScript==


// This one is ONLY for aniwave. It might be redundant now, but keep it just in case.
(function() {
    'use strict';

    let loadingDivFound = false;

    const checkForLoadingDiv = () => {
        const loadingDivs = document.querySelectorAll('#player div.loading');
        Array.from(loadingDivs).forEach((loadingDiv) => {
            if (getComputedStyle(loadingDiv)['background-image'].includes('url')) {
                loadingDivFound = true;
                setTimeout(() => {
                    if (loadingDivFound && getComputedStyle(loadingDiv)['background-image'].includes('url')) {
                        location.reload(); // Refresh the page
                    } else {
                        loadingDivFound = false; // Reset the flag if the image is no longer showing
                    }
                }, 1000); // Wait 1 seconds before refreshing the page
            }
        });
    }

    setInterval(() => {
        checkForLoadingDiv();
    }, 1000); // Check every second for the loading div
})();


// Can you make a TamperMonkey script that refreshes a page when the a selector called "div.loading" shows for longer than 6 seconds, make sure the div.loading has a "background: url" so it knows it's the right one
// Can you make it so it has to detect that the image is ALWAYS showing for those 6 seconds and if the image isn't showing, make it so the page won't refresh


// Reload and optionally notify when a certain message is shown on error message
(function() {
    'use strict';

    const enableNotifications = true; // Set this to true to enable notifications, or false to disable

    const errorMessages = [
        "Mysql error, could not connect",
        "max_user_connections",
        "502 Bad Gateway",
        "504 Gateway Time-out",
        "Something broke",
        "The database timed out running your query",
        "Server error, please try again",
        "we took too long to make this page for you",
        "A timeout occurred",
        "Connection timed out",
        "Server error, please refresh this page and try again",
        "Unable to load episode, please try again",
        "Too many connections. Please try again later",
        "Request is invalid.",
        "Unable to load episodes.",
        "Unable to load the server, please try again.",
        "This video file cannot be played.",
        "The media could not be loaded, either because the server or network failed or because the format is not supported.",
        "Unable to load server, please try again.",
        // Add more error messages here
    ];

    // Monitor for error messages and reload if found
    const observer = new MutationObserver(() => {
        const pageContent = document.body.textContent;
        for (const errorMessage of errorMessages) {
            if (pageContent.includes(errorMessage)) {
                if (enableNotifications) {
                    showNotification('Page is being refreshed due to an error');
                }
                location.reload();
                break;
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    // Show notification at the bottom center of the page
    function showNotification(message) {
        const notification = document.createElement('div');
        notification.textContent = message;
        notification.style.position = 'fixed';
        notification.style.bottom = '10px';
        notification.style.left = '50%';
        notification.style.transform = 'translateX(-50%)';
        notification.style.backgroundColor = 'rgba(255, 0, 0, 0.8)';
        notification.style.padding = '10px';
        notification.style.color = 'white';
        notification.style.borderRadius = '5px';
        notification.style.zIndex = '9999';
        document.body.appendChild(notification);
        setTimeout(() => {
            notification.remove();
        }, 3000);
    }
})();








/*

// Short and simple, this one does work
(function() {
    'use strict';

    let textsToCheck = [
        "Request is invalid.",
        "Unable to load episodes.",
        "Unable to load the server, please try again.",
        "This video file cannot be played.",
    ];
    let refreshInterval = 1000;

    setInterval(() => {
        for(let i=0; i<textsToCheck.length; i++) {
            if(document.body.innerText.includes(textsToCheck[i])) {
                location.reload();
            }
        }
    }, refreshInterval);
})();



(function() {
    'use strict';
    // Add more text to match here
    const textToMatch = [
        "Mysql error, could not connectToo many connections", "max_user_connections", "502 Bad Gateway", "504 Gateway Time-out", "Something broke", "The database timed out running your query", "Server error, please try again", "we took too long to make this page for you", "A timeout occurred", "Connection timed out", "Server error, please refresh this page and try again", "Unable to load episode, please try again", "Too many connections. Please try again later"
    ];

    // Refresh interval in milliseconds
    const refreshInterval = 1000;

    // Check for text and refresh page if found
    function checkForText() {
        for (const text of textToMatch) {
            if (document.body.innerText.includes(text)) {
                location.reload();
            }
        }
    }

    // Start checking for text periodically
    setInterval(checkForText, refreshInterval);
})();


(function() {
    'use strict';

    // List of trigger phrases that will cause the page to refresh
    const triggerPhrases = ["Mysql error, could not connectToo many connections", "max_user_connections", "502 Bad Gateway", "504 Gateway Time-out", "Something broke", "The database timed out running your query", "Server error, please try again", "we took too long to make this page for you", "A timeout occurred", "Connection timed out", "Server error, please refresh this page and try again", "Unable to load episode, please try again", "Too many connections. Please try again later"];

    function refreshPage() {
        location.reload();
    }

    // Function to continuously check for trigger phrases and refresh if detected
    function checkAndRefresh() {
        const pageText = document.body.innerText;

        for (const phrase of triggerPhrases) {
            if (pageText.includes(phrase)) {
                refreshPage();
                return; // Exit the loop after the first match is found
            }
        }

        // Re-run the check after a short delay
        setTimeout(checkAndRefresh, 1000); // Adjust the delay as needed
    }

    // Start the checking process
    checkAndRefresh();
})();
*/

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址