Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
UndercoverGoose
GitHub Repository: UndercoverGoose/classroom-cheats
Path: blob/master/scripts/quizlet_match.js
853 views
1
(function () {
2
const matches = {};
3
Quizlet.matchModeData.terms.forEach((term) => {
4
matches[term.word] = term.definition;
5
});
6
let css = "FormattedText notranslate TermText MatchModeQuestionGridTile-text";
7
if (document.getElementsByClassName(css).length === 0)
8
css = "MatchModeQuestionScatterTile";
9
const tiles = Array.from(document.getElementsByClassName(css));
10
const colors = [
11
"#f93640",
12
"#f98836",
13
"#f9e936",
14
"#3df936",
15
"#36f9d9",
16
"#3650f9",
17
"#7e36f9",
18
"#dc36f9",
19
"#ffffff",
20
"#a3a3a3",
21
"#424242",
22
];
23
Array.from(
24
document.getElementsByClassName("MatchModeQuestionGridTile-image")
25
).forEach((image) => {
26
image.style.display = "none";
27
});
28
29
let colorIndex = 0;
30
for (const term in matches) {
31
const definition = matches[term];
32
tiles.forEach((tile) => {
33
if (tile.textContent === term) {
34
tiles.forEach((box) => {
35
if (box.textContent === definition) {
36
box.style.background = colors[colorIndex];
37
box.style.color = "black";
38
}
39
});
40
tile.style.background = colors[colorIndex];
41
tile.style.color = "black";
42
colorIndex++;
43
}
44
});
45
}
46
})();
47
48