Saturday, August 22, 2015

UZBL LastPass Bookmarklet

In my attempt to be as minimalist as possible, I came across a wonderful browser I never knew existed before a few days ago, UZBL. From their site:

Uzbl follows the UNIX philosophy - "Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface."

Uzbl comes with uzbl-core, uzbl-browser and uzbl-tabbed. For everyday web browsing, I use uzbl-tabbed, which in my dmenu setup, I created a script so that it shows up as just 'uzbl'. Less typing. Uzbl has modes, and keyboard bindings similar to Vi/Vim, so if you are already familiar with that editor, you are almost there.

Now in order to replace Opera, which was my default browser, and was very lightwieght, I needed a few things in place:

  1. Could it render the pages that I visited often and were important to me. CHECK[1]
  2. Does it support LastPass...not in the usual way other browsers do, via extensions.

After much searching on google, I came across an email thread where someone else had accomplished this. Okay, so it can be done, but how? Breaking down the email, I needed to understand two things, how to get the javascript code from LastPass and how to create a bookmarklet for uzbl.


A bookmarklet as it turns out is just javascript, well, that's a simplified explanation, but for this article, that's all that is relevant, and LastPass already has bookmarklets, all I had to do was log into LastPass and I was greeted with this message:

**You are using a browser that currently does not have a LastPass plug-in available.
This may result in reduced functionality. We recommend you use Firefox so you can use the plugin.
Install the bookmarklet if that's not an option.
Clicking the bookmarklet link will show you three options and their explanations. I chose to grab Fill and Fill Forms. Once downloaded, the next step is an adventure, how to actually create an uzbl bookmarklet, luckily someone already created a wiki page on how to do it.

Unfortunately, I could not understand it at first, and missed a few things, so it took me a bit longer to figure out. This is what I did to get it working for me:
  1. Saved LastPass Fill Forms as lastpass_bookmarklet to my home directory.
  2. Run the command from the wiki:

    $ cat lastpass_bookmarklet | sed 's/javascript://' \
    | python -c 'import urllib, sys; print urllib.unquote(sys.stdin.read())' \
    > lastpass_autofill.js

  3. $ mv lastpass_autofill.js ~/.local/share/uzbl/scripts/
  4. $ chmod +x ~/.local/share/uzbl/scripts/lastpass_autofill.js
  5. Edit ~/.config/uzbl/config and add the following line
    @cbind !lpaf = script .local/share/uzbl/scripts/lastpass_autofill.js

That's it, so whenever you need to autofill your login details, just go to Cmd mode and type the keybind you had set in step 5.

1 - As a bonus, I was also able to view sites that opera 12.16 blocked due to certification errors.

No comments:

Post a Comment