Feedly LastModified Tweak

Replace the original relative date with absolute published/received date on Feedly

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Feedly LastModified Tweak
// @version        0.0.3.2
// @description    Replace the original relative date with absolute published/received date on Feedly
// @author         nodaguti
// @license        MIT License
// @include        http://feedly.com/*
// @include        https://feedly.com/*
// @run-at         document-end
// @note           This script is based on Feedly LastModified Fix (http://userscripts.org/scripts/show/292592) by ark4951.
// @grant          GM_addStyle
// @namespace https://greasyfork.org/users/1453
// ==/UserScript==

(function(){

// --- config ---

// Show received date instead of published date.  true/false (Default: false)
var USE_RECEIVED = false;

// Always show full date string.  true/false (Default: false)
// ** This option works on Title Only view only. **
var ALWAYS_FULL_DATE = false;

// Hide seconds if an article was published today  true/false (Default: false)
var HIDE_SECONDS = false;

// --- /config ---


function init(){
	var mo = new MutationObserver(function(){
		Array.prototype.slice.call(document.querySelectorAll("div.lastModified > span, div.metadata > span[title*='GMT']")).forEach(function(item){
			fixLastModified(item);
		});
	});

	mo.observe(document.getElementById("box"), { childList:true, subtree:true });

	GM_addStyle("\
		.lastModified{\
			/* Remove width limitation of div.lastModified */\
			width: auto !important;\
			overflow: auto !important;\
		}\
		.lastModifiedStr{\
			display: none;\
		}\
		.u0Entry .lastModifiedStr{\
			display: inline;\
		}\
		.u0Entry .lastModifiedFullStr{\
			display: none;\
		}\
		.u0Entry:hover .lastModifiedFullStr{\
			display: inline;\
		}\
		.u0Entry:hover .lastModifiedStr{\
			display: none;\
		}\
	");

	if(ALWAYS_FULL_DATE){
		GM_addStyle("\
			.u0Entry .lastModifiedFullStr{\
				display: inline;\
			}\
			.u0Entry .lastModifiedStr{\
				display: none;\
			}\
		");
	}
}


function fixLastModified(item){
	if(item.dataset.lastModified) return;

	var fixedDateString = USE_RECEIVED ?
		(item.title.match(/Received:(.+?GMT)/i) || [])[1] :
		(item.title.match(/published:(.+?GMT)/i) || [])[1];

	if(!fixedDateString) return;

	var fixedDate = new Date(fixedDateString);

	if((new Date()).getDate() === fixedDate.getDate()){
		item.innerHTML = "<span class='lastModifiedStr'>" +
			(
				HIDE_SECONDS ? ("0" + fixedDate.getHours()).slice(-2) + ":" + ("0" + fixedDate.getMinutes()).slice(-2) :
							   fixedDate.toLocaleTimeString()
			) + "</span>";
	}else{
		item.innerHTML = "<span class='lastModifiedStr'>" + fixedDate.toLocaleDateString() + "</span>";
	}

	item.dataset.lastModified = fixedDate.toLocaleString();
	item.innerHTML += "<span class='lastModifiedFullStr'>" + fixedDate.toLocaleString() + "</span>";
}


init();

})();