Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active May 14, 2025 12:37
Show Gist options
  • Save steipete/799f4f7a6ed6e96a02a5539d4a03b5b7 to your computer and use it in GitHub Desktop.
Save steipete/799f4f7a6ed6e96a02a5539d4a03b5b7 to your computer and use it in GitHub Desktop.
Windsurf Auto Continue press button JS. Windsurf Menu Help -> Toggle Developer Tools -> Paste into Console.
// Windsurf Auto Press Continue v13.2 (with added logging)
(() => {
const SCRIPT_NAME = 'Windsurf Auto Press Continue v13.2 (logged)'; // Updated name for clarity
let intervalId = null, lastClick = 0;
// --- Config ---
const BTN_SELECTORS = 'span[class*="bg-ide-button-secondary-background"]';
const BTN_TEXT_STARTS_WITH = 'continue';
const SIDEBAR_SELECTOR = null;
const COOLDOWN_MS = 3000;
const CHECK_MS = 1000;
// --- End Config ---
const clickBtn = () => {
if (Date.now() - lastClick < COOLDOWN_MS) {
// console.log(`${SCRIPT_NAME}: In cooldown.`); // Optional: very verbose
return;
}
const Ctx = (SIDEBAR_SELECTOR ? document.querySelector(SIDEBAR_SELECTOR) : null) ?? document;
if (SIDEBAR_SELECTOR && Ctx === document && !document.querySelector(SIDEBAR_SELECTOR)) console.log(`${SCRIPT_NAME}: Sidebar "${SIDEBAR_SELECTOR}" not found.`);
const allPotentialButtons = Array.from(Ctx.querySelectorAll(BTN_SELECTORS));
if (allPotentialButtons.length === 0) {
// console.log(`${SCRIPT_NAME}: No elements found with selector "${BTN_SELECTORS}".`); // Optional: can be verbose if it runs often
} else {
// console.log(`${SCRIPT_NAME}: Found ${allPotentialButtons.length} potential buttons with selector "${BTN_SELECTORS}".`); // Optional: can be verbose
}
const btnToClick = allPotentialButtons.find(btn => {
const text = (btn.textContent ?? "").replace(/[\s\u00A0]+/g, ' ').trim().toLowerCase();
const style = window.getComputedStyle(btn);
const isActuallyVisible = !!(btn.offsetWidth || btn.offsetHeight || btn.getClientRects().length);
const isNotHidden = style.visibility !== 'hidden';
const isDisplayed = style.display !== 'none';
const isOpaqueEnough = parseFloat(style.opacity) > 0;
const isEnabled = !btn.disabled;
const matchesText = text.startsWith(BTN_TEXT_STARTS_WITH);
const isVisibleAndInteractive = isActuallyVisible && isNotHidden && isDisplayed && isOpaqueEnough && isEnabled;
if (!matchesText) {
// console.log(`${SCRIPT_NAME}: Button with text "${btn.textContent.trim()}" did NOT start with "${BTN_TEXT_STARTS_WITH}".`); // Optional: very verbose
return false;
}
// If it matches text, log why it might not be considered clickable
if (!isVisibleAndInteractive) {
console.log(`${SCRIPT_NAME}: Button "${btn.textContent.trim()}" matched text, but was not fully visible/interactive. Details:`);
if (!isActuallyVisible) console.log(` - Not actually visible (offsetWidth/offsetHeight/getClientRects check failed)`);
if (!isNotHidden) console.log(` - Visibility was 'hidden'`);
if (!isDisplayed) console.log(` - Display was 'none'`);
if (!isOpaqueEnough) console.log(` - Opacity was not > 0 (Value: ${style.opacity})`);
if (!isEnabled) console.log(` - Button was disabled`);
}
return matchesText && isVisibleAndInteractive;
});
if (btnToClick) {
console.log(`${SCRIPT_NAME}: Clicking "${btnToClick.textContent.trim()}"`, btnToClick); // Log the element itself too
btnToClick.click();
lastClick = Date.now();
} else {
if (allPotentialButtons.length > 0) { // Only log this if we found some candidates but none passed all checks
// console.log(`${SCRIPT_NAME}: No suitable button to click this interval.`); // Optional: can be verbose
}
}
};
window.stopWindsurfAutoPressContinue_v13_2 = () => {
if (intervalId) {
clearInterval(intervalId);
console.log(`${SCRIPT_NAME}: Stopped (ID: ${intervalId}).`);
intervalId = null;
} else {
console.log(`${SCRIPT_NAME}: Not running or already stopped.`);
}
};
if (window.stopWindsurfAutoPressContinue_v13_2.intervalId) { // Check for a globally stored ID from a previous run
clearInterval(window.stopWindsurfAutoPressContinue_v13_2.intervalId);
console.log(`${SCRIPT_NAME}: Cleared pre-existing interval.`);
}
intervalId = setInterval(clickBtn, CHECK_MS);
window.stopWindsurfAutoPressContinue_v13_2.intervalId = intervalId; // Store globally for easier clearing if script is re-run
console.log(`${SCRIPT_NAME}: Started (ID: ${intervalId}). Checks every ${CHECK_MS/1000}s. To stop: window.stopWindsurfAutoPressContinue_v13_2()`);
clickBtn(); // Initial check
})();
@steipete
Copy link
Author

If you want to un-stuck Cursor/Windsurf even further (these dreaded edit_file issues), use my Claude Code MCP: https://github.com/steipete/claude-code-mcp

@steipete
Copy link
Author

TODO: For some reason this only works once you use the inspector to click on the button at least once, I'll fix that up later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment