您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
randomized delays auto-refresh
当前为
// ==UserScript== // @name FlexiRefresh // @namespace https://github.com/RustwuIf // @version 1.0.2 // @description randomized delays auto-refresh // @author Rustwulf // @match <all_urls> // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // Core settings const storageKey = 'autoRefreshState'; let isRunning = false; let remainingTime = 0; let countdownInterval = null; let minDelay = parseInt(localStorage.getItem('minDelay')) || 5; let maxDelay = parseInt(localStorage.getItem('maxDelay')) || 15; // Create UI elements const mainButton = document.createElement('button'); mainButton.style.cssText = ` position: fixed; bottom: 5px; left: 15px; padding: 2px 2px; background: #FF6B6B; color: white; border: none; border-radius: 8px; font-size: 10px; cursor: pointer; z-index: 99999; `; mainButton.textContent = '▶️⇧+T'; const settingsButton = document.createElement('button'); settingsButton.style.cssText = ` position: fixed; bottom: 5px; left: 55px; padding: 2px 2px; background: #FFFFFF; color: white; border: none; border-radius: 8px; font-size: 10px; cursor: pointer; z-index: 99999; `; settingsButton.textContent = '⚙️'; const countdownDisplay = document.createElement('div'); countdownDisplay.style.cssText = ` position: fixed; bottom: 23px; left: 17px; background: rgba(0,0,0,0.2); color: white; padding: 5px; border-radius: 8px; font-size: 9px; display: none; `; const settingsModal = document.createElement('div'); settingsModal.style.cssText = ` position: fixed; bottom: 20px; left: 10px; width: 200px; background: Black; border: 1px solid #ccc; padding: 20px; border-radius: 8px; z-index: 99999; display: none; box-shadow: 0 0 10px rgba(0,0,0,0.3); `; settingsModal.innerHTML = ` <h3 style="margin-bottom: 15px; color: white;">Settings</h3> <div style="display: flex; align-items: center; margin-bottom: 10px;"> <label style="width: 120px; margin-right: 10px; color: white;">Min Delay (s):</label> <input type="number" id="minDelay" value="${minDelay}" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 70px;"> </div> <div style="display: flex; align-items: center; margin-bottom: 20px;"> <label style="width: 120px; margin-right: 10px; color: white;">Max Delay (s):</label> <input type="number" id="maxDelay" value="${maxDelay}" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 70px;"> </div> <div style="display: flex; justify-content: flex-end;"> <button id="saveSettings" style="padding: 8px 15px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; margin-right: 10px;">Save</button> <button id="closeModal" style="padding: 8px 15px; background: #ff4d4d; color: white; border: none; border-radius: 4px; cursor: pointer;">Close</button> </div> `; // Append to DOM immediately document.body.appendChild(mainButton); document.body.appendChild(settingsButton); document.body.appendChild(countdownDisplay); document.body.appendChild(settingsModal); // Event listeners mainButton.addEventListener('click', () => { isRunning = !isRunning; localStorage.setItem(storageKey, isRunning); mainButton.textContent = isRunning ? '⏸️⇧+T' : '▶️⇧+T'; mainButton.style.backgroundColor = isRunning ? '#FF4444' : '#FF6B6B'; if (isRunning) startAutoRefresh(); else clearInterval(countdownInterval); }); settingsButton.addEventListener('click', () => settingsModal.style.display = 'block'); document.getElementById('closeModal').addEventListener('click', () => settingsModal.style.display = 'none'); document.getElementById('saveSettings').addEventListener('click', () => { minDelay = parseInt(document.getElementById('minDelay').value, 10); maxDelay = parseInt(document.getElementById('maxDelay').value, 10); localStorage.setItem('minDelay', minDelay); localStorage.setItem('maxDelay', maxDelay); settingsModal.style.display = 'none'; }); document.addEventListener('keydown', (e) => { if (e.shiftKey && e.key === 'T') { e.preventDefault(); mainButton.click(); } }); // Auto-refresh logic function startAutoRefresh() { const delay = Math.random() * (maxDelay - minDelay) + minDelay; remainingTime = Math.floor(delay); countdownDisplay.style.display = 'block'; countdownInterval = setInterval(() => { if (remainingTime <= 0) { clearInterval(countdownInterval); window.location.reload(); remainingTime = 0; } else { remainingTime--; countdownDisplay.textContent = `🔄 ${remainingTime}s`; } }, 1000); } // Restore state window.addEventListener('load', () => { const storedState = localStorage.getItem(storageKey); if (storedState === 'true') { isRunning = true; mainButton.textContent = '⏸️⇧+T'; mainButton.style.backgroundColor = '#FF4444'; startAutoRefresh(); } }); })();