Tab Icon and Name Changer

Allows you to change the tab icon and name

  1. // ==UserScript==
  2. // @name Tab Icon and Name Changer
  3. // @version 3.0
  4. // @description Allows you to change the tab icon and name
  5. // @match *://*/*
  6. // @grant GM_registerMenuCommand
  7. // @license MIT
  8. // @namespace http://your-namespace.com
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to change the tab icon
  15. function changeTabIcon(iconUrl) {
  16. const link = document.querySelector("link[rel*='icon']");
  17. if (link) {
  18. link.href = iconUrl;
  19. } else {
  20. const newLink = document.createElement('link');
  21. newLink.rel = 'icon';
  22. newLink.href = iconUrl;
  23. document.head.appendChild(newLink);
  24. }
  25. }
  26.  
  27. // Function to change the tab title
  28. function changeTabTitle(newTitle) {
  29. document.title = newTitle;
  30. }
  31.  
  32. // Create menu button in Tampermonkey menu
  33. GM_registerMenuCommand("Tab Icon and Name Changer", function() {
  34. const iconUrl = prompt("Enter the URL of the new tab icon:");
  35. if (iconUrl) {
  36. changeTabIcon(iconUrl);
  37. }
  38.  
  39. const newTitle = prompt("Enter the new tab title:");
  40. if (newTitle) {
  41. changeTabTitle(newTitle);
  42. }
  43. });
  44. })();