This NodeJS library helps you to communicate with chrome extension/app.
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);
});
sendMessage(msgObject)
- Send a message to chrome extension/app. ThemsgObject
must be a JSON object.on('message', handler)
- Listen messages from chrome extension/app.
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 commandsh install_host.sh
. - Open a tab with
chrome://extensions/
in chrome, load the extension with/demo
directory, you will see acube
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: