Socket
Socket
Sign inDemoInstall

chrome-remote-interface

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-remote-interface - npm Package Compare versions

Comparing version 0.14.0 to 0.14.1

27

bin/client.js

@@ -6,2 +6,3 @@ #!/usr/bin/env node

var fs = require('fs');
var path = require('path');

@@ -40,3 +41,3 @@ var program = require('commander');

var chromeRepl = repl.start({
'prompt': '>>> ',
'prompt': '\033[32m>>>\033[0m ',
'ignoreUndefined': true,

@@ -46,2 +47,6 @@ 'writer': display

// make the history persistent
var history_file = path.join(process.env.HOME, '.cri_history');
require('repl.history')(chromeRepl, history_file);
function overridePrompt(string) {

@@ -71,13 +76,20 @@ // hack to get rid of the prompt (clean line and reposition cursor)

// hard code a callback to display the event data
var override = function () {
var override = function (filter) {
// remove all the listeners (just one actually) anyway
chrome.removeAllListeners(eventName);
var status = {};
if (registeredEvents[eventName]) {
chrome.removeAllListeners(eventName);
// a filter will always enable/update the listener
if (!filter && registeredEvents[eventName]) {
delete registeredEvents[eventName];
status[eventName] = false;
} else {
status[eventName] = registeredEvents[eventName] = true;
event(function (message) {
// use the filter (or true) as a status token
var statusToken = (filter ? filter.toString() : true);
status[eventName] = registeredEvents[eventName] = statusToken;
event(function (params) {
var repr = {};
repr[eventName] = message;
if (filter) {
params = filter(params);
}
repr[eventName] = params;
overridePrompt(display(repr));

@@ -96,2 +108,3 @@ });

chromeRepl.on('exit', function () {
console.log();
chrome.close();

@@ -98,0 +111,0 @@ });

@@ -12,3 +12,3 @@ {

"homepage": "https://github.com/cyrus-and/chrome-remote-interface",
"version": "0.14.0",
"version": "0.14.1",
"repository": {

@@ -23,3 +23,4 @@ "type": "git",

"ws": "1.x.x",
"commander": "2.1.x"
"commander": "2.1.x",
"repl.history": "0.1.x"
},

@@ -26,0 +27,0 @@ "files": [

@@ -69,2 +69,25 @@ chrome-remote-interface

### Tab management
The bundled client exposes subcommands to interact with the HTTP frontend
(e.g., [List](#modulelistoptions-callback), [New](#modulenewoptions-callback),
etc.), run with `--help` to display the list of available options.
Here are some examples:
```javascript
$ chrome-remote-interface new 'http://example.com'
{ description: '',
devtoolsFrontendUrl: '/devtools/inspector.html?ws=localhost:9222/devtools/page/b049bb56-de7d-424c-a331-6ae44cf7ae01',
id: 'b049bb56-de7d-424c-a331-6ae44cf7ae01',
thumbnailUrl: '/thumb/b049bb56-de7d-424c-a331-6ae44cf7ae01',
title: '',
type: 'page',
url: 'http://example.com/',
webSocketDebuggerUrl: 'ws://localhost:9222/devtools/page/b049bb56-de7d-424c-a331-6ae44cf7ae01' }
$ chrome-remote-interface close 'b049bb56-de7d-424c-a331-6ae44cf7ae01'
```
### Inspection
Using the `inspect` subcommand it is possible to perform [command

@@ -78,3 +101,3 @@ execution](#chromedomainmethodparams-callback) and [event

Here's a sample session:
Here is a sample session:

@@ -106,6 +129,24 @@ ```javascript

The bundled client also exposes commands to interact with the HTTP frontend
(e.g., [List](#modulelistoptions-callback), [New](#modulenewoptions-callback),
etc.), run with `--help` to display the list of available options.
#### Event filtering
To reduce the amount of data displayed by the event listeners it is possible to
provide a filter function. In this example only the resource URL is shown:
```javascript
$ chrome-remote-interface inspect
>>> Network.enable()
{ result: {} }
>>> Network.requestWillBeSent(params => params.request.url)
{ 'Network.requestWillBeSent': 'params => params.request.url' }
>>> Page.navigate({url: 'https://www.wikipedia.org'})
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/' }
{ result: { frameId: '5530.1' } }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia_wordmark.png' }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png' }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/js/index-3b68787aa6.js' }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/js/gt-ie9-c84bf66d33.js' }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/img/sprite-bookshelf_icons.png?16ed124e8ca7c5ce9d463e8f99b2064427366360' }
{ 'Network.requestWillBeSent': 'https://www.wikipedia.org/portal/wikipedia.org/assets/img/sprite-project-logos.png?9afc01c5efe0a8fb6512c776955e2ad3eb48fbca' }
```
Embedded documentation

@@ -117,5 +158,6 @@ ----------------------

Protocol][rdp]. The `category` field determines if the member is a `command`,
an `event` or a `type`. Remember that this REPL interface provides completion.
an `event` or a `type`.
For example to learn how to call `Page.navigate`:
Remember that the REPL interface provides completion. For example to learn how
to call `Page.navigate`:

@@ -430,5 +472,4 @@ ```javascript

Note that the callback is fired when the tab is *queued* for removal,
but the actual removal will occur asynchronously. It typically takes
~200ms for this to occur.
Note that the callback is fired when the tab is *queued* for removal, but the
actual removal will occur asynchronously.

@@ -527,3 +568,3 @@ ### module.Version([options], [callback])

Page.enable();
once('ready', function() {
once('ready', function () {
Page.navigate({'url': 'https://github.com'});

@@ -530,0 +571,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc