FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.06k stars 213 forks source link

Non-selectable text in context sentences #134

Closed HelenFoster closed 3 years ago

HelenFoster commented 6 years ago

This has come up on Satori Reader recently ( e.g. https://satorireader.com/articles/sanzu-no-kawa-episode-1-edition-m ), where they added "訳" and "再" to the inline "notes" and "play" buttons, and Yomichan is sending them to Anki along with the sentence.

If I select a block of text in the browser and copy-and-paste it, the button text doesn't get copied. Checking the CSS on those buttons for the reason, I found this:

.noselect {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

Would it make sense to avoid grabbing non-selectable text? I'm not sure what this CSS feature is normally used for, and whether this use is typical.

toasted-nutbread commented 4 years ago

user-select is an interesting case. In typical cases, user-select: none should indicate that the text should be ignored. However, it may still be useful to scan such text, so disabling it entirely may not be optimal. (There is a similar difficulty with the CSS content attribute, which currently is never scanned.)

However, in the case of the satorireader.com URL you linked, the user-select: none style is combined with color: transparent, which I think we can be 99% certain that the element should be ignored when scanning. The scanning algorithm already ignores other non-visible elements, so I think this combination of styles should also qualify as non-visible.

This particular case will be resolved by #286.