Remove TV Tropes Namespace from Title

Removes the namespace from the tab title of a TV Tropes article so it's easier to tell the article name from a glance.

  1. // ==UserScript==
  2. // @name Remove TV Tropes Namespace from Title
  3. // @namespace http://userscripts.org/users/527104
  4. // @description Removes the namespace from the tab title of a TV Tropes article so it's easier to tell the article name from a glance.
  5. // @include *tvtropes.org*
  6. // @version 2.0
  7. // ==/UserScript==
  8.  
  9. var filteredNamespaces = new Array(
  10. "Main",
  11. "VideoGame",
  12. "Literature",
  13. "TVShow",
  14. "Music",
  15. "Anime",
  16. "Series",
  17. "Franchise"
  18. );
  19.  
  20. var regex = new RegExp("(" + filteredNamespaces.join("|") + ")\/", "i");
  21. var title = document.getElementsByTagName("title")[0] || null;
  22.  
  23. if (title) {
  24. title.innerHTML = title.innerHTML.trim().replace(regex, "");
  25. }