-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract.js
34 lines (28 loc) · 1.02 KB
/
extract.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
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelectorAll(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelectorAll(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
console.log('Starting BoA spending info extraction...')
waitForElm('.default-view.no-budget').then((categories) => {
categories.forEach((element) => {
let categoryName = element.querySelector('.cnx-regular.link-category-name').textContent.trim();
categoryName = categoryName.slice(0, categoryName.length - 16).trim();
let amount = element.querySelector('.cnx-regular.spent-amount').textContent.trim();
amount = amount.slice(0, amount.length - 6);
console.log(categoryName + ', ' + amount);
});
console.log('Finished extraction');
});