Skip to content

Instantly share code, notes, and snippets.

@MighteeCactus
Last active August 27, 2017 13:00
Show Gist options
  • Save MighteeCactus/08f5750ad105b7ca695db52fca7c9324 to your computer and use it in GitHub Desktop.
Save MighteeCactus/08f5750ad105b7ca695db52fca7c9324 to your computer and use it in GitHub Desktop.
Quick hack for google translate service to train listening of numbers in foreign language
function sayMeRandNum(min, max)
{
var num = min + (Math.floor(Math.random()*100000000000000) % (max - min));
$("#source").value = num
function triggerMouseEvent (node, eventType) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent (eventType, true, true);
node.dispatchEvent (clickEvent);
}
var srcListenButton = document.getElementById('gt-src-listen');
setTimeout(function() {
triggerMouseEvent (srcListenButton, 'mouseover');
triggerMouseEvent (srcListenButton, 'mousedown');
triggerMouseEvent (srcListenButton, 'mouseup');
}, 2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment