chrome-remote-interface
Advanced tools
Comparing version 0.14.1 to 0.14.2
@@ -26,5 +26,16 @@ #!/usr/bin/env node | ||
function inspect(options, args) { | ||
if (args.webSocket) { | ||
options.chooseTab = args.webSocket; | ||
function inspect(target, args, options) { | ||
// otherwise the active tab | ||
if (target) { | ||
if (args.webSocket) { | ||
// by WebSocket URL | ||
options.chooseTab = target; | ||
} else { | ||
// by tab id | ||
options.chooseTab = function (tabs) { | ||
return tabs.findIndex(function (tab) { | ||
return tab.id === target; | ||
}); | ||
}; | ||
} | ||
} | ||
@@ -139,3 +150,3 @@ | ||
function list(options, args) { | ||
function list(options) { | ||
Chrome.List(options, function (err, tabs) { | ||
@@ -150,4 +161,4 @@ if (err) { | ||
function _new(options, args) { | ||
options.url = args; | ||
function _new(url, options) { | ||
options.url = url; | ||
Chrome.New(options, function (err, tab) { | ||
@@ -162,3 +173,3 @@ if (err) { | ||
function activate(options, args) { | ||
function activate(args, options) { | ||
options.id = args; | ||
@@ -173,3 +184,3 @@ Chrome.Activate(options, function (err) { | ||
function close(options, args) { | ||
function close(args, options) { | ||
options.id = args; | ||
@@ -184,3 +195,3 @@ Chrome.Close(options, function (err) { | ||
function version(options, args) { | ||
function version(args, options) { | ||
Chrome.Version(options, function (err, info) { | ||
@@ -195,3 +206,3 @@ if (err) { | ||
function protocol(options, args) { | ||
function protocol(args, options) { | ||
options.remote = args.remote; | ||
@@ -210,3 +221,2 @@ Chrome.Protocol(options, function (err, protocol) { | ||
var action; | ||
var actionArguments; | ||
@@ -218,9 +228,8 @@ program | ||
program | ||
.command('inspect') | ||
.description('inspect a Remote Debugging Protocol target') | ||
.option('-w, --web-socket <url>', 'WebSocket URL') | ||
.command('inspect [<target>]') | ||
.description('inspect a target (defaults to the current tab)') | ||
.option('-w, --web-socket', 'interpret <target> as a WebSocket URL instead of a tab id') | ||
.option('-j, --protocol <file.json>', 'Remote Debugging Protocol descriptor') | ||
.action(function (args) { | ||
action = inspect; | ||
actionArguments = args; | ||
.action(function (target, args) { | ||
action = inspect.bind(null, target, args); | ||
}); | ||
@@ -238,5 +247,4 @@ | ||
.description('create a new tab') | ||
.action(function (args) { | ||
action = _new; | ||
actionArguments = args; | ||
.action(function (url) { | ||
action = _new.bind(null, url); | ||
}); | ||
@@ -247,5 +255,4 @@ | ||
.description('activate a tab by id') | ||
.action(function (args) { | ||
action = activate; | ||
actionArguments = args; | ||
.action(function (id) { | ||
action = activate.bind(null, id); | ||
}); | ||
@@ -256,5 +263,4 @@ | ||
.description('close a tab by id') | ||
.action(function (args) { | ||
action = close; | ||
actionArguments = args; | ||
.action(function (id) { | ||
action = close.bind(null, id); | ||
}); | ||
@@ -274,4 +280,3 @@ | ||
.action(function (args) { | ||
action = protocol; | ||
actionArguments = args; | ||
action = protocol.bind(null, args); | ||
}); | ||
@@ -288,3 +293,3 @@ | ||
if (action) { | ||
action(options, actionArguments); | ||
action(options); | ||
} else { | ||
@@ -291,0 +296,0 @@ program.outputHelp(); |
@@ -23,5 +23,5 @@ var defaults = require('./defaults.js'); | ||
var fetcher; | ||
if (info.Browser.startsWith('Chrome/')) { | ||
if (info.Browser.match(/^Chrome\//)) { | ||
fetcher = fetchFromChrome; | ||
} else if (info.Browser.startsWith('Microsoft Edge ')) { | ||
} else if (info.Browser.match(/^Microsoft Edge /)) { | ||
fetcher = fetchFromEdge; | ||
@@ -28,0 +28,0 @@ } else { |
@@ -12,3 +12,3 @@ { | ||
"homepage": "https://github.com/cyrus-and/chrome-remote-interface", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"repository": { | ||
@@ -21,2 +21,5 @@ "type": "git", | ||
}, | ||
"engines": { | ||
"node": ">=0.12.15" | ||
}, | ||
"dependencies": { | ||
@@ -23,0 +26,0 @@ "ws": "1.x.x", |
@@ -15,12 +15,14 @@ chrome-remote-interface | ||
Implementation | Notes | ||
--------------------|------ | ||
[Google Chrome][1] | native support | ||
[Microsoft Edge][2] | via the [Edge Diagnostics Adapter][edge-diagnostics-adapter] | ||
[Node.js][3.1] | via [node-inspector][3.2] (by connecting to `ws://127.0.0.1:8080/?port=5858` by default) | ||
Implementation | Notes | ||
---------------------|------ | ||
[Google Chrome][1.1] | native support; enable [port forwarding][1.2] in Chrome for Android | ||
[Microsoft Edge][2] | via the [Edge Diagnostics Adapter][edge-diagnostics-adapter] | ||
[Node.js][3.1] | via [`--inspect`][3.3] (with `--port 9229`) or via [node-inspector][3.2] (by connecting to `ws://127.0.0.1:8080/?port=5858` by default) | ||
[1]: https://www.chromium.org/ | ||
[1.1]: https://www.chromium.org/ | ||
[1.2]: https://developer.chrome.com/devtools/docs/remote-debugging-legacy | ||
[2]: https://www.microsoft.com/windows/microsoft-edge | ||
[3.1]: https://nodejs.org/ | ||
[3.2]: https://github.com/node-inspector/node-inspector | ||
[3.3]: https://chromedevtools.github.io/debugger-protocol-viewer/v8/ | ||
@@ -271,4 +273,4 @@ Installation | ||
- a `function` that takes the array returned by the `List` method and must | ||
return the numeric index of a tab; | ||
- a `function` that takes the array returned by the `List` method and returns | ||
the numeric index of a tab; | ||
- a tab `object` like those returned by the `New` and `List` methods; | ||
@@ -523,3 +525,3 @@ - a `string` representing the raw WebSocket URL, in this case `host` and | ||
```javascript | ||
on('event', function (message) { | ||
chrome.on('event', function (message) { | ||
if (message.method === 'Network.requestWillBeSent') { | ||
@@ -564,6 +566,6 @@ console.log(message.params); | ||
```javascript | ||
Network.enable(); | ||
Page.enable(); | ||
once('ready', function () { | ||
Page.navigate({'url': 'https://github.com'}); | ||
chrome.Network.enable(); | ||
chrome.Page.enable(); | ||
chrome.once('ready', function () { | ||
chrome.Page.navigate({'url': 'https://github.com'}); | ||
}); | ||
@@ -570,0 +572,0 @@ ``` |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
580980
13189
660