Full timestamps on Facebook posts

Shows full timestamps on Facebook posts

目前为 2017-01-22 提交的版本。查看 最新版本

// ==UserScript==
// @name      Full timestamps on Facebook posts
// @description Shows full timestamps on Facebook posts
// @match    *://www.facebook.com/*
// @run-at   document-start
// @grant    GM_addStyle
// @author   wOxxOm & JZersche
// @require  https://gf.qytechs.cn/scripts/12228/code/setMutationHandler.js
//
// @ require  http://momentjs.com/downloads/moment.min.js 
// ~Script requires this unapproved script, remove the space between the @ and the r, before use.
//
// @version 1.02
// @namespace https://gf.qytechs.cn/users/95175
// ==/UserScript==

GM_addStyle(
    '.full-timestamp { opacity: 0.56; color: #f00; }' +
    '.full-timestamp:hover { opacity: 1.0; }' +
    '.full-timestamp:before { content: " ("; }' +
    '.full-timestamp:after  { content: ")"; }'
);

// 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);

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">' + (moment(new Date(abbr.dataset.utime * 1000)).format('dddd, M/DD/YYYY []')) + '' +
            abbr.title.substr(+15, abbr.title.substr.length0)
                                .replace('January','').replace('February','')
                                .replace('March','').replace('April','')
                                .replace('May','').replace('June','')
                                .replace('July','').replace('August','')
                                .replace('September','').replace('October','')
                                .replace('November','').replace('December','')
                                .replace('at','')
                                .replace('pm','PM')
                                .replace('ber','').replace(' 31,','').replace('ry 21,','')
                                .replace('12,','').replace('','')
                                .replace('am','AM')
                                .replace('2017','')
                                .replace('2016','').replace(' 9','9')
                                .replace('017','').replace('016','')
                                .replace(' 18','').replace(' 19','')
                                .replace('ary','').replace('ry','')
                                .replace('er 4','').replace(' 13','')
                                .replace(' 15','').replace('y 10','')
                                .replace(' 20','').replace(' 14','')
                                .replace(' 11,','').replace(' 12','12')
                                .replace(' 22','')
                                .replace('15 ','').replace('er','')
                                .replace(' 27','').replace('r 28','')
                                .replace('30, ','').replace('14 ','')
                                .replace(',','').replace('','') +
                                //':' +
                                (
                                moment(new Date(abbr.dataset.utime * 1000)
                                )
                                .format(' · [UTC]Z')) + '</span>');

    }
}


/* Method #1          (moment(abbr.dataset.utime * 1000).format('dddd, M/DD/YYYY, h:mm:ss A · [UTC]-05:00')) + '</span>'); 
~ Problematic, because old posts end up showing 3 hours ahead, while recent posts show correct time for some unknown reason.*/

/* Method #2          (moment(abbr.dataset.utime * 1000).utcOffset.format('dddd, M/DD/YYYY, h:mm:ss A · [UTC]-05:00')) + '</span>');
~ Use this to subtract 3 hours, resulting in accurate older posts but newer posts show 3 hours behind. */

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址