Github - Hide bots and github-actions from dashboards

Minimizes pushs and commits from github actions and bots from github.com dashboard

As of 2023-09-09. See the latest version.

  1. // ==UserScript==
  2. // @name Github - Hide bots and github-actions from dashboards
  3. // @description Minimizes pushs and commits from github actions and bots from github.com dashboard
  4. // @namespace cuzi
  5. // @author cuzi
  6. // @version 1.8
  7. // @copyright 2020, cuzi (https://openuserjs.org/users/cuzi)
  8. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  9. // @icon https://raw.githubusercontent.com/hfg-gmuend/openmoji/master/color/72x72/E045.png
  10. // @match https://github.com/
  11. // @match https://github.com/dashboard-feed
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict'
  17.  
  18. document.head.appendChild(document.createElement('style')).innerHTML = `
  19. .Details:hover .newexpanderbutton .Link--secondary {
  20. color: var(--color-accent-fg) !important;
  21. }
  22. `
  23.  
  24. function unhideBot (ev) {
  25. const div = this
  26. div.classList.add('shotBot')
  27. div.removeEventListener('click', unhideBot)
  28. div.style.fontSize = ''
  29. if (div.querySelector('.no-border-bottom')) {
  30. div.querySelector('.no-border-bottom').classList.replace('no-border-bottom', 'border-bottom')
  31. }
  32. div.querySelector('.Box').style.display = ''
  33. if (div.querySelector('.body')) {
  34. div.querySelector('.body').style.height = ''
  35. div.querySelector('.body .d-flex').style.padding = ''
  36. } else {
  37. div.querySelector('.d-flex').style.padding = ''
  38. }
  39. div.querySelector('img.avatar').height = '32'
  40. div.querySelector('img.avatar').width = '32'
  41. div.style.cursor = ''
  42. if (div.querySelector('.newexpanderbutton')) {
  43. div.querySelector('.newexpanderbutton').remove()
  44. }
  45. }
  46.  
  47. function hideDiv (div, summary) {
  48. const expandButton = document.querySelector('button.js-details-target:not(.Header-link)[aria-expanded="false"]')
  49. div.style.fontSize = '10px'
  50. if (div.querySelector('.border-bottom')) {
  51. div.querySelector('.border-bottom').classList.replace('border-bottom', 'no-border-bottom')
  52. }
  53. div.querySelector('.Box').style.display = 'none'
  54. if (div.querySelector('.body')) {
  55. div.querySelector('.body').style.height = '22px'
  56. div.querySelector('.body .d-flex').style = 'padding: 0px !important;'
  57. } else {
  58. div.querySelector('.d-flex').style = 'padding: 0px !important;'
  59. }
  60. div.querySelector('img.avatar').height = '20'
  61. div.querySelector('img.avatar').width = '20'
  62. div.style.cursor = 'row-resize'
  63. div.addEventListener('click', unhideBot)
  64. const line = div.querySelector('.Details .flex-column .flex-justify-between.flex-items-baseline')
  65. if (line && expandButton && !line.querySelector('button.js-details-target')) {
  66. const newExpandButton = document.createElement('button')
  67. line.appendChild(newExpandButton)
  68. newExpandButton.outerHTML = expandButton.outerHTML.replace('js-details-target', 'js-details-target newexpanderbutton')
  69. }
  70. const aLinkPrimary = div.querySelector('.no-underline a.Link--primary')
  71. if (summary && aLinkPrimary && !div.querySelector('.summaryspan')) {
  72. const summarySpan = document.createElement('span')
  73. summarySpan.classList.add('summaryspan')
  74. summarySpan.appendChild(document.createTextNode(summary.replace(/\s+to\s*$/, '')))
  75. aLinkPrimary.parentNode.appendChild(summarySpan)
  76. }
  77. }
  78.  
  79. function hideBots () {
  80. // Hide single push events
  81. document.querySelectorAll(`
  82. #dashboard div.push:not(.shotBot),
  83. #dashboard div[classes*=push]:not(.shotBot),
  84. #dashboard div.body:not(.shotBot),
  85.  
  86. [data-repository-hovercards-enabled] div.push:not(.shotBot),
  87. [data-repository-hovercards-enabled] div[classes*=push]:not(.shotBot),
  88. [data-repository-hovercards-enabled] div.body:not(.shotBot)
  89. `).forEach(function (div) {
  90. const label = div.querySelector('.body .d-flex .d-flex .Label')
  91. const isAppUrl = div.querySelector('.body .d-flex .d-flex a.Link--primary[href^="/apps/"]')
  92. if (isAppUrl || (label && label.textContent === 'bot')) {
  93. hideDiv(div)
  94. }
  95. })
  96. // Hide grouped items
  97. document.querySelectorAll(`
  98. #dashboard div.body:not(.shotBot),
  99. [data-repository-hovercards-enabled] div.body:not(.shotBot)
  100. `
  101. ).forEach(function (div) {
  102. const isAppUrl = div.querySelector('.js-news-feed-event-group .d-inline-block[href^="/apps"] .avatar')
  103. if (isAppUrl) {
  104. const summary = div.querySelector('.dashboard-rollup-item>span') ? div.querySelector('.dashboard-rollup-item>span').textContent : null
  105. hideDiv(div, summary)
  106. }
  107. })
  108. }
  109.  
  110. hideBots()
  111. const iv = window.setInterval(hideBots, 200)
  112. window.setTimeout(() => window.clearInterval(iv), 5000)
  113. window.setInterval(hideBots, 5000)
  114. })()