Created
January 6, 2017 16:46
-
-
Save 1nsp1r3rnzt/527adde35116efd88e1662d188c2e65b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment