This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
main.py
108 lines (103 loc) · 4.67 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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
import time,keyboard,random
import pyautogui as pya
from fake_useragent import UserAgent
def GetUA():
ua=UserAgent()
userAgent=ua.random
return userAgent
webdriver_location="hacked_chromedriver.exe"
options=webdriver.ChromeOptions()
options.use_chromium=True
options.binary_location=r'C:\Program Files\Google\Chrome\Application\chrome.exe'
options.add_argument("--user-agent="+GetUA())
options.add_argument('--disable-extensions')
options.add_argument("--start-maximized")
options.add_argument("--disable-plugins-discovery")
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_experimental_option('useAutomationExtension',False)
options.add_experimental_option("excludeSwitches",["enable-automation"])
options.add_experimental_option('excludeSwitches',['enable-logging'])
browser=webdriver.Chrome(options=options,executable_path=webdriver_location)
browser.delete_all_cookies()
browser.get("https://www.nitrotype.com/race")
browser.execute_script("Object.defineProperty(navigator,'webdriver',{get:()=>undefined})")
runningEFE=False
keybind=input("-Start typing keybind, press on start of race: ")
autotof=int(input("-Automatically play through games [1/0]: "))
def exists(classname:str):
try:
if browser.find_element_by_css_selector(classname):
return True
except (Exception,NoSuchElementException):
return False
if autotof==0:
while True:
try:
browser.execute_script("let items=document.getElementsByClassName('ad');for(let i=0;i<items.length;i++){items[i].remove()}")
if keyboard.is_pressed(keybind)==True and runningEFE==False and browser.current_url=="https://www.nitrotype.com/race":
runningEFE=True
newtype=""
typestring=[]
print('-Waiting...')
if exists('.dash-letter')==False:
wait=WebDriverWait(browser,20)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.dash-letter')))
elements=browser.find_elements_by_class_name('dash-letter')
elements.pop()
print('-Reading...')
for e in elements:
text=e.get_attribute("textContent")
if "\xa0" in text:
text=str(text).replace("\xa0"," ")
typestring.append(text)
for c in typestring:
newtype=newtype+str(c)
if exists('.is-retracting'):
wait=WebDriverWait(browser,10)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.is-retracting')))
time.sleep(3)
print("-Working...")
pya.write(newtype,interval=0.0441)
print("-Finished...")
runningEFE=False
except Exception as e:
print("-Error: "+str(e))
else:
while True:
try:
browser.execute_script("let items=document.getElementsByClassName('ad');for(let i=0;i<items.length;i++){items[i].remove()}")
newtype=""
typestring=[]
print('-Waiting...')
if exists('.dash-letter')==False:
wait=WebDriverWait(browser,20)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.dash-letter')))
elements=browser.find_elements_by_class_name('dash-letter')
elements.pop()
print('-Reading...')
for e in elements:
text=e.get_attribute("textContent")
if "\xa0" in text:
text=str(text).replace("\xa0"," ")
typestring.append(text)
for c in typestring:
newtype=newtype+str(c)
if exists('.is-retracting'):
wait=WebDriverWait(browser,10)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.is-retracting')))
time.sleep(3)
print("-Working...")
pya.write(newtype,interval=0.0441)
print("-Finished...")
time.sleep(5)
browser.execute_script("window.location.reload()")
time.sleep(5)
except Exception as e:
print("-Error: "+str(e))