-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·50 lines (39 loc) · 1.19 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
#!/usr/bin/env python
from sys import argv
from selenium import webdriver
if len(argv) < 2:
print(f"Usage: {argv[0]} <input>")
exit(1)
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
browser = webdriver.Chrome(options=options)
browser.get("https://desmos.com/3d")
def get(selector):
return browser.find_element("css selector", selector)
def folder():
try:
get("button[aria-label='Add Item']").click()
get("div[aria-label='Add folder']").click()
get("textarea[aria-label='Folder']").send_keys(argv[1])
get(f"div[aria-label='Collapse {argv[1]} folder']").click()
except:
folder()
def graph(equation):
get("div.dcg-new-math-div").click()
get("textarea.dcg-focus-visible").send_keys(equation)
# move to folder
folder()
with open(argv[1]) as obj:
for line in obj:
if not line.strip():
continue
command, *args = line.split()
match command:
case "#":
continue
case "v":
x, y, z = args
graph(f"({x}, {y}, {z})")
case _:
x
print(f'Unexpected "{command}"')