-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.py
More file actions
198 lines (159 loc) · 7.55 KB
/
script.py
File metadata and controls
198 lines (159 loc) · 7.55 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Generated by Selenium IDE
import time as WAIT
import json
import schedule
import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from datetime import timedelta, datetime
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# Counter to stop the script after completion
class TestCsgoroll1:
# [Boolean] Will add a timed lock to the stash
isLocked = True
# [String] Option: 1 = 1 Hour, 2 = 2 Hours, 3 = 4 Hours, 4 = 8 Hours, 5 = 12 Hours, 6 = 1 Day, 7 = 7 Days (Remember to make this a string by putting "")
lockOption = "7"
levelOption = 1
def setup_method(self):
print("Loading Options into Variables...")
file = open('web/json/settings.json','r', encoding="utf-8")
jsonData = file.read()
obj = json.loads(jsonData)
file.close()
ProfilePath = obj['profilePath']
if obj['isStashed'] == "Yes":
self.isLocked = True
else:
self.isLocked = False
self.lockOption = obj['stashOption']
self.levelOption = int(obj['levelOption'])
optionsVar = webdriver.ChromeOptions()
optionsVar.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36")
optionsVar.add_argument(r"--user-data-dir=" + ProfilePath)
optionsVar.add_argument(r'--profile-directory=CSGOROLL Bot')
optionsVar.add_experimental_option('excludeSwitches', ['enable-logging'])
self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=optionsVar)
print("Checkmark 1")
self.vars = {}
balance = self.test_csgoroll1()
print("Checkmark 2")
self.teardown_method(balance)
def teardown_method(self, balance):
print("Exiting Script")
self.incrementLastRun(balance)
print("Teardown Method")
exit()
def test_csgoroll1(self):
# DOING ALL DAILIES
print("Claiming Dailies")
target_url = "https://www.csgoroll.com/en/boxes/world/daily-free"
self.driver.get(target_url)
self.driver.maximize_window()
WAIT.sleep(10)
if self.driver.current_url != target_url:
self.driver.find_element(By.XPATH, "/html/body/div[1]/div[7]/div[4]/div/div[2]/div[2]/div/form/input[5]").click()
WAIT.sleep(8)
self.driver.get(target_url)
WAIT.sleep(4)
#loop
for x in range(1, self.levelOption + 1):
self.driver.find_element(By.CSS_SELECTOR, "body > cw-root:nth-child(3) > mat-sidenav-container:nth-child(2) > mat-sidenav-content:nth-child(6) > div:nth-child(1) > cw-daily-free-boxes:nth-child(3) > cw-box-grid:nth-child(4) > section:nth-child(2) > cw-box-grid-item-gaming:nth-child(" + str(x) +") > div:nth-child(2) > button:nth-child(2)").click()
self.driver.execute_script("window.scrollTo(0,0)")
WAIT.sleep(3)
self.driver.find_element(By.CSS_SELECTOR, ".ng-star-inserted[fxlayoutalign='center center']").click()
WAIT.sleep(2)
self.driver.find_element(By.CSS_SELECTOR, "button[class='mat-focus-indicator close mat-icon-button mat-button-base']").click()
WAIT.sleep(1)
self.driver.get("https://www.csgoroll.com/en/boxes/world/daily-free")
WAIT.sleep(4)
# SELLING ALL ITEMS IN INVENTORY | Backpack > Select All Items > Sell
self.driver.find_element(By.XPATH, "/html/body/cw-root/cw-header/nav/div[2]/div/button[1]").click()
WAIT.sleep(1)
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/cw-portable-inventory/div/div[2]/button[1]").click()
WAIT.sleep(1)
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/cw-portable-inventory/div/footer/div/button").click()
WAIT.sleep(8)
self.driver.get("https://www.csgoroll.com/en/boxes/world/daily-free")
WAIT.sleep(4)
# STASHING 7 DAY SCRIPT START
#Dropdown
self.driver.find_element(By.XPATH, "/html/body/cw-root/cw-header/nav/div[2]/div/button[2]").click()
WAIT.sleep(1)
#Stash Button
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/cw-portable-profile/div/div[1]/a[4]").click()
WAIT.sleep(1)
#Max Amt
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/mat-dialog-container/cw-stash-modal/mat-dialog-content/section/section/form/div/div[1]/cw-amount-input/mat-form-field/div/div[1]/div[3]/div[2]/div/button").click()
WAIT.sleep(1)
if(self.isLocked):
#Toggle Lock
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/mat-dialog-container/cw-stash-modal/mat-dialog-content/section/section/form/div/div[2]/mat-slide-toggle").click()
WAIT.sleep(1)
#Dropdown
self.driver.find_element(By.XPATH, "/html/body/div[1]/div[2]/div/mat-dialog-container/cw-stash-modal/mat-dialog-content/section/section/form/div[2]/mat-form-field/div/div[1]/div[3]/mat-select").click()
WAIT.sleep(1)
#7Day Option (Change mat-option[n]; n= 1,2,3,4,5,6,7 to choose the different duration options)
self.driver.find_element(By.XPATH, "/html/body/div[1]/div[4]/div/div/div/mat-option[" + self.lockOption +"]").click()
WAIT.sleep(1)
#Confirm
self.driver.find_element(By.XPATH, "/html/body/div[1]/div[2]/div/mat-dialog-container/cw-stash-modal/mat-dialog-content/section/section/button").click()
WAIT.sleep(8)
# STASHING 7 DAY SCRIPT END
self.driver.get("https://www.csgoroll.com/en/boxes/world/daily-free")
WAIT.sleep(4)
# Web Scraping Total Amount in Stash
# Dropdown
# Dropdown
self.driver.find_element(By.XPATH, "/html/body/cw-root/cw-header/nav/div[2]/div/button[2]").click()
WAIT.sleep(1)
# Open Stash Interface
self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/cw-portable-profile/div/div[1]/a[4]").click()
WAIT.sleep(1)
item = self.driver.find_element(By.XPATH, "/html/body/div/div[2]/div/mat-dialog-container/cw-stash-modal/mat-dialog-content/section/div/cw-pretty-balance/span").text
self.driver.quit()
return item
def incrementLastRun(self, balance):
# Gets current time and compares with Scheduled Date
current_time_datetime = datetime.now()
# Parsing the Datetime format (changed to string)
current_time_str = current_time_datetime.strftime("%m/%d/%Y %H:%M:%S")
# Change back to Datetime
current_time_datetime = datetime.strptime(current_time_str,"%m/%d/%Y %H:%M:%S")
delta = timedelta(seconds=60)
current_time_datetime += delta
delta = timedelta(hours=24)
current_time_datetime += delta
current_time_str = current_time_datetime.strftime("%m/%d/%Y %H:%M:%S")
data = {
"dailyTime": current_time_str,
"balance": balance
}
with open("web/json/data.json", "w", encoding="utf-8") as outfile:
json.dump(data, outfile)
outfile.close()
return 1
instance = TestCsgoroll1()
# Gets current time and compares with Scheduled Date
unparsed_time = datetime.now()
# Parsing the Datetime format (changed to string)
current_time = unparsed_time.strftime("%m/%d/%Y %H:%M:%S")
file = open('web/json/data.json','r', encoding="utf-8")
jsonData = file.read()
obj = json.loads(jsonData)
file.close()
scheduledDate = datetime.strptime(obj['dailyTime'], "%m/%d/%Y %H:%M:%S")
# Change back to Datetime
current_time = unparsed_time.strptime(current_time,"%m/%d/%Y %H:%M:%S")
delta = timedelta(minutes=1)
current_time += delta
scheduledDate += delta
if(current_time > scheduledDate):
instance.setup_method()
else:
print("Wait until: " + str(scheduledDate))
date_str = str(scheduledDate.hour) + ":" + str(scheduledDate.minute)
schedule.every().day.at(date_str).do(instance.setup_method)
while True:
schedule.run_pending()
WAIT.sleep(60)