-
Notifications
You must be signed in to change notification settings - Fork 1
/
episopass.coffee
138 lines (123 loc) · 3.82 KB
/
episopass.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
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
#
# Facebookなどのログイン画面でEpisoPassを呼び出すブラウザ拡張機能
# ChromeでもFirefoxでも使えるはず
#
episodata = []#
$ ->
passelement = []
idelement = null
service = ''
if location.href.match /facebook.com/
passelement = $('#pass')
idelement = $('#email')
service = 'Facebook'
if location.href.match /amazon/
passelement = $('#ap_password')
idelement = $('#ap_email')
service = 'Amazon'
if location.href.match /linkedin.com/
# passelement = $('#login-password')
# idelement = $('#login-email')
passelement = $('#password')
idelement = $('#username')
service = 'LinkedIn'
if location.href.match /twitter.com/
passelement = $('.js-password-field')
idelement = $('.text-input')
# idelement = $('.email-input')
service = 'Twitter'
if location.href.match /github.com/
idelement = $('#login_field')
passelement = $('#password')
service = 'GitHub'
if location.href.match /value-domain.com/
idelement = $('#username')
passelement = $('#password')
service = 'ValueDomain'
if location.href.match /heroku.com/
idelement = $('#email')
passelement = $('#password')
service = 'Heroku'
if location.href.match /pinterest\./
idelement = $('#email')
passelement = $('#password')
service = 'Pinterest'
if location.href.match /tumblr.com/
idelement = $('#signup_email')
passelement = $('#signup_password')
service = 'Tumblr'
if location.href.match /gyazo.com/
idelement = $('input[name="email"]')
passelement = $('input[name="password"]')
service = 'Gyazo'
console.log "11111"
console.log service
console.log "222222"
console.log idelement
console.log "333333"
console.log passelement
# セーブされてるEpisoPassデータを読む
#episodata = []
#chrome.storage.local.get "episodata", (value) ->
# if Object.keys(value).length == 0
# episodata = []
# else
# episodata = value.episodata
#
# EpisoPass問題ページか判定
#
# これだけでは不充分な気がするな?
#
if $('#question') && $('#question').length > 0
#
# 新しいデータを追加
#
data = JSON.parse($('body').attr('episodata'))
episodata = []
chrome.storage.local.get "episodata", (value) ->
if Object.keys(value).length == 0
episodata = []
else
episodata = value.episodata
# 古いのを消す
newdata = []
for entry in episodata
console.log "each - " + entry.name
if entry.name != data.name
newdata.push entry
episodata = newdata
# 新しいのを足す
episodata.push data
# データをセーブ
chrome.storage.local.set
'episodata': episodata
, ->
console.log "saved episodata"
console.log episodata
#
# パスワード入力画面か判定し、
#
if idelement && passelement && passelement[0] != undefined && passelement.val() == ''
passelement.on 'click', ->
if !window.clicked
id = idelement.val()
id = 'masui' if !id || id == ''
name = "#{service}_#{id}"
# セーブされてるデータを読む
chrome.storage.local.get "episodata", (value) ->
episodata = value.episodata
for entry in episodata
if entry.name == name
div = $('<div>')
.css 'position','absolute'
.css 'left','0px'
.css 'top','0px'
.css 'width','400px'
.css 'height','450px'
.css 'background-color','#ddd'
.css 'border-radius','5px'
.css 'z-index',100
.attr 'id','episopass'
$('body').append div
exports.run entry,id,entry.seed,passelement
window.clicked = true