1nsp1r3rnzt
1/6/2017 - 4:46 PM

Truncate_Hide_PageTitle.js

// ==UserScript==
// @name           Truncate and Hide Page Title
// @namespace      my
// @version        0.2
// @description    Display first word of the page title
// @include        https://*
// @include        www*
// @include        http://*
// @copyright  2017, Ranjit Saini
// ==/UserScript==

var old_title = document.title;
var new_title = getFirstWord(old_title);
var new_title = new_title.substr(0, 4);

function getFirstWord(str) {
        if (str.indexOf(' ') === -1)
            return str;
        else
            return str.substr(0, str.indexOf(' '));
    }


window.addEventListener('load',
  function (e) {
    document.title="~~~" + new_title + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
 }, false);