Last active
August 29, 2015 14:24
-
-
Save simesy/f9c91ee0783493bb71c6 to your computer and use it in GitHub Desktop.
Turkish key replacement for duolingo. Install this script in the Tampermonkey extension in Chrome.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Turkish key replacement | |
// @namespace http://example.com/ | |
// @version 0.1 | |
// @description Type a backtick (`) after a letter to get the turkish variation. | |
// @author Simon Hobbs | |
// @match https://www.duolingo.com/skill/* | |
// @grant none | |
// ==/UserScript== | |
$(window).keyup(function() { | |
if (event.which == 192) { | |
$focus = $(':focus'); | |
text = $focus.val(); | |
start = $focus[0].selectionStart; | |
character = text.substring(start-2, start); | |
new_char = match_char(character); | |
new_text = text.substring(0,start-2) + new_char + text.substring(start, text.length); | |
$focus.val(new_text); | |
} | |
}); | |
function match_char(char) { | |
switch (char) { | |
case 'c`': | |
return 'ç'; | |
case 'i`': | |
return 'ı'; | |
case 'o`': | |
return 'ö'; | |
case 's`': | |
return 'ş'; | |
case 'u`': | |
return 'ü'; | |
} | |
return char; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment