Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //RESPONSE holds whatever the response is sent by the content scripts
- //SENDER holds the information about the TAB which is sending this information from the bg script (tab.id)
- //SENDRESPONSE is used to send back a response to the content scripts
- //BACKGROUND DEBUG WINDOW
- console.log("AIM Chat: Chrome Extension Messaging");
- chrome.runtime.onMessage.addListener(
- function(request, sender, sendResponse){
- console.log(JSON.parse(JSON.stringify(request.message)));
- //THIS SHOWS UP IN THE BACKGROUND DEBUG WINDOW
- if(request.message === "ContentScript: Background is a doof.") {
- //THIS SHOWS UP IN THE BROWSER DEBUG WINDOW
- sendResponse({ result: "Background: I'm gonna warn you! Then block you!" });
- }
- if(request.message === "PopupScript: How are you feeling, Background?") {
- //THIS SHOWS UP IN THE POPUP DEBUG WINDOW
- sendResponse({ result: "Background feel floopy." });
- }
- return true;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement