jscher2000 / Set Missing Title to Page Name

// ==UserScript==
// @name        Set Missing Title to Page Name
// @description Improve what appears on a tab for a page that doesn't have a <title>
// @namespace   JeffersonScher
// @include     *
// @version     1.1
// @grant       none
// @author      Jefferson "jscher2000" Scher
// @copyright   2014 Jefferson Scher
// @license     BSD 3-clause
// @updateURL https://openuserjs.org/meta/jscher2000/Set_Missing_Title_to_Page_Name.meta.js
// ==/UserScript==

// Don't run in framed pages, only top level pages
if (window.self == window.top){
  // If the <title> is missing or blank
  if (!document.title || document.title === ""){
    // Extract the last part of the path to the page and assign that as the title 
    var loc = location.pathname;
    document.title = decodeURIComponent(loc.substr(loc.lastIndexOf("/")+1));
  }
}