nsfwjs
nsfwjs copied to clipboard
Unable to use in service workers in manifest v3
Hi, First of all, thanks for your work.
With manifest v3, chrome replaced background scripts with service workers, which cannot access the DOM. I am building a web extension that parses the dom and then analyses the image in the background, quite like nsfw-filter.
I am able to load nsfwjs in the service worker, but any attempt to feed it an image fails because the service worker cannot manipulate anything like images. For instance, any image that I send to the service worker will appear as empty in it.
Is there anything obvious that I am doing wrong, or has someone encountered the same issue ?
FYI see https://github.com/infinitered/nsfwjs/issues/558
I believe I could use someone testing what I stated here: https://github.com/infinitered/nsfwjs/issues/558#issuecomment-975721013
Because NSFWJS is compiled to ES5, that might be the issue that brings in the unsafe eval. (code here: https://github.com/infinitered/nsfwjs/blob/master/tsconfig.json#L10)
It's my thought that changing that line to "es2018" or so would remove the unsafe evals. Can you check into this, and if that's the case I'll release a browser extension version of NSFWJS?
Oh @0xturboblitz - I misunderstood the ticket. If you can create a simple project/test that I can use, I'll take a look to see if I can do anything.
Hi there, I saw this thread and made an example project, just run yarn install, then yarn build and you should be good to go! (add the build file as the chrome extension) Here's the repo
There appears to be 3 different times a "Function" class is created which is generally bad practice, it's essentially the same as eval as far as I know. I know the typescript is translated into javascript and I think that's where it's being put in here.
Google says "You can no longer execute external logic using chrome.scripting.executeScript({code: '...'}), eval(), and new Function()." here
@Acorn221 - have you tried what I suggested, where you can set the compile target? I guess I could track it down and figure it out, but since you have a project in place, it's easier for you to give it a go.
Is there any update on this issue? 'Unsafe-eval' prevents from loading nsfwjs
model in extension Manifest V3.
I'm not sure what can be done, I think it needs to be packaged up using something other than browserify (probably on a fork) but I'm not sure whether or not any other transpilers will work