Skip to content

Instantly share code, notes, and snippets.

@ArcHound
Last active September 6, 2024 17:46
Show Gist options
  • Save ArcHound/c1afed52837a59e4275aac2c8becb71e to your computer and use it in GitHub Desktop.
Save ArcHound/c1afed52837a59e4275aac2c8becb71e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import math
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import ActionChains
def diff_p(a, b):
return (a[0] - b[0], a[1] - b[1])
if __name__ == "__main__":
""" That password game got me good, so I took the opportunity at this one. """
duration = 20
steps = 30
radius = 280
step = 2 * math.pi / (steps + 1)
t = 0
# calculate the circle and the point differences using radial coordinates
coordinates = []
while t < 2 * math.pi + 0.6: # a little extra to finish the circle
coordinates.append((round(radius * math.cos(t)), round(radius * math.sin(t))))
t += step
diffs = [
diff_p(coordinates[i], coordinates[i + 1]) for i in range(len(coordinates) - 1)
]
# setup the driver
driver = webdriver.Chrome()
driver.set_window_size(1400, 1000)
driver.get("https://neal.fun/perfect-circle/")
driver.implicitly_wait(10)
# click away the consent
consents = driver.find_elements(by=By.TAG_NAME, value="button")
consent = ""
for c in consents:
if c.get_attribute("class") == "fc-button fc-cta-consent fc-primary-button":
consent = c
ActionChains(driver).click(consent).perform()
driver.implicitly_wait(2)
# start the game
button = driver.find_element(by=By.TAG_NAME, value="button")
ActionChains(driver).click(button).perform()
driver.implicitly_wait(2)
# draw the circle
ac = ActionChains(driver, duration=duration)
ac.move_by_offset(-1 * radius, 0).click_and_hold().perform()
for i in range(len(diffs)):
ac.move_by_offset(diffs[i][0], diffs[i][1])
ac.perform()
# enough time for me to take a screenshot
time.sleep(20)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment