forked from wmarshall484/nps_hack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-end.js
More file actions
76 lines (61 loc) · 2.12 KB
/
start-end.js
File metadata and controls
76 lines (61 loc) · 2.12 KB
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
71
72
73
74
75
76
// ==UserScript==
// @name camp range [start end]
// @version 1
// @grant none
// ==/UserScript==
// @run-at document-idle
window.addEventListener('load', function() {
hasClicked = false
hasClickedEnd = false
counter = 0
START_DATE = "Oct 14, 2022"
END_DATE = "Oct 18, 2022"
// modify if next week
GO_FORWARD_LIMIT = 1
goForwardCount = 0
go_forward = document.querySelectorAll(`[aria-label*="Go Forward 5 Days"]`)
// if (goForwardCount < GO_FORWARD_LIMIT) {
// setTimeout(() => {}, 21)
// goForwardCount += 1
// }
// go_forward[0].click()
while (counter < 11 && !hasClicked) {
setTimeout(() => {
try {
// start date
start_selector = document.querySelectorAll(`[aria-label*="${START_DATE}"]`)
available_elements = Array.from(start_selector).filter((el) => {
// aria-label is element 1 in node
return el.attributes[1].value.includes('available')
})
if (available_elements[0] && !hasClicked) {
available_elements.length > 0 && available_elements[0].click()
hasClicked = true
console.log('clicked start')
setTimeout(() => {}, 500)
}
// end date
if (END_DATE) {
end_selector = document.querySelectorAll(`[aria-label*="${END_DATE}"]`)
available_end_elements = Array.from(end_selector).filter((el) => {
// aria-label is element 1 in node
return el.attributes[1].value.includes('available')
})
if (available_end_elements[0] && !hasClickedEnd) {
available_end_elements.length > 0 && available_end_elements[0].click()
hasClickedEnd = true
console.log('clicked end')
setTimeout(() => {}, 50)
}
}
// click add to cart
availability_selector = document.getElementsByClassName('availability-page-book-now-button-tracker')
availability_selector[0] && availability_selector[0].click()
console.log('Mischief managed')
} catch (err) {
console.error(err)
}
}, 2000)
counter += 1
}
}, false);