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

Can't use injected scripts #118

Open
aleksolutions opened this issue Jun 8, 2023 · 2 comments
Open

Can't use injected scripts #118

aleksolutions opened this issue Jun 8, 2023 · 2 comments

Comments

@aleksolutions
Copy link

When I try to inject a script to the client (I need to use some globals available in the site) and build the extension, the transpiled code tries to use getUrl but that method is not available on the client (obviously)

There is any way to make this work?

@samrum
Copy link
Owner

samrum commented Jun 9, 2023

The plugin creates a wrapper script for scripts that contain imports, so to avoid that you can remove imports from your script. Alternatively could drop a static script in public and manually inject it.

@gehaktmolen
Copy link

gehaktmolen commented Jun 19, 2023

Can't you just use the Chrome executeScript function?

await chrome.scripting.executeScript({
              target: {
                  tabId = 0,
                  // frameIds = []
              },
              func: runInjectScript,
              args: ['something', true, 123],
              world: 'MAIN'
          });

const runInjectScript = () => { console.log('Hi, show me window object:', window);}

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

3 participants