Kong Time

Keeps track of how much time you've spent on Kong today

当前为 2015-06-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Kong Time
// @namespace    http://alphaoverall.com
// @version      0.1
// @description  Keeps track of how much time you've spent on Kong today
// @author       AlphaOverall
// @include        http://www.kongregate.com/*
// ==/UserScript==
var then;
var ref;
function updateTime() {
    var now = new Date();
    if (Math.floor(((now-ref)/1000)) > 120) { 
        localStorage.setItem("kongRef", new Date());
        localStorage.setItem("kongThen", new Date());
        then = new Date(localStorage.getItem("kongThen"));
    }
    ref = new Date(localStorage.getItem("kongRef"));
    if (then === null) { then = new Date(localStorage.getItem("kongThen"));}
    var timeui = document.getElementById("timeui");
    var diff = now-then;
    var diffHrs = Math.floor((diff % 86400000) / 3600000);
    var diffMins = Math.round(((diff % 86400000) % 3600000) / 60000);
    timeui.innerHTML = 
        "<h2>Hey, "+active_user.username()+". You've been online for "+diffHrs+"h"+diffMins+"m "+ 
        "<img id=\"resetKongTimeImg\" style=\"width:2%; cursor:pointer;\" onclick='localStorage.setItem(\"kongThen\", new Date()); localStorage.removeItem(\"kongTotal\");' " +
        "src=\"http://icons.iconarchive.com/icons/icons8/windows-8/256/Very-Basic-Refresh-icon.png\"/></h2>";
    localStorage.setItem("kongRef", now);
}  
function init() {
    try {
        if (localStorage.getItem("kongThen") === null) { localStorage.setItem("kongThen", new Date());}
        then = new Date(localStorage.getItem("kongThen"));
        if (localStorage.getItem("kongRef") === null) { localStorage.setItem("kongRef", new Date());}
        ref = new Date(localStorage.getItem("kongRef"));
        var timeui = document.createElement("div");
        timeui.id = "timeui";
        timeui.className = "sitemessage";
        timeui.innerHTML = "<h2>Hey, "+active_user.username()+"</h2>";
        var global = document.getElementById("global");
        global.appendChild(timeui);
        var go = setInterval(updateTime, 1000);
    } catch (ex) { console.log(ex);}
} init();