YouTube Home Button Override

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

当前为 2023-07-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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 });
})();