-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathScrape.coffee
65 lines (51 loc) · 1.25 KB
/
Scrape.coffee
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
casper = require("casper").create(
viewportSize: { width: 1024, height: 768 }
)
args = casper.cli.args
#require("utils").dump(casper.cli.args);
email = password = null
files = []
if args.length < 3
console.log "Try to pass some arguments when invoking this script!"
casper.exit()
else
domain = args[0]
email = args[1]
password = args[2]
files = args[3].split("...")
casper.start "https://slack.com/signin", ->
@fill "form[action=\"/signin\"]",
domain: domain
, true
return
casper.then ->
@evaluate ->
# Submit the form (Google account not supported)
document.getElementsByTagName("form")[0].submit()
casper.then ->
@fill "form[id=\"signin_form\"]",
email: email
password: password
, true
return
casper.then ->
@evaluate ->
# Load the admin page to later upload emoticons to
window.location.href = "/admin/emoji"
casper.then ->
@evaluate ->
TS.web.toggleSection 'add_emoji_section'
getEmojiName = (a) ->
a = a.replace(/^.*[\\\/]/, '')
output = a.substr(0, a.lastIndexOf(".")) or a
return output
for file in files
((f) ->
casper.then ->
@fill "form[action=\"/customize/emoji\"]",
img: f
name: getEmojiName f
, true
)(file)
casper.run ->
casper.exit()