Adding a timer to Beeminder's web interface

I usually use the timer built into the iOS app, but at work I really wanted something on my desktop. So I wrote a line of JavaScript I can paste into the developer tools console to make any goal page’s input box auto-increment:

timer = setInterval(() => { const input = document.querySelector('input.mathyval'); if (!input.value) { startTime = new Date(); } input.value = ((new Date() - startTime) / 60000).toFixed(2); }, 1000);

It resets whenever I clear the box, which happens when I click “Add Progress” or manually delete its contents:

76fbadf1-6925-4f23-b037-5ce5cd92f30a

8 Likes

This is super clever! I wonder if it could be turned into a bookmarklet?

2 Likes

Yup! Any blob of JS that you can paste in the console also can be wrapped in javascript:(()=>{ ... })(), in general. Along with a little minification—not sure if necessary, but some browsers used to get grumpy about spaces iirc?

javascript:(()=>{setInterval(()=>{i=document.querySelector('input.mathyval');if(!i.value){s=Date.now()}i.value=((Date.now()-s)/60000).toFixed(2)},1000)})()
5 Likes