Closed ig3 closed 1 year ago
Adding a second of delay to sending the 'enable' message from the background process seems to make it reliable, which is consistent with the fault being a timing issue.
The message is sent from the background process in response to the onActivated event.
The documentation for onActivated is not quite correct: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/onActivated
It says the event occurs when the active tab changes. But it fires for each page navigation, even when neither the outer page nor the iframe are reloaded and the active tab does not change at all. So it is a bit excessive. But at least not too much work, so no great harm from too many messages.
But, the timing issue could be overcome by having the foreground code send a message to the background code, requesting whether enabled. This would only be sent when the foreground was ready to receive the response message, which might be quite delayed if it takes a long time to download and render the chapter.
Version 1.0.3 sends a message from content script to background script and the response is the isEnabled status. This only happens when the content script is running and ready, so it enables reliably.
fixed in 1.0.3
Using this add-on with calibre-web, which presents epub book content in an iframe, it usually works but sometimes when a new chapter is loaded, the add-on does not work in the iframe properly. I suspect because of load delays, the enable message, which is received OK in the main page, is not received in the iframe page.