Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. //RESPONSE holds whatever the response is sent by the content scripts
  2. //SENDER holds the information about the TAB which is sending this information from the bg script (tab.id)
  3. //SENDRESPONSE is used to send back a response to the content scripts
  4.  
  5. //BACKGROUND DEBUG WINDOW
  6. console.log("AIM Chat: Chrome Extension Messaging");
  7.  
  8. chrome.runtime.onMessage.addListener(
  9. function(request, sender, sendResponse){
  10. console.log(JSON.parse(JSON.stringify(request.message)));
  11.  
  12. //THIS SHOWS UP IN THE BACKGROUND DEBUG WINDOW
  13. if(request.message === "ContentScript: Background is a doof.") {
  14. //THIS SHOWS UP IN THE BROWSER DEBUG WINDOW
  15. sendResponse({ result: "Background: I'm gonna warn you! Then block you!" });
  16. }
  17. if(request.message === "PopupScript: How are you feeling, Background?") {
  18. //THIS SHOWS UP IN THE POPUP DEBUG WINDOW
  19. sendResponse({ result: "Background feel floopy." });
  20. }
  21. return true;
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement