Redmine: Add notes directly at the bottom

Make it easy to add notes without the need to click a button.

目前为 2025-01-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Redmine: Add notes directly at the bottom
  3. // @namespace im.outv.redmine.addnotes.redmine
  4. // @version 2024.1
  5. // @description Make it easy to add notes without the need to click a button.
  6. // @author Outvi V
  7. // @license MIT
  8. // @match https://www.redmine.org/issues/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. const HIDE_CLASS_NAME = 'addnotes-hide'
  13.  
  14. function addCss(css) {
  15. var block = document.createElement('style')
  16. block.innerText = css
  17. document.head.appendChild(block)
  18. return block
  19. }
  20.  
  21. function isToShow(fieldset) {
  22. // As of Redmine 6.0.2
  23. if (['add_notes', 'add_attachments'].includes(fieldset.id)) {
  24. return true;
  25. }
  26.  
  27. // redmine.org
  28. if (["Notes", "Files"].includes(fieldset.querySelector("legend")?.innerText)) {
  29. fieldset.classList.remove("addnotes-hide")
  30. return true;
  31. }
  32.  
  33. return false;
  34. }
  35.  
  36. ;(function () {
  37. 'use strict'
  38.  
  39. const hiddenCss = addCss(`
  40. .${HIDE_CLASS_NAME} { display: none; }
  41. `)
  42.  
  43. const dUpdate = document.querySelector('#update')
  44. dUpdate.style = ''
  45.  
  46. const dEditAreas = [...dUpdate.querySelectorAll('form div.box > fieldset')]
  47.  
  48. for (const fieldset of dEditAreas) {
  49. if (!isToShow(fieldset)) {
  50. fieldset.classList.add(HIDE_CLASS_NAME)
  51. }
  52. }
  53.  
  54. const _showAndScrollTo = window.showAndScrollTo
  55. window.showAndScrollTo = function (id, focus, ...args) {
  56. if (id === 'update' && focus === 'issue_notes') {
  57. hiddenCss.innerText = ''
  58. }
  59. _showAndScrollTo(id, focus, ...args)
  60. }
  61. })()

QingJ © 2025

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