dropWizard
dropWizard

Reputation: 3548

accessing chrome extension functions in console?

If I create a bunch of functions in a chrome extension, is there anyway to access them through the console?

for example:

contentScript.js

function test() {
    console.log('hello')
}

then be able to run test() in the console

Upvotes: 5

Views: 2985

Answers (2)

woxxom
woxxom

Reputation: 73865

The content scripts run in an "isolated world" which is a different context. By default devtools works in the page context so you need to switch the context selector in devtools console toolbar to your extension:

enter image description here

An alternative solution is to expose the functions in the page context by putting them into a <script> element in the web page, but that won't be your content script anymore, it'd be just a normal page script function (more info).

Upvotes: 7

Mykhaylo K
Mykhaylo K

Reputation: 24

You can access your extension's console by right click on the extension popup and then selecting "Inspect".

Upvotes: -1

Related Questions