Platform Detection
How detectors extract prompts, settings, and outputs per platform
Platform Detection
The Lazer extension uses modular platform detectors to extract prompts, generation settings, and output URLs from AI platform pages. Each detector is tailored to the specific DOM structure and UI patterns of one platform.
Architecture
Detector Modules
Each supported platform has a detector module in chrome-extension/detectors/:
sora.js- OpenAI Soragemini-veo.js- Google Gemini/Veofreepik.js- Freepik Pikasomidjourney.js- Midjourneyrunway.js- Runwayelevenlabs.js- ElevenLabssuno.js- Suno- (additional platforms as added)
Detector Interface
Each detector exports an object with:
- platform - Unique platform key (e.g., "openai-sora")
- displayName - Human-readable name (e.g., "OpenAI Sora")
- category - "image", "video", "audio", "multi"
- urlPatterns - Array of regex patterns to match platform URLs
- detect(url) - Returns true if current URL matches this platform
- extractPrompt(document) - Extracts prompt and negative prompt from DOM
- extractSettings(document) - Extracts model, aspect ratio, duration, etc.
- extractOutputs(document) - Extracts generated media URLs
Content Script Injection
When you visit a page:
- Extension's content script runs in page context
- Checks URL against all detector patterns
- If a match is found, runs that detector's extraction methods
- Sends extracted data to side panel via message passing
- Side panel displays detection banner and enables "Auto Fill"
DOM-Based Extraction
Detection is purely DOM-based (not network-based) due to Manifest V3 privacy constraints:
- Reads text content from prompt textareas and contenteditable elements
- Reads attribute values from select dropdowns and input fields
- Reads
srcandcurrentSrcfrom<img>and<video>elements - Reads
hreffrom download links - Reads
data-*attributes from custom UI components
Network interception (reading HTTP responses) is not used. All data is extracted from the visible DOM.
Extraction Methods
URL Pattern Matching
Each detector defines regex patterns to identify platform pages:
urlPatterns: [
/^https?:\/\/(www\.)?sora\.com/i,
/^https?:\/\/sora\.chatgpt\.com/i,
]
The detect() method tests the current URL against all patterns.
Prompt Extraction
The extractPrompt() method searches for prompt inputs in priority order:
- Primary selectors - Platform-specific data attributes (e.g.,
data-testid="sora-prompt-input") - Placeholder-based - Textareas with relevant placeholder text (e.g.,
placeholder*="Describe") - ARIA labels - Elements with
aria-label*="prompt" - Generic fallbacks - Any visible textarea or contenteditable element
- Displayed prompts - Prompt text shown in generation cards (for platforms that hide the input after generation)
Returns:
{
prompt: "A cat wearing sunglasses...",
negativePrompt: "blurry, low quality" // or null
}
Settings Extraction
The extractSettings() method finds generation parameters:
- Model name - From model selector buttons, badges, or dropdowns
- Aspect ratio - From aspect ratio buttons (e.g., "16:9", "1:1")
- Duration - From duration sliders or inputs (for video)
- Resolution - From resolution dropdowns
- Style - From style presets (image generators)
- Temperature - From advanced settings (AI Studio, etc.)
- Seed - From reproducibility controls (rarely visible)
Returns:
{
modelName: "Veo-3",
aspectRatio: "16:9",
duration: "5s",
resolution: "1080p"
}
Output Extraction
The extractOutputs() method finds generated media:
For Video Platforms
- Search for
<video>elements withsrcattributes - Extract
video.currentSrcorvideo.src - Extract poster image from
video.poster - Collect metadata:
duration,videoWidth,videoHeight - Check for download links with
.mp4,.webm,.movextensions
For Image Platforms
- Search for
<img>elements with specific class patterns or data attributes - Exclude small icons, avatars, UI elements (check
naturalWidth> 100px) - Extract
img.currentSrcorimg.src - Collect metadata:
naturalWidth,naturalHeight,alttext
For Audio Platforms
- Search for
<audio>elements withsrcattributes - Extract
audio.currentSrcoraudio.src - Collect metadata:
duration, waveform image URL - Check for download links with
.mp3,.wav,.oggextensions
Returns:
[
{
type: "video",
url: "https://cdn.platform.com/video123.mp4",
thumbnailUrl: "https://cdn.platform.com/thumb123.jpg",
metadata: {
duration: 5.2,
width: 1920,
height: 1080
}
}
]
Platform-Specific Notes
OpenAI Sora
- URL patterns:
sora.com,sora.chatgpt.com - Prompts are in a chat-style textarea
- Model badge often shows "Sora" or version variant
- Videos use
<video>tags withoaiusercontent.comCDN - Supports stills (images) in addition to video
Google Gemini / Veo
- URL patterns:
gemini.google.com,aistudio.google.com - Uses contenteditable divs for prompt input
- Model selector is a material design dropdown
- Videos use
googleusercontent.comorstorage.googleapis.comCDN - Supports Imagen (image) and Veo (video) generation
Freepik Pikaso
- URL patterns:
freepik.com/pikaso,freepik.com/ai/* - Has separate negative prompt field
- Style selector with preset chips
- Image outputs use
img.freepik.comCDN - Aspect ratio selector with icon buttons
Midjourney
- URL patterns:
midjourney.com - Prompts are in Discord-style messages
- Grid of 4 images per generation
- Upscale and variation buttons
- Images use
cdn.midjourney.com
Runway
- URL patterns:
runwayml.com - Multiple generation modes (Gen-1, Gen-2, Gen-3)
- Video and image outputs
- Duration selector for video
- Images and videos use
runwayml.comCDN
ElevenLabs
- URL patterns:
elevenlabs.io - Text-to-speech and voice cloning
- Voice selector dropdown
- Audio outputs with waveform visualization
- Uses
elevenlabs.ioCDN
Suno
- URL patterns:
suno.ai - Music generation from text prompts
- Genre, mood, and duration controls
- Audio outputs with cover art
- Uses
cdn.suno.ai
Adding New Platforms
To add support for a new platform:
- Create a new detector file in
chrome-extension/detectors/ - Implement the detector interface (platform, urlPatterns, extract methods)
- Add the detector to
chrome-extension/detectors/index.js - Test on the platform's generation pages
- Update documentation with platform-specific notes
Example Detector
const MyPlatformDetector = {
platform: "my-platform",
displayName: "My Platform",
category: "image",
urlPatterns: [
/^https?:\/\/(www\.)?myplatform\.com/i,
],
detect(url) {
return this.urlPatterns.some(pattern => pattern.test(url));
},
extractPrompt(document) {
const el = document.querySelector('textarea[name="prompt"]');
if (el?.value) {
return { prompt: el.value.trim(), negativePrompt: null };
}
return null;
},
extractSettings(document) {
// Extract model, settings, etc.
return {};
},
extractOutputs(document) {
const outputs = [];
document.querySelectorAll('.output-image img').forEach(img => {
outputs.push({
type: "image",
url: img.src,
thumbnailUrl: img.src,
metadata: {}
});
});
return outputs;
}
};
export default MyPlatformDetector;
Limitations
DOM Changes
AI platforms frequently update their UI. Detectors use multiple fallback selectors to remain resilient, but major redesigns may break detection until the detector is updated.
Dynamic Content
Some platforms load content asynchronously:
- Detection runs after
document_idle(when page is mostly loaded) - Click "Refresh Detection" if content loads after initial detection
- Some platforms lazy-load outputs only when scrolled into view
Private/Gated Pages
Detection only works on pages you can access:
- Requires active subscription for paid platforms
- Cannot detect content behind login walls
- Cannot access direct API responses (MV3 privacy restrictions)
CDN Expiry
Some platforms use temporary CDN URLs that expire:
- URLs may become invalid 1-24 hours after generation
- Lazer should fetch and store the media immediately
- Extension shows warning if URL appears to have expiry parameters
Network Requests
Detection cannot intercept network requests:
- Cannot read API responses
- Cannot access WebSocket messages
- Cannot sniff generation job metadata from XHR
All data must be present in the visible DOM.
Debugging Detection
To troubleshoot detection issues:
- Open browser DevTools (F12)
- Navigate to the Console tab
- Look for detection debug logs (if verbose mode is enabled)
- Inspect the page DOM to verify selectors
- Test each extraction method manually in console:
// In console:
const detector = // (load the detector module)
detector.extractPrompt(document)
detector.extractSettings(document)
detector.extractOutputs(document)
- Report issues with screenshots and console logs
Future Enhancements
Planned improvements to detection:
- Confidence scores - Rate detection quality (high/medium/low)
- Partial detection - Save what was detected even if incomplete
- Detection history - Log all detection attempts for debugging
- User corrections - Learn from manual edits to improve detection
- Community detectors - Allow users to submit updated selectors