Reputation: 11
I'm trying to create a chrome extension that uses Tesseract.js (https://github.com/naptha/tesseract.js) to perform OCR on the captured images from a webpage.
I've created content script and a service worker for my extension.
In the content script I'm sending the request to service worker to capture screenshot of the webpage, then I'm sending the screenshot back to the content script, and I initialize tesseract's service worker there and perform OCR on the screenshot.
The above approach works on most of the pages, however on pages that have stricter CSP like github, where the plicy looks like this: "worker-src github.com/assets-cdn/worker/ github.com/webpack/ github.com/assets/ gist.github.com/assets-cdn/worker/" this approach does not work.
How else can I use webworker on such pages?
I can't spawn webworker from the main chrome extension's service worker.
I've tried created a small html page with tesseract.min.js and worker.min.js files, and open it in a new tab, and ocr works fine there
const customTab = chrome.runtime.getURL('./ocr_page.html');
const tab = await chrome.tabs.create({
url: customTab
});
However I don't want to open a new tab everytime I want to do ocr on a page.
Upvotes: 1
Views: 110