Created
July 4, 2017 17:45
-
-
Save oleg-py/56caccdf59921ea0a9840a1450690b89 to your computer and use it in GitHub Desktop.
AliExpress: cancelling all orders on the page
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
// 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