Bookmarklet Generator Tool

Who doesn’t love a way to make their day more efficient. There are always ways to make your work better – it may take a time to recognize where efficiency gains can be made, but trust me it’s worth the effort. What if three clicks/page-loads were removed from your common tasks throughout a day? That adds up!

What sort of gains? Do you routinely have to copy and paste text from a webpage? Or do you often open URLs that have predicable patterns in them? These are all tasks that can be improved with simple bookmarklets.

Bookmarklet Generator Tool Icon

What is a Bookmarklet?

A bookmarklet is a smart bookmark in a web browser.

What does that mean exactly? Typically a bookmark is simply a URL with a name assigned to it. (you know – those things you often collect in your browser and forget they exist? Admit it – we’ve all done this…)

But a bookmarklet is more than just a URL – it’s Javascript code that is run when clicked. What Javascript? Whatever you choose really. It could scrape content off the page, open another URL, call an AJAX endpoint to fetch data, etc.

Sounds exciting – right?

How Write a Bookmarklet

The biggest trick to writing a bookmarklet is to start a one-line string of Javascript with javascript:. So a super-simple example is to have an alert box popup.

Simple bookmarklet example

One frustrating thing about writing a bookmarklet however is that the code needs to be on one line. This makes it difficult to edit and do development of course… You write 30 lines of code with if/loop statements and you need to wrap another if around… the closing } goes right after… shoot… this is hard to read…

A Better Way to Write a Bookmarklet

A tool has been born to make writing bookmarklets easier packed full of great features:

  • Script Editor
    • Beautified editor to write code the way it should be!
  • Bookmarklet formatting built in behind the scenes
    • No need to ensure you have the proper syntax, format, single-line properly formatted, etc.
  • Include jQuery on a page that doesn’t have jQuery with the check of a box
  • Versionable
  • Easily regenerate the beautified code in the editor from the bookmarklet
  • Generate HTML for embedding your bookmarklets into an HTML document for sharing with others

Try it out for yourself. Write your javascript, make a bookmarklet, and make your daily routines that much easier!

Tutorial 1: Get Page Content Bookmarklet

This tutorial will show how to make a simple bookmarklet that copies text of the main links from a Google search results page.

Create Bookmarklet version 1.0

First name the boomarklet and set the version number. Also, Google does not include jQuery on their page. Thus check the Include jQuery box to have jQuery accessible to your bookmarklet.

Vanilla Javascript can be used to write the bookmarklet as opposed to relying on jQuery. Including jQuery here is for the purpose of demonstrating how the jQuery option works.

configure the name and version of the bookmarklet

Write bookmarklet Code

On the Google search results page, each of the main links are <h3> elements. So a small block of jQuery will output the text.

bookmarklet code to output Google link text

Generate the Bookmarklet Link

Click the Generate Bookmarklet button and the code magic happens in the background.

In the yellow block is a button for dragging to the browsers bookmarklet bar. And just that simple a bookmarklet has been created and is ready to be used.

Bookmarklet link for dragging to browser bar
Bookmarklet added to browser bar

Additionally there are two HTML output blocks.

The Bookmarklet HREF can be used to manually add a bookmarklet to a browser, email to others, etc.

Bookmarklet HREF for manually adding to a browser

Copy the HREF, add a new page, and paste into the URL field.

Manually add a bookmark to the bookmark bar.
Right click on the bookmark bar and choose Add Page…
Paste the Bookmarklet HREF into the URL field.
Paste the Bookmarklet HREF into the URL field.

The Bookmarklet HTML box is the HTML that can be copied to an HTML page for publishing this link for others to use. This will result in a button on a page just like the yellow block above. Example CSS can be found under the Directions / Reference section.

Create Bookmarklet version 1.1

The bookmarklet currently only outputs to the browser console. And that’s not overly helpful. This bookmarklet tool has a built in mechanism for quickly reloading the bookmarklet into the editor for making alterations. A URL is built into the bookmarklet. This can be found by right clicking on the bookmarklet and clicking Edit...

For the sake of illustration, you can see here in the Bookmarklet HREF the same URL.

The bookmarklet edit URL is built into the bookmarklet
Bookmarklet edit URL is part of the bookmarklet

Clicking on this link will load v1.0 of the Google Link bookmarklet.

https://promincproductions.com/devtools/bookmarklet-generator/?code=qBhB2BhBzBjByBpBwB0B6AlAyAwApBmBoA0B5BwBlBvBmBLEwAqBRB1BlByB5B9A9AnA1BuBkBlBmBpBuBlBkBnApAlA3ACBCEyBXEEEGEIE9AkBvBjB1BtBlBuB0BuAFElBhB0BlBFBsBlB7E9EoAnAzEHE0BrE7AMFIEuAzByBjBgEvAvAjBvBkEuAqBxBbEdE_EvBtBvAeFgF5BuAtBnEdFzBnA7A3E5EIF-EnBlB0BFFHF8E0BzBCB5BUBhBnBOBhB7EKFoBBFqEsE1ACBwAlA1AEBuAhBwBTEjEDBoBpBsBkBoARF0BpA7AtEEBZEnFoALEyAhBlAzAFBoBzAjGpAuABFjBoBoAmBiEjB0BpBvBuBoApBsA2BsEuElAwABBXECHMEXEOEoA2BuAnEoEyBUBlB4B-EGFuBnB0BoBCHnGXEwA9GCB_GBHEHeHLGfHDHgHwAaFuBzBvBGFuAsBvBnBHHJHuBLHNHPHcGcHiH2H3AEB1H4HcGgAvAqAgAvBIEzB6AgA7BiAuBiA6AiAHBvBsHGFgAMBnErBzBiAsAiA2BJIiAxAuAwAVIiAeFJIxA9BgAqAvA&method=lzw64

Now update the Bookmarklet Version Number to 1.1, modify the Bookmarklet Code as needed, and click the Generate Bookmarklet button again.

Update the version of the bookmarklet and regenerate the bookmarklet.
Version 1.1 of the Google Links Bookmarklet

Now clicking this updated bookmarklet will copy the link text to the computers clipboard. Pasting will output the text into a text editor.

Given that this is a new version and code, the link to edit this bookmarklet is now changed. This updated bookmarklet can be re-published to those that it’s shared with and inform them of an updated version.

Tutorial: Bookmarklet with Prompt

There may be a need for an input field to be used with the bookmarklet. For example, if the URL is predicable and only needs an ID filled in, a bookmarklet like this will do the trick.

Clicking the bookmarklet will open a prompt. Enter an ID, click OK and the bookmarklet will open a URL with this ID appended to it (per the code).

Example Prompt Bookmarklet
A prompt for an ID is opened

Generate a bookmarklet

This bookmarklet generator tool is there for use as needed. With the examples above, a little knowledge of Javascript, and this tool there isn’t anything in the way from making awesome bookmarklets!