Full Height GitHub PR Status List

removes the max height of the merge status list in Github PRs to display all the checks without scrolling.

目前为 2024-04-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Full Height GitHub PR Status List
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description removes the max height of the merge status list in Github PRs to display all the checks without scrolling.
  6. // @author Othman Shareef (othmanosx@gmail.com)
  7. // @match https://github.com/*
  8. // @icon https://github.githubassets.com/favicons/favicon.svg
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. (function () {
  13. 'use strict';
  14. const elementSelector = '.merge-status-list';
  15.  
  16. const timers = new Map();
  17.  
  18. const waitForSelector = (selector = '', options = { timeout: 1000 }) => {
  19. return new Promise((resolve, reject) => {
  20. // Create a key from the selector and the optional id
  21. const key = selector;
  22.  
  23. // Clear the existing timer for the key (if any)
  24. const existingTimer = timers.get(key);
  25. if (existingTimer) {
  26. clearInterval(existingTimer);
  27. }
  28.  
  29. const startTime = Date.now();
  30. const timer = setInterval(() => {
  31. try {
  32. const element = document.querySelector(selector);
  33. if (element) {
  34. clearInterval(timer);
  35. timers.delete(key);
  36. resolve(element);
  37. } else if (Date.now() - startTime >= options.timeout) {
  38. clearInterval(timer);
  39. timers.delete(key);
  40. reject(new Error('Timeout ' + key));
  41. }
  42. } catch (error) {
  43. clearInterval(timer);
  44. timers.delete(key);
  45. reject(new Error('Invalid selector: ' + selector));
  46. }
  47. }, 100);
  48.  
  49. // Store the new timer
  50. timers.set(key, timer);
  51. });
  52. };
  53.  
  54. const removeMaxHeight = async () => {
  55. try {
  56. await waitForSelector(elementSelector);
  57. const existingCopyBtn = document.querySelector(elementSelector);
  58. existingCopyBtn.style.maxHeight = 'none';
  59. } catch (error) {
  60. console.error(error);
  61. }
  62. };
  63.  
  64. const observer = new MutationObserver(removeMaxHeight);
  65.  
  66. observer.observe(document.body, {
  67. childList: true,
  68. subtree: true,
  69. });
  70. })();