Nutaku reload helper

Satellite script for HHAuto++, Nutaku version

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Nutaku reload helper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Satellite script for HHAuto++, Nutaku version
// @author       Dorten D
// @match        http*://www.nutaku.net/games/harem-heroes/play*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var lastAnswer = (new Date()).getTime();
    window.addEventListener('message', function(event)
        {
            if (event.origin=="https://nutaku.haremheroes.com")
            {
                //console.log('NRH: recieved ',event);
                if (event.data.reloadMe)
                {
                    window.location.reload();
                }
                if (event.data.ImAlive)
                {
                    //console.log('NRH: ITS ALIVE!');
                    lastAnswer = (new Date()).getTime();
                }
            }
        }
    );

    setInterval(function(){
        if((new Date()).getTime() - lastAnswer > 15000) {
            console.log("NRH: it's dead :(");
            window.location.reload();
        }
    },2000);
})();