Skip to content

Instantly share code, notes, and snippets.

@mattwiebe
Created April 23, 2026 18:14
Show Gist options
  • Select an option

  • Save mattwiebe/786634444bd0d2ab76b251c9605b272c to your computer and use it in GitHub Desktop.

Select an option

Save mattwiebe/786634444bd0d2ab76b251c9605b272c to your computer and use it in GitHub Desktop.
Uber Eats: oneshot script to move all cart items to "Don't replace"
javascript:(async()=>{const L=window.location.pathname.match(/^\/([a-z]{2}-[a-z]{2})\//)?.[1]??'en-US',B='https://www.ubereats.com/_p/api',H={'Content-Type':'application/json','x-csrf-token':'x'},d=await(await fetch(`${B}/getDraftOrdersByEaterUuidV1?localeCode=${L}`,{method:'POST',headers:H,body:'{}'})).json();if(d.status!=='success'||!d.data.draftOrders.length){alert('Could not fetch cart.');return;}const{uuid:dUUID,shoppingCart:{cartUuid:cUUID,items}}=d.data.draftOrders[0],toUpdate=items.filter(i=>i.fulfillmentIssueAction?.type!=='REMOVE_ITEM');console.log(`Updating ${toUpdate.length}/${items.length} items...`);let ok=0;for(const i of toUpdate){const r=await(await fetch(`${B}/updateItemInDraftOrderV2?localeCode=${L}`,{method:'POST',headers:H,body:JSON.stringify({draftOrderUUID:dUUID,cartUUID:cUUID,item:{uuid:i.uuid,shoppingCartItemUuid:i.shoppingCartItemUuid,storeUuid:i.storeUuid,sectionUuid:i.sectionUuid,subsectionUuid:i.subsectionUuid,price:i.price,title:i.title,quantity:i.quantity,customizations:i.customizations??{},specialInstructions:i.specialInstructions??'',imageURL:i.imageURL??'',fulfillmentIssueAction:{type:'REMOVE_ITEM',selectionSource:'CONSUMER_SELECTED',itemSubstitutes:[]}}})})).json();r.status==='success'?ok++:console.error(`Failed: ${i.title}`,r);await new Promise(r=>setTimeout(r,300));}alert(`Done! ${ok}/${toUpdate.length} items set to "Don't replace".`);})();
(async function setAllItemsToDontReplace() {
const LOCALE = window.location.pathname.match(/^\/([a-z]{2}-[a-z]{2})\//)?.[1] ?? 'en-US';
const BASE_URL = 'https://www.ubereats.com/_p/api';
const HEADERS = { 'Content-Type': 'application/json', 'x-csrf-token': 'x' };
// 1. Fetch current draft order
const draftRes = await fetch(`${BASE_URL}/getDraftOrdersByEaterUuidV1?localeCode=${LOCALE}`, {
method: 'POST', headers: HEADERS, body: JSON.stringify({})
});
const draftData = await draftRes.json();
if (draftData.status !== 'success' || !draftData.data.draftOrders.length) {
console.error('Could not fetch draft orders:', draftData);
return;
}
const draftOrder = draftData.data.draftOrders[0];
const { uuid: draftOrderUUID, shoppingCart: { cartUuid: cartUUID, items } } = draftOrder;
// 2. Filter items that are NOT already "Don't replace"
const toUpdate = items.filter(item =>
item.fulfillmentIssueAction?.type !== 'REMOVE_ITEM'
);
console.log(`Updating ${toUpdate.length} of ${items.length} items to "Don't replace"...`);
// 3. Update each item sequentially
let successCount = 0;
for (const item of toUpdate) {
const res = await fetch(`${BASE_URL}/updateItemInDraftOrderV2?localeCode=${LOCALE}`, {
method: 'POST',
headers: HEADERS,
body: JSON.stringify({
draftOrderUUID,
cartUUID,
item: {
uuid: item.uuid,
shoppingCartItemUuid: item.shoppingCartItemUuid,
storeUuid: item.storeUuid,
sectionUuid: item.sectionUuid,
subsectionUuid: item.subsectionUuid,
price: item.price,
title: item.title,
quantity: item.quantity,
customizations: item.customizations ?? {},
specialInstructions: item.specialInstructions ?? '',
imageURL: item.imageURL ?? '',
fulfillmentIssueAction: {
type: 'REMOVE_ITEM',
selectionSource: 'CONSUMER_SELECTED',
itemSubstitutes: []
}
}
})
});
const data = await res.json();
if (data.status === 'success') { console.log(`✅ ${item.title}`); successCount++; }
else { console.error(`❌ ${item.title}`, data); }
await new Promise(r => setTimeout(r, 300));
}
console.log(`\nDone! ${successCount}/${toUpdate.length} items updated.`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment