The Hit List Bookmarklet for Mac and iOS
Now that my favorite task manager for Mac has gone 1.0 and The Hit List for iPhone is waiting for approval by Apple, I wanted a quick way for creating new tasks from content found on a website using Safari on Mac, iPhone and iPad.
- Select some text and click the bookmark: new task with the selection as its title.
- Don’t select text and click the bookmark: get a popup to enter the task’s title.
- Don’t select text, click the bookmark, leave the popup empty: the website’s title will be used for the task.
In all cases the URL is stored in the comment field of the task.
There is an official Safari extension to create tasks but it only works in Safari for Mac and creates tasks formatted differently than I wanted them to be. This is why I’ve created this bookmarklet.
Add the Bookmarklet to your Browser
To use this bookmarklet just drag the following link to your bookmarks. You can also right click it to copy or add it to your bookmarks depending on your browser. Then sync your bookmarks to your iOS device.
Bookmark this link: Task ✔ (Updated July 8th, 2011)
Creating tasks from selected text works on Mac and iPad. On iPad put the bookmarklet in your bookmarks bar and in Settings.app enable Always Show Bookmarks Bar. On iPhone, iPod touch and iPad when selected from the popover menu, the selected text gets deselected before using the bookmarklet. You should copy and paste the text from the website into the popup on those devices. It’s still very quick.
Updates
August 30th, 2011: Fixed a bug occurring on pages with embedded frames from other domains. The script can’t access these frames and now ignores them.
July 8th, 2011: Better handling of URLs with anchors; better handling of non-letter characters in the task’s title.
June 13th, 2011: It now preserves the hash part (after #) in Gmail URLs and other URLs with anchors. Using the text selection in Gmail (and other multi frame sites) is now supported.
Source Code
Read on if you want the bookmarklet as source code.
The bookmarklet
It’s one line. Remove all whitespaces.
The JavaScript
function addTask() {
var taskTitle = '';
var url = '';
// use selection
if (window.getSelection) {
taskTitle = window.getSelection().toString();
}
if (taskTitle == '') {
var frames = window.frames;
for (var i = 0; i < frames.length; i++) {
if (taskTitle == '') {
if (frames[i].document != undefined) {
taskTitle = frames[i].document.getSelection().toString();
}
} else {
break;
}
}
}
// nothing selected? show prompt
if (taskTitle == null || taskTitle == "") {
taskTitle = prompt("Enter a task description or leave empty to use this site's title:");
}
// prompt canceled? return
if (taskTitle == null) {
return false;
}
// nothing entered? use site's title
if (taskTitle == "") {
taskTitle = document.title
}
// redirect to THL
self.location = "thehitlist:///inbox/tasks?method=POST&title=" + encodeURIComponent(taskTitle) + "&url=" + encodeURIComponent(self.location);
}
// also needed in bookmarklet
addTask();void(0)
June 10th, 2011 at 18:37
Very useful, thanks!
I notice that in Gmail it sometimes doesn’t preserve the information after the # in the URL, which means the link back to the message won’t work. Other times it does work however – not sure why it is different.
June 11th, 2011 at 00:04
That is superb! Thanks for sharing that.
June 13th, 2011 at 01:09
Darren, I’ve updated the bookmarklet to preserve the hash part in Gmail URLs. Please update to the new version.
June 13th, 2011 at 21:58
Any update on the iOS release?
June 13th, 2011 at 23:05
Erik, you should follow the official Twitter account by THL’s developer at or the for updates on the app’s status.
July 8th, 2011 at 03:02
[...] What about a bookmarklet for quickly adding tasks to The Hit List on both the Mac and iPhone app? You can find that here. [...]
July 8th, 2011 at 17:13
[...] Ergänzend sei noch erwähnt, dass es für den Browser eurer Wahl noch ein Bookmarklet gibt. Dieses findet Ihr unter folgendem Link. [...]
July 9th, 2011 at 08:01
Would it be possible to transform this for use in Google Chrome or Firefox 5 for mac?
Is this difficult?
I ask because I use Google/Firefox with ActiveInbox for Gmail. In that way I could get mail into THL!
Thx
JP
July 12th, 2011 at 22:56
The bookmarklet already works in Chrome and Firefox.
July 12th, 2011 at 23:41
FYI… It also works in Fluid site-specific web-browsers. :-) http://fluidapp.com Thanks again, Daniel!!!
December 15th, 2012 at 21:04
Thank you very much!