Greasy Fork

Greasy Fork is available in English.

Full timestamps on Facebook posts

Shows full timestamps on Facebook posts

当前为 2017-01-21 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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  http://greasyfork.icu/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.01
// @namespace http://greasyfork.icu/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('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. */