Bookmarklets - No more boring tasks


19 Jun, 2022

Warning!!! Technical content ahead! This is the first post I’ve written a bit technical after a long gap. If you are not interested in stuff related to programming please revert back and view my other posts. Thank you 🙂

3.. 2.. 1.. Here we go…! Booking a ticket in Tatkal? Ordering a phone in Flipkart? The counter closes in a flash. Boom! Here it comes. Baam! There it goes. The offer ends before you wink your eyes. Feeling bored by doing the same task again and again? Leave your worries; Bookmarklet is there by your side. With it, you can automate almost everything on the web. Computers are so much faster than humans before your eyes could process the information in the web page and locate the submit button, Bookmarklet completes your job. Okay let me unravel the mystery of Bookmarklet to you, Brace yourselves.

Bookmarklets’ are nothing but a useful piece of code that can run on any loaded web page. This useful piece of code is written in JavaScript. If you know the basics of JS, you are almost on the top of everything. The name Bookmarklet is coined because this script resides on a bookmark. Any browser will surely have a facility to bookmark your favorite sites. Behind this facility, there is a grand opening to the world of automation of the web using JS. Let us go discover the creation of Bookmarklets.

Go to the bookmark bar and add a new bookmark. Name it whatever you want, Tatkal booker, Instant phone buyer, the Web Robo. Then in the URL enter the following code given here along with your own JavaScript code.

javascript:(function(){ //your JavaScript code here })()

You can add any code to this function and this will be executed on any loaded page the moment you click this bookmark. This is nothing but an anonymous JS function, nothing special in it. Most of the computer guys might know it. The power of the Bookmarklet is immeasurable. You can import any JS library from the CDNs’ and use them in the script. With the gift of JQuery you could almost implement any automation tasks on the web with swag, just like Selenium but without using it actually. No more late bookings and boring stuff, just Bookmarklets. Go now and start creating your own Bookmarklet. May the force be with you.

A simple Bookmarklet to log in to an application (might be useful if you debug a web-application 100 times/day like me)

javascript:(function(){document.getElementById("loginEmail”).value=”Your username”; document.getElementById(“password”).value=”Your password”; document.getElementById(“submit”).click();})()

Hope this helps people in web development field who feel bored to type their long username and password (known to the whole organization) again and again to login to their application with a quick click. If you are lazy even to do that click, you will surely find a way to automate even that as well. I felt logging in again and again to my application boring, that’s when I found this precious jewel “Bookmarklets”.

Have a great day!

That's it for now, thanks for reading! You can find me at @samuellawrentz on X.

This helps me increase the session time of my site. Thank you!

Can you stay a bit longer?