'Chrome extension to listen for when a "subscriber form" popup is rendered on a site and automatically inject name, email into the popup's form

I am learning to code and starting with browser plugins for practice. I have a plugin project where I have to do the following:

  1. Listen for what tab (and url) the user is currently on
  2. Listen for if a JS popup is rendered (specifically any of the popular popups that help sites grab new subscribers)
  3. Automatically inject the popup's subscriber form the name and email I have pre-approved the plugin to share

I think I have step 1 working right with the code below (I tested it with console.log statements.

chrome.tabs.onActivated.addListener(tab =\> {
chrome.tabs.get(tab.tabId, current_tab_info =\> {

});
});

If this is correct, what code should I add inside the chrome.tabs.get function to make steps 2 and 3 above work as intended?

Thank you for your support.

Best, N

The code above works fine, I am not sure how to proceed with steps 2 and 3 above.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source