Last active
March 13, 2020 23:52
-
-
Save spixi/d399b36ac76217b172ea9a583f198660 to your computer and use it in GitHub Desktop.
FB Timestamp Displayer
This file contains hidden or 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 FB Timestamp Displayer | |
// @namespace Facebook | |
// @match http://*.facebook.com/* | |
// @match https://*.facebook.com/* | |
// @run-at document-start | |
// @version 0.1 | |
// @author spixi | |
// @description Shows the timestamp of Facebook posts | |
// ==/UserScript== | |
//FB Timestamp Displayer | |
//Copyright (C) 2020 Marius Spix | |
//[email protected] | |
// | |
//This program is free software; you can redistribute it and/or | |
//modify it under the terms of the GNU Lesser General Public | |
//License as published by the Free Software Foundation; either | |
//version 3 of the License, or (at your option) any later version. | |
// | |
//This program is distributed in the hope that it will be useful, | |
//but WITHOUT ANY WARRANTY; without even the implied warranty of | |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
//Lesser General Public License for more details. | |
// | |
//You should have received a copy of the GNU Lesser General Public License | |
//along with this program; if not, write to the Free Software Foundation, | |
//Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
"use strict"; | |
document.addEventListener("DOMContentLoaded", function(){ | |
nodes = document.getElementsByClassName('timestampContent'); | |
for (i = 0; i < nodes.length; ++i) { | |
node[i].innerText = new Date(parseInt(node[i].parentNode().getAttribute('data-utime'))*1000).toLocaleString(); | |
} | |
}); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if(mutation.addedNodes.length == 1 && mutation.target.classList.contains("livetimestamp")) { //mutation.target.hasAttribute('data-utime') | |
var node = mutation.addedNodes[0]; | |
node.innerText = new Date(parseInt(mutation.target.getAttribute('data-utime'))*1000).toLocaleString(); | |
} | |
}); | |
}); | |
observer.observe(document, { childList: true, subtree: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment