Skip to content

Instantly share code, notes, and snippets.

@mog86uk
Last active September 3, 2018 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mog86uk/582295b7008609c8130e0c3a69664a7e to your computer and use it in GitHub Desktop.
Save mog86uk/582295b7008609c8130e0c3a69664a7e to your computer and use it in GitHub Desktop.
Automatically toggles between IME on and off states when doing the Japanese, Korean, and Chinese Duolingo courses (and their reverse trees).
/* ==UserStyle==
@name Duolingo IME Auto-Toggler
@description Automatically toggles between IME on and off states when doing the Japanese, Korean, and Chinese Duolingo courses (and their reverse trees).
@namespace mog86uk
@version 0.3.1
@author mog86uk (a.k.a. testmoogle)
@homepageURL https://gist.githubusercontent.com/mog86uk/582295b7008609c8130e0c3a69664a7e/raw/mog86uk-Duo-IME-Auto-Toggler.user.css
@supportURL https://gist.githubusercontent.com/mog86uk/582295b7008609c8130e0c3a69664a7e/
@license unlicense
@preprocessor stylus
@var checkbox enabledJA "Japanese?" 1
@var select modeJA "Japanese mode" {
"active-disabled": "ActiveDisabled",
"active-inactive": "ActiveInactive"
}
@var checkbox enabledKO "Korean?" 1
@var select modeKO "Korean mode" {
"active-disabled": "ActiveDisabled",
"active-inactive": "ActiveInactive"
}
@var checkbox enabledZS "Chinese?" 1
@var select modeZS "Chinese mode" {
"active-inactive": "ActiveInactive",
"active-disabled": "ActiveDisabled"
}
@var checkbox enabledEN "English (reverse tree) ?" 1
@var select modeEN "Which English course?" {
"For Japanese speakers": "E4J",
"For Korean speakers" : "E4K",
"For Chinese speakers" : "E4Z"
}
==/UserStyle== */
@-moz-document regexp("^https?:\\/\\/www\\.duolingo\\.(com|cn)\\/(practice|skill\\/(ja|ko|zs|en)\\/.+\\/(practice|test|\\d+)|bigtest\\/(ja|ko|zs|en)\\/\\d+|placement\\/(ja|ko|zs|en))$") {
if enabledJA {
if modeJA == "ActiveInactive" {
textarea[placeholder="Type in Japanese"],
input[placeholder="Type in Japanese"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: inactive;
}
}
else if modeJA == "ActiveDisabled" {
textarea[placeholder="Type in Japanese"],
input[placeholder="Type in Japanese"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: disabled;
}
}
}
if enabledKO {
if modeKO == "ActiveInactive" {
textarea[placeholder="Type in Korean"],
input[placeholder="Type in Korean"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: inactive;
}
}
else if modeKO == "ActiveDisabled" {
textarea[placeholder="Type in Korean"],
input[placeholder="Type in Korean"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: disabled;
}
}
}
if enabledZS {
if modeZS == "ActiveInactive" {
textarea[placeholder="Type in Chinese"],
input[placeholder="Type in Chinese"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: inactive;
}
}
else if modeZS == "ActiveDisabled" {
textarea[placeholder="Type in Chinese"],
input[placeholder="Type in Chinese"] {
ime-mode: active;
}
textarea[placeholder="Type in English"],
input[placeholder="Type in English"] {
ime-mode: disabled;
}
}
}
if enabledEN {
if modeEN == "E4J" {
if modeJA == "ActiveInactive" {
textarea[placeholder="日本語で入力してください"],
input[placeholder="日本語で入力してください"] {
ime-mode: active;
}
textarea[placeholder="英語で入力してください"],
input[placeholder="英語で入力してください"] {
ime-mode: inactive;
}
}
else if modeJA == "ActiveDisabled" {
textarea[placeholder="日本語で入力してください"],
input[placeholder="日本語で入力してください"] {
ime-mode: active;
}
textarea[placeholder="英語で入力してください"],
input[placeholder="英語で入力してください"] {
ime-mode: disabled;
}
}
}
else if modeEN == "E4K" {
if modeKO == "ActiveInactive" {
textarea[placeholder="한국어로 입력"],
input[placeholder="한국어로 입력"] {
ime-mode: active;
}
textarea[placeholder="영어로 입력"],
input[placeholder="영어로 입력"] {
ime-mode: inactive;
}
}
else if modeKO == "ActiveDisabled" {
textarea[placeholder="한국어로 입력"],
input[placeholder="한국어로 입력"] {
ime-mode: active;
}
textarea[placeholder="영어로 입력"],
input[placeholder="영어로 입력"] {
ime-mode: disabled;
}
}
}
else if modeEN == "E4Z" {
if modeZS == "ActiveInactive" {
textarea[placeholder="使用中文键入"],
input[placeholder="使用中文键入"] {
ime-mode: active;
}
textarea[placeholder="使用英语键入"],
input[placeholder="使用英语键入"] {
ime-mode: inactive;
}
}
else if modeZS == "ActiveDisabled" {
textarea[placeholder="使用中文键入"],
input[placeholder="使用中文键入"] {
ime-mode: active;
}
textarea[placeholder="使用英语键入"],
input[placeholder="使用英语键入"] {
ime-mode: disabled;
}
}
}
}
}
@-moz-document regexp("^https?:\\/\\/www\\.duolingo\\.(com|cn).*$") {
.mog86uk {ime-mode: auto;}
/*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This userstyle is FIREFOX only !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
https://www.duolingo.com
Designed for use in: lessons, skill strengthen, global practice, placement test, section test out, and crown test out... in each of the following courses:
- Japanese for English speakers
- English for Japanese speakers (a.k.a. "Japanese reverse tree")
- Korean for English speakers
- English for Korean speakers (a.k.a. "Korean reverse tree")
- Chinese for English speakers
- English for Chinese speakers (a.k.a. "Chinese reverse tree")
Description: Automatically switches IME between on (Japanese/Korean/Chinese) and off (English) state, based on which question type is encountered on Duolingo.
IMPORTANT:
- Only use this userstyle in FIREFOX! (Any version of it is fine.)
- Make sure you keep your keyboard on Japanese/Korean/Chinese IME at all times. Don't manually switch to another keyboard/language (i.e. English)!
- Depending on your setup, you may also need to switch your IME to hiragana/hangeul/hanzi at the start too. (Shouldn't be set to half-width alphanumeric.)
- Tested only on Windows 10 and only with the following IMEs:
- Microsoft Japanese IME
- Google Japanese Input
- JustSystems ATOK 2017
- Fujitsu Japanist 10
- Fujistu Japanist 2003
- Microsoft Korean IME
- Microsoft Chinese Pinyin
- FIREFOX is the only major web browser which currently supports the CSS3 "ime-mode" property required for this userstyle to work at all.
*/
}
@mog86uk
Copy link
Author

mog86uk commented Aug 28, 2018

  • Version 0.1.0 = Initial version.
  • Version 0.2.0 = Added (hopefully) support for people using the China site of Duolingo - http://duolingo.cn
  • Version 0.3.0 = Chinese fixed! Now actually works for the Chinese course correctly! (I had a really silly mistake in my code, where I had put the word "Korean" in four places where I had meant to put "Chinese"... An embarrassing copy-paste error.) ^^;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment