daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function myUberSpend() {
  2.   async function costForPage(pageNumber) {
  3.     const response = await fetch(`trips?page=${pageNumber}`, {
  4.       credentials: 'include'
  5.     });
  6.     const text = await response.text();
  7.     const prices = $(text).find("td.text--right");
  8.     if (!prices.length) return;
  9.     let costForPage = 0.0;
  10.     for (var i = 0; i < prices.length; i++) {
  11.       textPrice = prices[i].textContent.trim();
  12.       if (!/^\$\d+\.\d+$/.test(textPrice)) continue;
  13.       costForPage += parseFloat(textPrice.slice(1));
  14.     }
  15.     return costForPage;
  16.   }
  17.  
  18.   let currentPage = 1;
  19.   let totalCost = 0.0;
  20.   while (true) {
  21.     const pageCost = await costForPage(currentPage);
  22.     if (pageCost === undefined) break;
  23.     totalCost += pageCost;
  24.     currentPage++;
  25.   }
  26.   return totalCost;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top