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)

tags: , , ,

11 Responses to “The Hit List Bookmarklet for Mac and iOS”

  1. Darren says:

    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.

  2. Brian says:

    That is superb! Thanks for sharing that.

  3. (post author) Daniel M. Gattermann says:

    Darren, I’ve updated the bookmarklet to preserve the hash part in Gmail URLs. Please update to the new version.

  4. Erik says:

    Any update on the iOS release?

  5. (post author) Daniel M. Gattermann says:

    Erik, you should follow the official Twitter account by THL’s developer at or the for updates on the app’s status.

  6. Trackback from The Hit List Finally Lands On The iPhone And Is Definitely Worth The Wait : Mac Plazza – Super Sale for Mac

    [...] What about a bookmarklet for quickly adding tasks to The Hit List on both the Mac and iPhone app? You can find that here. [...]

  7. Trackback from PitsBlog » The Hit List, another GTD-Planner?

    [...] Ergänzend sei noch erwähnt, dass es für den Browser eurer Wahl noch ein Bookmarklet gibt. Dieses findet Ihr unter folgendem Link. [...]

  8. JP Bogers says:

    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

  9. (post author) Daniel M. Gattermann says:

    The bookmarklet already works in Chrome and Firefox.

  10. goochisan says:

    FYI… It also works in Fluid site-specific web-browsers. :-) http://fluidapp.com Thanks again, Daniel!!!

  11. Joe says:

    Thank you very much!

Leave a Comment!


313 posts. 18 pages. 423 comments. 53 categories. 42 queries. 1.519 seconds.
Blog © 2005-2014 Daniel M. Gattermann. Logos, trademarks, etc. © by their respective owners.