Skip to content

Instantly share code, notes, and snippets.

@haruo31
Created March 24, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruo31/7a2aac5c97795903fcc5472c6ec25f55 to your computer and use it in GitHub Desktop.
Save haruo31/7a2aac5c97795903fcc5472c6ec25f55 to your computer and use it in GitHub Desktop.
Greesemonkey script generates json list from aliexpress order list.
// ==UserScript==
// @name AliExpress order collector
// @version 1
// @include https://trade.aliexpress.com/orderList.htm*
// ==/UserScript==
function run() {
var elem = document.querySelector('.me-menu-body').appendChild(document.createElement('textarea'));
elem.value = (JSON.stringify(
Array.prototype.slice.call(document.querySelectorAll('.order-item-wraper'))
.map((e)=>{
var s = (c)=>e.querySelector(c).innerText;
return {
"id": s('.order-head p:first-child .info-body'),
"date": new Date(s('.order-head p:nth-child(2) .info-body').replace(/\./g,'')).toISOString(),
"amount": s('.order-head .amount-num').replace(/[^0-9]/g,''),
"items": Array.prototype.slice.call(
e.querySelectorAll('.product-right')
).map((ce)=>{
return {
'name':ce.querySelector('p:nth-child(2) .baobei-name').title,
'amount':ce.querySelector('.product-amount span:first-child').innerText.replace(/[^0-9]/g,''),
'qty':ce.querySelector('.product-amount span:nth-child(2)').innerText.replace(/[^0-9]/g,'')
};
})
}
})
));
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment