TaskRatchet bookmarklets

Worked great on chrome, thanks! Here’s my very modest change, I put all of the entered data up front. Also, on my mac/chrome, I was able to just copy/paste this version with indents and line-feeds.

javascript: (function() {
    task = 'PUT YOUR TASK NAME HERE';
    minutes_in_future = 15;
    dollars = 5;
    USERID = 'ADD_USERID_HERE';
    TOKEN = 'ADD_TOKEN_HERE';
  
    L = 'https://app.taskratchet.com/';
    if (location != L) {
        location = L
    } else {
        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': USERID,
                'X-Taskratchet-Token': TOKEN,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                'task': task,
                'due': datetime,
                'cents': dollars * 100
            })
        }).then((response) => {
            if (response.ok) {
                alert('task created:\n' + task + '\n' + datetime);
            } else {
                alert('ERROR. Task NOT created:\n' + task + '\n' + datetime);
            }
        })
    }
})();
3 Likes