-
Notifications
You must be signed in to change notification settings - Fork 3
/
AliExpressAnalytics_QuickNDurty.js
36 lines (33 loc) · 1.44 KB
/
AliExpressAnalytics_QuickNDurty.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
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
// header for csv
var ordersString = "Amount\tArticle\tDate\t\Status\r\n";
// regex to take the first line of order status (wihtout Open Dispute / Refund links)
var strRegexOrderStatus = new RegExp("^(.*?)[\r\n]+.*", "gi");
document.querySelectorAll('.order-item-wraper').forEach(function(node) {
var orderStatus = node.querySelectorAll('.product-action')[0].innerText;
var orderStatusTrimmed = orderStatus.replace(strRegexOrderStatus, '$1');
ordersString = ordersString +
node.querySelectorAll('.amount-num')[0].innerText + "\t" +
node.querySelectorAll('.baobei-name')[0].innerText + "\t" +
node.querySelectorAll('.info-body')[1].innerText + "\t" +
orderStatusTrimmed + "\r\n";
});
download(ordersString, 'orders.txt','text/plain;charset=utf-8');
var nextButton = document.querySelectorAll('.ui-pagination-navi.util-left > .ui-pagination-next.ui-goto-page')[0];
nextButton.click();