diff --git a/archivebox/plugins/chrome/on_Crawl__30_chrome_launch.bg.js b/archivebox/plugins/chrome/on_Crawl__30_chrome_launch.bg.js index f21666c1..408c0062 100644 --- a/archivebox/plugins/chrome/on_Crawl__30_chrome_launch.bg.js +++ b/archivebox/plugins/chrome/on_Crawl__30_chrome_launch.bg.js @@ -215,7 +215,25 @@ async function main() { const manifestPath = path.join(ext.unpacked_path, 'manifest.json'); if (fs.existsSync(manifestPath)) { const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8')); - const manifestName = manifest.name || ''; + let manifestName = manifest.name || ''; + + // Resolve message placeholder (e.g., __MSG_extName__) + if (manifestName.startsWith('__MSG_') && manifestName.endsWith('__')) { + const msgKey = manifestName.slice(6, -2); // Extract key from __MSG_key__ + const defaultLocale = manifest.default_locale || 'en'; + const messagesPath = path.join(ext.unpacked_path, '_locales', defaultLocale, 'messages.json'); + if (fs.existsSync(messagesPath)) { + try { + const messages = JSON.parse(fs.readFileSync(messagesPath, 'utf-8')); + if (messages[msgKey] && messages[msgKey].message) { + manifestName = messages[msgKey].message; + } + } catch (e) { + console.error(`[!] Failed to read messages.json: ${e.message}`); + } + } + } + console.error(`[*] Looking for match: ext.name="${ext.name}" manifest.name="${manifestName}"`); // Find matching extension from page by exact name match first diff --git a/archivebox/plugins/twocaptcha/tests/test_twocaptcha.py b/archivebox/plugins/twocaptcha/tests/test_twocaptcha.py index 2e3e6d9d..fd06cde5 100644 --- a/archivebox/plugins/twocaptcha/tests/test_twocaptcha.py +++ b/archivebox/plugins/twocaptcha/tests/test_twocaptcha.py @@ -142,13 +142,18 @@ def launch_chrome(env: dict, chrome_dir: Path, crawl_id: str): ) cdp_url = None + extensions_ready = False for _ in range(30): if process.poll() is not None: stdout, stderr = process.communicate() raise RuntimeError(f"Chromium failed:\n{stdout}\n{stderr}") cdp_file = chrome_dir / 'cdp_url.txt' - if cdp_file.exists(): + ext_file = chrome_dir / 'extensions.json' + if cdp_file.exists() and not cdp_url: cdp_url = cdp_file.read_text().strip() + if ext_file.exists(): + extensions_ready = True + if cdp_url and extensions_ready: break time.sleep(1) @@ -157,13 +162,6 @@ def launch_chrome(env: dict, chrome_dir: Path, crawl_id: str): stdout, stderr = process.communicate() raise RuntimeError(f"CDP URL not found after 30s.\nstdout: {stdout}\nstderr: {stderr}") - # Wait for extensions.json to be written (chrome launch hook parses chrome://extensions) - extensions_file = chrome_dir / 'extensions.json' - for _ in range(15): - if extensions_file.exists(): - break - time.sleep(1) - # Print chrome launch hook output for debugging import select if hasattr(select, 'poll'):