tesseract.js-chrome-extension icon indicating copy to clipboard operation
tesseract.js-chrome-extension copied to clipboard

OCR in extension won't work

Open kartashowRoman opened this issue 4 years ago • 4 comments

Hello! I have installed the extension but on button click no OCR occurs... nothing happens. What might be the reason? I just cloned the repo and uploaded the files. The popup opens but that's all

kartashowRoman avatar Oct 27 '21 18:10 kartashowRoman

I found this was due to a security policy change. When I right click and view the console in developer tools for the extension, I see that the content policy (which can be defined in the "manifest.json" of the chrome extension) doesn't give access Tessaract.js source files. I tried to work around this using nested injection (one of the injection approaches for content scripts in chrome extensions) but haven't been able to get this to work since it seems like the Tesseract.js file depends on the Worker.js file, and isn't properly accessing the local copy :/

jordansafer avatar Dec 14 '21 05:12 jordansafer

Same thing happening here! Any trick to fix it?

taouichaimaa avatar Feb 16 '22 15:02 taouichaimaa

It seems that since the browser implementation of tesseract.js utilizes a WebWorker, which loads code from tesseract.js-core which is hosted on a CDN (documentation found here), any attempts at accessing external resources are rejected. One solution that worked for me was directly loading workerPath and corePath from CDNs, and updating the "content_security_policy" in the manifest as needed. This also removes the need for local installations of the files. I've also loaded tesseract.min.js from a CDN for consistency, although using local installations works fine.

CSken avatar Mar 24 '22 07:03 CSken

Hello! this is not working with manifest version 3 . any idea how to make this work using manifest version 3 ?

sanjeev07 avatar May 16 '22 04:05 sanjeev07