YouTube Home Button Override

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

  1. // ==UserScript==
  2. // @name YouTube Home Button Override
  3. // @namespace http://tampermonkey.net/
  4. // @description Replaces the YouTube home button with a Pinterest link of your choosing
  5. // @author You
  6. // @license MIT
  7. // @match *://www.youtube.com/*
  8. // @run-at document-end
  9. // @version 0.0.1.20230725074000
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. // Replace the YouTube home button with a Pinterest link
  14. function overrideHomeButton() {
  15. const pinterestLink = "https://i.pinimg.com/originals/62/28/5a/62285a5f6ce177bb4fb752bb294bc649.gif"; // Replace this with your Pinterest link
  16. const homeButton = document.querySelector("#logo-icon");
  17.  
  18. if (homeButton) {
  19. const newLink = document.createElement("a");
  20. newLink.href = pinterestLink;
  21. newLink.target = "_blank";
  22. newLink.innerHTML = `<img src="${pinterestLink}" style="width: 100%; height: 100%; opacity: 0;" alt="Pinterest">`; // Set opacity to 0 (fully transparent)
  23.  
  24. homeButton.parentNode.replaceChild(newLink, homeButton);
  25. }
  26. }
  27.  
  28. // Wait for the YouTube page to load and then override the home button
  29. const observer = new MutationObserver(() => {
  30. const homeButton = document.querySelector("#logo-icon");
  31. if (homeButton) {
  32. overrideHomeButton();
  33. observer.disconnect();
  34. }
  35. });
  36.  
  37. observer.observe(document.body, { childList: true, subtree: true });
  38. })();