Github - Hide bots and github-actions from dashboards

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

2022-12-09 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  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.6
  7. // @description Hide bot's and github-actions' push from dashboard news
  8. // @copyright 2020, cuzi (https://openuserjs.org/users/cuzi)
  9. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  10. // @icon https://raw.githubusercontent.com/hfg-gmuend/openmoji/master/color/72x72/E045.png
  11. // @match https://github.com/
  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. div.querySelector('.body').style.height = ''
  34. div.querySelector('.body .d-flex').style.padding = ''
  35. div.querySelector('img.avatar').height = '32'
  36. div.querySelector('img.avatar').width = '32'
  37. div.style.cursor = ''
  38. if (div.querySelector('.newexpanderbutton')) {
  39. div.querySelector('.newexpanderbutton').remove()
  40. }
  41. }
  42.  
  43. function hideDiv (div, summary) {
  44. const expandButton = document.querySelector('button.js-details-target:not(.Header-link)[aria-expanded="false"]')
  45. div.style.fontSize = '10px'
  46. if (div.querySelector('.border-bottom')) {
  47. div.querySelector('.border-bottom').classList.replace('border-bottom', 'no-border-bottom')
  48. }
  49. div.querySelector('.Box').style.display = 'none'
  50. div.querySelector('.body').style.height = '22px'
  51. div.querySelector('.body .d-flex').style = 'padding: 0px !important;'
  52. div.querySelector('img.avatar').height = '20'
  53. div.querySelector('img.avatar').width = '20'
  54. div.style.cursor = 'row-resize'
  55. div.addEventListener('click', unhideBot)
  56. const line = div.querySelector('.Details .flex-column .flex-justify-between.flex-items-baseline')
  57. if (line && expandButton && !line.querySelector('button.js-details-target')) {
  58. const newExpandButton = document.createElement('button')
  59. line.appendChild(newExpandButton)
  60. newExpandButton.outerHTML = expandButton.outerHTML.replace('js-details-target', 'js-details-target newexpanderbutton')
  61. }
  62. const aLinkPrimary = div.querySelector('.no-underline a.Link--primary')
  63. if (summary && aLinkPrimary && !div.querySelector('.summaryspan')) {
  64. const summarySpan = document.createElement('span')
  65. summarySpan.classList.add('summaryspan')
  66. summarySpan.appendChild(document.createTextNode(summary.replace(/\s+to\s*$/, '')))
  67. aLinkPrimary.parentNode.appendChild(summarySpan)
  68. }
  69. }
  70.  
  71. function hideBots () {
  72. // Hide single push events
  73. document.querySelectorAll('#dashboard div.push:not(.shotBot),#dashboard div[classes*=push]:not(.shotBot)').forEach(function (div) {
  74. const label = div.querySelector('.body .d-flex .d-flex .Label')
  75. const isAppUrl = div.querySelector('.body .d-flex .d-flex a.Link--primary[href^="/apps/"]')
  76. if (isAppUrl || (label && label.textContent === 'bot')) {
  77. hideDiv(div)
  78. }
  79. })
  80. // Hide grouped items
  81. document.querySelectorAll('#dashboard div.body:not(.shotBot)').forEach(function (div) {
  82. const isAppUrl = div.querySelector('.js-news-feed-event-group .d-inline-block[href^="/apps"] .avatar')
  83. if (isAppUrl) {
  84. const summary = div.querySelector('.dashboard-rollup-item>span') ? div.querySelector('.dashboard-rollup-item>span').textContent : null
  85. hideDiv(div, summary)
  86. }
  87. })
  88. }
  89.  
  90. hideBots()
  91. const iv = window.setInterval(hideBots, 200)
  92. window.setTimeout(() => window.clearInterval(iv), 5000)
  93. window.setInterval(hideBots, 4000)
  94. })()