Github Action Workflow 自动全部启用

自动点击全部 Enable workflow,免去手动一个个点

  1. // ==UserScript==
  2. // @name Github Action Workflow 自动全部启用
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.8
  5. // @description 自动点击全部 Enable workflow,免去手动一个个点
  6. // @author You
  7. // @match https://github.com/*/actions*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13. window.onload = function () {
  14.  
  15. if (enable()) {
  16. let li = document.querySelector("#repo-content-pjax-container > div > div > div.hx_actions-sidebar.col-12.col-lg-3.pr-lg-4.pr-xl-5 > remote-pagination > ul").querySelectorAll("li");
  17.  
  18. for (let i = 1; i < li.length; i++) {
  19. let svg = li[i].querySelector(".octicon,.octicon-stop,mr-2,.color-text-warning");
  20. if (svg.className.animVal.indexOf("color-text-warning") != -1) {
  21. svg.parentNode.click();
  22. break;
  23. }
  24. }
  25. }
  26. if (enable()) {
  27. reload();
  28. }
  29. }
  30.  
  31. function enable() {
  32. let isContinue = true;
  33. let enableButton = document.querySelectorAll("button");
  34. if (enableButton != null) {
  35. for (let i = 0; i < enableButton.length; i++) {
  36. let button = enableButton[i];
  37. if (macth(button.innerHTML, 'Enable workflow')) {
  38. button.click();
  39. //reload();
  40. isContinue = false;
  41. }
  42. }
  43. }
  44. return isContinue;
  45. }
  46.  
  47. function macth(str, macthStr) {
  48. return str.indexOf(macthStr) != -1;
  49. }
  50.  
  51. function reload() {
  52. window.location.reload();
  53. }
  54. })();