Last active
April 29, 2020 20:55
-
-
Save kluszczyn/65b61ab5ddfb58d1d85a8761145e2bdc to your computer and use it in GitHub Desktop.
AliExpress Orders to CSV
This file contains hidden or 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 Orders Lines | |
// @match https://trade.aliexpress.com/orderList.htm* | |
// @grant unsafeWindow | |
// @grant GM_xmlhttpRequest | |
// @grant GM_setClipboard | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js | |
// ==/UserScript== | |
var data = []; | |
$(".order-item-wraper").each(async (ind, el)=>{ | |
let order = { | |
id: $(el).find(".order-info .first-row .info-body ").text().trim(), | |
status: $(el).find(".order-status .f-left").text().trim(), | |
orderPriceUS: $(el).find(".amount-num").text().trim(), | |
orderDate: new Date($(el).find(".order-info .second-row .info-body").text().trim()).toLocaleString("sv-SE"), | |
sellerName: $(el).find(".store-info .first-row .info-body").text().trim(), | |
}; | |
$(el).find(".order-body").each((i,e)=>{ | |
let row = JSON.parse(JSON.stringify(order)); | |
row["rowType"] = "product"; | |
row["productTitle"] = $(e).find(".product-sets .product-title").text().trim(); | |
row["productPriceUS"] = parseFloat($(e).find(".product-sets .product-amount span:first()").text().trim().slice(1).trim()); | |
row["productQuantity"] = $(e).find(".product-sets .product-amount span:eq(1)").text().trim().slice(1); | |
row["productProperties"] = $(e).find(".product-sets .product-property .val").text().replace(/(\r\n|\n|\r)/gm," ").replace(/\s+/g, " ").trim(); | |
row["productAction"] = $(e).find(".product-action").text().replace(/(\r\n|\n|\r)/gm," ").replace(/\s+/g, " ").trim(); | |
data.push(row); | |
}); | |
}); | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// Create a button to click at the top of the order list page which will load the product details to the clip board | |
$('#mybutton').one('click', function(){ | |
var r=$('<input/>').attr({ | |
type: "button", | |
id: "field", | |
value: 'LOAD CSV' | |
}); | |
$("body").append(r); | |
}); | |
$('<button/>', { | |
text: "LOAD", //set text 1 to 10 | |
id: 'csvBtn', | |
click: function () { | |
$("#csvBtn").text("Loading..."); | |
var s = "";// "rowType\t id\t productTitle\t productPriceUS\t productQuantity\t AUDtoUSForex\t productPriceAUD\t GSTrate\t GSTPerProductUS\t GSTPerProductAUD\t orderDate\t orderPriceUS\t orderPriceAUD\t sellerName\t url \n"; | |
Promise.all(data).then(() => { | |
data.forEach(e=> { | |
if (e.rowType === "product") { | |
s += e.id + "\t"; | |
s += e.orderDate + "\t"; | |
s += e.status + "\t"; | |
s += e.productAction + "\t"; | |
s += e.productTitle + "\t"; | |
s += e.productProperties + "\t"; | |
s += e.productQuantity + "\t"; | |
s += e.productPriceUS + "\t"; | |
s += e.orderPriceUS + "\t"; | |
s += e.sellerName + "\t"; | |
//s += "https://trade.aliexpress.com/order_detail.htm?orderId=" + e.id + "\t"; | |
s += "\n"; | |
} | |
}); | |
GM_setClipboard (s); | |
$("#csvBtn").text("Loaded to clipboard"); | |
}); | |
} | |
}).appendTo("#appeal-alert"); | |
function test(data){ return data;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is working great, thanks!
Now if there was only a way to display more than 30 results per page...I tried but just get error page:

<input type="hidden" value="10" name="pageSize">