您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Forces IME to switch between English and Japanese automatically for each typing question.
当前为
// ==UserScript== // @name Duolingo Auto IME On-Off // @namespace mog86uk-duo-autoime // @version 1.0 // @description Forces IME to switch between English and Japanese automatically for each typing question. // @author mog86uk (aka. testmoogle) // @match https://www.duolingo.com/* // @exclude https://www.duolingo.com/discussion // @exclude https://www.duolingo.com/topic/* // @require http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js // @grant none // @run-at document-idle // ==/UserScript== jQuery.noConflict(); jQuery(document).ready(function($) { 'use strict'; var typeLang = ""; var typeLangPrevious = ""; if (typeof $('html').css('ime-mode') === 'undefined' && typeof $('html').prop('inputMode') === 'undefined') { alert("If you're using Chrome or Opera, you'll need to enable the following browser flag:\n\n#enable-experimental-web-platform-features\n\nFirefox should work fine as it is, but Chrome and Opera need to enable this flag to be able to make use of the 'inputmode' experimental html attribute. (See the userscript's page on greasyfork if you need more help with enabling this browser flag.) ^^"); } function Start(mutationRecords) { if (/^https:\/\/www\.duolingo\.com.*\/practice$/.test(window.location.href) || /^https:\/\/www\.duolingo\.com\/skill\/ja\/(.)*$/.test(window.location.href)) { mutationRecords.forEach (function (mutation) { typeLang = $('textarea[data-test="challenge-translate-input"]').attr('lang'); if (typeLang !== typeLangPrevious || (typeLang === 'en' && $('textarea[data-test="challenge-translate-input"]').css('ime-mode') === 'auto')) { if (typeLang === 'en') { $('textarea[data-test="challenge-translate-input"]').attr('inputmode', 'latin').css('ime-mode', 'disabled').blur().focus(); } else if (typeLang === 'ja') { $('textarea[data-test="challenge-translate-input"]').attr('inputmode', 'kana').css('ime-mode', 'active').blur().focus(); } typeLangPrevious = typeLang; } }); } } if (window.top == window.self) { var observerOfStuff = new MutationObserver(Start); observerOfStuff.observe(document.body, { attributes: true, subtree: true }); } });