1

I have a script in my popup.html:

 </body>
 <script src="popup.js"></script>
 </html>

Through which I am trying to obtain the DOM of a particular tab. More specifically, I am attempting to determine the existence of a particular element on the current page in a specific tab and then use this information within popup.js. How would I go about doing this?

1 Answers1

1

You can't access current page DOM from a popup. You need a content script for that. Start by setting up these three scripts:

With these you can send messages between popup script and content script using background script as a proxy. Read about message passing here.

You can simplify the process a bit using executeScript instead a content script. You will still need a communication between popup script and a background page though.

Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105