flashlizi / node-chrome-bridge

A Chrome Extension/App Bridge for NodeJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Chrome Extension/App Bridge for NodeJS

This NodeJS library helps you to communicate with chrome extension/app.

Usage

var chromeBridge = require('chrome-bridge');

//send a message to chrome
chromeBridge.sendMessage({text:'hello chrome!'});

//listen message from chrome
chromeBridge.on('message', function(msg){
    console.log('received from chrome:', msg);
});

APIs

  • sendMessage(msgObject) - Send a message to chrome extension/app. The msgObject must be a JSON object.
  • on('message', handler) - Listen messages from chrome extension/app.

Demo

There is a simple demo Web Terminal, you can check it in the demo folder.

  • If you don't have NodeJS installed, install it first.
  • Install native host. open a terminal, cd to the /demo/host directory, run command sh install_host.sh.
  • Open a tab with chrome://extensions/ in chrome, load the extension with /demo directory, you will see a cube popup icon on the right of navigation bar.
  • Click it and open a page, play any commands on it, such as node -v.

Here is the screenshot:

效果演示图

About

A Chrome Extension/App Bridge for NodeJS

License:MIT License


Languages

Language:JavaScript 66.2%Language:Shell 21.7%Language:CSS 8.6%Language:HTML 3.6%