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://openuserjs.org/users/zachhardesty7
  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-2025, Zach Hardesty (https://zachhardesty.com/)
  7. // @license GPL-3.0-only; http://www.gnu.org/licenses/gpl-3.0.txt
  8. // @version 1.3.2
  9.  
  10. // @homepageURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/raw/master/github-inactive-dev-warning.user.js
  11. // @homepage https://github.com/zachhardesty7/tamper-monkey-scripts-collection/raw/master/github-inactive-dev-warning.user.js
  12. // @homepageURL https://openuserjs.org/scripts/zachhardesty7/Github_-_Inactive_Development_Warning
  13. // @homepage https://openuserjs.org/scripts/zachhardesty7/Github_-_Inactive_Development_Warning
  14. // @supportURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/issues
  15.  
  16.  
  17. // @match https://github.com/*/*
  18. // @require https://github.com/zachhardesty7/tamper-monkey-scripts-collection/raw/refs/tags/onElementReady@0.10.0/utils/onElementReady.js
  19. // ==/UserScript==
  20.  
  21. /* global onElementReady */
  22.  
  23. onElementReady(
  24. "[data-testid='latest-commit-details'] relative-time",
  25. { findOnce: false },
  26. (el) => {
  27. if (document.querySelector("#zh-banner-warning")) {
  28. return
  29. }
  30.  
  31. const date = new Date(el.getAttribute("datetime") || "")
  32. const daysSinceLastCommit = (Date.now() - date.getTime()) / 1000 / 60 / 60 / 24
  33. if (daysSinceLastCommit > 365) {
  34. renderWarning()
  35. } else if (daysSinceLastCommit > 182.5) {
  36. renderCaution()
  37. } else {
  38. /* noop */
  39. }
  40. },
  41. )
  42.  
  43. /** @param {HTMLElement} el - target */
  44. function displayMessage(el) {
  45. document
  46. .querySelector("#js-repo-pjax-container")
  47. ?.insertAdjacentElement("beforebegin", el)
  48. }
  49.  
  50. function renderWarning() {
  51. const banner = document.createElement("div")
  52. banner.id = "zh-banner-warning"
  53. banner.setAttribute(
  54. "style",
  55. `
  56. background-color: red;
  57. height: 100px;
  58. margin-bottom: 20px;
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. color: white;
  63. font-size: 36px;
  64. `,
  65. )
  66.  
  67. banner.textContent = "WARNING: repo hasn't received an update in 1+ year(s)"
  68.  
  69. displayMessage(banner)
  70. }
  71.  
  72. function renderCaution() {
  73. const banner = document.createElement("div")
  74. banner.id = "zh-banner-warning"
  75. banner.setAttribute(
  76. "style",
  77. `
  78. background-color: yellow;
  79. height: 50px;
  80. margin-bottom: 20px;
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. font-size: 24px;
  85. `,
  86. )
  87.  
  88. banner.textContent = "Caution: repo hasn't received an update in 6+ months"
  89.  
  90. displayMessage(banner)
  91. }

QingJ © 2025

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