// ==UserScript==
// @name Bunpro: Egg Timer
// @namespace http://tampermonkey.net/
// @version 0.3.3
// @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
// @downloadURL none
// ==/UserScript==
(function() {
var start = Date.now();
var interval = false;
$('HTML')[0].addEventListener('new-review-item', ()=>{
if ($('.review__stats.review-count-tracking')[0].innerText == '0/0') {
$('.home-dropdown').after('
00:00
');
start = Date.now();
if (interval != false) clearInterval(interval);
interval = setInterval(function() {
console.log('test');
var location = window.location.href;
if (window.location.href.match(/(study)|(cram)|(learn)/) == null) clearInterval(interval);
else {
var elapsed = ((Date.now()-start)/1000).toFixed()
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);
}
});
})();