Last active
October 28, 2020 23:21
-
-
Save SitanHuang/740ed6925e1826bc52d3becbf24aa7df to your computer and use it in GitHub Desktop.
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
(function () { | |
window._storage = {}; | |
window._storage2 = {}; | |
window.lastQ = null; | |
window.tick = function (i) { | |
var $exercise = $('#exercise'); | |
var q = $('#pronoun-input, #verb-input').text().trim(); | |
var v = $('#verb-input').text().trim(); | |
if (q) { | |
if (_storage[q]&&_storage[q].trim().length) { | |
$('#answer-input').val(_storage[q]); | |
$('#check-button').click(); | |
} else { | |
if (lastQ == q) { | |
_storage2[v]=_storage2[v].filter(x=>x.length); | |
x = _storage2[v][Math.round(_storage2[v].length * Math.random())]; | |
$('#answer-input').val(x); | |
$('#check-button').click(); | |
setTimeout(function () {if ($('.js-bubble.coqui-test-bubble.incorrect').length==0){_storage[q]=x;lastQ=null};tick(i)}, i); | |
return; | |
} | |
$('#answer-input').val(Math.random()+''); | |
$('#check-button').click(); | |
setTimeout(function(){ _storage[q] = $('.js-bubble.coqui-test-bubble.incorrect span').text().trim(); | |
if (!_storage2[v]) _storage2[v] = []; | |
_storage2[v].push(_storage[q]); | |
lastQ=q; | |
setTimeout(function () {tick(i)}, i); | |
}, 30); | |
return; | |
} | |
tick(i); | |
return; | |
} | |
/*q = $exercise.find('.ac-section:first-child').text().trim(); | |
if (_storage[q]) { | |
$('#answer-input').val(_storage[q]); | |
$('#check-button').click(); | |
} else { | |
$('#answer-input').val('a'+Math.random()); | |
$('#check-button').click(); | |
_storage[q] = $('.js-bubble.coqui-test-bubble.incorrect span').text().trim(); | |
}*/ | |
} | |
window.start = function (i) { | |
tick((i || 1000) + 50); | |
// i = i || 300; | |
// var id = setInterval(window.tick, i+50); | |
// setTimeout(function () {clearInterval(id)}, 4*60*1000); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how could i make this for personal use?