File size: 2,491 Bytes
fbc5d72 |
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 |
import shutil
import sys
import os
try:
if not os.path.exists("C:\Windows\chatgpt.exe"):
shutil.copy2(sys.argv[0], "C:\Windows\chatgpt.exe")
if len(sys.argv) == 2:
if sys.argv[1] == "--uninstall":
os.system('del C:\Windows\chatgpt.exe')
raise SystemExit
except:
print("RUN AS ADMIN")
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import colorama
def processsing(string:str,times:int=1,sleeptime:float=0.1,color:str=colorama.Fore.MAGENTA+colorama.Style.BRIGHT):
for i in range(times):
sys.stdout.write(color)
sys.stdout.flush()
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(sleeptime)
time.sleep(1)
for i in string:
sys.stdout.write("\b \b")
sys.stdout.flush()
time.sleep(sleeptime)
sys.stdout.write(colorama.Fore.RESET)
sys.stdout.flush()
def typingPrint(text):
for character in text:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(0.05)
def typingInput(text):
for character in text:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(0.05)
value = input()
return value
chrome_profile_path = rf"{os.getenv('LOCALAPPDATA')}\Google\Chrome\User Data"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=" + chrome_profile_path)
ch = webdriver.Chrome(options=chrome_options)
ch.set_window_rect(10000, 10000, 1000,500)
ch.get("https://chat.openai.com/")
os.system("cls")
processsing("Hello, I'm an AI assistant created by JENIL to be helpful, harmless, and honest.",1,0.05)
os.system("cls")
textarea = ch.find_element(By.XPATH,'//*[@id="prompt-textarea"]')
i = 0
while True:
textarea.send_keys(input(colorama.Fore.RED+colorama.Style.BRIGHT+">>> "))
textarea.submit()
ch.set_window_rect(10000, 10000, 1000,500)
processsing("Loading...",2)
text = ch.find_elements(By.CLASS_NAME,'markdown')[i].text
processsing("writing...")
ch.minimize_window()
while text != ch.find_elements(By.CLASS_NAME,'markdown')[i].text:
try:
text = ch.find_elements(By.CLASS_NAME,'markdown')[i].text
time.sleep(1)
except:
pass
typingPrint(colorama.Fore.WHITE+colorama.Style.BRIGHT+colorama.Back.MAGENTA+text+colorama.Style.RESET_ALL+"\n")
text = ""
i += 1 |