8591 15秒刷新並禁止頁面休眠

Automatically refreshes the page every 15 seconds and prevents the page from entering sleep mode.

目前为 2024-04-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         8591 15秒刷新並禁止頁面休眠
// @namespace    
// @version      0.1
// @description  Automatically refreshes the page every 15 seconds and prevents the page from entering sleep mode.
// @author       Scott
// @match        https://www.8591.com.tw/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Refresh interval in milliseconds (15 seconds)
    const refreshInterval = 15000;

    // Function to reload the page
    function reloadPage() {
        location.reload();
    }

    // Function to prevent the page from entering sleep mode
    function preventSleep() {
        if (document.visibilityState === 'visible') {
            const preventSleepFrame = document.createElement('iframe');
            preventSleepFrame.style.width = '0';
            preventSleepFrame.style.height = '0';
            preventSleepFrame.style.border = 'none';
            document.body.appendChild(preventSleepFrame);
        }
    }

    // Reload the page every refreshInterval milliseconds
    setInterval(reloadPage, refreshInterval);

    // Prevent the page from entering sleep mode
    setInterval(preventSleep, 5000); // Execute every 5 seconds
})();

QingJ © 2025

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