Am I getting a chrome security policy error because of code tokenization?

54 views Asked by At

I'm trying to implement Tesseract.js into a chrome extension but I get a CSP error whenever my background script runs, which container the Tesseract calls. I tried a simpler borwser extension that runs tessercat.js as an example but I get the same CSP error. It seems to come from these code blobs things that contain the Tesseract libraries, this sort of stuff:

https://ufile.io/pk6b26qj

The chrome extension example I mentioned also has this

https://github.com/jeromewu/tesseract.js-chrome-extension

There's even a 3MB javascript file in there.

The error I get is Content Security Policy: The page’s settings blocked the loading of a resource at blob:moz-extension://0312d6e0-72a6-49ea-8635-7468b207b6de/3090ffaf-993d-4cbf-ad80-2712368933f2 (“script-src”).

Obviously the alpha-numeric url part is different for the github extension, but same deal

Here's my background script:


chrome.tabs.onActivated.addListener((tabId, changeInfo, tab) => {

    chrome.tabs.captureVisibleTab({format: "png"}, function(imageUri){
        chrome.storage.local.set({image_uri: imageUri}); 

        Tesseract.recognize(
            imageUri,
            "eng"
        )
            .catch(err => console.error(err))
            .then(({data: {text}}) => {
                console.log(text)
            })  ;  
    });
});

and my manifest:

    "manifest_version": 2, 
    "name": "Name2Clip",
    "version": "0.1.0",
    "description": "things",
    "icons": {
        "128": "assets/global-icon128.png",
        "48": "assets/global-icon48.png",
        "16": "assets/global-icon16.png"
    },
    "browser_action": {
        "default_icon": "assets/global-icon16.png",
        "default_popup": "popup.html"
    },
    "background": {
        "scripts": [
            "scripts/main.js"
        ],
        "persistent": false
    },
    "permissions": [
        "<all_urls>",
        "activeTab",
        "unlimitedStorage",
        "storage"
    ]
}

I tried toggling off the security.csp.enable policy inside about:config but I still get the CSP error.

I'm running this on firefox 102.0.1

0

There are 0 answers