Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Chrome Extension Development

Chrome Extension Development

Build powerful Chrome extensions with Manifest V3, background workers, and content scripts.

JavaScriptChromeExtensionsBrowser
by Community
⭐0Stars
👁️5Views
.antigravity
# Chrome Extension Development

Build powerful Chrome extensions with Google Antigravity IDE. This comprehensive guide covers Manifest V3, service workers, content scripts, and modern extension architecture.

## Why Chrome Extensions?

Chrome extensions enhance browser functionality with access to tabs, storage, and web APIs. Google Antigravity IDE's Gemini 3 engine provides intelligent patterns for extension development and security best practices.

## Manifest V3 Configuration

```json
// manifest.json
{
  "manifest_version": 3,
  "name": "Antigravity Helper",
  "version": "1.0.0",
  "description": "AI-powered browsing assistant",
  "permissions": [
    "storage",
    "activeTab",
    "scripting",
    "contextMenus"
  ],
  "host_permissions": [
    "https://*.example.com/*"
  ],
  "background": {
    "service_worker": "background.js",
    "type": "module"
  },
  "content_scripts": [
    {
      "matches": ["https://*.example.com/*"],
      "js": ["content.js"],
      "css": ["content.css"],
      "run_at": "document_end"
    }
  ],
  "action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "icons/icon16.png",
      "48": "icons/icon48.png",
      "128": "icons/icon128.png"
    }
  },
  "options_page": "options.html",
  "icons": {
    "16": "icons/icon16.png",
    "48": "icons/icon48.png",
    "128": "icons/icon128.png"
  }
}
```

## Service Worker

```typescript
// background.ts
import { setupContextMenus } from "./contextMenus";
import { MessageHandler } from "./types";

// Initialize on install
chrome.runtime.onInstalled.addListener(async () => {
  await chrome.storage.local.set({ enabled: true, settings: {} });
  setupContextMenus();
});

// Message handling
const messageHandlers: Record<string, MessageHandler> = {
  async getPageData(request, sender) {
    const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
    if (!tab.id) return null;
    
    const results = await chrome.scripting.executeScript({
      target: { tabId: tab.id },
      func: () => ({
        title: document.title,
        url: window.location.href,
        content: document.body.innerText.slice(0, 5000),
      }),
    });
    
    return results[0]?.result;
  },
  
  async saveToStorage(request) {
    await chrome.storage.local.set(request.data);
    return { success: true };
  },
};

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  const handler = messageHandlers[request.action];
  
  if (handler) {
    handler(request, sender).then(sendResponse);
    return true; // Keep channel open for async response
  }
});

// Context menu handling
chrome.contextMenus.onClicked.addListener(async (info, tab) => {
  if (info.menuItemId === "analyze-selection" && info.selectionText) {
    // Process selected text
    const result = await analyzeText(info.selectionText);
    
    if (tab?.id) {
      chrome.tabs.sendMessage(tab.id, {
        action: "showResult",
        data: result,
      });
    }
  }
});
```

## Content Script

```typescript
// content.ts
interface Message {
  action: string;
  data?: unknown;
}

// Listen for messages from background
chrome.runtime.onMessage.addListener((message: Message, sender, sendResponse) => {
  switch (message.action) {
    case "showResult":
      showOverlay(message.data);
      break;
    case "extractData":
      sendResponse(extractPageData());
      break;
  }
  return true;
});

function showOverlay(data: unknown) {
  // Remove existing overlay
  document.getElementById("antigravity-overlay")?.remove();
  
  const overlay = document.createElement("div");
  overlay.id = "antigravity-overlay";
  overlay.innerHTML = `
    <div class="antigravity-modal">
      <button class="close-btn">&times;</button>
      <div class="content">${JSON.stringify(data, null, 2)}</div>
    </div>
  `;
  
  overlay.querySelector(".close-btn")?.addEventListener("click", () => {
    overlay.remove();
  });
  
  document.body.appendChild(overlay);
}

function extractPageData() {
  return {
    title: document.title,
    url: window.location.href,
    headings: Array.from(document.querySelectorAll("h1, h2, h3")).map(
      (h) => ({ tag: h.tagName, text: h.textContent })
    ),
    links: Array.from(document.querySelectorAll("a[href]")).map(
      (a) => ({ href: (a as HTMLAnchorElement).href, text: a.textContent })
    ),
  };
}

// Inject styles
const style = document.createElement("style");
style.textContent = `
  #antigravity-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
  }
`;
document.head.appendChild(style);
```

## Popup UI

```typescript
// popup.ts
document.addEventListener("DOMContentLoaded", async () => {
  const { enabled, settings } = await chrome.storage.local.get(["enabled", "settings"]);
  
  const toggle = document.getElementById("toggle") as HTMLInputElement;
  toggle.checked = enabled;
  
  toggle.addEventListener("change", async () => {
    await chrome.storage.local.set({ enabled: toggle.checked });
  });
  
  document.getElementById("analyze")?.addEventListener("click", async () => {
    const data = await chrome.runtime.sendMessage({ action: "getPageData" });
    displayResults(data);
  });
});
```

## Storage API

```typescript
// storage.ts
export async function getSettings<T>(key: string): Promise<T | null> {
  const result = await chrome.storage.local.get(key);
  return result[key] ?? null;
}

export async function setSettings<T>(key: string, value: T): Promise<void> {
  await chrome.storage.local.set({ [key]: value });
}

// Sync storage for cross-device
export async function syncSettings<T>(key: string, value: T): Promise<void> {
  await chrome.storage.sync.set({ [key]: value });
}
```

## Best Practices

- Use Manifest V3 for new extensions
- Minimize required permissions
- Handle service worker lifecycle properly
- Use TypeScript for type safety
- Implement proper error handling
- Test across different Chrome versions

Google Antigravity IDE provides Chrome extension templates and automatically validates your manifest configuration for security compliance.

When to Use This Prompt

This JavaScript prompt is ideal for developers working on:

  • JavaScript applications requiring modern best practices and optimal performance
  • Projects that need production-ready JavaScript code with proper error handling
  • Teams looking to standardize their javascript development workflow
  • Developers wanting to learn industry-standard JavaScript patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their javascript implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the JavaScript code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this JavaScript prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For JavaScript projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...