Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ImTranslator TTS Spidermonkey Script
// ==UserScript==
// @name Japanese Text-To-Speech
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match http://www.memrise.com/course/*/*/edit/
// @copyright 2012+, You
// ==/UserScript==
unsafeWindow.injectTTS = function(ttsURL) {
var $object = $('<OBJECT \
type="application/x-shockwave-flash"\
CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\
type="application/x-shockwave-flash"\
WIDTH="113"\
HEIGHT="100"\
CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8"\
ID=flash1>\
<PARAM ID="MOVIE" NAME="MOVIE" VALUE="' + ttsURL + '">\
<PARAM NAME="PLAY" VALUE="true">\
<PARAM NAME="LOOP" VALUE="false">\
<PARAM NAME="QUALITY" VALUE="high">\
<PARAM NAME="SCALE" VALUE="SHOWALL">\
\
<EMBED\
type="application/x-shockwave-flash"\
NAME="flash1"\
ID="flash1"\
SRC="' + ttsURL + '"\
WIDTH="113"\
HEIGHT="100"\
PLAY="true"\
LOOP="false"\
QUALITY="high"\
SCALE="SHOWALL"\
swLiveConnect="true"\
PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/" style="height: 0; overflow: hidden">\
</EMBED>\
</OBJECT>');
$('#levels').prepend($object);
};
$('#content').on('click', '.level-things tr.thing .column:nth-child(2) .text', function(e) {
$('<script>').attr('src', 'http://localhost:3001/api/1/tts/?lang=jp&callback=injectTTS&text=' + $(this).text()).appendTo('head');
});
$('#content').on('click', '.level-things tr.thing .column:nth-child(3) .text', function(e) {
$('<script>').attr('src', 'http://localhost:3001/api/1/tts/?lang=en&callback=injectTTS&text=' + $(this).text()).appendTo('head');
});
$('#content').on('click', '.level-things tr.thing td:first-child', function(e) {
$('<script>').attr('src', 'http://localhost:3001/api/1/tts/?lang=jp&callback=injectTTS&text=' + $(this).next().find('.text').text()).appendTo('head');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment