var PLUGIN_INFO = {NAME} Send to your Android Phone Android 端末に URL などを送信します Yuichi Tateno 2.3 2.3 https://github.com/vimpr/vimperator-plugins/raw/master/vimp_to_android_phone.js ; (function() { var apiVersion = '3'; var base = 'http://chrometophone.appspot.com'; var baseURL = base + '/send?ver=' + apiVersion; var signInURL = base + '/signin?extret=about:blankZ&ver=' + apiVersion; var signOutURL = base + '/signout?extret=about:blankZ&ver=' + apiVersion; // var loginURL = 'https://www.google.com/accounts/ServiceLoginAuth?service=ah&sig=d71ef8b8d6150b23958ad03b3bf546b7'; var serialize = function(hash) { var res = []; for (var key in hash) { res.push(encodeURIComponent(key) + '=' + encodeURIComponent(hash[key])); } return res.join('&'); } var sendToPhone = function(requestURL) { requestURL = baseURL + '&' + requestURL; var req = new libly.Request(requestURL, { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Extension': 'true' }); req.addEventListener('success', function(res) { var body = res.responseText; if (body.substring(0, 2) == 'OK') { liberator.echo('Send to phone successed.'); } else if (body.indexOf('LOGIN_REQUIRED' == 0)) { liberator.echo('Please login first'); liberator.open(signInURL, liberator.NEW_TAB); } else if (body.indexOf('DEVICE_NOT_REGISTERED') == 0) { liberator.echo('device not registered'); liberator.open(signOutURL, liberator.NEW_TAB); } }); req.addEventListener('failure', function(res) { liberator.echoerr('Send to phone failed.'); }); req.get(); } liberator.modules.commands.addUserCommand(["sp[hone]"], "Sent to your Android Phone", function(args) { if (args && args['-login']) { liberator.open(signInURL, liberator.NEW_TAB); return; } else if (args && args['-logout']) { liberator.open(signOutURL, liberator.NEW_TAB); return; } var req = { sel: libly.$U.getSelectedString() }; if (args && !args.arguments && !args['-title']) req.url = args[0]; else if (args && args.arguments) req.url = args.arguments[0]; if (args && args['-title']) req.title = args['-title']; else if (!req.url) req.title = content.document.title; if (!req.url) req.url = content.location.href; if (!req.title) req.title = req.url; if (!req.url || !req.url.match(/^https?/)) { liberator.echoerr('http/https schema only'); return; }; sendToPhone(serialize(req)); }, { options: [ [["-title", "-t"], liberator.modules.commands.OPTION_STRING], [["-login"], liberator.modules.commands.OPTION_NOARG], [["-logout"], liberator.modules.commands.OPTION_NOARG], ] }, { // replace: true }); })(); s/tree/?h=unlettter&id=a7a5fd47f3c636553de9b958192cb0c7fcc8667b'>root/refcontrol.js
blob: c5564715d60a876cfd8046c35f978fff767504e7 (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204