Skip to content

Instantly share code, notes, and snippets.

@simesy
Last active August 29, 2015 14:24
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 simesy/f9c91ee0783493bb71c6 to your computer and use it in GitHub Desktop.
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.
// ==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