DEV Community

Pavan A M
Pavan A M

Posted on

How I Built a Chrome Extension to Extract ChatGPT Search Queries

ChatGPT Query Extractor - Chrome Web Store

Auto-send prompts to ChatGPT and capture the internal search queries it generates

favicon chromewebstore.google.com

AI chat tools like ChatGPT have changed how people search for information. Instead of typing multiple search queries into Google, users now ask one question and let AI generate answers.

But something interesting happens behind the scenes.

AI systems often generate multiple internal search queries to gather relevant information before producing an answer. These queries are usually hidden from users.

So I built a Chrome extension called ChatGPT Query Extractor to capture and analyze these hidden queries.

This article explains why I built it, how it works, and some of the technical implementation details.

The Idea

While using AI tools for research and SEO, I noticed that AI models often generate several variations of search queries internally.

For example, if a user asks:

How can startups improve SEO using AI?

The AI might internally generate queries like:

AI SEO strategies for startups

tools for generative engine optimization

how AI search works in ChatGPT

These query variations are useful for:

SEO research

understanding AI search behavior

content strategy planning

analyzing generative engine optimization (GEO)

However, most AI interfaces do not expose these queries.

That’s where the idea for ChatGPT Query Extractor came from.

What the Extension Does

The extension helps users capture and analyze AI-generated queries during conversations.

Key features include:

Extract hidden search queries generated during AI responses

Display captured queries in the browser extension popup

Export queries for research or SEO analysis

Work directly inside the browser without external servers

The goal is to help researchers, developers, and marketers understand how AI systems generate search queries.

Technical Approach

The extension is built using Chrome Extension Manifest V3 and relies on several core components.

Main components:

Manifest configuration

Content scripts

Background service worker

Browser storage API

These components work together to observe page updates and capture relevant query information.

Extension Manifest Example

Every Chrome extension starts with a manifest file that defines the extension configuration and permissions.

Example:

{
"manifest_version": 3,
"name": "ChatGPT Query Extractor",
"version": "1.0",
"description": "Extract AI generated search queries from chat interfaces",
"permissions": [
"storage",
"activeTab"
],
"background": {
"service_worker": "background.js"
}
}

The manifest file specifies:

extension name

permissions

background scripts

browser actions

Detecting AI Responses

To capture queries generated during AI responses, the extension monitors the webpage for changes.

This is done using a MutationObserver, which detects when new content is added to the page.

Example:

const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
console.log("New AI response detected");
});
});

observer.observe(document.body, {
childList: true,
subtree: true
});

Whenever new content appears in the chat interface, the extension scans it to identify possible search queries.

Sending Data to the Background Script

Once a query is detected, it is sent to the background script for processing.

Example:

chrome.runtime.sendMessage({
type: "NEW_QUERY",
query: extractedQuery
});

The background script receives this data and stores it locally.

Storing Extracted Queries

The extension uses the Chrome Storage API to save extracted queries inside the browser.

Example:

chrome.storage.local.set({
queries: queryList
});

This allows users to review the queries later or export them for further analysis.

Privacy Considerations

Because the extension interacts with AI chat interfaces, privacy is an important concern.

To address this:

Queries are stored locally in the browser

No external servers are required

Users control when and how data is exported

This design keeps the extension lightweight and privacy-focused.

Potential Use Cases

There are several practical uses for extracting AI-generated queries.

These include:

SEO Research
Understanding what queries AI considers relevant for a topic.

Content Strategy
Discovering new keyword variations for blog posts and articles.

AI Behavior Analysis
Studying how AI systems break down complex questions.

Developer Research
Exploring how AI tools generate internal queries.

Try the Extension

If you want to explore how AI generates search queries, you can try the extension here:

Chrome Web Store

ChatGPT Query Extractor - Chrome Web Store

Auto-send prompts to ChatGPT and capture the internal search queries it generates

favicon chromewebstore.google.com

Project Website

GPT Query Extractor — Reveal ChatGPT's Hidden Search Logic

Auto-send bulk prompts to ChatGPT and capture every internal search query it generates. Free Chrome Extension for SEO pros and researchers.

favicon gptqueryextractor.netlify.app

Final Thoughts

AI-powered search is changing how people discover information. Understanding how these systems generate queries can provide valuable insights for developers, researchers, and marketers.

Tools like ChatGPT Query Extractor make it easier to analyze these hidden processes and explore how AI-assisted search works.

As AI tools continue evolving, analyzing query generation may become an important part of understanding modern search behavior.

Top comments (0)