How to Inject Scripts to Websites Using TamperMonkey

Ridbay
4 min readMay 31, 2020

--

What is TamperMonkey?

TamperMonkey is an extension on Google Chrome (and some other browsers like Opera, you can use GreaseMonkey as an alternative on Firefox ).

TamperMonkey

TamperMonkey allows you to inject additional JavaScript codes into web pages you load in your browser, you can add/remove features, and you can do some hacky stuff or automate things.

For example, let’s say you want to be able to download YouTube videos, You can use a TamperMonkey script to add a “Download” button to the videos.

TamperMonkey gives this awesome power and you can have access to pretty much everything you could get by writing a script or using some already-written scripts, and it has a dashboard that you can easily use to manage and edit the scripts in one interface.

You can also access hundreds of already written user scripts via this site Greasy Fork.

Just search for the script you want and and you will get a lot of scripts that are relevant to your search query.

So, how do you use TamperMonkey ?

Using Google Chrome as an example;

  1. Goto your Google Chrome extension page by clicking https://chrome.google.com/webstore/category/extensions?hl=en

2. Search for TamperMonkey

3. Click on “Add to Chrome”

4. Add the Extension to your chrome

5. Once it has been installed, Click on the Extension and click on Dashboard

6. Here you will have access to the TamperMonkey Dashboard

7. To install a new Script, go to Greasy Fork and search for user scripts, and in this example, I need a script that can download Youtube Videos, Let’s say I want to download NASA Astronauts Arrive at the International Space Station on SpaceX Spacecraft video.

8. If you click on that Youtube Video link before installing the “YouTube Download Script”, You would notice that there is no option to download the video;

9. On Greasy Fork, use a search query that is relevant to the particular script you want, e.g “Youtube downloader” then press “Enter”.

10. You will get a bunch of results relevant to your search query with the author details and some other information like ratings, date created, number of downloads etc.

11. Click on the script of your choice and in this example, I will use the first result “Local YouTube Downloader

12. Click on “Install this Script”

13. Click on Install

14. Go to the Website it works on (In our case, Youtube.com), and now we have the option to download the video

How do you manage the scripts/write your own custom user script?

  1. Click on TamperMonkey extension at the top right corner of your browser, and click on Dashboard

2. On the Dashboard, you will have access to already installed scripts, you can enable and disable the script.

3. To create your own user script, click the Plus (+) icon

4. This will open a text editor where you can write/paste your own codes

How do you perform actions on user scripts?

  1. Click the Checkbox at the back of the user script name

2. Then select the particular action you want to perform, then Click “Start

You can see how useful and awesome TamperMonkey is.

I hope you have learned something new.

Thanks for Reading!!!

--

--