Harpocrates

Helps the Olympian scripts when they need GreaseMonkey functions

当前为 2016-09-12 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Harpocrates
// @namespace    mobiusevalon.tibbius.com
// @version      0.1
// @author       Mobius Evalon
// @description  Helps the Olympian scripts when they need GreaseMonkey functions
// @license      Creative Commons Attribution-ShareAlike 4.0; http://creativecommons.org/licenses/by-sa/4.0/
// @include      /^https{0,1}:\/\/\w{0,}\.?mturk\.com.+/
// @include      /^https{0,1}:\/\/\w{0,}\.amazon\.com\/ap\/signin/
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

// use of unsafeWindow is necessary to get harpocrates into the un-sandboxed
// space with the rest of the olympian scripts
if(unsafeWindow.olympus === undefined) unsafeWindow.olympus = {};

unsafeWindow.olympus.harpocrates = {
	__12_hrs:43200000,
	get login_timestamp() {
		return GM_getValue("login_timestamp",0);
	},
	__init:function() {
		console.log("harpocrates init");
		if(/^https{0,1}:\/\/\w{0,}\.amazon\.com\/ap\/signin/i.test(window.location.href)) {
			olympus.style.add(".red {color: #f00;}");
			$("#signInSubmit-input").click(function() {
				GM_setValue("login_timestamp",Date.now());
			});
		}
		else this.display();
	},
	display:function() {
		var login_time = (this.login_timestamp*1);
		if(login_time > 0) {
			var time_left = ((this.__12_hrs-(Date.now()-login_time))/1000);
			$("span.header_links").append(
				$("<br/>"),
				$("<b/>")
					.attr("class",("logout_time"+(time_left <= 1800 ? " anim_pulse red" : "")))
					.text("Time to logout: "+(time_left <= 300 ? "any moment" : olympus.utilities.dhms(time_left)))
			);
		}
	}
};