Skip to content

Instantly share code, notes, and snippets.

@pedrogimenez
Created March 25, 2021 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrogimenez/efc88165785be9878cbaee0ad51a8d20 to your computer and use it in GitHub Desktop.
Save pedrogimenez/efc88165785be9878cbaee0ad51a8d20 to your computer and use it in GitHub Desktop.
How much have I spent on Uber Eats?
let moneySpent = 0
let linkSelector = "#main-content > div > div > div.du > div > div > div > a";
let nextButtonSelector = "#main-content > div > button";
let priceSelector = "body > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table:nth-child(1) > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td:nth-child(2) > div > span";
let alternativePriceSelector = "body > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr > td > table:nth-child(1) > tbody > tr > td > table > tbody > tr > td:nth-child(2)"
let closeButtonSelector = "#wrapper > div:nth-child(8) > div > div > div.db.af.bz > div > button";
let nextButton = document.querySelector(nextButtonSelector);
while (nextButton) {
nextButton.click();
await new Promise(r => setTimeout(r, 3000));
nextButton = document.querySelector(nextButtonSelector);
}
let links = document.querySelectorAll(linkSelector);
for (let i = 0; i < links.length; i++) {
link = links[i];
console.log(link);
link.click();
await new Promise(r => setTimeout(r, 3000));
let iframe = document.querySelector("iframe");
if (!iframe) {
continue;
}
let iframeContent = iframe.contentDocument;
let priceContainer = iframeContent.querySelector(priceSelector) || iframeContent.querySelector(alternativePriceSelector)
let price = parseInt(priceContainer.textContent.match(/\d+/)[0]);
moneySpent += price;
console.log(moneySpent);
document.querySelector(closeButtonSelector).click();
await new Promise(r => setTimeout(r, 3000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment