miko99 / The Pirate Bay's title Formatter

// ==UserScript==
// @name     The Pirate Bay's title Formatter
// @description improves titles for The Pirate Bay.
// @version  1
// @include     *
// @grant    none
// @auth miko99
// @updateURL https://openuserjs.org/meta/miko99/The_Pirate_Bays_title_Formatter.meta.js
// @license GPL-3.0-or-later
// ==/UserScript==

// TODO needs to find a list of urls
if (document.title == "The Pirate Bay - The galaxy's most resilient bittorrent site" )  
{
  var newTitlePrefix = "TPB - ";
  var newTitle;
  var elms = ["name", "tlt"]
  var elm;
  
  for ( elm of elms){
  
    elm= document.getElementById(elm);
    if (elm == null) continue;
    else {
      newTitle = elm.innerText;
      break;
    }
  
  } 
 
  
  if (newTitle== null)  newTitle=document.location.pathname;
 
  
  document.title = newTitlePrefix + decodeURI(newTitle);
  
  

}