-
Notifications
You must be signed in to change notification settings - Fork 1
/
memrise.js
96 lines (82 loc) · 1.87 KB
/
memrise.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(function($)
{
console.log("Developed by Jordan Doyle (https://doyle.wf)");
var getQuestion = function()
{
return $('.qquestion')[0].childNodes[0].nodeValue.trim();
};
var things, thingsUsers;
var getThings = function()
{
things = MEMRISE.garden.things;
thingsUsers = MEMRISE.garden.thingusers._list;
};
var getThingUser = function(id)
{
return thingsUsers.filter(function(e)
{
return e.thing_id === id;
})[0];
};
var getThingByQuestion = function(question)
{
getThings();
for(var id in things)
{
var thing = things[id];
var thingUser = getThingUser(thing.id);
if(thingUser)
{
var thisQuestion = thing.columns[thingUser.column_b].val;
var thisAnswer = thing.columns[thingUser.column_a].val;
if($.trim(question) === $.trim(thisQuestion))
{
return {
answer: thisAnswer,
question: thisQuestion
};
} else if($.trim(question) === $.trim(thisAnswer)) {
return {
answer: thisQuestion,
question: thisAnswer
};
}
}
}
};
setInterval(function()
{
if($('.qquestion').length)
{
var question = getThingByQuestion(getQuestion());
if($('.choice').length !== 0)
{
$('.choice').each(function(index)
{
if($(this).find('.val').text() === question.answer)
{
$(this).click();
}
});
} else if($('.typing-type-here').length) {
$('.typing-type-here').val(question.answer);
$('.next-button').click();
} else if($('.word-box-response').length) {
var words = question.answer.split(' ');
$.each(words, function(ind, val)
{
$('.word').each(function(index)
{
var actualThis = $(this).clone().children().remove().end().text();
if($.trim(actualThis) == $.trim(val))
$(this).click();
});
});
}
return;
}
if($('.next-icon').length) {
$('.next-icon').click();
}
}, 10);
})(jQuery);