Human Benchmark Cheat
unknown
python
2 years ago
2.6 kB
28
Indexable
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 pynput.keyboard import Key, Listener
from bs4 import BeautifulSoup
import time
# Define the URL of the webpage
url = "https://humanbenchmark.com/tests/number-memory"
# Create a new instance of the Chrome driver
driver = webdriver.Chrome()
# Load the webpage
driver.get(url)
# Wait for the page to load
wait = WebDriverWait(driver, 999999999)
wait.until(EC.presence_of_element_located((By.XPATH, '//button[text()="Start"]')))
# Set the initial state of the cheat toggle
cheat_toggled = False
def getNumber():
# Find the element displaying the number
number_found = driver.find_element(By.CLASS_NAME, "big-number").text;
# Log the number to the console for reference
print("Number to remember:", number_found)
return number_found
def startCheat():
# Find and click the button to start the test
start_button = driver.find_element(By.XPATH, '//button[text()="Start"]')
start_button.click()
while cheat_toggled:
# Get the number to remember
number_to_remember = getNumber();
# Wait for the input element to appear
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'input')))
# Find the input field
input_element = driver.find_element(By.CSS_SELECTOR, 'input')
# Type the remembered number into the input field
input_element.send_keys(number_to_remember)
# Press Enter to submit the answer
input_element.send_keys(Keys.ENTER)
# Click next to continue to the next number
next_button = driver.find_element(By.CLASS_NAME, 'css-de05nr.e19owgy710')
next_button.click()
###
# Everything below doesn't work, because there is a loop that keeps waiting for elements to appear.
# This means it will only be able to deal with my inputs before the script starts.
# I'm too lazy to fix it though
###
def on_press(key):
global cheat_toggled
if key == Key.up:
cheat_toggled = not cheat_toggled
print("Cheat toggled:", cheat_toggled)
if cheat_toggled:
startCheat()
return False
def on_release(key):
print('{0} release'.format(
key))
if key == Key.esc:
# Stop the listener
return False
# Collect events until released
with Listener(
on_press=on_press,
on_release=on_release) as listener:
listener.join()Editor is loading...
Leave a Comment