Maybe it's not the best idea but you can use chrome.tabs.sendMessage
and chrome.runtime.onMessage.addListener
to communicate between contentscript.js
and popup.js
contentscript.js
is running directly in page scope so you can easily detect when page is ready. After that you can send a message chrome.tabs.sendMessage(tabs.id, {action: 'pageReady'});
. In popup.js
you are listening to:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.action === 'pageReady') {
// Do what you want to do on page ready
}
});
It should works good for you. You can also send response to the caller:
contentscript.js
send information to the popup.js
that page is ready.
popup.js
do what you want to do (show table).
popup.js
send information to the contentscript.js
that table is added.
EDIT
I'm not sure about my solution because I found information that:
The popup, while being an extension page, is not a background page. It
is only accessible when it is open
I don't know if it is possible to listen on events in popup. You need to check it.