User Tools

Site Tools


A bookmarklet (bookmark applet) is a bookmark that acts upon the current page, instead of loading a new page, on invocation. This is usually achieved by executing JavaScript code via the 'javascript' URI scheme (e.g. enter “javascript:alert('foo')” as a URI to your browser).

While bookmarklets are a dirty hack around the inflexibility of 'modern' browsers, you can still use them in Uzbl.
The bookmark adding bind and script in the sample Uzbl config/scripts use the currently loaded URI, so unless you have a custom bind/script, you'll need to edit your bookmark file manually, to add the bookmarklet.

A more logical, or “uzbl” way to get the functionality of a JavaScript bookmarklet is to use the 'js' Uzbl command, or better yet, put the code into an external script and call it with the Uzbl command 'script'.
In either case, you need to remove the “javascript:” part, and percent-decode the bookmarklet URI. Here's a quick way: Copy the URI into clipboard and run the following shell code, which will put the cleared up JS code into a file called 'script.js'.

xclip -sel clip -o \
    | sed 's/javascript://' \
    | python -c 'import urllib, sys; print urllib.unquote(' \
    > script.js

(Hint: 'xsel' is a more advanced alternative to 'xclip'.)

Now you can make the script available with something like:

@cbind ;script0! = /path/to/script.js

One last way would be to bind some key(s) to “set uri = <bookmarklet_URI_goes_here>” in Uzbl's configuration, but that would be the dumbest option of all.

bookmarklets.txt · Last modified: 2016/08/31 14:10 (external edit)