Mark Stack Overflow Outdated Answers

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

  1. // ==UserScript==
  2. // @name Mark Stack Overflow Outdated Answers
  3. // @version 1.1
  4. // @name:zh-CN 标记Stack Overflow的过时答复
  5. // @description Changed the display time of the Stack Overflow Q & A page to ISO format and marked outdated responses
  6. // @description:zh-CN 将Stack Overflow 问答页面显示时间改为ISO格式的, 并标记出过时的答复
  7. // @namespace StackOverflow
  8. // @author fengxiaochuang
  9. // @match https://*.stackoverflow.com/questions/*
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. var currentYear = (new Date()).getYear();
  15. function check_expired_reply(text){
  16. var year = text.split("-")[0];
  17. if ((year * 1) - currentYear < 1898){
  18. return "<font style='color:red;text-decoration:line-through '>"+ text + "</font>"
  19. } else {
  20. return text;
  21. }
  22. }
  23.  
  24. $(".relativetime").each(function(index,elem){
  25. $(this).html(check_expired_reply($(this).prop("title")))
  26. })
  27.  
  28. $(".relativetime-clean").each(function(index,elem){
  29. $(this).html(check_expired_reply($(this).prop("title")))
  30. })