question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access chrome object in Extensions API

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: v1.5.0
  • Platform / OS version: windows
  • URLs (if applicable):
  • Node.js version: 8.10

What steps will reproduce the problem?

Please include code that reproduces the issue.

I’m trying to disable webRTC local IP leak by using:

await page.evaluateOnNewDocument(() => {
chrome.privacy.network.webRTCIPHandlingPolicy.set({
                    value: "default_public_interface_only"
                });
});

https://developer.chrome.com/extensions/api_index

What is the expected result? access to chrome object like extension background.js

What happens instead? chrome object in undefined

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ebidelcommented, Jul 12, 2018

You’re trying to evaluate that piece of code in the context of the page, but chrome.* aren’t available in the context of the page due to how CRXs work.

In the next release, you’ll be able to use target.page() to get a background_page Page object. From there, you can call page.evaluate and UI think your snippet should work.

upcoming docs: https://pptr.dev/#?product=Puppeteer&version=master&show=api-targetpage

0reactions
JCMaiscommented, Sep 24, 2021

did you have any luck implementing this @s16h ? Or anyone else

Read more comments on GitHub >

github_iconTop Results From Across the Web

API reference - Chrome Developers
The complete reference to all APIs made available to Chrome Extensions. This includes APIs for the deprecated Chrome Apps platform as well as...
Read more >
How do I access ALL window objects from a Chrome extension?
To gain access to everything available to the host window , I had to create a script element, put all the code I...
Read more >
Chrome incompatibilities - Mozilla - MDN Web Docs
In Chrome: JavaScript APIs are accessed under the chrome namespace. (cf. Chrome bug 798169). Asynchronous APIs: In Firefox: Asynchronous APIs ...
Read more >
chrome object or chrome.tabs object not accessible from script ...
am experimenting with the chrome extensions API and I ran into a problem which I don't understand,. I have a background script "background.js"...
Read more >
Set Chrome app and extension policies (Windows)
Step 3: Get Chrome app or extension IDs · Open the Chrome Web Store. · Find and select the app or extension you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found