Greasy Fork

Greasy Fork is available in English.

Bunpro: Egg Timer

Times your review session.

当前为 2018-06-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bunpro: Egg Timer
// @namespace    http://tampermonkey.net/
// @version      0.2.4
// @description  Times your review session.
// @author       Kumirei
// @include      https://bunpro.jp/*
// @require      http://greasyfork.icu/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @grant        none
// ==/UserScript==

(function() {
		var elapsed = 0;
		var interval = false;
		waitForKeyElements('#reviews', function() {
				$('.help-button').after('<div id="egg-timer" class="help-button" style="left: 60px;">00:00</div>');
				elapsed = 0;
				if (interval != false) clearInterval(interval);
				interval = setInterval(function() {
						elapsed++;
						var seconds = String(elapsed % 60);
						if (seconds < 10) seconds = '0' + seconds;
						var minutes = String(Math.floor(elapsed/60) % 60);
						if (minutes < 10) minutes = '0' + minutes;
						var hours = '';
						if (elapsed/60 >= 60) {
								hours = String(Math.floor(elapsed/3600));
								if (hours < 10) hours = '0' + hours;
								hours += ':';
						}
						var timestamp = hours + minutes + ':' + seconds;
						$('#egg-timer')[0].innerText = timestamp;
				}, 1000);
		});
})();