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
604 stars 45 forks source link

Set "show popup" to ctrl for text doesn't disable the popup when hovering over text with a HTML title attribute #946

Closed Ileca closed 2 years ago

Ileca commented 2 years ago

I have set "show popup" to ctrl for text, meaning the popup should only be shown when I press this key. However, the popup is not disabled when it comes to hover over text with a HTML title attribute that contains Japanese. You can use https://vndb.org/ and hover over any line from the Recent Changes box. If the line's title attribute has Japanese in it, the popup will be triggered regardless of my setting and show the popup for the first recognized Japanese word.

birtles commented 2 years ago

Hi! Thanks for filing this. That's a really good point. I guess we should check what sort of element the title is attached to.

Ileca commented 2 years ago

I noticed that if you set ctrl for pictures (after I noticed that the popup was also triggered because of the alt attribute of the img element), this behavior stops. Not sure I understand what's the point of setting this addon for pictures. I assume it's for "text in SVG images"? If that's the case, then, the popup being also triggered by the alt attribute is also an issue?

birtles commented 2 years ago

I noticed that if you set ctrl for pictures (after I noticed that the popup was also triggered because of the alt attribute of the img element), this behavior stops. Not sure I understand what's the point of setting this addon for pictures. I assume it's for "text in SVG images"? If that's the case, then, the popup being also triggered by the alt attribute is also an issue?

"Images" there effectively refers to the alt or title attribute of any element, but typically those attributes show up most often on images. In this issue I think we should narrow it so that setting only applies to <img>, <picture>, <video> etc. and treat everything else as text.

The reason there are two settings is because a lot of users want the popup to show up automatically (i.e. without pressing the Ctrl key) but find it annoying when it shows up for images with alt/title text (e.g. certain image galleries do that it seems). So, with that setting, they can enable the Ctrl for images only and it will never popup unless they explicitly make it do so.

Ileca commented 2 years ago

What I don't understand is how are you supposed to navigate the Japanese in a title tooltip? I mean, it only works for the first word so far. For the alt, I guess it's for when pictures are not loaded, which doesn't happen often, but I can see a use here, at least.

birtles commented 2 years ago

What I don't understand is how are you supposed to navigate the Japanese in a title tooltip? I mean, it only works for the first word so far. For the alt, I guess it's for when pictures are not loaded, which doesn't happen often, but I can see a use here, at least.

It actually uses a different lookup mode in this case, looking up each of the words in turn.

For example in this screenshot it's showing the results for 国際, 外交, and タイムライン in turn.

image

If you switch tabs, it's only going to operate from the start of the string, but hopefully it's still helpful sometimes.

Here's another example:

image

When there are only word result, it shows a little title at the top:

image