Copilot Continue

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

30.06.2025 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Copilot Continue
// @namespace   https://snomiao.com
// @match       *://*/*
// @grant       none
// @version     1.2.7
// @author      snomiao
// @description Auto-clicks the "Continue" button when GitHub Copilot gets stuck
// @homepage    https://github.com/snomiao/copilot-continue.user.js
// @supportURL  https://github.com/snomiao/copilot-continue.user.js/issues
// @license     MIT
// @compatible  chrome
// @compatible  firefox
// @compatible  edge
// @compatible  opera
// ==/UserScript==

/*
 * Copilot Continue - A userscript to automatically continue GitHub Copilot
 *
 * This script automatically clicks the "Continue" button when GitHub Copilot
 * shows interruption messages like:
 * - "Copilot has been working on this problem for a while"
 * - "Run command in the terminal"
 * - "Allow task run?"
 *
 * The script runs in VS Code web environments and checks for interruptions every second.
 *
 * Notes for Copilot: dont forget to bump version number in the header when you modify this script.
 */

const actionMatchers = {
  cilckContinue: [
    /^Copilot has been working on this problem for a while/,
    /^Run command in terminal/,
    /^Run command `.*`\?/,
    /^Run command in background terminal/,
    /^Continue to iterate\?/,
    /^Allow task run\?/,
    /^Allow test run\?/,
  ],
  clickGrant: [
    /^To get more relevant Copilot Chat results, we need permission to read the contents of your repository on GitHub./,
  ],
  clickTryAgain: [
    /^The model unexpectedly did not return a response, which may indicate a service issue. Please report a bug./,
    /^Sorry, your request failed. Please try again./,
  ],
  clickRetryIcon: [/^Language model unavailable/],
};

const actions = {
  default: () =>
    console.warn("No action matched. Please check the action matchers."),
  refresh: () => (location.reload()),
  clickRetryIcon: () => $$('a[aria-label="Retry"]').findLast(Boolean)?.click(),
  cilckContinue: () =>
    $$("a.monaco-button").findLast(textContentEq("Continue"))?.click(),
  clickGrant: () =>
    $$("a.monaco-button").findLast(textContentEq("Grant"))?.click(),
  clickTryAgain: (
    (tryAgainCount = 0) =>
      () => {
        if (tryAgainCount >= 3) return (location.reload());
        const btn = $$("a.monaco-button").findLast(textContentEq("Try Again"));
        if (!btn) return;
        btn.click();
        tryAgainCount++;
      }
  )(),
};
function textContentEq(content) {
  return (e) => e.textContent === content;
}
const enable = !!document.querySelector("meta#vscode-workbench-auth-session");

// Prevent double execution if loaded both as userscript and extension
if (enable && !globalThis.copilotContinueLoaded) {
  main();
  globalThis.copilotContinueLoaded = true;
}

function main() {
  const clear = useInterval(() => loop(), 1e3);
  return () => clear();
}
function loop() {
  const text = $$("div.rendered-markdown")
    .map((e) => e.innerText)
    .flatMap((e) => (e ? [e] : [])) // empty filter
    .map((e) => e.replace(/\s+/g, " "));

  for (const [action, matchers] of Object.entries(actionMatchers)) {
    if (text.some((s) => matchers.some((m) => s.match(m)))) {
      (actions[action] || actions.default)?.();
      return;
    }
  }
}

function $$(sel) {
  return [...document.querySelectorAll(sel)];
}

function useInterval(...args) {
  const id = setInterval(...args);
  return () => clearInterval(id);
}