Run Workflow Label Enhancer

Changes the label of branch selection dropdown in Run Workflow Action from "Use Workflow From" to "Destination Branch"

  1. // ==UserScript==
  2. // @name Run Workflow Label Enhancer
  3. // @namespace https://sanketmishra.me
  4. // @version 0.1
  5. // @description Changes the label of branch selection dropdown in Run Workflow Action from "Use Workflow From" to "Destination Branch"
  6. // @author Sanket Mishra
  7. // @match https://github.com/*
  8. // @match https://*.github.com/*
  9. // @icon https://github.githubassets.com/favicons/favicon-dark.png
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. const ACTIONS_PAGE_REGEX = /\/actions\/workflows\/.+\.yaml$/;
  17. const INTERVAL_DURATION = 1000;
  18.  
  19. let intervalId = null;
  20.  
  21. function isPrActionsPage() {
  22. return ACTIONS_PAGE_REGEX.test(window.location.pathname);
  23. }
  24.  
  25. function replaceBranchSelectionLabel() {
  26. const parentDiv = document.getElementsByClassName("branch-selection")[0];
  27.  
  28. if (!parentDiv) {
  29. return;
  30. }
  31.  
  32. const labelDiv = [...parentDiv.children].find(
  33. (child) => child.textContent.trim().toLowerCase() === "use workflow from"
  34. );
  35.  
  36. if (!labelDiv) {
  37. return;
  38. }
  39.  
  40. labelDiv.textContent = "Destination Branch";
  41. }
  42.  
  43. function shouldRun() {
  44. return isPrActionsPage();
  45. }
  46.  
  47. function execute() {
  48. if (shouldRun()) {
  49. replaceBranchSelectionLabel();
  50. }
  51. }
  52.  
  53. function runOnInterval() {
  54. if (intervalId !== null) {
  55. clearInterval(intervalId);
  56. intervalId = null;
  57. }
  58.  
  59. // Run it immediately for the first time
  60. execute();
  61.  
  62. // Setup an interval to check whether the bors button is in DOM
  63. // Add it to the DOM if not present. Do nothing if present.
  64. intervalId = setInterval(() => {
  65. execute();
  66. }, INTERVAL_DURATION);
  67. }
  68.  
  69. runOnInterval();
  70. })();

QingJ © 2025

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