Skip to content

Instantly share code, notes, and snippets.

@oleg-py
Created July 4, 2017 17:45
Show Gist options
  • Save oleg-py/56caccdf59921ea0a9840a1450690b89 to your computer and use it in GitHub Desktop.
Save oleg-py/56caccdf59921ea0a9840a1450690b89 to your computer and use it in GitHub Desktop.
AliExpress: cancelling all orders on the page
// Untested after refactoring
function aliBulkCancel () {
const cancelBody = oid => {
const fd = new FormData()
fd.append(`_csrf_token`, document.querySelector('input[name*=csrf]').value)
fd.append(`action`, "cancelOrder/cancel_order_action")
fd.append(`event_submit_do_buyer_request`, "anything")
fd.append(`order_id`, oid)
fd.append("_fm.ca._0.r", "buyerCannotPayment")
return fd
}
const cancel = oid => fetch('https://trade.aliexpress.com/ajax/ajaxResult.htm', {
method: 'POST',
credentials: "same-origin",
body: cancelBody(oid)
})
const ids = Array.from(document.querySelectorAll('.info-body'), el => el.textContent).filter(s => /^\d+$/.test(s))
Promise.all(ids.map(cancel)).then(() => window.location.reload(), console.error)
}
aliBulkCancel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment