Skip to content

Instantly share code, notes, and snippets.

@1nsp1r3rnzt
Created January 6, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1nsp1r3rnzt/527adde35116efd88e1662d188c2e65b to your computer and use it in GitHub Desktop.
Save 1nsp1r3rnzt/527adde35116efd88e1662d188c2e65b to your computer and use it in GitHub Desktop.
// ==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