Duolingo Auto IME On-Off

Forces IME to switch between English and Japanese automatically for each typing question.

< Feedback on Duolingo Auto IME On-Off

Question/comment

§
Posted: 2018-08-27

Does this work for Chinese as well?

Hi, is this script also working for Chinese? The Chinese IME has the same issue that one has to switch back and forth which is kind an annoying... Would be awesome!

mog86ukAuthor
§
Posted: 2018-08-27

This userscript only works for Japanese. I stopped using this userscript months ago, as a Chrome update removed support for the "inputmode" properties I was using to switch IME on and off.

I now use a userstyle on Firefox instead for this:
https://userstyles.org/styles/159509/duolingo-auto-ime-on-off

However, that userstyle is only designed for Japanese too...

After reading your post, I decided to spend this morning making a new userstyle that will hopefully work for all the following courses:

  • Japanese for English speakers
  • Chinese for English speakers
  • Korean for English speakers
  • English for Japanese speakers
  • English for Chinese speakers
  • English for Korean speakers

To install and use this userstyle, you'll need a decent userstyle extension for Firefox. I use and recommend "Stylus":

https://addons.mozilla.org/firefox/addon/styl-us/

Here's the link to the new userstyle I made. Just click the "raw" button on this page and Stylus should ask if you want to get my userstyle.

https://gist.github.com/mog86uk/582295b7008609c8130e0c3a69664a7e

Please free to try it out. I haven't tested it as much with Chinese, as I'm only a complete beginner in the language. So it would help me to have someone test it more fully. Hope it works well for you. Let me know. ^^

§
Posted: 2018-08-28

@mog86uk : AWESOME, thank you so very much for your effort!

Just 1-2 problems:

  1. the gist website is blocked in China, so it was quite troublesome to get the script. I managed to download the CSS file and install it but there was an error message during the install. But I was able to "update" the script via Stylus so it should be properly installed now. So that problem seems solved but might be an issue for other people who are based in China.

  2. In China, one is always redirected to duolingo.cn. There seems to be a way to get to the .com page by going to the profile page and changing the .cn to com but the script is not working for me after doing this.

So, for the moment, the script is not working for me:(

But nevertheless, awesome reaction and awesome advise with Stylus!

§
Posted: 2018-08-28
Edited: 2018-08-28

while testing the script, it looks it sometimes changes correctly from Chinese to English (the IME symbol changes) but the input is still Chinese characters...

As far as I tested, the script never changes from English to Chinese...

Last but not least: what is this active-inactive and active-disabled toggle? :)

PS: while testing I had a few successful changes from Chinese to English. But not vv. and not consistent... :/

mog86ukAuthor
§
Posted: 2018-08-28
Edited: 2018-08-29
  1. the gist website is blocked in China, so it was quite troublesome to get the script. I managed to download the CSS file and install it but there was an error message during the install. But I was able to "update" the script via Stylus so it should be properly installed now. So that problem seems solved but might be an issue for other people who are based in China.

Ah, I didn't consider that gist/github might be blocked in China. I'm not too sure where else to host it where it will be picked up properly by Stylus.

  1. In China, one is always redirected to duolingo.cn. There seems to be a way to get to the .com page by going to the profile page and changing the .cn to com but the script is not working for me after doing this.

I've made an edit to my userstyle to make it hopefully work on both .com and .cn version of the Duolingo website. Hopefully you'll be able to update to the new version of the script inside Stylus, without needing to go directly to the gist website again. ^^

it looks it sometimes changes correctly from Chinese to English (the IME symbol changes) but the input is still Chinese characters...

What you've described sounds exactly like what happened to me with my Chinese IME when I had the script set to "active-disabled" option. Windows 10's "Microsoft Pinyin" doesn't handle being "disabled" correctly. So I set "active-inactive" as the default option for Chinese in my script.

As far as I tested, the script never changes from English to Chinese...

That sounds like what happens if I manually toggle from 中 to 英 while IME is active. With Microsoft Pinyin IME, I have to make sure it's on 中 at the start of the Duolingo session and ensure to avoid manually toggling to 英, then the script will toggle back and forth between IME active(中) and IME inactive automatically. (See the next section for detail on this.) ^^

Last but not least: what is this active-inactive and active-disabled toggle?

My script works by using a simple CSS property called "ime-mode". This offers three different modes: "active", "inactive", "disabled".

  • active = Turn IME on.
  • inactive = Turn IME off.
  • disabled = Block IME from being used at all.

Inactive: When an IME turns off, its icon changes to an A or symbol, and you type English. You can still manually reactivate the IME even when a text box has been set to IME inactive.

Disabled: When an IME is blocked, its icon usually changes to an X, or maybe to A or . All functionality of the IME is meant to be blocked and should therefore mean you're left with only typing English. You shouldn't be able to turn the IME on in a text box that has been set to IME disabled.

Active: When an IME turns back on, this purely means the IME goes back to whatever mode was in use before it got either turned off or disabled. IME turning back on doesn't mean it will switch to its Chinese mode. If your IME has two modes ( and ) and you were using mode before IME got turned off, then you'll be on when IME turns back on.

The "active-inactive" and "active-disabled" options are therefore a choice of which ime-modes you want it to use when Duolingo switches between Chinese and English typing questions.


Microsoft Japanese IME has both an inactive mode and a disabled mode. So either of the two settings will work. However, "active-disabled" seems better in my opinion, because this prevents you accidentally switching to Japanese or using any other IME functions on English typing questions.

Microsoft Korean IME doesn't have an "inactive" mode. So "active-disabled" is the only option for this particular Korean IME.

Microsoft Chinese Pinyin IME doesn't have a "disabled" mode. When you tell it to disable, the only thing it does is change its icon to and carries on functioning like nothing happened... So "active-inactive" is the only option for this particular Chinese IME.


Hope this helps. Sorry for such a messy long post. It has helped me understand more clearly after writting all this down anyway, haha. ^^

mog86ukAuthor
§
Posted: 2018-08-28
Edited: 2018-08-29

What operating system and which Chinese IME are you using?

I'm really interested in Asian character input softwares. I've used several different Japanese IMEs, but so far I've only tried the Microsoft Pinyin one for Chinese. I'd like to try out other Chinese IMEs and test how they function with my userstyle. ^^

§
Posted: 2018-08-29

Firstly: Super, thanks a bunch!!!

Ah, I didn't consider that gist/github might be blocked in China. I'm not too sure where else to host it where it will be picked up properly by Stylus.

After installation, the script is updating, so once installed, there shouldn't be an issue in China as the link https://gist.githubusercontent.com/mog86uk/582295b7008609c8130e0c3a69664a7e/raw/mog86uk-Duo-IME-Auto-Toggler.user.css is working. Only the gist.github.com URL seems blocked...

I've made an edit to my userstyle to make it hopefully work on both .com and .cn version of the Duolingo website. Hopefully you'll be able to update to the new version of the script inside Stylus, without needing to go directly to the gist website again. ^^

The script is now also "working" (see below) with .cn domain!! Thanks!

What you've described sounds exactly like what happened to me with my Chinese IME when I had the script set to "active-disabled" option. Windows 10's "Microsoft Pinyin" doesn't handle being "disabled" correctly. So I set "active-inactive" as the default option for Chinese in my script.

I run it on active-inactive mode now.

That sounds like what happens if I manually toggle from 中 to 英 while IME is active. With Microsoft Pinyin IME, I have to make sure it's on 中 at the start of the Duolingo session and ensure to avoid manually toggling to 英, then the script will toggle back and forth between IME active(中) and IME inactive automatically. (See the next section for detail on this.) ^^

  1. I have the odd situation now that if I put the IME to 中 in Win10, it switches to 英 in Firefox. The switch seems to happen first time when going to Duolingo website and then it stays as 英. When I go to another Win application, it switches back to 中...
  2. In Firefox on some pages (especially Duolingo but also others), I cannot manually toogle from 英 to 中.
  3. Duolingo seems to "start" right (I had put IME to 中 in Win) . It switches to 中 if the first test is in Chinese and starts in 英 if English. But the switch from 英 to 中 does not work. I need to manually toogle to 中 and then the script automatically toggles to 英 again - but not back to 中...

So, we are half-way there! LOL

Thanks a bunch for explaining the active/inactive modes!

§
Posted: 2018-08-29

@mog86uk schrieb: What operating system and which Chinese IME are you using?

I'm using Win10 and the IME (simplified) that comes with it :) I think it is just "Microsoft Pinyin".

I actually tried to find alternative input methods (for simplified Chinese) for Win10 but I failed. There is the old Microsoft Office 2010 IME but it seems messy to install that on Win10. So, I guess this is good news as this should make it easier for developers ;)

mog86ukAuthor
§
Posted: 2018-08-30
Edited: 2018-08-30

Sorry, I was busy yesterday, but today I've had a chance to look through my code... And I have some very good news!

New update! It should work for you now. ^^

The reason it was switching from 中 to 英 correctly but not switching from 英 to 中 at all turned out to be because of something a LOT more simple than what I had feared...

There was an embarrassing copy-paste error in my code. In four places it had the word "Korean" where I meant to write the word "Chinese"... This meant that it never detected ANY of the occasions where Duolingo was asking the user to type in Chinese at all, and therefore it wasn't telling the IME to do anything on these questions. ^^;

Hope you are able to update to this new version of my userstyle (version 0.3.0). ^^

mog86ukAuthor
§
Posted: 2018-08-30
Edited: 2018-08-30
  1. I have the odd situation now that if I put the IME to 中 in Win10, it switches to 英 in Firefox. The switch seems to happen first time when going to Duolingo website and then it stays as 英. When I go to another Win application, it switches back to 中...

There are two reasons for why that might be.

First, maybe irrelevant reason: There's a setting in Windows 10 called "Let me set a different input method for each app window". (Settings → Time & Language → Region & language → Advanced keyboard settings.) When this is enabled, you can be on 中 mode in one open application and 英 mode in another open application at the same time, or even on completely different languages in each application. I have this setting enabled as I like it this way.

Second, probably more relevant reason: If you haven't focussed on any text entry fields on the page (such as if you are simply scrolling or clicking links), then IMEs are supposed to be in their "disabled" mode. The IME should show an X symbol (the same as Microsoft Japanese IME and Korean IME), however Microsoft Pinyin instead just shows and isn't truly disabled either. (You can't really tell that it's not disabled, as you can't type anything when not focussed on a text entry field.)

When you click in a text entry field on the page, IMEs should then go back to their "enabled" state (whichever enabled state was last in use).

List of states for Microsoft Pinyin:

  • Enabled 中 active
  • Enabled 英 active
  • Enabled 英 inactive (Can't manually switch to this. Looks the same as active.)
  • Disabled 英 (Not truly disabled at all, but IME icon stays on 英)
  1. In Firefox on some pages (especially Duolingo but also others), I cannot manually toogle from 英 to 中.

See what I said for 1, what I said about "disabled" mode.

  1. Duolingo seems to "start" right (I had put IME to 中 in Win) . It switches to 中 if the first test is in Chinese and starts in 英 if English. But the switch from 英 to 中 does not work. I need to manually toogle to 中 and then the script automatically toggles to 英 again - but not back to 中...

Hopefully now it automatically toggles back to 中 too? ^^

§
Posted: 2018-08-31

You! Got! It! :)

With the new version of the script everything works as advertised and now it is actually fun to make the Duolingo exercises with keyboard! No more keyboard fiddling!!!

I will test further and see if I find any issues. But for the moment:

THANK YOU!!!

PS: If anybody from Duolingo is reading this: IMHO such script/behavior is necessary. The script allows to make the excercise in a "natural" way allowing to focus on content/learning. The fiddling with the keyboard is only something for very determined learners who can accept the permanent interruption...

mog86ukAuthor
§
Posted: 2018-09-03

Glad you like it. ^^

However, I need to point out a problem I'm aware of with my userstyle...

You won't have noticed it if you're only using it for the Chinese course.

Currently, the "Korean mode" overrides the "Japanese mode", and the "Chinese mode" overrides both Korean and Japanese modes.

So, if the user has all three languages enabled in my settings popup (which is the default), then if "Chinese mode" is set to "active-inactive", this will mean Korean and Japanese will be set to "active-inactive" too.

Korean IME won't toggle correctly with the active-inactive mode.


The cause of this problem is that userstyles can't really detect which course the user is actually doing. So all enabled languages get applied no matter which course the user is currently on.

So really I need to make a userscript instead.

mog86ukAuthor
§
Posted: 2018-09-03
Edited: 2018-09-03

https://greasyfork.org/en/scripts/371886-duolingo-ime-auto-toggler

↑ This is my new userscript for toggling IME on-off. ^^

It should behave exactly the same as my userstyle, except that I haven't yet made its settings user configurable. (I need to make it so people can choose which courses they want the IME to not automatically toggle, but it's a lot of hassle to settings dialogs for userscripts compared to how it is in Stylus.)

This userscript should detect which of the six specific courses the user is currently on and work correctly for all the following:

  • Japanese course for English speakers
  • Korean course for English speakers
  • Chinese course for English speakers
  • English course for Japanese speakers
  • English course for Korean speakers
  • English course for Chinese speakers

The Japanese and Korean courses and their reverse trees are set to the "active-disabled" mode; the Chinese course and its reverse tree are set to the "active-inactive" mode. (So it's the same as what the defaults are in my userstyle.)

This userscript is only really helpful to people who are doing both Chinese and Korean courses, since they require different modes and it would be a pain to manually adjust the userstyle settings every time they switch course. Japanese IME toggles correctly under either mode anyway.

Since you're doing only the Chinese course, you may prefer to just keep using the userstyle. However, it's unlikely I'll be update my userstyle any further.

If you do feel like testing this new userscript anyway though, that would be great. ^^

§
Posted: 2018-09-20
Edited: 2018-09-20

I'm sorry for the very slow response.

I have installed the new userscript when you posted it but didn't find the time to respond properly and also wanted to test more.

First of all: super, THANK YOU! Having a userscript is better for me as I won't need the Stylus extension anymore:)

I tested but found that I usually have to manually switch to 英 or 中 in the first question of the session and then usually have to manually switch again when there is a 英/中 change. From then on the script works reliably and if I remember correctly, the script also works for all following tests during that session.

I tried a few things like making sure the right keyboard is selected and reload the Duolingo page before starting a test but that doesn't seem to fix it.

Any idea where the issue could be?

Thank you very much and thank you for the script!

mog86ukAuthor
§
Posted: 2018-09-21
Edited: 2018-09-21

Thanks so much for replying!

I'm assuming the following is correct:

  • Course = Chinese course for English speakers
  • IME = Microsoft Pinyin
  • OS = Windows 10
  • You've turned off the Stylus extension and are now using only Tampermonkey/Greasemonkey (i.e. You don't have both my userstyle and my userscript running at the same time, as that would probably cause problems.)

I've just tested using my userscript with the Chinese course under the same conditions as listed above.

My userscript never fails to toggle to "active" when a Chinese typing question loads and "inactive" for when an English typing question loads. It is functioning exactly the same as the userstyle with the "active-inactive" setting for the Chinese course.

So unfortunately there's no mistake or bug to be fixed. However, I think I've found the issue you are having. It will be very hard to explain, but I'll try...


First of all, remember in a previous post I mentioned the Microsoft Pinyin IME states?

List of states for Microsoft Pinyin:

  • Enabled 中 active
  • Enabled 英 active
  • Enabled 英 inactive (Can't manually switch to this. Looks the same as active.)
  • Disabled 英 (Not truly disabled at all, but IME icon stays on 英)

There are two "active" modes ( and ) and one "inactive" mode (). When you press the Shift key, it toggles only between "active 中" and "active 英". There's no way to toggle to "inactive 英" manually.

(And "disabled" doesn't work in Microsoft Pinyin, unlike for the Japanese and Korean IMEs.)


Second thing, remember in a previous post where I mentioned the following Windows 10 setting?

There's a setting in Windows 10 called "Let me set a different input method for each app window". (Settings → Time & Language → Region & language → Advanced keyboard settings.) When this is enabled, you can be on 中 mode in one open application and 英 mode in another open application at the same time, or even on completely different languages in each application. I have this setting enabled as I like it this way.

If that setting is enabled, then whenever you press shift to toggle Microsoft Pinyin IME between "active 中" and "active 英" in any Firefox window or tab, it also takes effect in the tab you are doing Duolingo in. If that setting is disabled, then even doing it in other applications will cause problems for your Duolingo tab in Firefox.


On English typing questions, the userscript should make your IME switch to "inactive 英" without fail every single time. If you accidentally tap Shift while still on this question, then it will toggle between "active 中" and "active 英".

On Chinese typing questions, the userscript will only make your IME go back to "active", but not specifically to 中. It goes to whatever the last used "active" mode was.

Therefore, if the IME's last used "active" mode was "active 英", then it will remain on 英 when a Chinese typing question loads.


*** Solution ***

So long as you start Duolingo with your last active mode being 中 and then NEVER manually toggle to 英 while doing Duolingo, then there shouldn't be any issue. It should successfully jump between "active 中" and "inactive 英" correctly for you on every question.

However, if for example you have an online Chinese-English dictionary open in another Firefox tab and you decide to look up a word while doing Duolingo, then you'll likely press shift and manually toggle to "active 英" at some point. This will then affect the Duolingo Firefox tab too. In this situation, you'll need to ensure to toggle back to "active " before returning to the Duolingo tab (to ensure the last used "active" mode is always 中, never 英).


Sorry, I knew it would be too tricky for me to explain this in a brief way. Now it's ended up as a ridiculously long messy post. I hope this post still managed to help. ^^

Post reply

Sign in to post a reply.