Last active
April 28, 2026 00:13
-
-
Save xxnuo/d366127bf9bf582ce51d30e529c9fff0 to your computer and use it in GitHub Desktop.
Antigravity Auto Retry Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| const internalKey = '__antigravityAutoRetry__'; | |
| const matchRetry = /\bretry\b/i; | |
| window[internalKey]?.stop(); | |
| let running = false; | |
| let queued = false; | |
| let rootObserver = null; | |
| let panelObserver = null; | |
| let panel = null; | |
| let lastClickedAt = 0; | |
| let runCount = 0; | |
| const normalizeText = value => value.replace(/\s+/g, ' ').trim(); | |
| const log = message => console.log(`[antigravityAutoRetry] ${message}`); | |
| const isVisible = element => { | |
| if (!element || !element.isConnected) { | |
| return false; | |
| } | |
| const style = getComputedStyle(element); | |
| return style.display !== 'none' && style.visibility !== 'hidden' && element.getClientRects().length > 0; | |
| }; | |
| const isEnabled = button => !button.disabled && button.getAttribute('aria-disabled') !== 'true'; | |
| const getPanel = () => document.getElementById('antigravity.agentSidePanelInputBox'); | |
| const getRetryButton = target => { | |
| for (const button of target.querySelectorAll('button')) { | |
| if (!isEnabled(button) || !isVisible(button)) { | |
| continue; | |
| } | |
| if (matchRetry.test(normalizeText(button.textContent || ''))) { | |
| return button; | |
| } | |
| } | |
| return null; | |
| }; | |
| function schedule() { | |
| if (!running || queued) { | |
| return; | |
| } | |
| queued = true; | |
| queueMicrotask(run); | |
| } | |
| const attachPanelObserver = target => { | |
| panelObserver?.disconnect(); | |
| panelObserver = null; | |
| if (!target || !running) { | |
| return; | |
| } | |
| panelObserver = new MutationObserver(schedule); | |
| panelObserver.observe(target, { | |
| childList: true, | |
| subtree: true, | |
| characterData: true, | |
| attributes: true, | |
| attributeFilter: ['disabled', 'aria-disabled', 'class', 'style'] | |
| }); | |
| }; | |
| const run = () => { | |
| queued = false; | |
| runCount += 1; | |
| if (!running) { | |
| log(`run #${runCount}: skipped, stopped`); | |
| return; | |
| } | |
| const nextPanel = getPanel(); | |
| if (nextPanel !== panel) { | |
| panel = nextPanel; | |
| attachPanelObserver(panel); | |
| } | |
| if (!panel) { | |
| log(`run #${runCount}: panel not found`); | |
| return; | |
| } | |
| const retryButton = getRetryButton(panel); | |
| if (!retryButton) { | |
| log(`run #${runCount}: retry button not found`); | |
| return; | |
| } | |
| lastClickedAt = Date.now(); | |
| retryButton.click(); | |
| log(`run #${runCount}: clicked Retry`); | |
| }; | |
| const controller = { | |
| start() { | |
| if (running) { | |
| return controller.status(); | |
| } | |
| running = true; | |
| rootObserver = new MutationObserver(schedule); | |
| rootObserver.observe(document.documentElement, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| schedule(); | |
| log('started'); | |
| return controller.status(); | |
| }, | |
| stop() { | |
| running = false; | |
| queued = false; | |
| rootObserver?.disconnect(); | |
| panelObserver?.disconnect(); | |
| rootObserver = null; | |
| panelObserver = null; | |
| panel = null; | |
| lastClickedAt = 0; | |
| log('stopped'); | |
| return controller.status(); | |
| }, | |
| status() { | |
| return { | |
| running, | |
| panelFound: Boolean(getPanel()), | |
| lastClickedAt | |
| }; | |
| } | |
| }; | |
| window[internalKey] = controller; | |
| window.antigravityAutoRetry = controller; | |
| controller.start(); | |
| log('Loaded and started. Use antigravityAutoRetry.start() / stop() / status().'); | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage Instructions: Click "Toggle Developer Tools" within the Help menu on the top toolbar. Then, switch to the Console tab, type
allow pastingand press Enter. Finally, paste the JavaScript code into the console and press Enter to execute it.