node-chrome-bridge
node-chrome-bridge copied to clipboard
A Chrome Extension/App Bridge for NodeJS
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. ThemsgObjectmust 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
NodeJSinstalled, install it first. - Install native host. open a terminal, cd to the
/demo/hostdirectory, run commandsh install_host.sh. - Open a tab with
chrome://extensions/in chrome, load the extension with/demodirectory, you will see acubepopup 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:
