PR page improvements

many things for github PRs

  1. // ==UserScript==
  2. // @name PR page improvements
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description many things for github PRs
  6. // @author Me
  7. // @match https://github.com/ebuzzing/*/pull/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. let lastUrl = location.href;
  15.  
  16. // --------
  17. // -------- PR jobs no scroll, infinite height
  18. // --------
  19. // Add style to the document
  20. const style = document.createElement('style');
  21. style.textContent = '.branch-action-item.open>.merge-status-list.hide-closed-list { max-height: 1000vh !important; }';
  22. document.head.appendChild(style);
  23.  
  24. // Create a MutationObserver to monitor the DOM for changes
  25. const observer = new MutationObserver(mutations => {
  26. mutations.forEach(mutation => {
  27. if (mutation.addedNodes.length > 0) {
  28. // Check if any of the added nodes contain the elements we are interested in
  29.  
  30. // --------
  31. // -------- PR jobs links target blank
  32. // --------
  33. document.querySelectorAll('a.status-actions').forEach(e => {
  34. e.setAttribute('target', '_blank');
  35. });
  36.  
  37. // --------
  38. // -------- All sonarcloud links target blank
  39. // --------
  40. [...document.querySelectorAll('a')].filter(e => e.getAttribute('href').includes("http")).forEach(link => link.setAttribute('target', '_blank'));
  41.  
  42. // --------
  43. // -------- For Marine highlight buttons in red in PRs that do not belong to you
  44. // --------
  45. if (document.querySelector("#partial-discussion-header > div.d-flex.flex-items-center.flex-wrap.mt-0.gh-header-meta > div.flex-auto.min-width-0.mb-2 > a").innerText !== "github-louis-yvelin") Array.from(document.querySelectorAll("div.merge-message button")).forEach((e) => e.setAttribute('style', "background-color: red"));
  46.  
  47. }
  48. lastUrl = location.href;
  49. });
  50. });
  51.  
  52. // Configure the observer to watch for additions to the child list of the target node
  53. const config = { childList: true, subtree: true };
  54.  
  55. // Start observing the document body for changes
  56. observer.observe(document.body, config);
  57.  
  58. // --------
  59. // -------- Add hide whitespace by default
  60. // --------
  61. const goToFilesElement = document.querySelector("#repo-content-pjax-container > div > div.clearfix.js-issues-results > div.px-3.px-md-0.ml-n3.mr-n3.mx-md-0.tabnav > nav > a:nth-child(4)");
  62. goToFilesElement&& goToFilesElement.setAttribute('href', goToFilesElement.getAttribute('href') + '?w=1');
  63. })();

QingJ © 2025

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