您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Refresh the windows if no network activity for a while.
当前为
- // ==UserScript==
- // @name DC_auto_refresh
- // @author Ladoria
- // @version 0.4
- // @grant none
- // @description Refresh the windows if no network activity for a while.
- // @match http://www.dreadcast.net/Main
- // @copyright 2015+, Ladoria
- // @namespace InGame
- // ==/UserScript==
- var last_request = new Date();
- var last_refresh = new Date();
- var request_time_limit = 20000; // In ms. Time limit to refresh.
- var refresh_time_limit = 10000; // In ms. Time limit to refresh again.
- $(document).ready( function() {
- setInterval( function() {
- var date_now = new Date().getTime();
- // If no network activity for a while, reload.
- if (date_now - last_request.getTime() >= request_time_limit) {
- // If reload failed, waiting for a while.
- if (date_now - last_refresh.getTime() >= refresh_time_limit) {
- last_refresh = new Date();
- window.location.reload();
- }
- }
- }, 1000);
- // Update last request time
- $(document).ajaxComplete( function(a,b,c) {
- last_request = new Date();
- });
- });
- console.log('DC - Auto Refresh started');