How to send selected item from devTools page to chrome sidebar page

I am working on the chrome devTools extension. Basically, I have a sidebar panel added to the Element panel. devtools.js

chrome.devtools.panels.elements.createSidebarPane("ChromeTrast", function(sidebar) {
  sidebar.setPage('devTools/chromeTrastDevTools.html');
}

chrometrastDevTools.html

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
</head>
<body>
  <p id="devTool-report"></p>
  <script src="../resources/jquery.js"></script>
  <script src="../resources/mustache.js"></script>
  <script src="../element/chromeTrastElement.js"></script>
  <script src="../element/RGB.js"></script>
  <script src="chromeTrastSidebar.js"></script>
</body>
</html>

In devtools.js I need to get the selected item ($ 0) and send it to chrometrastSidebar.js.

Basically, I am looking to transfer data from devtools.js> chrometrastSidebar.js

chrometrastSidebar.js is the source file from the html page of the sidebar.

I tried using chrome.devtools.inspectedWindow.eval (), but that did not work.

I did some research, but all messages are sent from the content to the bacground page.

thanks for any help

+4
1
You would preferably use to get and receive as below accordingly.

chrome.extension.sendMessage({greeting: "hello"}, function(response) {
  console.log(response.farewell);
});


chrome.extension.onMessage.addListener(
 function(request, sender, sendResponse) {
 if (request.greeting == "hello") sendResponse({farewell: JSON.stringify(sender)});
});
0

All Articles