-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.js
108 lines (94 loc) · 2.92 KB
/
export.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
97
98
99
100
101
102
103
104
105
106
107
108
const executeInterval = 200
const virtualScroll = !!document.querySelector("#virtual-note-list-id")
let scrollArea = document.querySelector("#virtual-note-list-id") || document.querySelector("#note-list-block")
const noteSet = new Set()
started = false
let lastScrollTop = scrollArea.scrollTop
function downloadNotes(startName, endName) {
let noteList = document.querySelectorAll("#note-list-block .note-container")
let noteNames = document.querySelectorAll("#note-list-block .note-container .heading span")
// let noteContents = document.querySelectorAll("#note-list-block .note-container .content span")
let cardHeight = noteList[0].clientHeight
let noteListLen = noteList.length
console.log(noteNames[0].textContent, noteNames[noteListLen - 1].textContent)
let k = 0
for (let j = 0; j < noteListLen; j++) {
let noteName = noteNames[j].textContent
// let noteContent = noteContents[j].textContent.substring(0, 30)
// if (noteSet.has(noteContent)) {
// continue
// }
// noteSet.add(noteContent)
if (startName && !started) {
if (noteName === startName) {
started = true
console.log("started", startName)
} else {
continue
}
} else {
started = true
}
if (noteSet.has(noteName)) {
setTimeout(() => {
console.log("duplicate note name, move the previous notes first", noteName)
}, k * executeInterval)
k++
return
}
noteSet.add(noteName);
if (endName && noteName === endName) {
setTimeout(() => {
console.log("endName reached", endName)
}, k * executeInterval)
k++
return
}
(function (k) {
setTimeout(() => {
noteList[j].click()
console.log("noteCardClicked", noteName)
}, k * executeInterval)
})(k)
k++
(function (k) {
setTimeout(() => {
const exportBtn = document.querySelector('.v-contextmenu>div>li.v-contextmenu-submenu li:nth-child(3)')
exportBtn.click()
console.log("exportBtnClicked", noteName)
}, k * executeInterval)
})(k)
k++
}
if (!virtualScroll) {
(function (k) {
setTimeout(() => {
console.log("downloaded", noteSet.keys())
}, k * executeInterval)
})(k)
k++
return
}
(function (k) {
setTimeout(() => {
scrollArea.scrollBy(0, cardHeight * noteListLen)
console.log("scrolled", noteListLen)
}, k * executeInterval)
})(k)
k++
// (function (k, lastScrollTop, scrollArea, noteSet, endName) {
setTimeout(() => {
if (lastScrollTop !== scrollArea.scrollTop) {
lastScrollTop = scrollArea.scrollTop
console.log("downloading more notes")
downloadNotes(startName, endName)
} else {
console.log("downloaded", noteSet.keys())
}
}, k * executeInterval)
// })(k, lastScrollTop, scrollArea, noteSet, endName)
k++
}
const startName = "10月31日"
const endName = ""
downloadNotes(startName, endName)