易读时间日期 for Github和StackOverflow等网站

把Github,stackoverflow等网站的时间转换为ISO格式,方便阅读。

  1. // ==UserScript==
  2. // @name ISO Formatted Time/Date for Github & StackOverflow
  3. // @name:zh-CN 易读时间日期 for Github和StackOverflow等网站
  4. // @namespace coolan
  5. // @version 1.0
  6. // @description Change time/date to ISO format for Github and stackoverflow websites.
  7. // @description:zh-CN 把Github,stackoverflow等网站的时间转换为ISO格式,方便阅读。
  8. // @author coolan
  9. // @match https://github.com/*
  10. // @match https://askubuntu.com/*
  11. // @match https://stackapps.com/*
  12. // @match https://superuser.com/*
  13. // @match https://serverfault.com/*
  14. // @match https://mathoverflow.net/*
  15. // @match https://*.stackoverflow.com/*
  16. // @match https://*.stackexchange.com/*
  17. // @icon https://github.com/favicon.ico
  18. // @grant none
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. 'use strict';
  23. function replaceTime(){
  24. var time_list = document.querySelectorAll("span.relativetime, span.relativetime-clean")
  25. time_list.forEach(function(ele) {
  26. ele.innerText = ele.title.substring(0,16);
  27. })
  28. var items = document.getElementsByTagName("relative-time")
  29. for (var i = 0; i < items.length; i++) {
  30. var item = items[i];
  31. item.innerHTML = item.getAttribute("datetime").substring(0,16).replace(/T/," ");
  32. }
  33. }
  34. replaceTime();
  35. var observer = new MutationObserver(function (mutations, observer) {
  36. replaceTime();
  37. });
  38. var body = document.querySelector('body');
  39. var options = { 'childList': true };
  40. observer.observe(body, options);
  41.  
  42. })();

QingJ © 2025

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