Advertisement

Safari-to-1Password search bookmarklet for iOS

1Password on iOS is the best way I've found to manage secure passwords, but the 4.0 version did not make it easy to search for passwords straight from Safari, iCab or another browser (well, not Chrome, which doesn't support bookmarklets).

The recent 4.1 release added several bug-fixes and added two URL schemes:

  • Added support for ophttp:// and ophttps:// URLs. To open 1Password from Mobile Safari, simply type "op" in front of the address.

  • Added support for onepassword://search/search_text to open 1Password and perform search.

Unfortunately, opening 1Password's browser from Safari (or iCab) isn't really what I want. I want to be able to use iCab and retrieve login information from 1Password. Generally what I want to do is search 1Password for the current domain, but it's not an exact science. For example, if I'm at "www.instapaper.com" I might want to search for "instapaper.com" or just "instapaper".

I could have just thrown up an empty prompt, but I didn't want to type any more than I had to, and I still think it's easier to delete what is not necessary than type what is necessary.

What I needed was a compromise.

Instead of an empty prompt or just automatically searching for current domain, I decided to combine them, and put up a prompt showing the current domain information pre-filled, but editable.

It works like this:

1) Tap the bookmarklet and JavaScript prompt will appear with the current domain name pre-filled in the editable area:

2) If you're happy with what's in the prompt area, just tap 'OK'

(But in my example I'm going to assume I want to search for 'instapaper' instead of 'www.instapaper.com')

3) Once you have the search term you want, tap 'OK' and Safari will ask you to confirm if you want to open this in 1Password:

After you tap 'Open', 1Password will open (prompting for your Master Password if necessary), and then search for the term.

Voilà!

You can find my bookmarklet at Github. (Again, please note that I don't know JavaScript very well, so I've pieced this together from other examples. If you can make suggestions on how to improve it, please do, either here or at Github.)

Update 2013-02-11: Thanks to Duane Toler for suggesting an improvement in the comments below. I have updated the Gist so you will get his corrected version, which will search for the root domain (i.e. 'google.com' rather than 'www.google.com'). Note that the version in the comments has a mismatched quote, but the Github version does not.

Remember, you'll need version 4.1 of 1Password on iOS for this to work.

Other 1Password for iOS articles you might be interested in:

1) ios-browser-pw-integration:

This is proof of concept code that shows how an iOS password management app (like 1Password) could use URL schemes and JavaScript bookmarklets to communicate with mobile Safari and Chrome to make it easier for users to fill in login forms on websites.

2) MacStories has some more information on using the new search terms, including a bookmarklet to open the current page from Safari in 1Password's internal browser.