Github - Inactive Development Warning

display big banner if project's last commit over 6 months ago and giant banner if over 1 year ago

  1. // ==UserScript==
  2. // @name Github - Inactive Development Warning
  3. // @namespace https://zachhardesty.com
  4. // @author Zach Hardesty <zachhardesty7@users.noreply.github.com> (https://github.com/zachhardesty7)
  5. // @description display big banner if project's last commit over 6 months ago and giant banner if over 1 year ago
  6. // @copyright 2019-2021, Zach Hardesty (https://zachhardesty.com/)
  7. // @license GPL-3.0-only; http://www.gnu.org/licenses/gpl-3.0.txt
  8. // @version 1.3.1
  9.  
  10. // @homepageURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/raw/master/github-inactive-dev-warning.user.js
  11. // @homepageURL https://openuserjs.org/scripts/zachhardesty7/Github_-_Inactive_Development_Warning
  12. // @supportURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/issues
  13.  
  14.  
  15. // @match https://github.com/*/*
  16. // @require https://gf.qytechs.cn/scripts/419640-onelementready/code/onElementReady.js?version=887637
  17. // ==/UserScript==
  18. /* global onElementReady */
  19.  
  20. onElementReady(
  21. ".repository-content .Box-header .js-details-container.Details relative-time",
  22. { findOnce: false },
  23. (el) => {
  24. if (document.querySelector("#zh-banner-warning")) return
  25.  
  26. // @ts-ignore
  27. const date = new Date(el.attributes.datetime.value)
  28. const daysSinceLastCommit =
  29. (Date.now() - date.getTime()) / 1000 / 60 / 60 / 24
  30. if (daysSinceLastCommit > 365) {
  31. renderWarning()
  32. } else if (daysSinceLastCommit > 182.5) {
  33. renderCaution()
  34. } else {
  35. /* noop */
  36. }
  37. }
  38. )
  39.  
  40. /**
  41. * @param {HTMLElement} el - target
  42. */
  43. function displayMessage(el) {
  44. document
  45. .querySelector("#js-repo-pjax-container")
  46. .insertAdjacentElement("beforebegin", el)
  47. }
  48.  
  49. function renderWarning() {
  50. const banner = document.createElement("div")
  51. banner.id = "zh-banner-warning"
  52. banner.setAttribute(
  53. "style",
  54. `
  55. background-color: red;
  56. height: 100px;
  57. margin-bottom: 20px;
  58. display: flex;
  59. justify-content: center;
  60. align-items: center;
  61. color: white;
  62. font-size: 36px;
  63. `
  64. )
  65.  
  66. banner.textContent = "WARNING: repo hasn't received an update in 1+ year(s)"
  67.  
  68. displayMessage(banner)
  69. }
  70.  
  71. function renderCaution() {
  72. const banner = document.createElement("div")
  73. banner.id = "zh-banner-warning"
  74. banner.setAttribute(
  75. "style",
  76. `
  77. background-color: yellow;
  78. height: 50px;
  79. margin-bottom: 20px;
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. font-size: 24px;
  84. `
  85. )
  86.  
  87. banner.textContent = "Caution: repo hasn't received an update in 6+ months"
  88.  
  89. displayMessage(banner)
  90. }

QingJ © 2025

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