漫畫瀏覽器擴充功能的畫布擷取、權限管理與 OCR 後備方案
Canvas Capture, Permissions, and Fallback OCR for Manga Browser Extensions
漫畫翻譯擴充功能透過分階段擷取畫面、按需請求權限,並配合雲端日韓直排 OCR 和網點修補,處理現代漫畫閲讀器的圖片擷取與文字覆蓋問題。MangaTranslate 提供 Chrome v3.2.7 和 Firefox v3.2.1 擴充功能,並設有每日免費試用額度及瀏覽器本機的 TextCover Studio 編輯功能。
Key Takeaway: Modern AI manga translator extensions pair CORS-safe <canvas> image capture and user-triggered permissions with cloud-backed vertical JP/KR OCR plus screentone inpainting, avoiding ugly text overlays and heavy local setups. MangaTranslate (mangatranslate.com) provides Chrome v3.2.7 and Firefox v3.2.1 extensions, no-signup daily free trial credits, and browser-local TextCover Studio editing.
Developer threads on DEV often frame browser-based manga translators as a broken compromise: either paste clunky floating text boxes over artwork or abandon extensions altogether for a standalone web uploader. That framing attacks a strawman.
No production comic reader runs neural inpainting inside a Manifest V3 service worker on CPU. The real systems bottleneck in a browser extension is acquiring clean image pixels from hostile or virtualized viewers, scoping permissions responsibly, and routing difficult layouts to comic-aware OCR and inpainting pipelines.
Why Naive <img> Scraping Breaks on Modern Comic Viewers
Early reader scripts assumed every chapter loaded as plain sequential <img> tags. Current manga portals and vertical webtoon viewers break that assumption in three ways:
-
Lazy-loaded vertical webtoons: Long-strip viewers attach
IntersectionObserverhooks that keep offscreen panels blank or swap placeholder thumbnails until scrolled into view. -
HTML5
<canvas>and tiled surfaces: Many viewers paint pages onto<canvas>elements—sometimes shuffling image tiles in memory—leaving zero standalone image URLs in the DOM. -
CORS-tainted canvas buffers (
SecurityError): When scripts render cross-origin CDN images onto a<canvas>withoutAccess-Control-Allow-Originheaders, callingcanvas.toBlob()ortoDataURL()fails immediately with a security error.
Tiered Canvas Capture and Visible-Tab Fallback
A resilient extension avoids treating <canvas> readers as dead ends by resolving pixels in stages: check untainted canvases and direct image blobs first, then fall back to host-permitted background fetches or DPR-scaled visible-tab region capture when a canvas is tainted:
async function captureComicRegion(node, tabId) {
if (node instanceof HTMLCanvasElement) {
try {
const blob = await new Promise((resolve, reject) =>
node.toBlob((b) => (b ? resolve(b) : reject(new Error("Blank canvas"))), "image/png")
);
return { source: "canvas-direct", blob };
} catch (err) {
if (err.name !== "SecurityError") throw err;
}
}
const box = node.getBoundingClientRect();
const dpr = window.devicePixelRatio || 1;
return chrome.runtime.sendMessage({
type: "CAPTURE_TAB_CROP",
tabId,
rect: {
x: Math.round(box.left * dpr),
y: Math.round(box.top * dpr),
w: Math.round(box.width * dpr),
h: Math.round(box.height * dpr),
},
});
}
Two engineering details decide whether that fallback produces readable OCR or garbage:
-
Visible-tab constraints:
captureVisibleTabonly snapshots pixels painted inside the active foreground tab. Tall Korean manhwa strips exceeding viewport height need scroll-and-stitch capture with an overlap band so dialogue crossing a slice edge is never clipped. -
Physical pixel scaling: Scaling coordinates by
devicePixelRatiopreserves small Japanese furigana (振り仮名) and thin Hangul strokes on HiDPI screens before OCR runs.
Permission Scoping, Privacy Triggers, and Browser Parity (v3.2.7 vs. v3.2.1)
Skepticism around <all_urls>, tabs, and downloads permissions is justified whenever an extension runs opaque background scripts. Those permissions exist because comic readers visit diverse publisher portals and creator galleries rather than a single domain—but trustworthy architecture locks down when uploads occur:
- Action-gated network requests: Image payloads should leave the browser only on explicit user actions—clicking translate, enabling an opt-in domain/path auto-translate rule (disabled by default), checking shared output, or sending feedback—never during silent idle browsing.
-
Abuse control on free guest trials: Supporting no-signup daily free trial credits (
5free daily credits per IP) opens an easy abuse vector for automated scripts. In Chromev3.2.7, MangaTranslate (mangatranslate.com) keeps a lightweight helper tab open during guest verification instead of demanding immediate registration, while signed-in accounts synchronize5daily check-in credits across web and extension workflows. -
Honest cross-browser capabilities: Extension APIs differ across browser vendors, so documentation should match shipped builds rather than generic promises:
-
Chrome & Chromium (
v3.2.7on Chrome Web Store — Chrome, Edge, Brave, Opera, Vivaldi): Includes Default Mode in-place overlays on images and<canvas>, optional domain/path auto-translate (off by default), region cropping, local reading history, and guest trial helper verification. -
Firefox (
manga-translatev3.2.1on Mozilla Add-ons, plus Firefox for Android): Covers page scanning, single/batch translation, compatible<canvas>and webtoon capture, strip merging, ZIP/image export, and Email or Google login. - Safari & Mobile Chrome: Neither supports desktop Chrome extensions, and there is no native Safari extension. Readers on iPhone, iPad, or macOS Safari upload screenshots or chapters in the browser web app or installable web/PWA interface instead.
-
Chrome & Chromium (
Answering Common Questions: ChatGPT, Google Lens, and OCR Fallbacks
Can ChatGPT, Gemini, or Google Translate replace a manga extension?
General multimodal LLMs (ChatGPT and Gemini) and Google Lens solve adjacent but distinct tasks:
- Where chat LLMs excel: Unpacking slang, historical puns, or cultural subtext when you paste a single cropped speech bubble into a chat prompt.
- Where generic tools fail: Chat models output plain transcripts outside the comic image, forcing constant window-switching. Meanwhile, generic camera/screenshot overlays regularly misorder vertical right-to-left Japanese columns, merge phonetic ruby characters into kanji words, or stamp solid boxes over shaded Korean webtoon art.
- What comic-tuned fallback OCR adds: Dedicated visual pipelines separate enclosed dialogue balloons from line art, apply script-specific reading order (right-to-left columns for Japanese manga/doujinshi; top-to-bottom horizontal bubbles for Korean webtoons), execute vertical JP/KR OCR + screentone inpainting, and reflow text cleanly inside the restored panel.
How can developers verify extension OCR and inpainting quality?
Instead of relying on unverified promotional numbers, inspect any extension on the same three edge cases using your own authorized pages:
- Dense vertical dialogue with furigana: Confirm small ruby glosses do not corrupt noun recognition or reverse column sequence.
-
Borderless captions and
<canvas>panels: Test whether non-<img>viewers export crisp frames without cropping balloon edges across tall strip seams. - Halftone and gradient reconstruction: Inspect erased speech areas over monochrome screentones or colored lighting gradients for smearing, then verify whether individual bubbles remain editable afterward.
Comparison: Extensions vs. General AI vs. Local Pipelines
| Tool / Workflow | Setup & Platforms | Canvas & Live Tab Reading | Vertical JP & Webtoon OCR | Post-Edit Layer Recovery | Access Model |
|---|---|---|---|---|---|
| MangaTranslate (mangatranslate.com) | Zero-setup Web + Chrome v3.2.7 + Firefox v3.2.1 + Android + installable Web/PWA |
Live image & <canvas> capture; Firefox Android supported |
Vertical JP/KR OCR, strip slicing, halftone & gradient screentone inpainting | Free browser-local TextCover Studio saves .mt.png editable layers |
No-signup daily free trial credits + daily check-in credits; optional credit packs/plans |
| Mokuro | Local Python CLI + HTML viewer | Offline CBZ/folder reader only (no live browser extension) | Accurate raw Japanese OCR preserving selectable text | Built for Japanese study (Yomitan hover), not translated typesetting |
Free & open source (local hardware) |
| Koharu / BallonsTranslator | Local desktop runtime (NVIDIA GPU recommended) | Offline folder batches; desktop editor canvas | Swappable comic detectors, lama inpainting, custom LLM backends |
Interactive boxes & PSD export (BallonsTranslator) |
Free & open source (BYO GPU / API key) |
| ChatGPT / Gemini / Google Lens | Web chat or OS/mobile screenshot tool | Manual upload or basic overlay box | Lacks bubble masking and screentone inpainting | None (requires manual editing elsewhere) | Free capped tiers / paid plans |
Subscription Reading Extensions (Torii, Ichigo Reader, Scan Translator) |
Browser extension (+ cloud API) | In-page translation across supported comic portals | Comic-oriented OCR and rendered overlays | Limited standalone layer editing | Restrictive trials or paid subscription |
Honest Trade-Offs: When Local Mokuro or Koharu Makes More Sense
Extensions do not win every workload. Choosing the right stack comes down to hardware and reading intent:
-
Use
Mokurofor Japanese language study: When you want selectable original Japanese text overlays for dictionary lookups (YomitanorAnki) rather than replacing dialogue with translated prose, Mokuro fits far better. -
Use
KoharuorBallonsTranslatorfor offline GPU bulk jobs: If you already maintain an NVIDIA GPU workstation, process multi-volume offline archives regularly, and want full control over local model weights or custom API keys, local pipelines win on unit economics. -
Use
MangaTranslate (mangatranslate.com)for zero-setup reading and browser-local cleanup: When you switch between Chrome (v3.2.7) and Firefox (v3.2.1) tabs, read across laptop and mobile browsers without Python dependencies, or want vertical JP/KR OCR + screentone inpainting right away with no-signup daily free trial credits, a browser-native workflow avoids setup friction. Whenever an automated pass misreads stylized SFX or tight margins, opening the page in TextCover Studio lets you edit text, fonts, direction, and strokes 100% locally in your browser—zero server uploads and zero OS-specific desktop installers required.
Quick Engineering Checklist
- Audit trigger boundaries: Keep domain auto-translate off by default and confirm uploads occur only on explicit actions.
-
Test
<canvas>and HiDPI scaling: Verify tainted-canvas fallback paths preserve crisp furigana and stitch tall webtoon strips cleanly. -
Keep a post-edit escape hatch: Pair automated OCR/inpainting with editable layer exports (
.mt.pngor layered desktop files) for pages that need human polish. - Stay within authorized content: Only capture or translate licensed raw portals, creator-published webcomics, or personal DRM-free archives per site terms.
來源:DEV Community · dev.to