-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathback.html.txt
92 lines (77 loc) · 4.08 KB
/
back.html.txt
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
{{FrontSide}}
<hr id=answer>
<div style='font-family: Arial; font-size: 20px;'>{{back}}</div>
</br></br>
<div class="sources">
{{sources}}
</div>
<script>/*
// script to rip off bunpro
(function() {
JLPT_level = document.querySelector("#grammar-point-header > div.lesson-progress").innerText.slice(0,2);
lesson_id = (function(){
txt = document.querySelector("#grammar-point-header > div.lesson-progress").innerText.trim();
lesson_num = txt.slice("N4 Lesson ".length, txt.search(":")).trim();
lesson_section = txt.slice(txt.search(": ")+2, txt.search("/")).trim();
if (lesson_num.length == 1) { lesson_num = "0" + lesson_num; }
if (lesson_section.length == 1) { lesson_section = "0" + lesson_section; }
// str->int: integers must not start by 0; convert N5 to 0, N4 to 1....
first_digit = parseFloat(JLPT_level[1]) * -1 + 5 + 1
return "" + first_digit + lesson_num + lesson_section
})()
pattern = document.querySelector("#grammar-point-header > span.grammar-point-page-title").innerText.trim()
sources_html = (function() {
formed_html = "";
sources = Array.from(document.querySelectorAll("body > div > div.section > div.row-fluid > section > div > div.study-info.more > div > div.supplemental-links > div > div")).
filter(function (el) { return el.id.startsWith("supplemental_link") });
while (sources.length > 0) {
resource_link = sources.pop().innerHTML;
description = sources.pop().innerText;
formed_html = "<div class=\"sources_description\">" + description + "</div>" + resource_link + formed_html;
}
formed_html = "<div class=\"sources\">" + formed_html + "</div>";
return formed_html;
})()
csv = (function(){
grammar_left = document.querySelector("body > div > div.section > div.row-fluid > section > div > div.study-info.meaning > div > div > div.meaning-display").innerHTML.replace(/\n/g, "").trim();
grammar_right = document.querySelector("body > div > div.section > div.row-fluid > section > div > div.study-info.meaning > div > div > div.setsumei-show").innerHTML.replace(/\n/g, "").trim();
grammar = "<div class=\"grammar_meaning\">" + grammar_left + "</div><div class=\"grammar_pattern\">" + grammar_right + "</div>";
csv = lesson_id + "00" + ";" +
JLPT_level + ";" +
"rule" + ";" +
pattern + ";" +
pattern + ";" +
grammar + ";" +
sources_html + ";" +
"bunpro, rule, " + JLPT_level + ", " + pattern.replace(/[~{}()\s\s+\[\]!!【】()、。;:;]/g, "_") + "\n";
elems = document.querySelector("ul.examples-holder").querySelectorAll("ul");
for (i=0;i<elems.length;i++) {
exampleNode = elems[i]
lid = "" + (i+1);
if (lid.length == 1) { lid = "0" + lid; }
english = exampleNode.querySelector("li.example-sentence-english").innerHTML
japanese = exampleNode.querySelector("li.japanese-example-sentence").innerHTML
csv = csv +
lesson_id + lid + ";" +
JLPT_level + ";" +
"example" + ";" +
pattern + ";" +
japanese + ";" +
english + ";" +
sources_html + ";" +
"bunpro, example, " + JLPT_level + ", " + pattern.replace(/[~{}()\s\s+\[\]!!【】()、。;:;]/g, "_") + "\n";
}
return csv;
})()
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
download(JLPT_level + "_" + lesson_id + "_" + pattern + ".csv", csv)
})()
*/</script>