YouTube Home Button Override

Replaces the YouTube home button with a Pinterest link of your choosing

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         YouTube Home Button Override
// @namespace    http://tampermonkey.net/
// @description  Replaces the YouTube home button with a Pinterest link of your choosing
// @author       You
// @license      MIT
// @match        *://www.youtube.com/*
// @run-at       document-end
// @version 0.0.1.20230725074000
// ==/UserScript==

(function() {
    // Replace the YouTube home button with a Pinterest link
    function overrideHomeButton() {
        const pinterestLink = "https://i.pinimg.com/originals/62/28/5a/62285a5f6ce177bb4fb752bb294bc649.gif"; // Replace this with your Pinterest link
        const homeButton = document.querySelector("#logo-icon");

        if (homeButton) {
            const newLink = document.createElement("a");
            newLink.href = pinterestLink;
            newLink.target = "_blank";
            newLink.innerHTML = `<img src="${pinterestLink}" style="width: 100%; height: 100%; opacity: 0;" alt="Pinterest">`; // Set opacity to 0 (fully transparent)

            homeButton.parentNode.replaceChild(newLink, homeButton);
        }
    }

    // Wait for the YouTube page to load and then override the home button
    const observer = new MutationObserver(() => {
        const homeButton = document.querySelector("#logo-icon");
        if (homeButton) {
            overrideHomeButton();
            observer.disconnect();
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();