birchill / 10ten-ja-reader

A browser extension to translate Japanese by hovering over words.
https://addons.mozilla.org/firefox/addon/10ten-ja-reader/
GNU General Public License v3.0
589 stars 43 forks source link

Anyway to translate words in extension pages? #700

Closed shoaibshakeel381 closed 3 years ago

shoaibshakeel381 commented 3 years ago

Some extensions provide their own pages for various options. Like LiveTL extension allows viewing youtube streams in an embedded page. But 10ten does not work if I hover over any jp words in these pages. And example url to such pages looks lke this:

moz-extension://6b7e49f4-a4b0-491c-a14d-59f1ade60751/watch.html?continuation=op2w0wRiGlhDaWtxSndvWVZVTkJWMU41UlhOZlNXODRUWFJ3V1ROdExYcHhTVXhCRWd0RVJqaFhTMVo0YWtZMk9Cb1Q2cWpkdVFFTkNndEVSamhYUzFaNGFrWTJPQ0FCQAFyAggEeAE%253D&video=DF8WKVxjF68&isReplay=true

Anyway to support such pages?

birtles commented 3 years ago

Hi! Thanks for filing this.

Unfortunately it's not easy to support this since none of the browsers allow specifying extension pages as part of the scheme for content scripts. As a result, 10ten won't get automatically injected into extension pages.

Oddly, I think the Safari version might just work in this case because it uses the activeTab permission which doesn't require specifying the scheme for automatically injecting content scripts.

We might be able to do something similar here but unfortunately I think it would require the user to perform some action (e.g. press a keystroke or click a button) in order to activate the add-on for an extension page. We'd also have to add the activeTab permission and I'm not sure if there would be any issue in combining that with the content_scripts member.

shoaibshakeel381 commented 3 years ago

thanks for the reply. Yeah I just checked MDN pages and looks like only a few known schemes are suppoerted.

birtles commented 3 years ago

Thanks! I've actually tried this before and both Firefox and Chrome reject manifests which specify extension schemes and they furthermore prevent you from injecting content scripts into those pages. That said, I haven't tried using activeTab + user interaction for this. It's possible that might work.