Bunpro: Egg Timer

Times your review session.

当前为 2019-07-26 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bunpro: Egg Timer
// @namespace    http://tampermonkey.net/
// @version      0.3.2
// @description  Times your review session.
// @author       Kumirei
// @include      *bunpro.jp/*
// @exclude      *community.bunpro.jp*
// @require      https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @require      https://greasyfork.org/scripts/370623-bunpro-helpful-events/code/Bunpro:%20Helpful%20Events.js?version=615700
// @grant        none
// ==/UserScript==

(function() {
		var elapsed = 0;
		var interval = false;
		$('HTML')[0].addEventListener('quiz-page', function() {
				$('.home-dropdown').after('<div id="egg-timer" class="help-button" style="left: 60px; top: 0; padding: 0;">00:00</div>');
				elapsed = 0;
				if (interval != false) clearInterval(interval);
				interval = setInterval(function() {
						var location = window.location.href;
						if (window.location.href.match(/(study)|(cram)/) == null)  clearInterval(interval);
						else {
								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);
		});
})();