DC_auto_refresh

Refresh the windows if no network activity for a while.

当前为 2015-07-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name		DC_auto_refresh
// @author		Ladoria
// @version		0.3
// @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 = 10000; // 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 (date_now - last_refresh.getTime() >= refresh_time_limit) {
				window.location.reload();
				last_refresh = new Date();
			}
		}
	}, 1000);
	
	// Update last request time
	$(document).ajaxComplete( function(a,b,c) {
		last_request = new Date();
	});
});
console.log('DC - Auto Refresh started');