Super crappy and thrown together as fast as possible :)
- Install node and casperjs, and make sure you have python
- Fill out fields in sub.js
- Run check.py
- Get first sub :)
import urllib2 | |
import time | |
import subprocess | |
import sys | |
import os | |
while True: | |
print "checking" | |
try: | |
req=urllib2.urlopen("https://secure.twitch.tv/products/crasskitty/ticket/new?ref=below_video_subscribe_button") | |
except urllib2.HTTPError as e: | |
if e.code == 404: | |
print e.code | |
except urllib2.URLError as e: | |
pass | |
else: | |
# 200 | |
print "subbing" | |
subprocess.call(["casperjs", "sub.js"], cwd=os.getcwd()) | |
sys.exit(0) | |
time.sleep(5) |
var casper = require('casper').create(), | |
system = require('system'), | |
channel; | |
// Cookies copied from chrome inspector | |
// Fill these out | |
var p = { | |
"_twitch_session_id" : "", | |
"unique_id" : "", | |
"session_unique_id" : "", | |
"api_token" : "", | |
"bits_sudo" : "", | |
"bknx_fa" : "", | |
"bknx_ss" : "", | |
"csrf_token" : "", | |
"language" : "", | |
"last_login" : "", | |
"login" : "", | |
"name" : "", | |
"persistent" : "", | |
"sudo" : "", | |
"unique_id" : "" | |
}; | |
for (var key in p) { | |
if (p.hasOwnProperty(key)) { | |
phantom.addCookie({ | |
'name': key, | |
'value': p[key], | |
'domain': ".twitch.tv" | |
}); | |
} | |
} | |
casper.start('https://twitch.tv/directory/following', function () { | |
//casper.echo('Start callback has cookie: ' + JSON.stringify(phantom.cookies)); | |
this.capture('twitch.png'); | |
}); | |
casper.thenOpen('https://secure.twitch.tv/products/crasskitty/ticket/new?ref=below_video_subscribe_button', function() { | |
// Wait here for page js to make forms work | |
casper.wait(5000, function() { | |
this.echo('should appear after 5s'); | |
}); | |
this.capture('sub.png'); | |
}); | |
casper.then(function() { | |
// CC Info here | |
// Fill these out | |
this.sendKeys('div.field.first_name input', ''); | |
this.sendKeys('div.field.last_name input', ''); | |
this.sendKeys('div.field.email input', ''); | |
this.sendKeys('div.field.card_number input', ''); | |
this.sendKeys('div.field.cvv input', ''); | |
this.sendKeys('div.field.zip input', ''); | |
this.fillSelectors('div.month', { | |
'select': '' | |
}, false); | |
this.fillSelectors('div.month', { | |
'select': '' | |
}, false); | |
this.click('button.submit.button.primary') | |
this.capture('form.png'); | |
}); | |
casper.then(function() { | |
}); | |
casper.run(); |