Skip to content

xypha/Bookmarklets

Repository files navigation

Bookmarklets

A small collection of JavaScript bookmarklets I wrote for Firefox (but should work in other browsers too).

Suggestions for improving their code are welcome.

Introduction to bookmarklets

Click on ⏵ to show/hide the explanation.

What is a bookmarklet?

Show/Hide

Bookmarklets are saved and used as normal bookmarks in any web browser.

Each bookmarklet (or simply marklet) contains JavaScript commands and as such, they are simple "one-click" tools which add functionality to the browser. Hence, each file ends with a .js extension.

Bookmarklets always begin with javascript:. Some browsers automatically delete this label when pasting, so make sure it's there.
Bookmarklet code shown below is minified i.e., it contains only the information a computer needs to execute the commands quickly.
Copy and paste the code at UnMinify.com to expand it so it is easier for humans to read, or visit un-minified link in contents to view the original code with comments.
If you choose to alter the un-minified code to your own needs, use Minify JS to compact it before bookmarklet creation.

Visit Wikipedia to learn more about bookmarklets.

How to install and use bookmarklets?

Show/Hide

"Installation" of a bookmarklet is performed by creating a new bookmark, and pasting the code into the URL destination field.

Image: 'Add bookmark' window in Firefox - paste bookmarklet code in URL field

Add bookmark window in Firefox - paste bookmarklet code in URL field

The contents of Name, Tags or Keyword fields are optional.
Choose something that will make it easy for you to remember a bookmarklet's function and use it from the Bookmarks Toolbar, and locate or search for it in your browser's Bookmark Manager.
You can leave these other fields blank too. The content of these fields won't change the function of the bookmarklet.

Contents

Sl No. Name Link (Un-minified) Last Updated
1 Open IMDb trailer in new tab Link 2024.03.29
2 Set Invidious preferences in two clicks Link 2024.03.29

Open IMDb trailer in new tab

This bookmarklet enables you to open the featured trailer/video in a new tab on any IMDb movie/TV show title page.

Save below code as a bookmarklet -

javascript:(function(){var elem=document.querySelector("video.jw-video.jw-reset");var src=elem.getAttribute("src");window.open(src)})()

How to use the bookmarklet -

Show/Hide

Step 1 - Open an IMDb page. Example: Terminator 2
Step 2 - Click on this bookmarklet.

  • If a featured trailer is present next to the movie or show's poster (Image 1a), it will open in a new tab/window as per your browser setting. (Image 1b)

Image 1a: Featured trailer (red arrow ⬇️) is present next to the movie or show's poster -

Featured trailer is present next to the movie or show's poster

Image 1b: Trailer will open in a new tab or window -

Trailer will open in a new tab or window

  • If a featured trailer is not present, but Videos are present on the page (Image 1c), you can choose one of two options -
  • Click on this bookmarklet. A video (usually the 1st one but its random sometimes) will open in a new tab. (or)
  • Click on a desired video, wait for the page and video to load, then click on this bookmarklet. The desired video will open in a new tab/window.

Image 1c: Movie or show's videos on the main page -

Movie or show's videos on the main page

  • If a featured trailer is not present and there are no videos, then nothing happens when the bookmarklet is clicked.

Set Invidious preferences in two clicks

If you frequently switch Invidious instances (seen here & here)
and usually stick to the same preferences across instances,
then this bookmarklet is for you.

Save below code as a bookmarklet -

javascript:(function(){document.getElementById("video_loop").checked=!1;document.getElementById("autoplay").checked=!1;document.getElementById("continue").checked=!1;document.getElementById("continue_autoplay").checked=!1;document.getElementById("local").checked=!1;document.getElementById("listen").checked=!1;document.getElementById("speed").options[4].selected=!0;document.getElementById("quality").options[1].selected=!0;document.getElementById("quality_dash").options[6].selected=!0;document.getElementById("volume").value="50";document.getElementById("comments[0]").options[0].selected=!0;document.getElementById("comments[1]").options[0].selected=!0;document.getElementById("captions[0]").options[4].selected=!0;document.getElementById("captions[1]").options[2].selected=!0;document.getElementById("captions[2]").options[1].selected=!0;document.getElementById("related_videos").checked=!0;document.getElementById("annotations").checked=!1;document.getElementById("extend_desc").checked=!0;document.getElementById("vr_mode").checked=!1;document.getElementById("save_player_pos").checked=!0;document.getElementById("automatic_instance_redirect").checked=!0})()

How to use the bookmarklet -

Show/Hide

Step 1 - Open the Preferences page of an Invidious instance. Example: yewtu.be (Image 2a)
Step 2 - Click on this bookmarklet.
Step 3 - Check if the preferences set by the bookmarklet are as desired. (Image 2b)
Step 4 - Click on the Save preferences button at the bottom of the webpage.

Image 2a: Preferences - Website defaults -

Preferences - Website defaults

Image 2b: Preferences set by bookmarklet -

Preferences set by bookmarklet