Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chrome.devtools.panels.create("TT's Automatron", "devtool/icon.ico", "devtool/panel.html",
- function(panel) {
- var panelconsole;
- panel.onShown.addListener(function tmp(panel) {
- panel.onShown.removeListener(tmp);
- panelconsole = panel;
- // this works
- chrome.runtime.sendMessage({type:'get-status'}, function(response) {
- panelconsole.write_queue(response.globalstatus);
- });;
- // this does not work - cannot listen to the same messages from popup.js
- // as I do it in background.js
- chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
- alert();
- });
- });
- }
- );
- // listening to the same messages as in devtools panel
- chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
- switch(request.type) {
- alert('This works');
- // recognising different messages
- case "start-tron":
- // ..some code..
- sendResponse({globalstatus: globalstatus});
- break;
- }
- });
- chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
- chrome.runtime.sendMessage({type: "start-tron", tabid:tabs[0].id});
- });
- var port = chrome.runtime.connect({name: 'automatron_console'});
- port.onMessage.addListener(function(item) {
- // if reference exists - panel is open
- if (panelconsole) {
- panelconsole.write_log(item);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement