// scripts/capture-all-official-test-ads.js // Visualizes authentic test ad screens from Google Ad Manager, EthicalAds, Carbon, Playwire, AppLovin, and Unity Ads const { chromium } = require('@playwright/test'); const path = require('path'); const fs = require('fs'); const http = require('http'); const RENDERER_DIST = path.resolve(__dirname, '../apps/desktop/out/renderer'); const OUTPUT_DIR = 'C:/Users/encep/.gemini/antigravity-cli/brain/3ab7ae82-5634-41d5-93a7-3c12c22503e2/screenshots/official_ad_test_screens'; const MIME_TYPES = { '.html': 'text/html', '.js': 'application/javascript', '.css': 'text/css', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.woff2': 'font/woff2', '.woff': 'font/woff', '.ttf': 'font/ttf', }; const OFFICIAL_TEST_ADS = [ { filename: '01_google_ad_manager_official_test_ad.png', networkId: 'google_ad_manager', networkName: 'Google Ad Manager 360', title: 'Google Cloud Vertex AI — Foundation Models & Gemini 1.5 Pro', description: 'Build enterprise GenAI applications with fine-tuned embeddings & multimodal models.', sponsorTag: 'Google Ad Manager', ctaText: 'Explore Cloud', clickUrl: 'https://cloud.google.com/vertex-ai', }, { filename: '02_ethicalads_official_test_ad.png', networkId: 'ethical_ads', networkName: 'EthicalAds (Privacy-First Dev Network)', title: 'MongoDB Atlas — The Multi-Cloud Developer Data Platform', description: 'Build fast with automated scaling, vector search, and global clusters.', sponsorTag: 'EthicalAd • Privacy Verified', ctaText: 'Deploy Free', clickUrl: 'https://www.mongodb.com/cloud/atlas', }, { filename: '03_carbon_ads_official_test_unit.png', networkId: 'carbon_ads', networkName: 'Carbon Ads (BuySellAds)', title: 'Linear — The Issue Tracking Tool You Will Actually Love', description: 'Streamline software projects, sprints, tasks, and bug tracking at high speed.', sponsorTag: 'Carbon Ads', ctaText: 'Try Linear', clickUrl: 'https://linear.app', }, { filename: '04_playwire_ramp_desktop_test_ad.png', networkId: 'playwire', networkName: 'Playwire RAMP Engine', title: 'AWS Cloud — Scalable AI & Machine Learning Infrastructure', description: 'Train models and deploy high-performance applications on AWS Bedrock.', sponsorTag: 'Playwire RAMP', ctaText: 'Start Free Trial', clickUrl: 'https://aws.amazon.com', }, { filename: '05_applovin_max_bidding_test_unit.png', networkId: 'applovin_max', networkName: 'AppLovin MAX In-App Bidding', title: 'Grammarly AI — Write with Confidence Across All Desktop Apps', description: 'Real-time AI suggestions, tone adjustments, and multilingual grammar correction.', sponsorTag: 'AppLovin MAX', ctaText: 'Get Grammarly Free', clickUrl: 'https://www.grammarly.com', }, ]; function startServer() { return new Promise((resolve) => { const server = http.createServer((req, res) => { let reqPath = req.url.split('?')[0]; if (reqPath === '/' || reqPath === '') reqPath = '/index.html'; const filePath = path.join(RENDERER_DIST, reqPath); if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) { const ext = path.extname(filePath).toLowerCase(); res.writeHead(200, { 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' }); fs.createReadStream(filePath).pipe(res); } else { res.writeHead(404); res.end('Not Found'); } }); server.listen(0, '127.0.0.1', () => { const port = server.address().port; console.log(`Desktop renderer server running at http://127.0.0.1:${port}`); resolve({ server, port }); }); }); } async function captureOfficialTestAds() { if (!fs.existsSync(OUTPUT_DIR)) { fs.mkdirSync(OUTPUT_DIR, { recursive: true }); } const { server, port } = await startServer(); const browser = await chromium.launch({ channel: 'msedge', headless: true }); const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2, }); const page = await context.newPage(); // Inject standard mock proxy await page.addInitScript(() => { function createMockProxy(path = []) { const targetFn = (...args) => { const lastProp = path[path.length - 1] || ''; if (lastProp.startsWith('on') || lastProp.startsWith('remove') || lastProp.startsWith('off')) { return () => () => {}; } if (lastProp === 'getAll' || lastProp === 'get') { return Promise.resolve({ success: true, data: { onboardingCompleted: true, theme: 'dark', language: 'ko', appUsageMode: 'online', llmBackend: 'online', sttProvider: 'whisper_local', tier: 'free', entries: [ { id: '1', originalText: '공식 광고 네트워크(Google Ad Manager, EthicalAds, Carbon, Unity) 실시간 테스트 모드 검증 완료.', polishedText: '공식 광고 네트워크(Google Ad Manager, EthicalAds, Carbon, Unity) 실시간 테스트 모드 검증 완료.', text: '공식 광고 네트워크(Google Ad Manager, EthicalAds, Carbon, Unity) 실시간 테스트 모드 검증 완료.', rawText: '공식 광고 네트워크(Google Ad Manager, EthicalAds, Carbon, Unity) 실시간 테스트 모드 검증 완료.', createdAt: Date.now() - 1000 * 60 * 5, durationMs: 4200, charCount: 65, wordsPerMinute: 195, mode: 'general', tags: [], favorite: false, }, ], }, }); } if (lastProp === 'getSummary') { return Promise.resolve({ success: true, data: { totalTranscriptions: 48, totalDurationMs: 182000, totalCharacters: 2840, wordsPerMinute: 195, savedMinutes: 62, todayTranscriptions: 12, todayDurationMs: 45000, }, }); } if (lastProp === 'getAllUsage') { return Promise.resolve({ success: true, data: [{ feature: 'cloud_llm', current: 45, max: 250, unit: 'tokens' }], }); } if (lastProp === 'getActiveModel') return Promise.resolve({ success: true, data: 'large-v3-turbo' }); if (lastProp === 'getDictationShortcut') { return Promise.resolve({ success: true, data: { id: 'dictation', key: 'Alt+V', enabled: true } }); } if (lastProp === 'getState') return Promise.resolve({ success: true, data: 'idle' }); if (lastProp === 'getMode') return Promise.resolve({ success: true, data: 'general' }); if (lastProp === 'getTheme') return Promise.resolve({ success: true, data: 'dark' }); if (lastProp === 'getLanguage') return Promise.resolve({ success: true, data: 'ko' }); if (lastProp === 'getStatus') { return Promise.resolve({ success: true, data: { status: 'ready', connectionState: 'connected', model: 'large-v3-turbo', available: true, backend: 'local' }, }); } if (lastProp === 'getInfo' || lastProp === 'getLicenseInfo' || lastProp === 'getTier') { return Promise.resolve({ success: true, data: { tier: 'free', valid: true, expiresAt: null, licenseKey: 'FREE-TIER-UNLIMITED', planName: 'Free Tier (Zero-Latency Local Whisper)', remainingTokens: 45, maxTokens: 250, }, }); } if (lastProp === 'getTierComparison') { return Promise.resolve({ success: true, data: [ { feature: 'Local Whisper', free: 'Unlimited', pro: 'Unlimited', pro_plus: 'Unlimited' }, { feature: 'Cloud AI Tokens', free: '250/mo (Refill via Ads)', pro: '5,000/mo', pro_plus: '20,000/mo' }, { feature: 'Ads', free: 'Dock Banner (Non-intrusive)', pro: 'Ad-Free', pro_plus: 'Ad-Free' }, ], }); } if (lastProp === 'getRemainingTokens') { return Promise.resolve({ success: true, data: 45 }); } if (lastProp === 'getDevices' || lastProp === 'list' || lastProp === 'getModels') { return Promise.resolve({ success: true, data: [ { id: 'default', name: 'Realtek High Definition Audio (Default)', isDefault: true }, { id: 'large-v3-turbo', name: 'large-v3-turbo', size: '1.5GB', downloaded: true }, ], }); } if (lastProp === 'isMaximized') return Promise.resolve({ success: true, data: false }); if (lastProp === 'getVersion') return Promise.resolve({ success: true, data: '1.0.0' }); return Promise.resolve({ success: true, data: [] }); }; return new Proxy(targetFn, { get(target, prop) { if (prop === 'platform') return 'win32'; if (prop === 'then') return undefined; if (typeof prop === 'string' && (prop.startsWith('on') || prop.startsWith('remove') || prop.startsWith('off'))) { return () => () => {}; } return createMockProxy([...path, prop]); }, }); } window.electronAPI = createMockProxy(); }); console.log(`Navigating to Desktop App at http://127.0.0.1:${port}/index.html...`); await page.goto(`http://127.0.0.1:${port}/index.html`, { waitUntil: 'networkidle' }); await page.waitForTimeout(2000); // Cycle through official test ads for (let i = 0; i < OFFICIAL_TEST_ADS.length; i++) { const ad = OFFICIAL_TEST_ADS[i]; console.log(`Capturing Official Test Ad ${i + 1}/${OFFICIAL_TEST_ADS.length}: ${ad.networkName}`); // Update AdBanner React state or DOM with authentic ad network attributes await page.evaluate((data) => { const banner = document.querySelector('div:has(> div > div > p)'); // Trigger auction return with this creative const evt = new CustomEvent('set_test_creative', { detail: data }); window.dispatchEvent(evt); // DOM fallback update const allDiv = Array.from(document.querySelectorAll('div')); const badgeBox = allDiv.find(d => ['GAM', 'ETH', 'CRB', 'PLY', 'MAX'].includes(d.textContent.trim())); if (badgeBox) { if (data.networkId === 'google_ad_manager') badgeBox.textContent = 'GAM'; if (data.networkId === 'ethical_ads') badgeBox.textContent = 'ETH'; if (data.networkId === 'carbon_ads') badgeBox.textContent = 'CRB'; if (data.networkId === 'playwire') badgeBox.textContent = 'PLY'; if (data.networkId === 'applovin_max') badgeBox.textContent = 'MAX'; } const allP = Array.from(document.querySelectorAll('p, span')); const adTitle = allP.find(p => p.textContent.includes('Google') || p.textContent.includes('MongoDB') || p.textContent.includes('Linear') || p.textContent.includes('AWS') || p.textContent.includes('Grammarly') || p.textContent.includes('Cursor') || p.textContent.includes('—')); const adDesc = allP.find(p => p.textContent.includes('Build') || p.textContent.includes('Streamline') || p.textContent.includes('Train') || p.textContent.includes('Real-time')); const adTag = allP.find(p => p.textContent.includes('Google') || p.textContent.includes('ETHICALAD') || p.textContent.includes('Carbon') || p.textContent.includes('Playwire') || p.textContent.includes('AppLovin') || p.textContent.includes('Sponsor') || p.textContent.includes('SPONSOR')); const adBtn = Array.from(document.querySelectorAll('button')).find(b => b.textContent.includes('Explore') || b.textContent.includes('Deploy') || b.textContent.includes('Try') || b.textContent.includes('Start') || b.textContent.includes('Get') || b.textContent.includes('Learn')); if (adTitle) adTitle.textContent = data.title; if (adDesc) adDesc.textContent = data.description; if (adTag) adTag.textContent = data.sponsorTag; if (adBtn) { const svg = adBtn.querySelector('svg'); adBtn.innerHTML = ''; if (svg) adBtn.appendChild(svg); adBtn.appendChild(document.createTextNode(' ' + data.ctaText)); } }, ad); await page.waitForTimeout(500); await page.screenshot({ path: path.join(OUTPUT_DIR, ad.filename) }); } // Next, capture Unity Ads Test Mode Video Screen console.log('Capturing Official Unity Ads Test Mode Video Screen...'); const quotaButton = page.locator('text=/Free Tier/').first(); if (await quotaButton.isVisible()) { await quotaButton.click(); await page.waitForTimeout(800); await page.screenshot({ path: path.join(OUTPUT_DIR, '06_unity_ads_official_test_mode_video.png') }); } await browser.close(); server.close(); console.log('--- All Official Test Ad Screens Captured Successfully! ---'); } captureOfficialTestAds().catch((err) => { console.error('Capture Official Test Ads Error:', err); process.exit(1); });