Copilot Continue

Auto-clicks the "Continue" button when GitHub Copilot gets stuck

当前为 2025-06-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Copilot Continue
  3. // @namespace https://snomiao.com
  4. // @match *://*/*
  5. // @grant none
  6. // @version 1.1.0
  7. // @author snomiao
  8. // @description Auto-clicks the "Continue" button when GitHub Copilot gets stuck
  9. // @homepage https://github.com/snomiao/copilot-continue.user.js
  10. // @supportURL https://github.com/snomiao/copilot-continue.user.js/issues
  11. // @license MIT
  12. // @compatible chrome
  13. // @compatible firefox
  14. // @compatible edge
  15. // @compatible opera
  16. // ==/UserScript==
  17.  
  18. // webhook...update = fetch(globalThis.GM_info.script.downloadURL)
  19.  
  20. /*
  21. * Copilot Continue - A userscript to automatically continue GitHub Copilot
  22. *
  23. * This script automatically clicks the "Continue" button when GitHub Copilot
  24. * shows interruption messages like:
  25. * - "Copilot has been working on this problem for a while"
  26. * - "Run command in the terminal"
  27. * - "Allow task run?"
  28. *
  29. * The script runs in VS Code web environments and checks for interruptions every second.
  30. */
  31.  
  32. const enable = !!document.querySelector("meta#vscode-workbench-auth-session");
  33.  
  34. if (enable) main()
  35.  
  36. function main() {
  37. const clear = useInterval(() => clickContinue, 1e3);
  38. return () => clear();
  39. }
  40.  
  41. function clickContinue() {
  42. const stucked = $$("div.rendered-markdown")
  43. .map((e) => e.innerText)
  44. .flatMap((e) => (e ? [e] : [])) // empty filter
  45. .findLast(
  46. (s) =>
  47. false ||
  48. s.match(/Copilot has been working on this problem for a while/) ||
  49. s.match(/Run command in the terminal/) ||
  50. s.match(/Allow task run\?/)
  51. );
  52. if (!stucked) return;
  53. const btn = $$("a.monaco-button").findLast(
  54. (e) => e.textContent === "Continue"
  55. );
  56. if (!btn) return;
  57. btn.click();
  58. return true;
  59. }
  60.  
  61. function $$(sel) {
  62. return [...document.querySelectorAll(sel)];
  63. }
  64.  
  65. function useInterval(...args) {
  66. const id = setInterval(...args);
  67. return () => clearInterval(id);
  68. }