diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js index 8943b846f..b57ba9949 100644 --- a/src/pages/Background/index.js +++ b/src/pages/Background/index.js @@ -1,2 +1,11 @@ console.log('This is the background page.'); console.log('Put the background scripts here.'); + + +chrome.runtime.onMessage.addListener(messageReceived); + +function messageReceived(msg, sender, sendResponse) { + console.log('inside the background paghe', msg, sender, sendResponse) + return sendResponse({ farewell: "goodbye" }); + +} \ No newline at end of file diff --git a/src/pages/Content/index.js b/src/pages/Content/index.js index d9e44cee1..525becbd7 100644 --- a/src/pages/Content/index.js +++ b/src/pages/Content/index.js @@ -3,4 +3,14 @@ import { printLine } from './modules/print'; console.log('Content script works!'); console.log('Must reload extension for modifications to take effect.'); + + printLine("Using the 'printLine' function from the Print Module"); + +chrome.runtime.onMessage.addListener(messageReceived); + +function messageReceived(msg, sender, sendResponse) { + console.log('inside the CONTENT paghe', msg, sender, sendResponse) + return sendResponse({ farewell: "goodbye" }); +} + diff --git a/src/pages/Popup/Popup.jsx b/src/pages/Popup/Popup.jsx index df1684b13..9e500b688 100644 --- a/src/pages/Popup/Popup.jsx +++ b/src/pages/Popup/Popup.jsx @@ -4,6 +4,24 @@ import './Popup.css'; import { Text } from '@chakra-ui/react' const Popup = () => { + const [name, setName] = React.useState(''); + + const handleClick = () => { + console.log('handleClick function!',); + + /*chrome.runtime.sendMessage('{ greeting: name }', function (response) { + console.log('response in popup click handler', response); + });*/ + + + chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { + chrome.tabs.sendMessage(tabs[0].id, { type: name }, function (response) { + alert(response) + }); + }); + + + } return (
@@ -14,6 +32,9 @@ const Popup = () => { PLANES + + setName(e.target.value)} /> +