Use the prompt below to generate a Chrome extension in Claude. Load it in Developer Mode, scrape ads cleanly, and export everything you need.
Paste into a fresh Claude chat. Ask for a downloadable ZIP if possible.
Create a complete Chrome extension that scrapes ads from Facebook's Ad Library with the following specifications:
## CORE FUNCTIONALITY
1. Ad Scraping
- Scrape ads from facebook.com/ads/library pages
- Extract these fields for each ad:
* Headline (primary text, usually bold or large)
* Description (secondary text)
* Body text (main ad copy)
* Advertiser name, link, and page ID
* All images with metadata (src, alt, dimensions)
* All videos with metadata (src, poster, duration)
* Call to action buttons (text and links)
* Date information (when ad started running)
* Targeting information if available
* Destination URL
- Implement four detection strategies since Facebook’s structure varies:
* Strategy 1: Look for data-testid attributes
* Strategy 2: Analyse divs with media and text content with sensible height
* Strategy 3: Find article or role elements containing ads
* Strategy 4: Look for text such as “Started running on” or “Launched”
- Remove duplicate or nested containers
- Handle auto scroll to load more ads, fifteen scrolls with short intervals
2. Text Extraction
- Separate headline, description, and body text into distinct fields
- Filter out noise such as Sponsored, Learn More, Shop Now
- Headline: prefer h1, h2, strong, ten to two hundred characters
- Description: secondary text, twenty to three hundred characters
- Body: longer blocks, thirty plus characters
3. Export Options, five total
a) Copy to Clipboard, formatted text output:
AD #1
----------------
ADVERTISER: Nike
DATE: October 1, 2024
HEADLINE: Just Do It
DESCRIPTION: Get 25% off
BODY TEXT: Full ad copy here...
CALL TO ACTION: Shop Now → url
IMAGES: list with URLs
VIDEOS: list with URLs
b) Export JSON, complete structured data:
{
"id": "ad_timestamp_index",
"headline": "...",
"description": "...",
"bodyText": "...",
"advertiser": {"name": "...", "link": "...", "pageId": "..."},
"images": [{"src": "...", "alt": "...", "width": 0, "height": 0}],
"videos": [{"src": "...", "duration": 0, "needsTranscription": true}],
"cta": [{"text": "...", "link": "..."}],
"dateInfo": "...",
"targetingInfo": [...],
"destinationUrl": "..."
}
c) Export CSV, spreadsheet columns:
ID, Advertiser, Date, Headline, Description, Body Text, CTA, Destination URL, Image Count, Video Count, Targeting
Properly escape commas, quotes, and new lines
d) Export Video URLs, text file with
One URL per line, plus optional detailed list with advertiser, duration, thumbnail
e) Download All Creative
Use chrome.downloads API
Download images and videos individually with clear naming, for example img_Advertiser_ad1_1.jpg
Show real time progress
Create a summary file with download statistics
Handle failures gracefully
## TECHNICAL ARCHITECTURE
Manifest V3 Structure
- manifest.json with permissions: activeTab, storage, scripting, downloads
- Host permissions: https://www.facebook.com/*
- Content script injected on https://www.facebook.com/ads/library/*
- Background service worker
- Popup HTML, JS, and CSS
Files Required
1. manifest.json
2. popup.html
3. popup.js
4. content.js
5. background.js
6. styles.css
7. icons folder with 16, 32, 48, 128 px
Key Functions
- extractAdData
- extractHeadline
- extractDescription
- extractBodyText
- extractImages
- extractVideos
- extractCTA
- downloadAllCreativeSimple using chrome.downloads.download
- formatAdsForCopy
- convertToCSV
## USER INTERFACE
Popup Design
- Header titled “FB Ad Scraper”
- Status indicator with message
- Two scrape buttons:
Scrape Current Page
Scrape with Auto Scroll
- Stats display, ads found and advertisers
- Export section with five buttons
- Preview section showing the first five ads
- Debug button
Styling
- Clean blue theme
- Card based layout
- Highlight colour on Download All Creative
- Responsive
## ERROR HANDLING
- Continue when individual ads fail
- Report success and failure counts
- Debug mode to inspect page structure
- Use chrome.downloads API for cross origin files
- Validate data before export
## DOCUMENTATION
Create these files
1. README.md
2. QUICK_START.md
3. DOWNLOAD_CREATIVE_GUIDE.md
4. VIDEO_DOWNLOAD_GUIDE.md
5. VIDEO_TRANSCRIPTION.md with examples for Whisper, AssemblyAI, Google
6. Python scripts: download_videos.py and organize_downloads.py
## IMPORTANT REQUIREMENTS
Must Use
- chrome.downloads.download
- Manifest V3
- Chrome Storage API
- Multiple ad detection strategies
Must Avoid
- External CDN libraries
- JSZip
- Direct fetch for cross origin downloads
- Fragile hard coded selectors
Must Include
- downloads permission
- Progress messages
- Error handling
- Clear file naming
- Summary file
## DATA QUALITY
- Extract clean text without navigation elements
- Separate headline, description, body
- Filter sponsored labels and call to action labels
- Capture all images and videos with metadata
- Preserve advertiser information and targeting when present
## TESTING CHECKLIST
- Load without errors on the Ad Library
- Detect ads with multiple strategies
- Extract headline, description, body separately
- Capture all images and videos
- Export JSON and CSV correctly
- Copy formatted text to clipboard
- Download images and videos with chrome.downloads
- Show progress
- Handle errors
- Persist data between sessions
## EXAMPLE USAGE FLOW
1. Install the extension
2. Go to facebook.com/ads/library
3. Search for a brand
4. Open the popup
5. Click Scrape with Auto Scroll
6. Wait for fifteen scrolls
7. See the stats
8. Click Download All Creative
9. Files appear in the Downloads folder
10. Run organise script if needed
## OUTPUT
Provide all extension files with working code, documentation, helper scripts, installation instructions, a ZIP ready for Load Unpacked, and brief testing notes. Code must be production ready and well commented.
You will get prompts, templates, and setups that save time.