Skip to content

Commit

Permalink
Support cross-extension messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimyr committed Feb 21, 2020
1 parent 1df5aee commit 1749f85
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/chrome/backgroundscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ chrome.runtime.onMessage.addListener(function(request, sender, responseCallback)
}
});

// Add listener for cross-extension messaging. (See https://developer.chrome.com/extensions/messaging#external)
chrome.runtime.onMessageExternal.addListener(function(request) {
if (request && request.action === 'toggle-markdown') {
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
var tab = tabs[0];
chrome.tabs.sendMessage(tab.id, {action: 'button-click', });
});
}
});
// Add the browserAction (the button in the browser toolbar) listener.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.sendMessage(tab.id, {action: 'button-click', });
Expand Down

0 comments on commit 1749f85

Please sign in to comment.