Greasy Fork

Greasy Fork is available in English.

Duolingo IME Auto-Toggler

Automatically toggles between IME on and off states when doing the Japanese, Korean, and Chinese Duolingo courses (and their reverse trees).

当前为 2018-09-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Duolingo IME Auto-Toggler
// @namespace    mog86uk-duolingo-ime-auto-toggler
// @version      0.1
// @description  Automatically toggles between IME on and off states when doing the Japanese, Korean, and Chinese Duolingo courses (and their reverse trees).
// @author       mog86uk (a.k.a. testmoogle)
// @include      /^https?:\/\/www\.duolingo\.(com|cn)($|\/.*$)/
// @grant        GM_addStyle
// @noframes
// ==/UserScript==

/*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This userscript is for FIREFOX only !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/

(function() {
    'use strict';
    var j4e, k4e, z4e, e4j, e4k, e4z;

    // Japanese for English speakers
    j4e =`
		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;
		}`;

    // Korean for English speakers
	k4e =`
		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;
	    }`;

    // Chinese for English speakers
    z4e =`
    	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;
        }`;

    // English for Japanese speakers (a.k.a. "Japanese reverse tree")
    e4j =`
    	textarea[placeholder="日本語で入力してください"],
        input[placeholder="日本語で入力してください"] {
            ime-mode: active;
        }
        textarea[placeholder="英語で入力してください"],
        input[placeholder="英語で入力してください"] {
            ime-mode: disabled;
        }`;

    // English for Korean speakers (a.k.a. "Korean reverse tree")
    e4k =`
    	textarea[placeholder="한국어로 입력"],
        input[placeholder="한국어로 입력"] {
            ime-mode: active;
        }
        textarea[placeholder="영어로 입력"],
        input[placeholder="영어로 입력"] {
            ime-mode: disabled;
        }`;

    // English for Chinese speakers (a.k.a. "Chinese reverse tree")
    e4z =`
    	textarea[placeholder="使用中文键入"],
        input[placeholder="使用中文键入"] {
            ime-mode: active;
        }
        textarea[placeholder="使用英语键入"],
        input[placeholder="使用英语键入"] {
            ime-mode: inactive;
        }`;

    switch (document.title) {
    	case "Duolingo | Learn Japanese for free":
        	GM_addStyle(j4e);
            break;
    	case "Duolingo | Learn Korean for free":
    		GM_addStyle(k4e);
            break;
    	case "Duolingo | Learn Chinese for free":
    		GM_addStyle(z4e);
            break;
    	case "Duolingo | 無料で英語を学ぼう":
    		GM_addStyle(e4j);
            break;
    	case "듀오링고 | 무료로 영어를 배우세요.":
    		GM_addStyle(e4k);
            break;
    	case "多邻国 | 免费学习英语":
    		GM_addStyle(e4z);
            break;
    }
})();