Tampermonkey: A strong Google extension to modify your web

Profile picture of MikeHe-creator

Draft

Jan 9, 2024

·

3 min read

·

112 Views

Tampermonkey allows users to customize and enhance the functionality of your favorite web pages. Userscripts are small JavaScript programs that can be used to add new functionality to web pages or modify existing functionality. With Tampermonkey, you can easily create, manage and run these userscripts on any website.

For example, using Tampermonkey, you can add a new button to a web page that can quickly share a link on social media, or automatically fill in a form with personal information. This is particularly useful in the digital age, as web pages are often used as user interfaces to access a wide range of services and applications.

Additionally, Tampermonkey enables you to easily find and install userscripts created by other users. This means you can quickly and easily access an extensive library customized for your favorite web pages without spending hours writing your own code.

Here is a simple example. Change the name of a user on YouTube:

1. Prepare

  1. Install Tampermonkey

  2. Check this user's name on YouTube.

    2. Write JavaScript in Tampermonkey

    1. click the icon of Tampermonkey and then write New Script ( the icon is+).

  1. Here, write your code and save:

    // ==UserScript==
    // @name         New Userscript
    // @namespace    http://tampermonkey.net/
    // @version      2024-01-09
    // @description  try to take over the world!
    // @author       You
    // @match        https://www.youtube.com/@Nazaru_Lan
    // @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
    
        // Your code here...
        function modifyChannelName() {
            var channelNameElement = document.getElementById("text");
            if (channelNameElement) {
                channelNameElement.textContent = "Chinese Guy in Japan";
            } else {
                console.error("找不到指定的元素(ID: text)");
            }
        }
    
        var observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.addedNodes.length > 0) {
                    modifyChannelName();
                }
            });
        });
    
        observer.observe(document.documentElement, { childList: true, subtree: true });
    
        window.addEventListener("DOMContentLoaded", function() {
            modifyChannelName();
        });
    })();
  2. Refresh and Check:

So this web became a white boy who said he is a Chinese boy living in Japan (Joking).

This Extension only modifies the code loaded locally and will not affect the data in the server. Only you can see the modified web page. As long as you know JavaScript, you can do a lot of things with it, and you don't need to download other plug-ins to improve your browsing experience. If you don’t know how, it doesn’t matter. There are many interesting third-party scripts on the extension website. Choose the script you need. You can even use it to do magic, start a live broadcast on TikTok and make money. Enjoy yourself!


Profile picture of MikeHe-creator

Written By

Who-am-I?

No bio found