提示文章时间

提示文章时间。支持csdn,掘金,思否,博客园,stackoverflow,知乎专栏,简书。有问题发邮件:xky1000@qq.com

  1. // ==UserScript==
  2. // @name 提示文章时间
  3. // @namespace xky1000.cn
  4. // @match https://blog.csdn.net/*
  5. // @match https://juejin.cn/*
  6. // @match https://segmentfault.com/*
  7. // @match https://www.jianshu.com/p/*
  8. // @match https://www.cnblogs.com/*/p/*
  9. // @match https://stackoverflow.com/questions/*
  10. // @match https://zhuanlan.zhihu.com/p/*
  11. // @version 0.1.5
  12. // @author xky
  13. // @grant GM_addStyle
  14. // @license MIT
  15. // @description 提示文章时间。支持csdn,掘金,思否,博客园,stackoverflow,知乎专栏,简书。有问题发邮件:xky1000@qq.com
  16. // ==/UserScript==
  17.  
  18.  
  19. GM_addStyle(`#display-date {
  20. position: fixed;
  21. top: 0;
  22. left: 0;
  23. z-index: 10000;
  24. background-color: #ff9999;
  25. padding: 0 13px 0 8px;
  26. color:#000;
  27. font-size: 10px;
  28. }`)
  29. {
  30. function display(text) {
  31. const date = new Date(text);
  32. const year = date.getFullYear();
  33. const month = date.getMonth() + 1;
  34. const day = date.getDate();
  35. const div = document.createElement('div')
  36. div.id = 'display-date'
  37. div.innerText = `${year}/${month}/${day}`
  38. document.body.appendChild(div);
  39. }
  40.  
  41. const siteHandlers = {
  42. 'blog.csdn.net': () => display(document.querySelector('.time').innerText.match(/\d{4}-\d{2}-\d{2}/)),
  43. 'juejin.cn': () => setTimeout(() => display(document.querySelector('.meta-box .time').dateTime), 500),
  44. 'segmentfault.com': () => display(document.querySelector('time').dateTime),
  45. 'www.jianshu.com': () => setTimeout(() => display(document.querySelector('time').dateTime), 500),
  46. 'www.cnblogs.com': () => display(document.querySelector('#post-date').innerText),
  47. 'stackoverflow.com': () => display(document.querySelector('.relativetime').title),
  48. 'zhuanlan.zhihu.com': () => display(document.querySelector('.ContentItem-time').innerText.match(/\d{4}-\d{2}-\d{2}/))
  49. }
  50.  
  51. siteHandlers[location.hostname]();
  52. }

QingJ © 2025

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