-
Notifications
You must be signed in to change notification settings - Fork 1
/
haleakala-sunrise-reservation.js
71 lines (55 loc) · 2.1 KB
/
haleakala-sunrise-reservation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// A script for getting a reservation for the Haleakala Sunrise
// 1. Sign up at https://www.recreation.gov to create an account
// 2. Open https://www.recreation.gov/ticket/facility/253731
// 3. Run the script a couple of minutes before the reservation opening time:
const delay = async ms => new Promise(resolve => setTimeout(resolve, ms));
const delayTimeMs = 200;
const jQuery = window.$;
const makeReservation = async () => {
// Select tour
console.log('Select tour');
const tourOptionsSelectId = "tour-options";
const tourOptionsSelect = document.getElementById(tourOptionsSelectId);
const haleakalaSunriseTourId = 255;
tourOptionsSelect.value = haleakalaSunriseTourId;
// Select Date
console.log('Click to open calendar');
const openCalendarButtonClasses = [
".SingleDatePickerInput_calendarIcon",
".SingleDatePickerInput_calendarIcon_1"
];
jQuery(openCalendarButtonClasses.join("")).click();
await delay(delayTimeMs);
console.log('Click to pick the date');
jQuery('[aria-label="Monday, January 13, 2020, available"]').click()
await delay(delayTimeMs);
// Select number of guests
console.log('Click to open the number of guests dropdown');
jQuery('[aria-label="Guests"]').click();
await delay(delayTimeMs);
console.log('Click to add 1 guest');
jQuery('[aria-label="Add Vehicle Passs"]').click();
await delay(delayTimeMs);
console.log('Click to close the number of guests dropdown');
jQuery('[aria-label="Close"]').click();
await delay(delayTimeMs);
// Select time
console.log('Click to open the time dropdown');
jQuery('[aria-label="Time"]').click();
await delay(delayTimeMs);
console.log('Click to pick the time');
jQuery('[title="7:00 AM"]').click();
await delay(delayTimeMs);
console.log('Click "Continue to Booking" button')
jQuery('.select-tour-time-buttons button').click();
};
const intervalId = setInterval(async () => {
const date = new Date();
console.log(date);
if (date.getHours() === 7) {
// Use this for testing:
// if (date.getMinutes() === 37) {
clearInterval(intervalId);
await makeReservation();
}
}, 200);