TaskRatchet bookmarklets

This bookmarklet will create a task with a description that’s hard-coded into it – i.e., the same task name every time you use the bookmarklet.
The task will be due a specific number of minutes into the future – the same number of minutes every time you use the bookmarklet (but those minutes are always add on to the time at which you use the bookmarklet).

I use it to create an “emergency” task that makes me do a small amount of work immediately, to get me out of a state of frozen overwhelm, as described at Rod's Beeminder Journal - #4 by alys and in the comments below it (one of them includes a bash script version of this). You could use it if you often create the same task in TaskRatchet. You could make as many of these bookmarklets as you wanted, each with their own task name and number of minutes.

The bookmarklet uses TaskRatchet’s API so you have to get your User ID and API Token from the account page.

AN IMPORTANT NOTE: This bookmarklet will work only if you use it while you are looking at the TaskRatchet website. That’s because of the Cross-Origin Resource Sharing (CORS) security mechanism. I think there are ways to work around that, based on what I’ve been reading, so I’m hoping to make a new version that can be used no matter what site you’re looking at, but I don’t know when/if I’ll do that. :slight_smile:

How to edit the code:

  1. See the instructions in the top post of this thread.
  2. Paste your TaskRatchet API User ID where it says ‘ADD_USERID_HERE’. You must keep the single-quotes around the value.
  3. Paste your TaskRatchet API Token where it says ‘ADD_TOKEN_HERE’. You must keep the single-quotes around the value.
  4. Put whatever text you like where it says ‘PUT YOUR TASK NAME HERE’. You must keep the single-quotes around the value. Don’t use any single quotes as part of the text!
  5. Find where it says minutes_in_future=15; and change 15 to whatever number of minutes you want (e.g., 120 for 2 hours). You do not need to put single-quotes around it. You do need to keep the equals sign and semi-colon in place.
  6. If you want to customise the amount you’ll pay if you don’t complete the task on time, find where it says 'cents':500 - that’s $5. Change 500 to whatever you want. You do not need to put single-quotes around it. You do need to keep the colon in front of it (colon, not semi-colon).

When you use the bookmarklet, you’ll see a popup saying whether it was successful (“task created”) or not (“ERROR. Task NOT created”).

Post here if you have questions, comments, or improvements, or if any of this is confusing!

EDIT 2022-04-26: See the more convenient version below by @coolhandlouis!

This is the code to copy:
javascript:(function(){ task='PUT YOUR TASK NAME HERE'; minutes_in_future=15; datetime=new Date(+new Date() + 60000*minutes_in_future).toLocaleString('en-US').replace(/:[0-9][0-9] /g,' '); fetch('https://api.taskratchet.com/api1/me/tasks', { method:'POST', headers:{ 'X-Taskratchet-Userid':'ADD_USERID_HERE', 'X-Taskratchet-Token':'ADD_TOKEN_HERE', 'Content-Type':'application/json' }, body: JSON.stringify({'task':task, 'due':datetime, 'cents':500 }) }).then((response) => { if (response.ok) { alert('task created:\n' +task+' \n '+datetime ); } else { alert('ERROR. Task NOT created:\n' +task+' \n '+datetime ); } }) })();

4 Likes