Skip to content

Instantly share code, notes, and snippets.

@chrisle
Last active October 2, 2025 15:23
Show Gist options
  • Save chrisle/c6f187278e27f0168d982cd84de08b92 to your computer and use it in GitHub Desktop.
Save chrisle/c6f187278e27f0168d982cd84de08b92 to your computer and use it in GitHub Desktop.
Claude Code VS Code Extension YOLO Mode
/**
* YOLO Mode for Claude Code in VS Code:
* Automatically clicks YES to any prompts in the Claude VS Code interface.
*
* To use:
* 1. Click Help > Toggle Developer Tools in VS Code.
* 2. Go to the Console tab.
* 3. Type "allow pasting" and press Enter.
* 4. Paste this entire script and press Enter.
* 5. Type "_auto_claude_.start()" to start the auto-clicker.
* 6. Type "_auto_claude_.stop()" to stop the auto-clicker.
*
* Changes:
* - 1.1.0: Improved button detection logic to handle various text patterns and nested iframes.
* - 1.0.0: Initial release.
*/
(function() {
function createAutoClicker() {
let intervalId = null;
let isRunning = false;
function findButtonInIframes(doc = document) {
// Strategy 1: Find button with "Yes" text and a span containing "1"
const buttons = doc.querySelectorAll('button');
for (const button of buttons) {
const text = button.textContent?.trim() || '';
if (text.includes('Yes')) {
const span = button.querySelector('span');
if (span && span.textContent?.trim() === '1') {
return button;
}
}
}
// Strategy 2: Find button by exact text patterns
for (const button of buttons) {
const text = button.textContent?.trim() || '';
if (text === '1 Yes' || text === 'Yes 1' || text === '1Yes') {
return button;
}
}
// Strategy 3: Find any button with "Yes" and contains a number
for (const button of buttons) {
const text = button.textContent?.trim() || '';
if (text.includes('Yes') && /\d/.test(text)) {
return button;
}
}
// Recursively check all iframes
const iframes = doc.querySelectorAll('iframe');
for (const iframe of iframes) {
try {
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
if (iframeDoc) {
const found = findButtonInIframes(iframeDoc);
if (found) return found;
}
} catch (e) {
// Cross-origin iframe, skip
console.debug('Cannot access iframe:', e);
}
}
return null;
}
function checkAndClick() {
const button = findButtonInIframes();
if (button) {
console.log('Button found, clicking...');
button.click();
return true;
}
return false;
}
return {
start() {
if (isRunning) {
console.log('Auto-clicker already running');
return;
}
console.log('Auto-clicker started');
isRunning = true;
// Check immediately
checkAndClick();
// Then check every 500ms
intervalId = setInterval(checkAndClick, 500);
},
stop() {
if (!isRunning) {
console.log('Auto-clicker not running');
return;
}
console.log('Auto-clicker stopped');
isRunning = false;
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
},
isRunning() {
return isRunning;
}
};
}
// Expose to global window context
window._auto_claude_ = createAutoClicker();
console.log('Auto-clicker loaded. Use: _auto_claude_.start() / _auto_claude_.stop()');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment