Foldable GitLab boards

Allows to fold any board in GitLab boards

当前为 2019-05-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Foldable GitLab boards
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Allows to fold any board in GitLab boards
  6. // @author Himalay
  7. // @include https://gitlab.*
  8. // ==/UserScript==
  9.  
  10. let foldableGitLabBoardsIntervalCount = 0
  11. const foldableGitLabBoardsInterval = setInterval(() => {
  12. const boards = [...document.querySelectorAll('.board.is-draggable')]
  13.  
  14. if (foldableGitLabBoardsIntervalCount > 100) clearInterval(foldableGitLabBoardsInterval)
  15. if (boards.length) {
  16. clearInterval(foldableGitLabBoardsInterval)
  17.  
  18. document.body.appendChild(
  19. Object.assign(document.createElement('style'), {
  20. textContent: `.board.is-collapsed .board-title>span {
  21. width: auto;
  22. margin-top: 24px;
  23. }`,
  24. }),
  25. )
  26.  
  27. boards.forEach((board) => {
  28. const boardTitle = board.querySelector('.board-title')
  29. const toggleIcon = Object.assign(document.createElement('i'), {
  30. classList: 'fa fa-fw board-title-expandable-toggle fa-caret-down',
  31. style: 'cursor: pointer',
  32. })
  33.  
  34. toggleIcon.addEventListener('click', (e) => {
  35. board.classList.toggle('is-collapsed')
  36. e.target.classList.toggle('fa-caret-down')
  37. e.target.classList.toggle('fa-caret-right')
  38. })
  39.  
  40. boardTitle.prepend(toggleIcon)
  41. })
  42. }
  43.  
  44. foldableGitLabBoardsIntervalCount++
  45. }, 100)