I was looking at a Wassat (Wellington Open Source Show & Tell) notice and looked back at one of the organisers, Grant, presentation on Bookmarklets on YouTube and slides. I thought it was an interesting idea and decided to explore it further.
As you are doing the JS event after the page has loaded, and you have a script that changes the background colour of the page, you can go back to prior running of Bookmarklet by just refreshing the page and it brings you back to the original page load state.
Sounds cool and I was intrigued by it. So I started by wonder exactly what you could do to on mr YouTube. The code train one shows how to build them and challenges (no new lines in JS) but his examples are a bit weak. The 2nd video discusses a webpage mrColes that takes your JS and converts it into a Bookmarklet:
All the above videos do not show any examples that made me jump out and go mad on them, so I started looking on web search and came across this site Jesses Bookmarklets and there are quite a few examples to test and you can browse by topic. I quite liked the ^Highlight Word^ (my quotes don’t seem to work in wordpress at the moment) and the ^zap white background^ which changes background colour on the page you are reading.
At Statz n stuff site there is one bookmarklet that allows you to play snakes and another with Asteroids (actually that one I want to play with), there is also this website Website Asteroids where you can get the bookmarklet more easily.
A couple of practical ones are where you highlight text, press Bkmklet and it takes you to Wiki or Google for searching , I’ve now set a couple of these up, they are useful and predictable.
Another video on BkmkLets I thought was really good and the demo for testing in Chrome is very educational (firefox does not have developer snippets):
I saw on the Statz page a Timer, but couldn’t get it to work, but found this site 7is7.com where you can setup your own bookmarklet to start a timer from a specific date & time, slightly fiddly as you have to set start time, but form other articles I’ve done on getting a timer running for projects this is pretty simple and handy.
Open in New Tab/New Window
This has been a bit of a challenge for me. I had a couple of Bkmklts that I put on my browser bar so that I could access them right away, one being selecting a bit of text in a web page and then looking it up on Wiki or looking it up in DuckDuckGo. The only issue being it did it in the tab that you had selected the text in, rather than opening another tab. At the time I did a bit of searching on the topic and didn’t have much success. I’ve since had another attempt that has been more successful. Now they are much more usable.
the window.open JS code does different things depending on your browser seetup. I have firefox and the window.open default is Open a New TAB, that is a FireFox default, in other browsers it might be open a new Browser Window, so the Bookmarklet will open in a completely new browser window. If you want to chage the browser default you have to go into the specific browser settings to do so.
I’d heard of Greasemonkey doing the JS injection into a web page. There is a Firefox add in for it. The video below goes through the fundamentals of what its trying to do:
This allows you to programmatically change specific websites that you visit and store the script related to the actions. You can filter which websites it effects and create a library for different actions on different sites. As it sits in the background it automatically runs when you open the specified URL.
I like the idea of being able to do more things with bookmarks and the bookmarklet is a nice feature to use, especially being able to alter some of the structure on existing pages, one I was playing with was transposing rows , altering bullet points to numbers and adding row numbers
I think these might have their place as productivity tools if they are in a handy location. Im please with colouring white background one for reducing eye strain on web pages, also the google and wiki searches too. I’ll bear them in mind for finding simple, practical uses.
Searching for popular bookmarklets and articles such as the best 10 BMLets a lot I’d never use as they do not do much for me, but there is a potential for bespoke code for repetitive tasks like autofill forms and uploading data onto a form or database through a webpage, or even for some validation testing on websites. A handy button to run some simple code may be just the right process to use.