-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
1025 lines (828 loc) · 43 KB
/
main.py
File metadata and controls
1025 lines (828 loc) · 43 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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import random
import time
import logging
import subprocess
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException,StaleElementReferenceException
from flask import Flask, render_template, request, send_file
import threading
import time
import os
import requests
import capsolver
import json
def get_chromedriver_version():
try:
result = subprocess.run(['chromedriver', '--version'], capture_output=True, text=True)
return result.stdout.strip()
except Exception as e:
logging.error(f"Could not get ChromeDriver version: {e}")
return "Unknown version"
def get_chrome_version():
commands = [
['chromium', '--version'],
['chromium-browser', '--version'],
['google-chrome', '--version'],
['google-chrome-stable', '--version'],
['chrome', '--version'],
['chromedriver', '--version'],
]
for command in commands:
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
parts = result.stdout.strip().split()
for part in parts:
if part and part[0].isdigit():
return part
except Exception:
continue
logging.warning("Could not detect Chrome/Chromium version. Falling back to 9999.0.0.0 for CRX download.")
return "9999.0.0.0"
def get_chromedriver_path():
candidates = [
os.getenv("CHROMEDRIVER"),
"/usr/bin/chromedriver",
"/usr/lib/chromium/chromedriver",
"chromedriver",
]
for candidate in candidates:
if not candidate:
continue
if os.path.isabs(candidate):
if os.path.exists(candidate):
return candidate
continue
try:
result = subprocess.run([candidate, "--version"], capture_output=True, text=True, check=True)
if result.stdout.strip():
return candidate
except Exception:
continue
raise FileNotFoundError("Could not find a working chromedriver binary.")
def natural_sleep(base, variance=2):
time.sleep(base + random.uniform(-variance, variance))
def is_recaptcha_present(driver):
try:
# First check if the reCAPTCHA iframe exists and is visible
iframe = driver.find_element(By.CSS_SELECTOR, "iframe[src*='recaptcha']")
if iframe.is_displayed():
# reCAPTCHA iframe is present, now check if it's solved
try:
token_field = driver.find_element(By.CSS_SELECTOR, "textarea#g-recaptcha-response")
token = token_field.get_attribute("value").strip()
if token:
return False # reCAPTCHA solved
except NoSuchElementException:
pass
return True # reCAPTCHA present and unsolved
except NoSuchElementException:
pass
return False # No CAPTCHA iframe found => assume absent
def call_capsolver(driver, extension_id="bbdhfoclddncoaomddgkaaphcnddbpdh", enable_auto=True) -> None:
original_window = driver.current_window_handle
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[-1])
try:
driver.get(f"chrome-extension://{extension_id}/popup.html")
# List of all settings you want to toggle
settings = [
"recaptcha_auto_open",
"recaptcha_auto_solve"
]
for setting in settings:
expected_class = "off" if enable_auto else "on"
desired_class = "on" if enable_auto else "off"
try:
# Wait for the toggle with expected current class
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, f'div.settings_toggle.{expected_class}[data-settings="{setting}"]'))
)
toggles = driver.find_elements(By.CSS_SELECTOR, f'div.settings_toggle.{expected_class}[data-settings="{setting}"]')
for toggle in toggles:
driver.execute_script("arguments[0].click();", toggle)
except Exception as e:
pass
finally:
driver.close()
driver.switch_to.window(original_window)
def send_discord_webhook(webhook_url, title, log_results, color=16711680):
"""
Sends an embedded message to a Discord webhook with log results as fields.
"""
fileds = []
for app in log_results:
data = {"name":app,"value":f"Status : {log_results[app]["status"]}\nPoints : {log_results[app]["points"]}","inline":False}
fileds.append(data)
embed = {
"title": title,
"color": color,
"fields": fileds
}
data = {"embeds": [embed]}
response = requests.post(webhook_url, json=data)
if response.status_code == 204:
print("Message sent successfully!")
else:
print(f"Failed to send message: {response.status_code}, {response.text}")
# Define ANSI escape codes for colors
class LogColors:
HEADER = "\033[95m" # Purple
OKBLUE = "\033[94m" # Blue
OKGREEN = "\033[92m" # Green
WARNING = "\033[93m" # Yellow
FAIL = "\033[91m" # Red
RESET = "\033[0m" # Reset color
app = Flask(__name__)
log = logging.getLogger('werkzeug')
log.disabled = True
# Path for storing the CAPTCHA image and result
CAPTCHA_IMAGE_PATH = "./static/screenshot.png"
CAPTCHA_RESULT_PATH = "./static/captcha_result.txt"
def runFlask():
try:
app.run(host="0.0.0.0", port=5000, debug=False, use_reloader=False)
except:
pass
@app.route("/")
def index():
return render_template("index.html")
@app.route("/captcha")
def serve_captcha():
return send_file(CAPTCHA_IMAGE_PATH, mimetype="image/png")
@app.route("/submit", methods=["POST"])
def submit():
user_input = request.form.get("captcha_text")
if user_input:
with open(CAPTCHA_RESULT_PATH, "w") as f:
f.write(user_input)
return "CAPTCHA submitted successfully! The script will now continue."
return "Invalid input, please try again."
extensionIds = {"nodepay":"lgmpfmgeabnnlemejacfljbmonaomfmm","grass":"ilehaonighjijnmpnagapkhpcdbhclfg","gradient":"caacbgbklghmpodbdafajbgdnegacfmo","dawn":"fpdkjdnhkakefebpekbdhillbhonfjjp",
"despeed":"ofpfdpleloialedjbfpocglfggbdpiem","teneo":"emcclcoaglgcpoognfiggmhnhgabppkm","grass-node":"lkbnfiajjmbhnfledhphioinpickokdi"}
docker = os.getenv("ISDOCKER")
if not docker:
from dotenv import load_dotenv
#For developement environment
load_dotenv()
def setup_logging():
# Now simplified; run() handles basicConfig for unified setup.
# Can be removed if no other logging responsibilities.
pass # Kept for potential future logging setup (e.g., handlers).
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])
def handle_cookie_banner(driver):
"""
Handle the cookie banner by clicking the "ACCEPT ALL" button if it's present.
Args:
driver (webdriver): The WebDriver instance.
"""
try:
# Match button by visible text
cookie_button = driver.find_element(By.XPATH, "//button[contains(translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'ACCEPT ALL')]")
if cookie_button:
logging.info('Cookie banner found. Accepting cookies...')
cookie_button.click()
time.sleep(random.randint(3, 11)) # simulate human behavior
logging.info('Cookies accepted.')
except NoSuchElementException:
logging.info("No cookie banner found.")
except Exception as e:
logging.warning(f"Unexpected error while handling cookie banner: {e}")
def askCapcha():
while not os.path.exists(CAPTCHA_RESULT_PATH):
time.sleep(1)
# Read the CAPTCHA result
with open(CAPTCHA_RESULT_PATH, "r") as f:
captcha_text = f.read().strip()
logging.info("CAPTCHA entered.")
return captcha_text
def add_cooki(driver, cooki):
driver.execute_script(f"localStorage.setItem('{cooki['key']}', '{cooki['value']}');")
def runTeneo(driver, email=None, password=None, extension_id=None, cookie=None, delay_multiplier=1.0):
return {"status":"disabled","points":"none"}
driver.set_window_size(1024, driver.get_window_size()['height'])
logging.info(f"{LogColors.HEADER}🚀 Navigating to Teneo Website...{LogColors.RESET}")
driver.get("https://dashboard.teneo.pro")
timeout = max(10, 20 * delay_multiplier) # Ensure a minimum wait time of 10 seconds
wait = WebDriverWait(driver, timeout) # Set a max wait time based on delay multiplier
natural_sleep(15,variance=7)
if cookie:
add_cooki(driver, {"key": "accessToken", "value": cookie})
add_cooki(driver,{"key":"auth","value":json.dumps({"state":{"accessToken":cookie,"signupToken":None,"passwordResetTimeout":{"email":"","state":None,"timestamp":0,"duration":0}},"version":0})})
add_cooki(driver,{"key":"sb-node-b-auth-token","value":json.dumps({"access_token":cookie,"token_type":"bearer"})})
driver.refresh()
try:
time.sleep(15)
wait.until(EC.url_contains("/dashboard"))
logging.info("Log in sucessfull")
except:
logging.error("Nodepay cookie seems to be expired")
return
if driver.current_url == "https://dashboard.teneo.pro/dashboard":
logging.info(f"{LogColors.OKBLUE}✅ Inside the dahboard.....{LogColors.RESET}")
logging.info(f"{LogColors.OKGREEN}🖥️ Accessing extension settings page...{LogColors.RESET}")
driver.get(f'chrome-extension://{extension_id}/index.html')
try:
driver.add_cookie({"accessToken":cookie})
driver.refresh()
joinButton = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Join now')]")))
joinButton.click()
logging.info("Join Now button was clicked......")
natural_sleep(3*delay_multiplier)
clearMemory(driver)
driver.get(f'chrome-extension://{extension_id}/index.html')
except:
pass
natural_sleep(3*delay_multiplier)
connect_button = driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/div[1]/div/button[1]")
logging.info(f"{LogColors.WARNING}🔍 Button says {connect_button.text}{LogColors.RESET}")
while connect_button.text.strip().lower() == "connect node":
logging.info(f"{LogColors.OKBLUE}🤔 Ooooooooooo....Maybe I should click it.....{LogColors.RESET}")
connect_button.click()
logging.info(f"{LogColors.OKGREEN}👌 I just clicked it!!!{LogColors.RESET}")
time.sleep(random.randint(3,10)*delay_multiplier)
if "disconnect" in connect_button.text.lower():
logging.info(f"{LogColors.OKGREEN}Connected Sucessfully{LogColors.RESET}")
logging.info(f"{LogColors.OKGREEN}💸 Earning...{LogColors.RESET}")
return
logging.info(driver.current_url)
logging.info("Login Failed")
return
time.sleep(random.randint(3, 7))
logging.info(f"{LogColors.HEADER}🔑 Entering credentials...{LogColors.RESET}")
email_element = driver.find_element(By.XPATH, "/html/body/div/main/div/div/div[2]/div/div/div[1]/input")
email_element.send_keys(email)
password_element = driver.find_element(By.XPATH, "/html/body/div/main/div/div/div[2]/div/div/div[2]/div/input")
password_element.send_keys(password)
logging.info(f"{LogColors.OKBLUE}🖱️ Clicking the login button...{LogColors.RESET}")
login_button = driver.find_element(By.XPATH, "/html/body/div/main/div/div/div[2]/div/div/button")
login_button.click()
logging.info(f"{LogColors.WARNING}⏳ Waiting for response...{LogColors.RESET}")
time.sleep(random.randint(10, 50))
logging.info(f"{LogColors.OKGREEN}🖥️ Accessing extension settings page...{LogColors.RESET}")
driver.get(f'chrome-extension://{extension_id}/index.html')
time.sleep(random.randint(3, 7))
joinButton = driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/button")
joinButton.click()
time.sleep(random.randint(3, 7))
driver.get(f'chrome-extension://{extension_id}/index.html')
time.sleep(random.randint(3, 7))
logging.info(f"{LogColors.OKGREEN}💪 Clicking the connect button...{LogColors.RESET}")
connect_button = driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/div[1]/div/button[1]")
if connect_button.text.strip().lower() == "connect node":
logging.info(f"{LogColors.OKBLUE}🤝 Clicking the connect button...{LogColors.RESET}")
connect_button.click()
else:
logging.info(f"{LogColors.FAIL}👀 Button does not say 'Connect'. Skipping click.{LogColors.RESET}")
logging.info(f"{LogColors.OKGREEN}💸 Earning...{LogColors.RESET}")
time.sleep(random.randint(1, 30))
return
def runDawn(driver, email, password, extension_id,capsolver_token=None, delay_multiplier=1.0):
def dawnBalance():
element = wait.until(EC.visibility_of_element_located((By.ID, "dawnbalance")))
return element.text
driver.get(f"chrome-extension://{extension_id}/pages/dashboard.html")
timeout = max(10, 20 * delay_multiplier) # Ensure a minimum wait time of 10 seconds
wait = WebDriverWait(driver, timeout) # Set a max wait time based on delay multiplier
logging.info(f"{LogColors.HEADER}🚀 Navigating to Dawn website...{LogColors.RESET}")
natural_sleep(15,variance=7)
try:
alert = wait.until(EC.alert_is_present())
alert_text = alert.text.lower()
alert.accept()
if "expired" not in alert_text:
wait.until(EC.alert_is_present()).accept()
except:
logging.info(f"{LogColors.OKBLUE}✅ Already Logged in, Skipping...{LogColors.RESET}")
refresh_button = wait.until(EC.element_to_be_clickable((By.ID, "refreshpoint")))
refresh_button.click()
balance = dawnBalance()
logging.info(f"{LogColors.OKGREEN}💰 Your Dawn Balance is {balance}{LogColors.RESET}")
element = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "connecttext")))
if element.text.lower() == "connected":
logging.info(f"{LogColors.OKGREEN}🔗 Dawn is connected{LogColors.RESET}")
logging.info(f"{LogColors.HEADER}💸 Earning started...{LogColors.RESET}")
return {"status":"Connected","points":balance}
return {"status":"Disonnected","points":balance}
driver.get(f"chrome-extension://{extension_id}/pages/signin.html")
emailElement = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='email']")))
emailElement.send_keys(email)
passElement = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='password']")))
passElement.send_keys(password)
capElement = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='puzzelAns']")))
capchaImg = wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='puzzleImage']")))
if capsolver_token:
solved = False
while not solved:
try:
os.remove(CAPTCHA_IMAGE_PATH)
os.remove(CAPTCHA_RESULT_PATH)
except FileNotFoundError:
pass
capchaImg.screenshot(CAPTCHA_IMAGE_PATH)
capElement.click()
capElement.clear()
result = capsolver.solve_dawn(capsolver_token)
capElement.send_keys(result)
login_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='loginButton']")))
login_button.click()
try:
wait.until(EC.url_changes(driver.current_url))
solved = True
logging.info(f"{LogColors.OKGREEN}✅ CAPTCHA Solved Successfully!{LogColors.RESET}")
except:
logging.info(f"{LogColors.FAIL}❌ Incorrect CAPTCHA, retrying...{LogColors.RESET}")
logging.info(f"{LogColors.HEADER}💸 Earning started.{LogColors.RESET}")
return {"status":"Connected","points":element.text}
flask_thread = threading.Thread(target=runFlask, daemon=True)
flask_thread.start()
logging.info(f"{LogColors.WARNING}⚠️ Solve the CAPTCHA at http://localhost:5000{LogColors.RESET}")
solved = False
while not solved:
try:
os.remove(CAPTCHA_IMAGE_PATH)
os.remove(CAPTCHA_RESULT_PATH)
except FileNotFoundError:
pass
capchaImg.screenshot(CAPTCHA_IMAGE_PATH)
capElement.click()
capElement.clear()
capElement.send_keys(askCapcha())
login_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='loginButton']")))
login_button.click()
try:
wait.until(EC.url_changes(driver.current_url))
solved = True
logging.info(f"{LogColors.OKGREEN}✅ CAPTCHA Solved Successfully!{LogColors.RESET}")
except:
logging.info(f"{LogColors.FAIL}❌ Incorrect CAPTCHA, retrying...{LogColors.RESET}")
logging.info(f"{LogColors.HEADER}💸 Earning started.{LogColors.RESET}")
def runGrass(driver, email, password, extension_id, delay_multiplier=1):
MAX_GRASS_RETRIES = 5 # Maximum number of retry attempts for the main loop
retry_count = 0 # Initialize retry counter
while True: # Main retry loop for Grass connection
try:
logging.info(f"🚀 Starting Grass automation...")
logging.info(f"🌍 Navigating to Grass dashboard...")
clearMemory(driver)
driver.get("https://app.grass.io/dashboard")
natural_sleep(15*delay_multiplier,variance=3)
handle_cookie_banner(driver)
natural_sleep(15*delay_multiplier,variance=3)
login_element = driver.find_element(By.XPATH,"//button[text()='Sign In']")
if not login_element:
logging.info(f"✅ Already logged in. Skipping login process.")
WebDriverWait(driver, random.randint(10, 50) * delay_multiplier).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
logging.info(f"🔧 Accessing extension settings...")
driver.get(f'chrome-extension://{extension_id}/index.html')
WebDriverWait(driver, random.randint(3, 7) * delay_multiplier).until(EC.presence_of_element_located((By.XPATH, "//button")))
logging.info(f"🚀 Activating extension...")
timeout = 0
while True:
status_elements = driver.find_elements(By.XPATH, "//p[@class='chakra-text css-uzsxi7']")
if not status_elements:
logging.warning("Grass status element not found. Assuming not connected and will retry or fail.")
if timeout > 60 * delay_multiplier:
# Raise an exception if the status element is not found after the timeout
raise Exception("Grass status element not found after timeout.")
time.sleep(1)
timeout +=1
driver.refresh() # Attempt to refresh the extension page
natural_sleep(5)
continue # Retry finding the element
status_text = status_elements[0].text.lower()
if "connected" in status_text:
break # Exit the status check loop
if timeout > 60 * delay_multiplier:
logging.error("Grass Failed to connect after timeout")
# Raise an exception if connection fails after the timeout
raise Exception("Grass failed to connect after timeout")
time.sleep(1)
logging.info("waiting for grass to connect")
timeout += 1
logging.info(f"🎉 Successfully logged in! Grass is running...")
# handle_cookie_banner(driver) # Likely not needed here, on the extension page
logging.info(f"💰 Earning in progress...")
break
logging.info(f"🔄 Redirecting to login page...")
driver.get("https://app.grass.io/login")
natural_sleep(7,3)
handle_cookie_banner(driver)
logging.info(f"🔑 Entering login credentials...")
username = driver.find_element(By.NAME, "email")
username.send_keys(email)
button = driver.find_element(By.XPATH, "//button[contains(text(), 'CONTINUE')]")
button.click()
natural_sleep(5*delay_multiplier)
use_password_button = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "//button[translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')='USE PASSWORD INSTEAD']"))
)
use_password_button.click()
logging.info("Clicked on Use Password Instead......")
natural_sleep(random.uniform(2,5))
passwd_field = driver.find_element(By.NAME, "password")
passwd_field.send_keys(password)
signin_button = driver.find_element(By.XPATH, "//button[contains(translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'SIGN IN')]")
signin_button.click()
logging.info(f"➡️ Clicking login button...")
logging.info(f"⏳ Waiting for login response...")
WebDriverWait(driver, random.randint(10, 50) * delay_multiplier).until(EC.url_contains("dashboard"))
logging.info(f"⏳ Log in successful.......")
logging.info(f"🔧 Accessing extension settings...")
driver.get(f'chrome-extension://{extension_id}/index.html')
login_element = driver.find_element(By.XPATH,"//button[text()='Sign In']")
if login_element:
login_element.click()
logging.info(f"🚀 Activating extension...")
natural_sleep(7)
timeout = 0
while True:
status_elements_after_login = driver.find_elements(By.XPATH, "//p[@class='chakra-text css-uzsxi7'] | //p[contains(text(),'Grass is Connected')] | //p[contains(text(),'Connected')]")
if not status_elements_after_login:
logging.warning("Grass status element not found after login. Will retry or fail.")
if timeout > 60 * delay_multiplier:
# Raise an exception if status element is not found after login and timeout
raise Exception("Grass status element not found after login and timeout.")
time.sleep(1)
timeout +=1
driver.refresh() # Refresh the extension page
natural_sleep(5)
continue # Retry finding the element
status_text_after_login = status_elements_after_login[0].text.lower()
logging.info(f"Grass status after login attempt: {status_text_after_login}")
if "connected" in status_text_after_login:
break # Exit the post-login status check loop
if timeout > 60 * delay_multiplier:
logging.error("Grass Failed to show connected status after login")
# Raise an exception if connected status is not shown after login and timeout
raise Exception("Grass failed to show connected status after login and timeout")
time.sleep(1)
logging.info("waiting for grass to show connected status after login")
timeout += 1
logging.info(f"🎉 Successfully logged in and extension confirmed! Grass is running...")
# handle_cookie_banner(driver) # Likely not needed here, on the extension page
logging.info(f"💰 Earning in progress...\n\n\n")
break
except BaseException as be: # Catching BaseException for wider capture during debugging
print(f"[DEBUG] runGrass caught an exception: {type(be).__name__}") # Raw print for immediate debug output
# Modified error log below to be more user-friendly and hide verbose stack trace from 'be'
logging.error(f"😥 Grass encountered a {type(be).__name__}. Will attempt to retry.")
retry_count += 1 # Increment retry counter
if retry_count >= MAX_GRASS_RETRIES:
logging.error(f"Max retries ({MAX_GRASS_RETRIES}) reached for Grass. Skipping this app.")
return # Exit the function, stopping retries for Grass
logging.info(f"Retrying Grass connection in 300 seconds... (Attempt {retry_count}/{MAX_GRASS_RETRIES})")
try:
if driver: # Ensure driver object exists
clearMemory(driver) # Attempt to clear tabs
driver.get('about:blank') # Navigate to a blank page to reset state
except Exception as ce:
logging.error(f"Error during cleanup before retry: {ce}")
time.sleep(300) # Wait 300 seconds before the next attempt
def runNodepay(driver, cookie=None, email=None, passwd=None, api_key=None, delay_multiplier=1):
driver.set_window_size(1024, driver.get_window_size()['height'])
driver.get("https://app.nodepay.ai/dashboard")
time.sleep(random.randint(9,16))
if cookie and driver.current_url != "https://app.nodepay.ai/dashboard":
add_cooki(driver, {"key": "np_token", "value": cookie})
add_cooki(driver, {"key": "np_webapp_token", "value": cookie})
driver.refresh()
driver.get("https://app.nodepay.ai/dashboard")
time.sleep(random.randint(9,16))
WebDriverWait(driver, random.randint(8, 13) * delay_multiplier).until(EC.url_contains("dashboard"))
if driver.current_url != "https://app.nodepay.ai/dashboard":
logging.error("Nodepay cookie seems to be expired")
driver.save_screenshot("nodepay_login_failed.png")
return
if driver.current_url != "https://app.nodepay.ai/dashboard":
with open("./static/cloud.js", "r", encoding="utf-8") as f:
inject_js_content = f.read()
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": inject_js_content})
driver.refresh()
site_key = "0x4AAAAAAAx1CyDNL8zOEPe7"
task_id = capsolver.create_turnstile_task(api_key, site_key, "https://app.nodepay.ai/login")
input_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@id='basic_user']"))
)
input_element.send_keys(email)
password_element = driver.find_element(By.XPATH, "//input[@id='basic_password']")
password_element.send_keys(passwd)
solved_token = None
while not solved_token:
solved_token = capsolver.get_turnstile_response(task_id, api_key)
WebDriverWait(driver, 1 * delay_multiplier).until(lambda d: solved_token is not None)
driver.execute_script("""
const captchaInput = document.querySelector('[name="cf-turnstile-response"]');
if (captchaInput) {
captchaInput.value = arguments[0];
captchaInput.dispatchEvent(new Event("input", { bubbles: true }));
captchaInput.dispatchEvent(new Event("change", { bubbles: true }));
}
if (window.turnstile && typeof window.tsCallback === "function") {
window.tsCallback(arguments[0]);
}
""", solved_token)
button_element = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//button[span[text()='Access My Account']]")
))
button_element.click()
WebDriverWait(driver, random.randint(3, 7) * 30 * delay_multiplier).until(
EC.url_contains("dashboard")
)
logging.info("Log In successful")
extension_id = extensionIds['nodepay']
driver.get(f'chrome-extension://{extension_id}/index.html')
WebDriverWait(driver, random.randint(8, 13) * delay_multiplier).until(
EC.presence_of_element_located((By.XPATH, "//span[contains(@class, 'font-bold') and contains(@class, 'text-green')]")
))
connected = driver.find_element(By.XPATH, "//span[contains(@class, 'font-bold') and contains(@class, 'text-green')]")
if connected.text.strip().lower() == "connected":
logging.info("The extension is connected :D")
price_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//span[contains(@class, 'text-16px') and contains(@class, 'font-bold') and contains(@class, 'mr-1') and contains(@class, 'truncate')]")
))
price_text = price_element.text.strip()
logging.info(f"Your nodepay season earnings is {price_text}")
return
def runGradientNode(driver, email, password, delay_multiplier=1):
"""
Automates the login and navigation process for Gradient Node.
Args:
driver: Selenium WebDriver instance.
email: User's email address.
password: User's password.
delay_multiplier: Multiplier for random sleep intervals and timeout duration.
"""
timeout = max(10, 20 * delay_multiplier) # Ensure a minimum wait time of 10 seconds
wait = WebDriverWait(driver, timeout) # Set a max wait time based on delay multiplier
def earning_status():
pass
logging.info(f"🚀 Starting Gradient Node automation...")
logging.info(f"🌍 Visiting Gradient Network dashboard...")
clearMemory(driver)
driver.get("https://app.gradient.network/dashboard")
natural_sleep(random.randint(9, 15) * delay_multiplier)
if driver.current_url == "https://app.gradient.network/dashboard":
logging.info(f"✅ Already logged in. Skipping login process.")
logging.info(f"🔧 Accessing extension settings...")
driver.get("chrome-extension://caacbgbklghmpodbdafajbgdnegacfmo/popup.html")
natural_sleep(2)
logging.info(f"💰 Earning in progress...")
return
logging.info(f"🔄 Redirecting to login page...")
driver.get("https://app.gradient.network/")
wait.until(EC.presence_of_element_located((By.TAG_NAME, "body")))
logging.info(f"🔑 Entering email...")
email_input = wait.until(EC.presence_of_element_located((By.XPATH,
'//input[@placeholder="Enter Email"]')))
email_input.send_keys(email)
natural_sleep(2)
logging.info(f"🔒 Entering password...")
password_input = wait.until(EC.presence_of_element_located((By.XPATH,
'//input[@placeholder="Enter Password"]')))
password_input.send_keys(password)
natural_sleep(2)
logging.info(f"➡️ Clicking login button...")
button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,
'button.custom-flying-button.bg-black.text-white')))
button.click()
natural_sleep(3)
logging.info(f"🔀 Waiting for login to complete...")
wait.until(EC.url_contains("dashboard"))
logging.info(f"🔀 Switching back to main window...")
window_handles = driver.window_handles
driver.switch_to.window(window_handles[0])
logging.info(f"🔧 Accessing extension settings...")
driver.get("chrome-extension://caacbgbklghmpodbdafajbgdnegacfmo/popup.html")
natural_sleep(2)
logging.info(f"💰 Earning in progress...")
logging.info(f"🎉 Successfully logged in! Gradient Node is running...")
logging.info(f"💰 Earning in progress...")
def download_extension(extension_id, driver=None, output_path=None):
"""
Downloads a Chrome extension from Chrome's update service.
Args:
extension_id (str): The ID of the Chrome extension to download.
output_path (str): Optional destination file path for the CRX.
Returns:
None
"""
if output_path is None:
output_path = f"./{extension_id}.crx"
if docker == 'true':
try:
browser_version = get_chrome_version()
params = {
"response": "redirect",
"prodversion": browser_version,
"acceptformat": "crx3",
# Inferred from Chrome's extension update endpoint format.
"x": f"id={extension_id}&uc",
}
logging.info(f"Downloading CRX for ID: {extension_id} using Chrome update service...")
response = requests.get(
"https://clients2.google.com/service/update2/crx",
params=params,
timeout=60,
allow_redirects=True,
)
response.raise_for_status()
with open(output_path, "wb") as crx_file:
crx_file.write(response.content)
logging.info(f"Saved extension {extension_id} to {output_path}")
except requests.RequestException as e:
logging.error(f"Failed to download extension {extension_id} from Chrome update service: {e}")
except OSError as e:
logging.error(f"Failed to save extension {extension_id} to {output_path}: {e}")
else:
# Non-Docker: Manual download (unchanged).
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():
# Centralized logging: called once at script start.
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# setup_logging() call no longer needed for basicConfig.
# Call if it has other non-basicConfig logging tasks.
logging.info('Starting the script (run function)...')
branding = fr'''{LogColors.OKBLUE}
$$$$$$$\ $$\ $$\
$$ __$$\ $$ | $$ |
$$ | $$ | $$$$$$\ $$$$$$$\ $$ | $$\ $$\ $$\ $$\ $$$$$$\ $$$$$$$\
$$ | $$ |$$ __$$\ $$ _____|$$ | $$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\
$$ | $$ |$$ / $$ |$$ / $$$$$$ / $$ | $$ | $$ |$$$$$$$$ |$$ | $$ |
$$ | $$ |$$ | $$ |$$ | $$ _$$< $$ | $$ | $$ |$$ ____|$$ | $$ |
$$$$$$$ |\$$$$$$ |\$$$$$$$\ $$ | \$$\ \$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
\_______/ \______/ \_______|\__| \__| \_____\____/ \_______|\_______/ {LogColors.RESET}'''
logging.info(branding)
user_data_dir = os.path.join(os.getcwd(), "chrome_user_data")
os.makedirs(user_data_dir, exist_ok=True)
#Delete the singleton locked file
found = False
for filename in os.listdir(user_data_dir):
if filename.strip().lower() == "singletonlock": #strip and lower
actual_path = os.path.join(user_data_dir, filename)
os.remove(actual_path)
logging.info(f"Removed {filename} file.")
found = True
break
if not found:
logging.info("SingletonLock file not found")
chrome_options = Options()
#Prevent Images from loading to save resources
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
prefs = {"profile.managed_default_content_settings.images":2}
chrome_options.add_experimental_option("prefs", prefs)
#Set profile
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f"user-data-dir={user_data_dir}")
chrome_options.add_argument("--profile-directory=Default")
# Read variables from the OS env
# Fetch universal credentials if available
all_email = os.getenv('ALL_EMAIL')
all_pass = os.getenv('ALL_PASS')
# Fetch individual credentials, falling back to all_email/all_pass if not set
grass_email = os.getenv('GRASS_USER') or os.getenv('GRASS_EMAIL', all_email)
grass_password = os.getenv('GRASS_PASS', all_pass)
gradient_email = os.getenv('GRADIENT_EMAIL', all_email)
gradient_password = os.getenv('GRADIENT_PASS', all_pass)
dawn_email = os.getenv('DAWN_EMAIL', all_email)
dawn_password = os.getenv('DAWN_PASS', all_pass)
teneo_cooki = os.getenv('TENEO_COOKI') or os.getenv("TENEO_COOKIE")
teneo_email = os.getenv('TENEO_EMAIL', all_email)
teneo_password = os.getenv('TENEO_PASS', all_pass)
np_cooki = os.getenv('NP_COOKI') or os.getenv("NP_COOKIE") or os.getenv("NODEPAY_COOKIE")
np_email = os.getenv("NODEPAY_EMAIL",all_email)
np_password = os.getenv("NODEPAY_PASSWORD",all_pass)
twoCapApiKey = os.getenv("API_KEY")
webhook_url = os.getenv("DISCORD_WEBHOOK") or os.getenv("WEBHOOK")
delay_multiplier = int((os.getenv("DELAY")) or 1)
if docker == 'true':
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/136.0.0.0 Safari/537.36")
chromedriver_version = get_chromedriver_version()
logging.info(f'Using {chromedriver_version}')
logging.info("Installing rektCaptcha")
download_extension("bbdhfoclddncoaomddgkaaphcnddbpdh")
chrome_options.add_extension("bbdhfoclddncoaomddgkaaphcnddbpdh.crx")
# 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")
if dawn_email and dawn_password:
logging.info("Installing Dawn Internet....")
download_extension(extensionIds['dawn'])
id = extensionIds['dawn']
chrome_options.add_extension(f"./{id}.crx")
if teneo_email and teneo_password:
logging.info("Installing Teneo Community Node....")
download_extension(extensionIds['teneo'])
id = extensionIds['teneo']
chrome_options.add_extension(f"./{id}.crx")
if np_cooki:
logging.info("Installing Nodepay Node....")
download_extension(extensionIds['nodepay'])
id = extensionIds['nodepay']
chrome_options.add_extension(f"./{id}.crx")
chromedriver_path = get_chromedriver_path()
logging.info(f"Using ChromeDriver binary at {chromedriver_path}")
driver = webdriver.Chrome(service=Service(executable_path=chromedriver_path), options=chrome_options)
else:
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)
if (np_cooki) or (twoCapApiKey and np_email and np_password):
logging.info("Installing nodepay")
download_extension(extensionIds['nodepay'],driver)
if (teneo_email and teneo_password and twoCapApiKey) or teneo_cooki:
logging.info("Installing teneo Community Node....")
download_extension(extensionIds['teneo'],driver)
if dawn_email and dawn_password:
logging.info('Installing Dawn')
download_extension(extensionIds['dawn'],driver)
# Enable CDP
driver.execute_cdp_cmd("Network.enable", {})
# Block CSS requests
driver.execute_cdp_cmd("Network.setBlockedURLs", {"urls": ["*.css", "*.png", "*.svg"]})
#call_capsolver(driver,enable_auto=False)
results = {}
def safe_execute(app_key, func, *args, **kwargs):
try:
results[app_key] = func(*args, **kwargs)
except Exception as e:
logging.error(f'Error in {app_key}: {e}')
results[app_key] = f'Error: {e}'
try:
logging.info(f"Delay Multiplier is {delay_multiplier}")
if gradient_email and gradient_password:
safe_execute("gradient", runGradientNode, driver, gradient_email, gradient_password,delay_multiplier)
clearMemory(driver)
if grass_email and grass_password:
safe_execute("grass", runGrass, driver, grass_email, grass_password, extensionIds['grass'],delay_multiplier)
clearMemory(driver)
if np_cooki:
safe_execute("nodepay", runNodepay, driver, cookie=np_cooki,delay_multiplier=delay_multiplier)
elif np_email and np_password and twoCapApiKey:
safe_execute("nodepay", runNodepay, driver, passwd=np_password, email=np_email, api_key=twoCapApiKey)
clearMemory(driver)
if teneo_cooki:
safe_execute("teneo", runTeneo, driver, extension_id=extensionIds['teneo'],cookie=teneo_cooki,delay_multiplier=delay_multiplier)
elif teneo_email and teneo_password:
safe_execute("teneo", runTeneo, driver, teneo_email, teneo_password, extensionIds['teneo'],delay_multiplier=delay_multiplier)
clearMemory(driver)
if dawn_email and dawn_password: