Skip to content

Instantly share code, notes, and snippets.

@mvark
Created February 21, 2024 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvark/4c310046a9b164b85669a9e8e8e4a31d to your computer and use it in GitHub Desktop.
Save mvark/4c310046a9b164b85669a9e8e8e4a31d to your computer and use it in GitHub Desktop.
Reverse Clock Bookmarklet - This handy tool counts down the time you set, helping you stay focused and improve your estimation skills for tasks like reading articles, watching videos, or completing online assignments.
javascript:(function() {
var t, ts, h, m, s, u, c, tmr, f = document.createElement("div");
f.id = "revClock";
f.style.cssText = "position: fixed; top: 10px; right: 10px; background-color: rgba(0, 0, 0, 0.5); padding: 10px; z-index: 9999; text-align: center; font-size: 20px; color: white;";
document.body.appendChild(f);
t = prompt("Enter number of minutes:");
if (t === null || isNaN(t) || t < 0) {
alert("Invalid input. Please enter a positive number for minutes.");
return;
}
ts = parseInt(t) * 60;
u = function() {
h = Math.floor(ts / 3600);
m = Math.floor((ts % 3600) / 60);
s = ts % 60;
tmr = h.toString().padStart(2, '0') + ":" +
m.toString().padStart(2, '0') + ":" +
s.toString().padStart(2, '0');
if (ts <= 0) {
clearInterval(c);
tmr = t + " minute(s) up!";
}
const n = new Date();
var fn = n.toLocaleString("en-GB");
f.innerHTML = tmr + "<br>" + fn;
ts--;
};
c = setInterval(u, 1000);
u();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment