GitHub Clear Dashboard

Removes trash from github dashboard.

  1. // ==UserScript==
  2. // @name GitHub Clear Dashboard
  3. // @description Removes trash from github dashboard.
  4. // @version 1.0.1
  5. // @author tariel36
  6. // @namespace https://github.com/tariel36/github-clear-dashboard
  7. // @match https://github.com/
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. const inter = 100;
  12. const maxCounter = (3 * 1000) / inter;
  13.  
  14. let counter = 0;
  15.  
  16. const interval = setInterval(() => {
  17. tryLoadMore();
  18. centerList();
  19. }, inter);
  20.  
  21. function clearDashboard() {
  22. const mainDiv = document.querySelector('.application-main > div > div > div');
  23.  
  24. if (mainDiv) {
  25. mainDiv.remove();
  26. }
  27.  
  28. const side = getSide();
  29.  
  30. if (side) {
  31. side.style = "display: flex; justify-items: center; justify-content: center; width: 100%;";
  32.  
  33. const innerDiv = side.querySelector('div');
  34.  
  35. if (innerDiv) {
  36. innerDiv.style = 'min-width: 350px; max-width: 800px; width: 50%;';
  37. }
  38. }
  39.  
  40. centerList();
  41. }
  42.  
  43.  
  44. function tryLoadMore() {
  45. counter++;
  46.  
  47. if (counter >= maxCounter) {
  48. clearInterval(interval);
  49. return;
  50. }
  51.  
  52. const side = getSide();
  53.  
  54. const btn = side?.querySelector('button');
  55.  
  56. if (!btn) {
  57. return;
  58. }
  59.  
  60. btn.classList.remove('width-full');
  61.  
  62. const form = document.querySelector('.js-repos-container > form');
  63.  
  64. if (form) {
  65. form.style = 'text-align: center';
  66. }
  67.  
  68. btn.click();
  69. }
  70.  
  71. function centerList() {
  72. const side = getSide();
  73.  
  74. if (!side) {
  75. return;
  76. }
  77.  
  78. const repos = [...side.querySelectorAll('.list-style-none')];
  79.  
  80. if (!repos) {
  81. return;
  82. }
  83.  
  84. repos.forEach(x => {
  85. x.querySelectorAll('li')
  86. .forEach(y => {
  87. y.style = 'text-align: center;';
  88. y.querySelector('div').style = 'justify-content: center;';
  89. });
  90. });
  91. }
  92.  
  93. function getSide() {
  94. return document.querySelector('aside.feed-left-sidebar');;
  95. }
  96.  
  97. window.addEventListener('load', function() {
  98. clearDashboard();
  99. }, false);

QingJ © 2025

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