Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name FB: Full Timestamps 2018
- // @match https://www.facebook.com/*
- // @match https://*.facebook.com/*
- // @match http://www.facebook.com/*
- // @match http://*.facebook.com/*
- // @run-at document-start
- // @grant GM_addStyle
- // @author wOxxOm & JZersche
- // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
- // @require http://momentjs.com/downloads/moment.min.js
- // @version 3.1
- // @namespace https://greasyfork.org/users/95175
- // @description Shows full timestamps on Facebook posts
- // @downloadURL none
- // ==/UserScript==
- var options = { weekday: 'long', year: 'numeric', month: 'numeric', day: '2-digit' };
- GM_addStyle(
- '.full-timestamp { opacity: 0.85; color: #09f; }' +
- '.full-timestamp:hover { opacity: 1.0; }' +
- '.full-timestamp:before { content: ""; }' +
- '.full-timestamp:after { content: ""; }' +
- '.timestampContent {display: none; }'
- );
- // process the already loaded portion of the page if any
- expandDates(document.querySelectorAll('abbr[data-utime]'));
- // process the stuff added from now on
- setMutationHandler(document, 'abbr[data-utime]', expandDates);
- setMutationHandler(document, '._5pcq', expandPostIDs);
- function expandDates(nodes) {
- for ( var i = 0, abbr; (abbr = nodes[i++]); )
- {
- if (abbr.querySelector('.full-timestamp')) {
- // already processed
- continue;
- }
- abbr.insertAdjacentHTML('beforeend', '<span class="full-timestamp">' +
- ' on ' + abbr.title
- .replace(/am|pm/,'')
- .replace(/0\d/, number => number[1]).replace(218,2018) +
- (moment(new Date(abbr.dataset.utime * 1000)).format(':ss') + abbr.title.match('pm|am') + '' ));
- }
- }
- function expandPostIDs(nodes) {
- for ( var i = 0; i < nodes.length; i++ )
- {
- var element = nodes[i];
- if(element.innerHTML.includes('Post ID') === false && element.className === '_5pcq')
- {
- element.insertAdjacentHTML('beforeend', '<br> ' + element.href.replace('/groups/','Group: ').replace('/permalink/','<br>Post ID: ').slice(24,100).replace('/',''));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement