The panel was doing the HTTP call itself, which meant any mirror sitting behind a Cloudflare-style anti-bot check returned "<!doctype html>…" for a POST from Origin: file:// and JSON.parse choked on it. Moving the fetch into index.js gets rid of the whole class of browser-context interceptors (CORS preflights, captive portals, anti-bot pages) and lets the addon look at the response body before trying to parse it — an HTML body is now reported cleanly as "server returned an HTML page instead of JSON". While there, chain a small mirror list — translate.disroot.org, translate.plausibility.cloud, lingva.ml — so a single mirror being down does not take the feature with it. A user whose saved URL points at a mirror that stopped resolving (translate.argosopentech.com is the notable case) now transparently gets a translation from the next mirror in line instead of a stack trace. Verified end-to-end from Node against both a working URL and a dead one; the dead one falls through to disroot as expected.
19 lines
569 B
JSON
19 lines
569 B
JSON
{
|
|
"id": "translate",
|
|
"name": "Translate",
|
|
"version": "0.1.2",
|
|
"description": "Right-click a selection to translate it. Sidebar panel with LibreTranslate or Google as the backend.",
|
|
"author": "Silent Mode",
|
|
"icon": "🌐",
|
|
"main": "index.js",
|
|
"capabilities": ["sidebar-panel", "context-menu-item"],
|
|
"context-menu-items": [
|
|
{
|
|
"id": "translate-selection",
|
|
"label": "Translate selection",
|
|
"when": "selectionText",
|
|
"icon": "🌐"
|
|
}
|
|
],
|
|
"updateURL": "https://navigate.st/bns/theseus.x/extensions/translate/updates.json"
|
|
}
|