-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
267 lines (188 loc) · 8.61 KB
/
main.py
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import random
import time
import logging
import subprocess
extensionIds = {"nodepay":"lgmpfmgeabnnlemejacfljbmonaomfmm","grass":"ilehaonighjijnmpnagapkhpcdbhclfg","gradient":"caacbgbklghmpodbdafajbgdnegacfmo","dawn":"fpdkjdnhkakefebpekbdhillbhonfjjp"}
docker = os.getenv("ISDOCKER")
def setup_logging():
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def clearMemory(driver):
"""Closes unused tabs to save memory."""
window_handles = driver.window_handles
# Keep the first tab open
driver.switch_to.window(window_handles[0])
# Close all other tabs
for handle in window_handles[1:]:
driver.switch_to.window(handle)
driver.close()
# Switch back to the first tab to ensure driver is on a valid window
driver.switch_to.window(window_handles[0])
# function to handle cookie banner: If a cookie banner is present press the button containing the accept text
def handle_cookie_banner(driver):
"""
Handle the cookie banner by clicking the "Accept" button if it's present.
Args:
driver (webdriver): The WebDriver instance.
"""
try:
cookie_banner = driver.find_element(By.XPATH, "//button[contains(text(), 'ACCEPT')]")
if cookie_banner:
logging.info('Cookie banner found. Accepting cookies...')
cookie_banner.click()
time.sleep(random.randint(3, 11))
logging.info('Cookies accepted.')
except Exception:
pass
def runGrass(driver,email,password,extension_id):
# Navigate to a webpage
logging.info('Navigating to the website...')
time.sleep(5)
window_handles = driver.window_handles
driver.switch_to.window(window_handles[0])
driver.get("https://app.getgrass.io/")
time.sleep(random.randint(3,7))
handle_cookie_banner(driver)
logging.info('Entering credentials...')
username = driver.find_element(By.NAME,"user")
username.send_keys(email)
passwd = driver.find_element(By.NAME,"password")
passwd.send_keys(password)
logging.info('Clicking the login button...')
button = driver.find_element(By.XPATH, "//button")
button.click()
logging.info('Waiting response...')
time.sleep(random.randint(10,50))
logging.info('Accessing extension settings page...')
driver.get(f'chrome-extension://{extension_id}/index.html')
time.sleep(random.randint(3,7))
logging.info('Clicking the extension button...')
button = driver.find_element(By.XPATH, "//button")
button.click()
logging.info('Logged in successfully.')
handle_cookie_banner(driver)
logging.info('Earning...')
time.sleep(random.randint(1,30))
def runNodepay():
pass
def runGradientNode(driver,email,password):
logging.info("Visiting app.gradient.network...................")
window_handles = driver.window_handles
driver.switch_to.window(window_handles[0])
driver.get("https://app.gradient.network/")
time.sleep(random.randint(6,13))
logging.info('Entering credentials...')
email_input =driver.find_element(By.XPATH, '//input[@class="ant-input css-11fzbzo ant-input-outlined rounded-full h-9 px-4 text-sm"]')
email_input.send_keys(email)
time.sleep(random.randint(6,13))
password_input = driver.find_element(By.XPATH, '//input[@placeholder="Enter Password"]')
password_input.send_keys(password)
button = driver.find_element(By.CSS_SELECTOR, 'button.custom-flying-button.bg-black.text-white')
button.click()
time.sleep(random.randint(6,13))
window_handles = driver.window_handles
driver.switch_to.window(window_handles[0])
logging.info('Clicking the extension button...')
driver.get("chrome-extension://caacbgbklghmpodbdafajbgdnegacfmo/popup.html")
time.sleep(random.randint(6,13))
button = driver.find_element(By.XPATH,"/html/body/div[3]/div/div[2]/div/div[1]/div/div/div/button")
button.click()
time.sleep(random.randint(6,13))
button = driver.find_element(By.XPATH,"//button[@class='w-full h-[48px] text-center flex-row-center rounded-[125px] text-[16px] font-normal leading-[100%] bg-black text-white mt-[32px] z-20 Helveticae']")
button.click()
logging.info('Logged in successfully.')
logging.info('Earning...')
def download_extension(extension_id, driver=None,repo_path="./crx-dl/crx-dl.py"):
"""
Downloads a Chrome extension using the crxdl script.
Args:
extension_id (str): The ID of the Chrome extension to download.
repo_path (str): Path to the crxdl executable script.
Returns:
None
"""
if docker == 'true':
try:
print(f"Starting download for extension ID: {extension_id}")
result = subprocess.run(["python3",repo_path, extension_id], check=True, text=True, capture_output=True)
print("Download successful!")
print(result.stdout)
except subprocess.CalledProcessError as e:
print("An error occurred while downloading the extension:")
print(e.stderr)
else:
url = f"https://chromewebstore.google.com/detail/{extension_id}"
print(f"Opening: {url}")
# Open the extension's page
driver.get(url)
# Wait for the page to load
time.sleep(5)
#Since I am lazy to automate this add the extension manually XOXO
input("Add the extension and press enter")
return
def run():
setup_logging()
logging.info('Starting the script...')
chrome_options = Options()
chrome_options.add_argument("--disable-blink-features=CSSAnimations,CSSTransitions")
prefs = {"profile.managed_default_content_settings.images":2}
chrome_options.add_experimental_option("prefs", prefs)
# Read variables from the OS env
if docker == 'true':
grass_email = os.getenv('GRASS_USER')
grass_password = os.getenv('GRASS_PASS')
gradient_email = os.getenv('GRADIENT_EMAIL')
gradient_password = os.getenv('GRADIENT_PASS')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless=new')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0")
# Check if credentials are provided
if grass_email and grass_password:
logging.info('Installing Grass')
download_extension(extensionIds["grass"])
id = extensionIds["grass"]
chrome_options.add_extension(f"./{id}.crx")
if gradient_email and gradient_password:
logging.info('Installing Gradient')
download_extension(extensionIds['gradient'])
id = extensionIds["gradient"]
chrome_options.add_extension(f"./{id}.crx")
driver = webdriver.Chrome(options=chrome_options)
else:
grass_email = input('Enter GRASS_USER: ')
grass_password = input('Enter GRASS_PASS: ')
gradient_email = input('Enter GRADIENT_EMAIL: ')
gradient_password = input('Enter GRADIENT_PASS: ')
driver = webdriver.Chrome(options=chrome_options)
if grass_email and grass_password:
logging.info('Installing Grass')
download_extension(extensionIds["grass"],driver)
if gradient_email and gradient_password:
logging.info('Installing Gradient')
download_extension(extensionIds['gradient'],driver)
try:
if gradient_email and gradient_password:
runGradientNode(driver,gradient_email,gradient_password)
clearMemory(driver)
if grass_email and grass_password:
runGrass(driver,grass_email,grass_password,extensionIds['grass'])
clearMemory(driver)
#Loading a simple webpage to save resources as gradient node website is really heavy
#I could use this as a way to see advertisement lol
#if u are reading this and want your website instead of example.com contact me XD
driver.get("https://example.com")
except Exception as e:
logging.error(f'An error occurred: {e}')
driver.quit()
while True:
try:
time.sleep(3600)
except KeyboardInterrupt:
logging.info('Stopping the script...')
driver.quit()
break
run()