Bunpro: Egg Timer

Times your review session.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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

(function () {
  var start = Date.now();
  var interval = false;
  var timerAdded = false;
  $("HTML")[0].addEventListener("new-review-item", () => {
    if ($(".review__stats.review-count-tracking")[0].innerText == "0/0") {
      if (timerAdded == false) {
        $(".home-dropdown").after(
          '<div id="egg-timer" class="help-button" style="left: 60px; top: 0; padding: 0;">00:00</div>'
        );
        timerAdded = true;
      }
      start = Date.now();
      if (interval != false) clearInterval(interval);
      interval = setInterval(function () {
        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);
    }
  });
})();