Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to extend chrome's __commandLineAPI

Google Chrome devtools comes with an extended API provided by so called Command Line Api. API reference can be found here. Access to the API is implemented by wrapping console input with with statement like this:

with (__commandLineAPI || { __proto__: null }) {
    //blah-blah-blah your code goes here
}

Suppose I want to add my own methods to __commandLineAPI object. For example debugAll function that takes any object and invoke debug for all function properties. Is there any way to extend it?

like image 976
Yury Tarabanko Avatar asked Nov 11 '22 06:11

Yury Tarabanko


1 Answers

I'm not sure you can modify the __commandLineAPI directly, but a chrome extension could provide extra global functions which you can use.

There's not a lot of info, but see here on the chrome site where they say:

Chrome extensions can inject additional helper methods into the commandline API. For example, the Debug Utils extension (github) offers hooks for breaking on property access, event firings, and method calls.

Also, there's an example they provide on github

That example uses devtools_page key in manifest.json to specify an HTML page to load for each instance of DevTools open and the chrome.devtools.inspectedWindow API to provide functions globally

like image 99
Luke H Avatar answered Nov 15 '22 08:11

Luke H