Created
February 12, 2018 14:41
-
-
Save chadlavi/18e538397ad9248cda79950d0d5c3919 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 Remove title counts | |
// @namespace https://gist.github.com/chadlavi/18e538397ad9248cda79950d0d5c3919 | |
// @downloadURL https://gist.github.com/chadlavi/18e538397ad9248cda79950d0d5c3919/raw/hide-tile-counts.user.js | |
// @updateURL https://gist.github.com/chadlavi/18e538397ad9248cda79950d0d5c3919/raw/hide-tile-counts.user.js | |
// @version 1.1 | |
// @description make the title of the page always be "Facebook" when on facebook | |
// @author Chad Lavimoniere | |
// @include http*://*.facebook.com/* | |
// @include http*://twitter.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function titleModified() { | |
if (document.getElementsByTagName('title')[0].text.match(/\(\d+\)/g).length > 0) { | |
document.getElementsByTagName('title')[0].text = document.getElementsByTagName('title')[0].text.match(/[^\(\d+\)|\ ]/g).join(''); | |
} | |
} | |
window.onload = function() { | |
var titleEl = document.getElementsByTagName("title")[0]; | |
var docEl = document.documentElement; | |
if (docEl && docEl.addEventListener) { | |
docEl.addEventListener("DOMSubtreeModified", function(evt) { | |
var t = evt.target; | |
if (t === titleEl || (t.parentNode && t.parentNode === titleEl)) { | |
titleModified(); | |
} | |
}, false); | |
} else { | |
document.onpropertychange = function() { | |
if (window.event.propertyName == "title") { | |
titleModified(); | |
} | |
}; | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment