Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonusumit1994/10bd1b331dab960a9acaa65e4ccc5623 to your computer and use it in GitHub Desktop.
Save sonusumit1994/10bd1b331dab960a9acaa65e4ccc5623 to your computer and use it in GitHub Desktop.
A minimal script to check overall spend till date on Zomato and Swiggy
/*
For Swiggy orders detail wise
Step 1: Go to Swiggy.com,
Step 2: Click on your "Name" then click on "Orders".
Step 3: Scroll to the very bottom and click on "Show More Orders", until nothing new gets added.
Step 4: Do a right click anywhere on the screen and click on "Inspect", in the inspector,
go to console copy and paste the below snippet and press enter.
*****IMPORTANT****
Make sure all the steps till step 3 is followed before doing the step 4.
*/
restauratnt_name_node_list = document.getElementsByClassName('_3h4gz');
amount_node_list = document.getElementsByClassName('_3Hghg');
order_details_node_list = document.getElementsByClassName('_2uT6l');
order_name_node_list = document.getElementsByClassName('nRCg_');
amount_regex = /\d+.\d*/g;
total_amount = 0.0
console.log("restaurant_name,order_name,order_details,current_amount");
for (let i = 0; i < amount_node_list.length; i++) {
current_amount = amount_node_list[i].innerHTML;
restaurant_name = restauratnt_name_node_list[i].innerHTML;
order_details = order_details_node_list[i].innerHTML;
order_name = order_name_node_list[i].innerHTML;
console.log(restaurant_name,",",order_name,",",order_details,",",current_amount);
if (current_amount.match(amount_regex)) {
amount = parseFloat(current_amount.match(amount_regex)[0])
total_amount += amount;
}
}
console.log("Total amount spent on Swiggy so far is INR ", total_amount);
/*zomato expense - just a workaround
Go page by page and keep repeating the same code, But if you have so many orders then crawlwer can help.
Will update with crawlwer in future.
The below snippets will help you find total money spent on Zomato so far by any individual.
For Zomato:
Step 1: Go to Zomato.com,
Step 2: Go to "Profiles", click on "Order History"
Step 3: Do a right click anywhere on the screen and click on "Inspect", in the inspector,
go to console copy and paste the below snippet and press enter.
Step 4: Keep repeating the same code without amount declaration on all pages
*********
Used parseFloat - instead of parseInt -> to consider the decimal values too
*********
*/
order_details_class = "sc-hPeUyl gCkrBS";
//comment below if you don't want amount to over-written
total_amount = 0.0
order_details_node_list = document.getElementsByClassName(order_details_class);
console.log("order_number,ordered_items,ordered_time,amount");
for ( var i = 0; i < order_details_node_list.length-4; i+=4){
order_number = order_details_node_list[i].innerHTML;
current_amount = order_details_node_list[i+1].innerHTML;
ordered_items = order_details_node_list[i+2].innerHTML;
ordered_time = order_details_node_list[i+3].innerHTML;
if (current_amount.match(amount_regex)) {
amount = parseFloat(current_amount.match(amount_regex)[0])
total_amount += amount;
}
console.log(order_number,",",ordered_items,",",ordered_time,",",current_amount);
}
console.log("Total amount spent on Zomato so far is INR",total_amount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment