Mark Stack Overflow Outdated Answers

Changed the display time of the Stack Overflow Q & A page to ISO format and marked outdated responses

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name               Mark Stack Overflow Outdated Answers
// @version            1.1
// @name:zh-CN         标记Stack Overflow的过时答复
// @description        Changed the display time of the Stack Overflow Q & A page to ISO format and marked outdated responses
// @description:zh-CN  将Stack Overflow 问答页面显示时间改为ISO格式的, 并标记出过时的答复
// @namespace          StackOverflow
// @author             fengxiaochuang
// @match              https://*.stackoverflow.com/questions/*
// @grant              none
// @run-at             document-end
// ==/UserScript==

var currentYear =  (new Date()).getYear();
function check_expired_reply(text){
    var year = text.split("-")[0];
    if ((year * 1) - currentYear < 1898){
        return "<font style='color:red;text-decoration:line-through '>"+ text + "</font>"
    } else {
        return text;
    }
}

$(".relativetime").each(function(index,elem){
    $(this).html(check_expired_reply($(this).prop("title")))
})

$(".relativetime-clean").each(function(index,elem){
    $(this).html(check_expired_reply($(this).prop("title")))
})