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

Toggle addon on/off #9

Closed LuisOskar closed 7 years ago

LuisOskar commented 7 years ago

Hello, I was wondering if its possible to add an option to toggle the addon on/off?

Or even if it remains on make it so that it doesn't show the popups.

Thanks.

birtles commented 7 years ago

You can toggle it on and off using the toolbar button. Or do you mean there should be a keyboard shortcut?

tgrandgent commented 7 years ago

I just came from Rikaichan and was accustomed to toggling it by right-clicking on the page and choosing "Rikaichan" in the context menu. This usually gets the job done with a lot less mouse movement compared to heading up to the toolbar. It would be nice if you could add this.

birtles commented 7 years ago

Adding a toggle to the right-click menu is definitely do-able. I'll add it in the next release.

I'd be interested in if anyone is looking for a keyboard shortcut too (I know rikaichan had this but I could never remember what it was so I never used it).

LuisOskar commented 7 years ago

Yeah, a keyboard shortcut. I used this on chrome so you could turn on and off addons with shortcuts. But I also stopped doing it there since it takes a while to "load it up". However, i'd be great if we could set a shortcut that simply toggles functionality on/off without disabling the addon itself. Unfortunately clicking on the toolbar does slow down my workflow a ton since im constantly reading / writing japanese stuff.

birtles commented 7 years ago

Sure, can do. Rikaichamp actually keeps the dictionary in memory after the first time you turn it on so once you've loaded it once, toggling it back on should be pretty much instant.

What is the desired keyboard shortcut?

LuisOskar commented 7 years ago

It might be better to make the shortcut configurable (as diff people have different tastes). I've noticed that in Firefox (for Mac at least) the "⌘E" is not being used so that could be an option.

tbys commented 7 years ago

A configurable shortcut key for toggling the addon on and off would be very welcome.

Like Rikaichan, the addon sometimes interferes with the browser in unexpected ways, so I frequently have to turn it off.

birtles commented 7 years ago

So it turns out Web Extensions has a commands feature just for this and there is a bug for making this configurable in Firefox (i.e. for all extensions; see also bug 1325692 and bug 1320332). So I might just add the shortcut key with some sort of sensible default and rely on there being a browser-wide way of configuring this in the future.

The allowed key patterns are:

I don't see Alt + R being used in the list of shortcut key so maybe that's an option?

Otherwise, I assume most people are using one hand to move the mouse to hover over words so a keyboard shortcut you can do with only your non-dominant hand would be good. Alt + R would fit that bill for right-handers and is probably not too bad to left-handers. Otherwise, perhaps Alt + 6? (roku sounds a little like rikai and is in the middle of the keyboard?)

LuisOskar commented 7 years ago

Alt+R seems definitively better than alt+6

redshoulder commented 7 years ago

Yes a keyboard shortcut (and if possible custom) would be very helpful.

inmyth commented 7 years ago

+1 for mouse right-click. If the toggle button is elsewhere then I will move the cursor away from the word of interest to click it. Then I will forget where the word was.

birtles commented 7 years ago

I've added the right-click menu to the trunk version but I still need to an an option to turn it off. By default I think it should be disabled since I don't think add-ons should clutter up your right-click menu unless they have a really good reason to or you opt-in. So I still need to write a bit more code to request the "contextMenus" permission on-demand.

tgrandgent commented 7 years ago

It's good to have an option to turn the context menu item off, but I think there's a case to be made for making it opt-out instead of opt-in. The really good reason in this case is discoverability. If it's not there by default, users may not notice it or try it and end up missing out on a handy feature they might've liked. Rikaichan had it there by default. And other popular add-ons have their context menu items enabled by default, for example LastPass, uBlock, NoScript, etc.

I understand the desire to avoid clutter though.

birtles commented 7 years ago

Fair enough. Perhaps I'll go with default on then -- requesting the permissions up-front is certainly a lot simpler.

birtles commented 7 years ago

I've made the context menu configurable and added the Alt+R shortcut key. I guess I need to make it possible to disable the Alt+R shortcut key too.

birtles commented 7 years ago

Looks like there is no way to programmatically disable commands (for now at least) so I'm just going to leave this shortcut as always-on.