Skip to content

Instantly share code, notes, and snippets.

@neopheus
Created December 8, 2023 16:03
Show Gist options
  • Select an option

  • Save neopheus/e4fe5ed6715a3b5a8c2528a5a2ff6577 to your computer and use it in GitHub Desktop.

Select an option

Save neopheus/e4fe5ed6715a3b5a8c2528a5a2ff6577 to your computer and use it in GitHub Desktop.
Uber Eats Download Invoice
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const downloadInvoice = async (orderUUID) => {
try {
console.log(`Downloading invoice for order UUID: ${orderUUID}`);
const invoiceResponse = await fetch('https://www.ubereats.com/_p/api/getInvoiceFilesV1?localeCode=fr', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-csrf-token': 'x' }, // Remplacez 'x' par votre token CSRF réel
body: JSON.stringify({ orderUUID }),
});
const invoiceData = await invoiceResponse.json();
if (invoiceData.status === "success" && invoiceData.data.files) {
invoiceData.data.files.forEach(file => {
const a = document.createElement("a");
a.href = file.downloadURL;
a.download = ""; // Le nom du fichier sera déduit de l'URL
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(a.href);
a.remove();
});
console.log(`Invoice for order ${orderUUID} downloaded.`);
}
await delay(1000); // Attente de 1 seconde entre chaque téléchargement
} catch (error) {
console.error('Error downloading invoice:', error);
}
};
const fetchAllOrders = async (lastWorkflowUUID = '') => {
console.log('Fetching orders...');
const res = await fetch('/api/getPastOrdersV1?localeCode=fr', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-csrf-token': 'x' },
credentials: 'include',
body: JSON.stringify({ lastWorkflowUUID }),
});
const { data } = await res.json();
for (const order of Object.values(data.ordersMap)) {
await downloadInvoice(order.baseEaterOrder?.uuid);
}
console.log('Batch of orders processed.');
if (data.meta?.hasMore) {
const lastOrder = Object.values(data.ordersMap).pop();
await delay(5000); // Attente de 5 secondes avant de récupérer le prochain lot
return fetchAllOrders(lastOrder.baseEaterOrder?.uuid);
} else {
console.log('All orders processed and invoices downloaded.');
}
};
fetchAllOrders();
@neopheus
Copy link
Author

neopheus commented Oct 31, 2025

(async () => {
  let count = 0;
  while (true) {
    // Cherche le bouton dont le texte contient "Voir plus"
    const buttons = [...document.querySelectorAll("button")];
    const voirPlus = buttons.find(b => b.textContent.trim().toLowerCase().includes("voir plus"));
    if (!voirPlus) {
      console.log("✅ Plus de bouton 'Voir plus' trouvé — toutes les commandes sont affichées !");
      break;
    }

    voirPlus.scrollIntoView({ behavior: "smooth", block: "center" });
    voirPlus.click();
    count++;
    console.log(`🟢 Clic n°${count} sur "Voir plus"`);
    await new Promise(r => setTimeout(r, 1500)); // pause entre les clics
  }
})();

@neopheus
Copy link
Author

(async () => {
  const boutons = [...document.querySelectorAll('a, button')]
    .filter(el => el.textContent.trim().toLowerCase().includes('télécharger la facture'));

  console.log(`📄 ${boutons.length} factures détectées.`);

  for (const [i, bouton] of boutons.entries()) {
    bouton.scrollIntoView({ behavior: "smooth", block: "center" });
    console.log(`⬇️ Clic ${i + 1}/${boutons.length} sur "Télécharger la facture"`);
    bouton.click();
    await new Promise(r => setTimeout(r, 1500)); // pause entre les clics
  }

  console.log("✅ Tous les boutons 'Télécharger la facture' ont été cliqués.");
})();

@hamzaPixl
Copy link

@neopheus ahah t un boss merci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment