Tab Name Changer

Lets you change the tab title for the current page

  1. // ==UserScript==
  2. // @name Tab Name Changer
  3. // @version 0.0.2
  4. // @description Lets you change the tab title for the current page
  5. // @match *://*/*
  6. // @grant GM_registerMenuCommand
  7. // @namespace random-uuid:c58b8350-b784-4996-bc18-9927cebe4862
  8. // @license none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to change the tab title and save it to local storage
  15. function changeTabTitle(newTitle) {
  16. document.title = newTitle;
  17. localStorage.setItem(window.location.href, newTitle);
  18. }
  19.  
  20. // Function to clear the tab title from local storage
  21. function clearTabTitle() {
  22. localStorage.removeItem(window.location.href);
  23. document.title = '';
  24. }
  25.  
  26. // Function to load the tab title from local storage with delay
  27. function loadTabTitle() {
  28. setTimeout(function() {
  29. const savedTitle = localStorage.getItem(window.location.href);
  30. if (savedTitle) {
  31. document.title = savedTitle;
  32. }
  33. }, 1000); // 2000 milliseconds delay
  34. }
  35.  
  36. // Create menu button in Tampermonkey menu for changing the tab title
  37. GM_registerMenuCommand("Tab Name Changer", function() {
  38. const newTitle = prompt("Enter the new tab title:");
  39. if (newTitle) {
  40. changeTabTitle(newTitle);
  41. }
  42. });
  43.  
  44. // Create menu button in Tampermonkey menu for clearing the tab title
  45. GM_registerMenuCommand("Clear Tab Title", function() {
  46. clearTabTitle();
  47. });
  48.  
  49. // Load the tab title when the page loads
  50. loadTabTitle();
  51. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址