ig3 / zhongwen

A fork of the "Zhongwen" extension modified to support content in iframes.
https://chrome.google.com/webstore/detail/zhongwen-chinese-english/kkmlkkjojmombglmlpbpapmhcaljjkde
GNU General Public License v2.0
0 stars 0 forks source link

operation in iframes #2

Closed ig3 closed 1 year ago

ig3 commented 1 year ago

The content script loads to all frames but it only accepts messages in the top level frame. So, it seems it loads but won't do anything in the other frames. Why?

ig3 commented 1 year ago

Attempting to access the document object of an iframe from the parent fails if the content of the parent and iframe are not the same origin. Errors like:

failed with: DOMException: Permission denied to access property "document" on cross-origin object

So the current implementation of lookup for content in an iframe only works for iframes that are same origin.

If the content script is loaded into every iframe already. If it received the signals to enable/disable, it could perform lookup within the iframe without one frame having to look into the other. This then leaves the issue of how and where to present the pop-ups. Separately in each frame? Of by some sort of messaging, to always appear in the top frame? The advantage of the latter is that the pop-up can occupy more of the browser window, even if the iframe content window is small.

ig3 commented 1 year ago

Scant testing but processing messages in every frame with pop-up in top level frame by messaging seems to be working in development. There is an issue coordinating turning on/off across multiple tabs. The indicator changes for all tabs but the operational state seems only to change for the current tab. Need to do more testing to understand what is/isn't happening.

ig3 commented 1 year ago

I changed handling of iframes to be message based, with the pop-up only displayed in the top frame.