Skip to content

February 26, 2006


Safari Google Toolbar-like Highlighting

I find using a web browser to be a more pleasant experience when I can use the Google Toolbar. The features that make using it so much more pleasant is being able to pinpoint where in the result document my query terms appeared. I feel like it enables me to quickly get at the “meat” of the information I’m searching for. I love Safari, but have used Firefox because the Google Toolbar is available for it. Thanks to Pierre-Luc Samuel’s superb Ultimate Highlight Bookmarklet 1.5b, I was well on my way to getting my beloved highlighting back. My only problem with it was that I often write more specific queries to Google; most often including quoted phrases. Unfortunately, his Safari-compatible Bookmarklet didn’t handle quoted phrases. Below is my update to his bookmarklet that now supports quoted phrases as well.
Highlight (Note: Bookmarklet updated March 04, 07)
Drag the link above to Safari’s Bookmark Bar. I recommend dragging it all the way to the left on the Bookmark Bar. If you do, you can simple hit Command-1 and quickly launch and, when hit again, quit the highlighting of your last search phrase.
The Bookmarklet has a few problems, the most important of which is that it relies of the google referrer link to provide the query terms. If you run it from a page that you didn’t connect to from a Google results page, you’ll have to enter the terms you want highlighted by hand.

Read more from Technical
12 Comments Post a comment
  1. Jan 25 2007

    Thanks so much – this is awesome. Time to set Safari to default browser again 🙂

  2. Derek Peschel
    Mar 3 2007

    I didn’t know Safari could run Javascrpt like that… this is a neat trick! But where did all the percent-39s come from? According to my ASCII chart, they turn into 9s. Pierre-Luc’s original code has backslash followed by ‘ in the same place. And ‘ is character 39 decimal which is 27 hex. The backslashes seem to have disappeared entirely in your version.

    I hope I’m not screwing up here. I’ve only clicked on the bookmarklet and dismissed the “enter keywords” box, so I don’t know what actually happens.

  3. Conrad
    Mar 3 2007

    The %39s are supposed to be ‘ s. The bookmarklet highlights terms used in the referring search query or in the “enter keywords” box.

  4. Derek Peschel
    Mar 4 2007

    I know what the bookmarklet is suppsoed to do, I meant I didn’t know what it actually does. Maybe the %39s are supposed to be quotes but they aren’t, they’re 9s. That’s my point — there’s a serious mistake in the encoded form of the text which breaks the code.

    I was wondering whether I was wrong, but trying the code I see I’m not wrong. I did a search, clicked the bookmarklet, and clicked “close” in the display that popped up. Then I got an error from Safari. Changing each 39 to \%27 seems to fix everything. (Using just %27 won’t work.)

  5. Derek Peschel
    Mar 4 2007

    Conrad, thinking about that last comment, I realized you weren’t disagreeing with my original comment. So I’m sorry if I sounded too confrontational just now.

  6. Conrad
    Mar 4 2007

    No worries. I’m grateful for the debugging help and I certainly should have been more considerate in my reply. I’ve updated the bookmarklet to reflect your findings. BTW, should I change the ‘%20’s to ‘\%20’s? One problem I’ve never been able to fix is getting the bookmarklet to recognize quoted phrases so that it would highlight “Google Toolbar” and not “Google” and “Toolbar” individually. I’m wondering if the problem I’ve been having could be traced to not escaping the spaces correctly. Note: the bookmarklet above doesn’t include the functions I wrote to parse quoted phrases, but if you’d like to take a look at it, please let me know.
    Again, thanks for the debugging!

  7. Will
    Mar 13 2008

    Wow! That’s awesome! I really like it – thanks.

    Now the only other feature of Google Toolbar which I miss in Safari is the Next/Previous buttons, so I don’t have to go back to the Google Search Results page to check the next search hit. Do you think this is achievable using a similar technique?


  8. Conrad
    Mar 13 2008

    Thanks WIll,
    I keep thinking about building a custom browser based on WebKit, with interface elements designed around the needs of a user who is an adept, or even expert, web-searcher. Over the years I’ve accumulated a bunch of notes on how people who consider themselves expert web-search users interact with their browsers, including how they use tabs, browser history, bookmarks, and, of course, the Google Toolbar and their search results. If I can make a paper-prototype that I like, I’ll post it and some of my notes. But to answer your question directly, I don’t know if the next/previous buttons can be implemented in this way – I’m not aware of a way of getting access to other search results via the referrer URL.

  9. sbt
    Oct 24 2008

    “so that it would highlight “Google Toolbar” and not “Google” and “Toolbar” individually. ”
    some of the ff extensions do searches and highlight. could you look at (then emulate) the js files that do that? It’s also controversial whether non-alphanum chars should be highlighted/clickable. eg,
    “search words”
    (usually) gives same results as
    but highlighting and clickability can be either Literal, or (more complicated!) Equivalent (for lack of better label). by Literal, i mean that “search words” only highlights
    search words {highlighter drops the double quotes}
    and search-words highlights only
    search-words {highlighter ignores search words}

    if highlight/click is Equivalent, then either phrase will find either phrase in the text.

  10. Aug 22 2009

    I was SO excited when I found this blog. I sorely miss the highlight function in Safari. I’m using the current Safari 4.0.2. How disappointed I was when I tried the bookmarklet and found it wouldn’t work. Is there any update or chance for an update of this javascript jem?


  11. Alex
    Apr 26 2010

    Please make this work in the latest version of safari! …or is there a working alternative by now?

Share your thoughts, post a comment.


Note: HTML is allowed. Your email address will never be published.

Subscribe to comments