Created
March 24, 2019 23:16
-
-
Save haruo31/7a2aac5c97795903fcc5472c6ec25f55 to your computer and use it in GitHub Desktop.
Greesemonkey script generates json list from aliexpress order list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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