Last active
February 24, 2021 09:13
-
-
Save 5j9/9115c19ee4f01e2a20feaea6548328c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A simple script to unignore all the ignored words in a specific course in memrise. | |
You need to provide USERNAME, PASSWORD, and COURSE_URL below. | |
""" | |
from selenium.webdriver import Chrome | |
USERNAME = '' | |
PASSWORD = '' | |
COURSE_URL = 'https://app.memrise.com/course/{number}/{name}/' | |
driver = Chrome() | |
driver.implicitly_wait(5) | |
get = driver.get | |
get('https://app.memrise.com/signin') | |
select = driver.find_element_by_css_selector | |
selects = driver.find_elements_by_css_selector | |
select('#username').send_keys(USERNAME) | |
select('#password').send_keys(PASSWORD) | |
select('[type=submit]').click() | |
get(COURSE_URL) | |
ignored_text = select('.pull-right').text | |
if ignored_text == '0 ignored': | |
raise SystemExit('You have no ignored words on this course.') | |
print(ignored_text) | |
ignored = int(ignored_text.partition(' ')[0]) | |
level_urls = [level.get_attribute('href') for level in selects('.level.clearfix')] | |
for level_url in level_urls: | |
get(level_url) | |
if (ignored_text := select('.pull-right').text) == '0 ignored': | |
continue | |
select('.ignore-show').click() | |
select('.ignore-none').click() | |
select('.ignore-save').click() | |
ignored -= int(ignored_text.partition(' ')[0]) | |
if ignored == 0: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment