Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome Extension Manifest v3 Service Worker #1229

Open
AleCucina opened this issue Jan 11, 2024 · 2 comments
Open

Chrome Extension Manifest v3 Service Worker #1229

AleCucina opened this issue Jan 11, 2024 · 2 comments

Comments

@AleCucina
Copy link

I noticed there is a problem obfuscating the service worker of a manifestv3 chrome extension.
Now the function to run a script is:

    const example = "Hello World!"
    chrome.scripting.executeScript({
        func: (param) => {
            console.log(param) // Hello World!
        },
        args: [example],
        target: { tabId: tabId }
    })

But probably with the obfuscated code a problem arises because what is inside the func() loses meaning since the rest of the obfuscated code is in the service worker and not in the content of the page.

Does anyone know how to fix this problem?
Thanks in advance!

@younes-zeboudj
Copy link

I have the same use case, I had to create a file 'functionX' , pass 'function1' to the 'func' attribute, make the obfuscator skip function1, obfuscate the file 'functionX', and insert a function with name 'function1' and the resulte of 'functionX' obfuscation as body to the obfuscated background.js

@younes-zeboudj
Copy link

workaround:

// javascript-obfuscator:disable
function myfunc=(param) => {
    console.log(param) // Hello World!
}
// javascript-obfuscator:enable

   const example = "Hello World!"
    chrome.scripting.executeScript({
        func: myfunc,
        args: [example],
        target: { tabId: tabId }
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants