A
A
Alexander Karpov2017-01-20 11:55:37
JavaScript
Alexander Karpov, 2017-01-20 11:55:37

How can I access the Google Chrome browser API through the console?

In general, I'm trying to somehow feel the JavaScript APIs for Google Chrome, the documentation of which is here: tyts
For example, there is chrome.alarms , but when I just want to get this object in the console (DevTools which) I get undefined , probably because this console does not have access to this API. How then to be?
Tell me please. Thank you!
I tried to touch api from the extension. Quickly sketched an extension, did this:
09e6809a6c564ef9a3d81766accc3a9b.png
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2017-01-20
@vitali1995

As far as I know, only extensions have access to the browser api. And only to those apis that are specified in the manifest. The console operates on the page environment.

P
plartem, 2017-01-20
@plartem

Content scripts have some limitations. They cannot:
Use chrome.* APIs, with the exception of:
- extension ( getURL , inIncognitoContext , lastError , onRequest , sendRequest )
- i18n
- runtime ( connect , getManifest , getURL , id , onConnect , onMessage , sendMessage )
- storage
( https ://developer.chrome.com/extensions/content_scripts )
Move the code to the background script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question