Bookmarklets for better browsing

Bookmarklets for better browsing

Bookmarklets are a feature in Nyxt that allow you to quickly create and consume snippets of JavaScript.

Wikipedia provides a succinct introduction and historical context:

A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser. Bookmarklets are unobtrusive JavaScripts stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. Bookmarklets are usually JavaScript programs.

Unlike in typical browsers, bookmarklets are not second-class citizens relegated to bookmarks- they are first-class commands! Because of their status in Nyxt, you can:

Defining bookmarklets in Nyxt is straightforward:

(define-bookmarklet-command color-internal-external-links
  "Color internal links red, external links blue, and in-page links orange."
  "(function(){var i,x; ...")

You provide:

  1. A name for your bookmarklet, this corresponds to its function/command
  2. A documentation string describing what the bookmarklet does
  3. Any JavaScript code you would like to run

… and that's it!

We've included a collection of Bookmarklets we think would be useful in our bookmarklets.lisp file. They include commands to:

The currently provided bookmarklets were sourced from Jesse Ruderman's public domain works.

A great illustration of how useful bookmarklets can be is shown below. We start with the Wikipedia page for Salmon.

After executing our sort-table bookmarklet, every single table has a header above it that we can use to sort the elements in the table alphabetically, by column.

We were then able to click and sort by "Scientific Name".

We hope you enjoy using these bookmarklets and find many more to add to your collection!

Thanks for reading :-)