-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
144 lines (115 loc) · 5.01 KB
/
main.py
File metadata and controls
144 lines (115 loc) · 5.01 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# NOTE: must run " pip install -U selenium "
import msvcrt
import threading
import time
import pickle
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome()
#driver = webdriver.Firefox()
def new_tab(site):
driver.execute_script('window.open("' + site + '","_blank");')
def change_focus(window):
driver.switch_to_window(driver.window_handles[sites_open.index(window)])
end_program = False
def check_end():
#checks if the program should end or not
global end_program
while True:
if msvcrt.kbhit():
key = ord(msvcrt.getch())
if key == 27:
end_program = True
print('stopping program on next run-through...')
break
#start the thread to check for end of program
t = threading.Thread(target=check_end)
t.daemon = True
t.start()
driver.get('https://www.kickstarter.com/signup?ref=nav')
new_tab('https://lastpass.com/generatepassword.php')
new_tab('http://www.pseudorandom.name/')
new_tab('https://www.sharklasers.com/inbox')
sites_open = ['KICKSTARTER', 'MAIL', 'RANDOM_NAME', 'RANDOM_PASS']
# I do not know why I have to open up the new tabs opposite from how the indices are laid out in this list
while True:
change_focus('RANDOM_PASS')
##driver.get('https://www.google.com')
##driver.find_element_by_name('q').click()
##WebDriverWait(driver, 10).until(lambda s: s.find_element_by_id("selectpw").is_displayed())
#driver.find_element_by_id('selectpw').click()
##WebDriverWait(driver, 10).until(lambda s: s.find_element_by_id("password").is_displayed())
#driver.find_element_by_id('password').send_keys(Keys.CONTROL, 'c')
password = driver.find_element_by_id('password').get_attribute('value')
change_focus('RANDOM_NAME')
name = driver.find_element_by_tag_name('h1').get_attribute('innerHTML')
change_focus('MAIL')
email = driver.find_element_by_id('email-widget').get_attribute('innerHTML')
print(password)
print(name)
print(email)
change_focus('KICKSTARTER')
driver.find_element_by_id('user_name').send_keys(name)
driver.find_element_by_id('user_email').send_keys(email)
driver.find_element_by_id('user_email_confirmation').send_keys(email)
driver.find_element_by_id('user_password').send_keys(password)
driver.find_element_by_id('user_password_confirmation').send_keys(password)
# click submit button
driver.find_element_by_xpath("//*[@class='btn btn--green btn--block submit']").click()
# write credentials to accounts.txt
with open('accounts.dat', 'rb') as f:
l = pickle.load(f)
l.append([name, email, password])
print('appending: ', [name, email, password])
print(l)
with open('accounts.dat', 'wb') as f:
pickle.dump(l, f)
driver.find_element_by_id('js-user_nav_select').click()
driver.find_element_by_link_text('Account').click()
driver.find_element_by_link_text('Re-send verification email').click()
# get the subjects of the emails
change_focus('MAIL')
correct_subject = "Action Needed. Please verify your email address for Kickstarter."
subject_found = False
while not subject_found:
subjects = driver.find_elements_by_xpath("//*[@class='td3']")
for s in subjects:
if correct_subject in s.get_attribute('innerHTML'):
email_message = s
subject_found = True
email_message.click()
#wait until the message is open
WebDriverWait(driver, 10).until(lambda s: s.find_element_by_id("back_to_inbox_link").is_displayed())
#open message and verify email address
WebDriverWait(driver, 10).until(lambda s: s.find_element_by_partial_link_text('https://www.kickstarter.com/profile/verify_email?').is_displayed())
driver.find_element_by_partial_link_text('https://www.kickstarter.com/profile/verify_email?').click()
driver.switch_to_window(driver.window_handles[-1])
WebDriverWait(driver, 10).until(lambda s: s.find_element_by_id("js-user_nav_select").is_displayed())
driver.close()
#log out and go back to sign up page
change_focus('KICKSTARTER')
driver.execute_script('location.reload()')
driver.find_element_by_id('js-user_nav_select').click()
driver.find_element_by_link_text('Log out').click()
driver.get('https://www.kickstarter.com/signup?ref=nav')
if end_program:
break
#reset all the tabs
change_focus('MAIL')
driver.find_element_by_id('forget_button').click()
driver.get('https://www.sharklasers.com/inbox')
change_focus('RANDOM_NAME')
driver.get('http://www.pseudorandom.name/')
change_focus('RANDOM_PASS')
driver.get('https://lastpass.com/generatepassword.php')
driver.quit()
# use the below to delete the latest entry
##with open('accounts.dat', 'rb') as f:
## l = pickle.load(f)
##
##l.pop(-1)
##
##with open('accounts.dat', 'wb') as f:
## pickle.dump(l, f)