Created
February 21, 2024 12:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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