RunPod Show Stop Pod Button. RunPod Larger Logs

RunPod 添加 Stop Pod 按钮。RunPod Log 页面放大

  1. // ==UserScript==
  2. // @name RunPod Show Stop Pod Button. RunPod Larger Logs
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-12-24
  5. // @description RunPod 添加 Stop Pod 按钮。RunPod Log 页面放大
  6. // @author Ganlv
  7. // @match https://www.runpod.io/console/*
  8. // @icon https://www.runpod.io/favicon.ico
  9. // @grant GM_addStyle
  10. // @grant unsafeWindow
  11. // @license MIT
  12. // ==/UserScript==
  13. (function () {
  14. 'use strict';
  15. GM_addStyle(`
  16. .css-fm445e {
  17. align-items: initial;
  18. }
  19. body > div.MuiDialog-root.MuiModal-root > div.MuiDialog-container.MuiDialog-scrollPaper > div.css-1f59w55 {
  20. max-width: initial;
  21. height: 100%;
  22. }
  23. #modal-root .w-full.sm\\:max-w-\\[40rem\\] {
  24. max-width: 120rem;
  25. }
  26. #modal-root .sm\\:min-h-\\[60dvh\\] {
  27. min-height: 95dvh;
  28. }
  29. `);
  30. setInterval(() => {
  31. document.querySelectorAll('span[aria-label="More Actions"][id^="pod-button-"]').forEach((el) => {
  32. const podId = el.id.replace('pod-button-', '');
  33. if (el?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.querySelector('.MuiLabel-success') && el?.parentElement?.parentElement?.lastElementChild?.textContent !== 'Stop Pod') {
  34. const span = document.createElement('span');
  35. span.textContent = 'Stop Pod';
  36. span.classList.add('custom-stop-pod-button');
  37. span.style.display = 'flex';
  38. span.style.marginLeft = '9px';
  39. span.style.padding = '6px 13.5px';
  40. span.style.alignItems = 'center';
  41. span.style.color = '#ffffff';
  42. span.style.backgroundColor = '#ff0000';
  43. span.style.borderRadius = '10px';
  44. span.style.fontWeight = 'bold';
  45. span.style.fontSize = '0.8125rem';
  46. span.style.fontFamily = 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"';
  47. span.style.lineHeight = '1.5';
  48. span.style.textDecoration = 'none';
  49. span.style.cursor = 'pointer';
  50. span.addEventListener('click', () => {
  51. if (confirm(`Are you sure to stop pod ID: ${podId}?`)) {
  52. fetch('https://api.runpod.io/graphql', {
  53. method: 'POST',
  54. headers: {
  55. 'Authorization': `Bearer ${unsafeWindow.Clerk.session.lastActiveToken.jwt.claims.__raw}`,
  56. 'Content-Type': 'application/json',
  57. 'X-Team-Id': unsafeWindow.localStorage.getItem('selectedTeam'),
  58. },
  59. body: JSON.stringify({
  60. operationName: 'stopPod',
  61. query: 'mutation stopPod($input: PodStopInput!) { podStop(input: $input) { id desiredStatus lastStatusChange } }',
  62. variables: {
  63. input: {
  64. podId: podId,
  65. }
  66. },
  67. }),
  68. referrer: 'https://www.runpod.io/',
  69. referrerPolicy: 'strict-origin-when-cross-origin',
  70. mode: 'cors'
  71. }).then(res => res.json()).then(res => {
  72. console.log(res);
  73. document.querySelector('button[aria-label="Refresh"]')?.click();
  74. });
  75. }
  76. });
  77. el?.parentElement?.parentElement?.insertAdjacentElement('beforeend', span);
  78. }
  79. });
  80. }, 1000);
  81. })();