DC_auto_refresh

Refresh the windows if no network activity for a while.

2015-07-16 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 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');