read-aloud
read-aloud copied to clipboard
Selected text in iframe, reads from top of page
Selecting text in an iframe and pressing the play/pause keyboard shortcut: alt p (default),
or clicking on the Read Aloud toolbar button.
Starts reading from the top of the page, just as it does without selected text.
Expected The selected text should be read.
Example
https://www.autohotkey.com/docs/Program.htm
Select some text, for example, triple-click to select the paragraph that starts with "Tip: If your browser supports it, ..."
Press the Read Aloud play/pause keyboard shortcut: alt p (default)
Read aloud starts reading from the top of the page: "Using the Program AutoHotkey doesn't do anything on its own; ..."
The same thing happens after clicking on the Read Aloud toolbar icon, with a text selection (in an iframe).
What works
It works to right-click on selected text in an iframe and choose: "Read aloud selected text"
But it takes a lot more steps than just pressing the keyboard shortcut
- select text (in an iframe)
- move the mouse over the selected text
- right-click
- move the mouse to the entry "Read aloud selected text"
Depending on if the selected text is near the top or bottom of the browser, the right-click menu opens upwards or downwards.
And depending on how many browser extensions have entries in the right-click menu. If it opened downwards, then the mouse has to be moved past about 12 menu items. (tested in Edge) If the menu opened upwards, then the mouse has to be moved past about 2 items. (tested in Edge)
A possible solution
Maybe the play/pause keyboard shortcut and possibly the toolbar icon, could call the method in the right-click menu: "Read aloud selected text" when it detects selected text.
Read Aloud seems to already detect when there is selected text, because the right-click option "Read aloud selected text", only appears when there is selected text.
Notes
The following issue might be the same or related, but it only mentions "iframe" without any details: Read Aloud doesn't read iframe form https://github.com/ken107/read-aloud/issues/224
System
Read Aloud Version1.55.0 Edge 103.0.1264.37 (Official build) (64-bit) Windows 21H2
When the iFrame is crossdomain, our content script isn't able to access the frame to grab the selected text. This is the issue.
The context menu is handled specially by the browser. When there's selected text, the browser automatically adds options to the context menu that deals with text selection, it's not our extension doing it. Afaik there's no way to call this method manually.
The way to fix this issue is still using content scripts, but we need to inject it into all iframes at the same time. Then grab the text and selected texts from all the frames, and figure out which ones to read aloud, and in which order. Determining the ordering and the synchronization aspect of it are both challenging problems. I have not found a satisfactory way to do this, and hence this remains open.