MY WEBSITE IS MOVING!

I’ve created a new site at JotheDev.com! Click the button below to go there now.

This website will be deleted by October 2020.

Hey! You’re lazy, right? You get food delivered on DoorDash rather than getting in your car to get it. But you’re probably indecisive too. There are hundreds of restaurants on DoorDash and it’s hard to decide what to get. This becomes even more complicated when your wife says she’s fine with anything (when she really isn’t).

Well, worry no more with RandomDash! RandomDash is a program which will choose a random restaurant for you and also chooses a random dish from their menu. Just log in to DoorDash, click start and watch it do its magic!

Click here to download it now!

MORE INFO FOR NERDS

This project was created in C# and heavily relies on the CefSharp library. Click here to view the GitHub project.

HOW IT WAS DONE

DoorDash doesn’t have an official API, which was a total bummer for this project. It would have been a thousand times easier with an API. But luckily, I came up with a clever solution.

I embedded a Chromium browser into the program with CefSharp. After the user logs in, the program has the ability to “scrape” the HTML of DoorDash and get a list of all the restaurants presented to the user. I then just randomly choose a restaurant and navigate to its store page.

To choose a random menu item, it was a little trickier. In order to get a total of how many menu items there are, I executed this Javascript snippet on the Chromium browser:

browser.GetMainFrame().ExecuteJavaScriptAsync("document.getElementsByClassName('sc-kGsDXJ fvLYbn').length");

This Javascript snippet gets an array of all elements with the class sc-kGsDXJ fvLYbn and returns the length of that array. Elements with that class are the buttons for the store’s menu items.

I then choose a random button, and using Javascript I can click the button:

browser.GetMainFrame().ExecuteJavaScriptAsync("document.getElementsByClassName('sc-kGsDXJ fvLYbn')[randomNum].click()");

As you can see, the .click() function does the clicking part. After this, we present the browser to the user!

By the way, this is massively oversimplified. I ended up using Timers and BackgroundWorkers to get the whole thing working properly. If you want to get into those juicy deets, click here.