Skip to content

Instantly share code, notes, and snippets.

@trey
Created February 8, 2012 00:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trey/1763416 to your computer and use it in GitHub Desktop.
Save trey/1763416 to your computer and use it in GitHub Desktop.
Use Custom Search Engines in Chrome for Named Bookmarklets

Use Custom Search Engines in Chrome for Named Bookmarklets

One of the things I loved about using Safari was that I could have items in my bookmark bar that I could invoke with ⌘1, ⌘2, etc. This was especially nice for things like bookmarklets. For example, I'm viewing an article that I want to read later, I could hit ⌘2 and save it to Instapaper.

Chrome has no such shortcuts for its bookmark bar, but it does have custom search engines.

The idea behind these is allowing you to set a search engine for something like Amazon and be able to type amazon⇥, enter a search term, and get your results without having to do it by manually typing into a search field on the site.

But it can do so much more.

Let's use the Instapaper bookmarklet as an example. Let's say I already have it in my bookmark bar.

  • Go to Bookmarks > Bookmark Manager, or enter ⌥⌘B
  • Right-click on the Bookmarklet and select Edit
  • Focus on the bit that starts with javascript:...
  • Select it all and copy it.

copy the long JavaScript bookmark

Now we create the custom search engine.

  • Right-click on the address bar and select "Edit Search Engines", or go to Preferences and click "Manage Search Engines..." under "Search"

edit search engines

  • Enter the following to the bottom of the list (you may have tons of things in here already):
    • In the "Add a new search engine" field, enter whatever you want to call it. This doesn't matter in terms of functionality. In our case, we'll enter "Instapaper"
    • In the "Keyword" field, enter the shortcut you want to use. I'm going to use "r" for "Read Later".
    • In the "URL with %s..." field, paste what you copied from the bookmark earlier.
  • Now you can close that browser tab.

enter new search engine

Now when you land on a large article, you can highlight the address bar (⌘L) and then type your keyword "r" and hit return. Sure, it's a couple more keystrokes than just hitting ⌘2, but now you don't have to remember an arbitrary number.

the end result

I have several of these setup for things like "p" to save the current page to Pinboard, "of" to add a link to the current page to OmniFocus, "t" for Tumblr.

This is now one of my favorite features of Chrome, and I would have a hard time going back to Safari.

Thanks to Hernán Ciudad for teaching me this trick.

Bonus

Enable syncing your custom search engines by tweaking things in chrome://flags/.

@trey
Copy link
Author

trey commented Dec 5, 2012

This is a Solutions Log post.

@lancehilliard
Copy link

Do 'javascript:...' "search engines" still work for you? Chrome '29.0.1547.76 m' on Windows isn't providing me this functionality. When I type the search engine keyword in the omnibox, the omnibox changes appearance as you'd expect when I'm about to specify the query text (that is, the omnibox recognizes the "search engine" by keyword), but, when I press Enter, nothing happens to the current page, and its URL re-appears in the omnibox.

It's as if it's by design that 'javascript:...' search engines would silently fail.

@chipbite
Copy link

Seems to be not working. Someone said js execution was disabled intentionally.
Haven't found much on this, except https://code.google.com/p/chromium/issues/detail?id=97068

@GRClark
Copy link

GRClark commented Sep 12, 2018

Notice some funny keys your using so I'm assuming it's a Mac - would you happen to have information on doing this for Windows or Linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment