forked from vimpr/vimperator-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alert.js
476 lines (439 loc) · 19.7 KB
/
alert.js
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/* {{{
###################################################################################
# SL 部分は、Takahito Yagami さんの著作権物です。 #
# JavaScriptでSLを走らせる「SL.JS」を作りました ::: creazy photograph #
# http://creazy.net/2008/02/sl_js.html #
###################################################################################
}}} */
// PLUGIN_INFO {{{
let PLUGIN_INFO = xml`
<VimperatorPlugin>
<name>Alert</name>
<name lang="ja">アラート</name>
<description>Displays an alert after the specified time.</description>
<description lang="ja">指定時間後にアラートダイアログを出したりする。タイマー。</description>
<version>1.0.2</version>
<author mail="[email protected]" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
<detail lang="ja"><![CDATA[
かなり変梃な仕様です。
== Command ==
:alert [<TIME> | <METHOD> | <MESSAGE>] ...:
<TIME> 分後に、<MESSAGE> を表示する。
<METHOD> でアラート方法を指定する。
引数はどのような順番でも良い。
e.g.:
>||
:alert 1.5 ugh
:alert -meow=4 -alert 2.0 This is Message!
:alert This 1.5 -meow=4 -pokimon=10 is Message!
||<
== Methods ==
:-alert:
標準的な JS の alert
:-gunsou:
恐ろしい軍曹が出現
:-pokimon:
ピッカー!
使用には注意してください!
:-meow:
"みゃお"
:-quit:
Firefox を終了する
== Thanks ==
SL 部分は下記のスクリプトからパクリました!
プラグインから呼べるように多少書き換えています。
JavaScriptでSLを走らせる「SL.JS」を作りました ::: creazy photograph
http://creazy.net/2008/02/sl_js.html
]]></detail>
</VimperatorPlugin>`;
// }}}
(function () {
////////////////////////////////////////////////////////////////////////////////
// SL - copyright (c) Takahito Yagami
////////////////////////////////////////////////////////////////////////////////
let sl = function (next) {
var document = content.document;
/**
* SL.JS
*
* # execute bookmarklet below
* javascript:(function(){var d=document,sl_open,sl_run,sl_close,s=d.createElement('script');s.charset='UTF-8';s.src='http://labs.creazy.net/sl/bookmarklet.js';d.body.appendChild(s)})();
*
* @author Takahito Yagami <takahito.yagami[at]gmail[dot]com> (a.k.a yager)
* @version v1.0.0 2008/02/16
*/
(function(){
//------------------------------------------------------------
// Setting (You can chage options in this block)
//------------------------------------------------------------
var sl_speed = 100;
var sl_pitch = 15;
var sl_tx_color = "#FFFFFF";
var sl_bg_color = "#000000";
//------------------------------------------------------------
//------------------------------------------------------------
// SL Parts
//------------------------------------------------------------
var sl_steam = [];
sl_steam[0]
=" (@@) ( ) (@) ( ) @@ () @ O @ O @<br>"
+" ( )<br>"
+" (@@@@)<br>"
+" ( )<br>"
+"<br>"
+" (@@@)<br>";
sl_steam[1]
=" ( ) (@@) ( ) (@) () @@ O @ O @ O<br>"
+" (@@@)<br>"
+" ( )<br>"
+" (@@@@)<br>"
+"<br>"
+" ( )<br>";
var sl_body
=" ==== ________ ___________ <br>"
+" _D _| |_______/ \\__I_I_____===__|_________| <br>"
+" |(_)--- | H\\________/ | | =|___ ___| _________________ <br>"
+" / | | H | | | | ||_| |_|| _| \\_____A <br>"
+" | | | H |__--------------------| [___] | =| | <br>"
+" | ________|___H__/__|_____/[][]~\\_______| | -| | <br>"
+" |/ | |-----------I_____I [][] [] D |=======|____|________________________|_ <br>";
var sl_wheels = [];
sl_wheels[0]
="__/ =| o |=-O=====O=====O=====O \\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_wheels[1]
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|=O=====O=====O=====O |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_wheels[2]
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\O=====O=====O=====O_/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_wheels[3]
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\_O=====O=====O=====O/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_wheels[4]
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|= O=====O=====O=====O|_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_wheels[5]
="__/ =| o |=-~O=====O=====O=====O\\ ____Y___________|__|__________________________|_ <br>"
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
sl_steam[0] = sl_steam[0].replace(/ /g,' ');
sl_steam[1] = sl_steam[1].replace(/ /g,' ');
sl_body = sl_body.replace(/ /g,' ');
sl_wheels[0] = sl_wheels[0].replace(/ /g,' ');
sl_wheels[1] = sl_wheels[1].replace(/ /g,' ');
sl_wheels[2] = sl_wheels[2].replace(/ /g,' ');
sl_wheels[3] = sl_wheels[3].replace(/ /g,' ');
sl_wheels[4] = sl_wheels[4].replace(/ /g,' ');
sl_wheels[5] = sl_wheels[5].replace(/ /g,' ');
var sl_patterns = [];
sl_patterns[0] = sl_steam[0] + sl_body + sl_wheels[0];
sl_patterns[1] = sl_steam[0] + sl_body + sl_wheels[1];
sl_patterns[2] = sl_steam[0] + sl_body + sl_wheels[2];
sl_patterns[3] = sl_steam[1] + sl_body + sl_wheels[3];
sl_patterns[4] = sl_steam[1] + sl_body + sl_wheels[4];
sl_patterns[5] = sl_steam[1] + sl_body + sl_wheels[5];
//------------------------------------------------------------
// SL Initialize
//------------------------------------------------------------
var sl_counter = 0;
var sl_position = 0;
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
if (window.opera||document.layers) {
var windowWidth = window.innerWidth;
} else if (document.all) {
var windowWidth = document.body.clientWidth;
} else if(document.getElementById){
var windowWidth = window.innerWidth;
}
var sl_style_base
='display: block;'
+'position: absolute;'
+'text-align: left;'
+'overflow: visible;'
+'white-space: pre;'
+'font: 12px/12px monospace;';
var sl_style_main
=sl_style_base
+'top: '+(scrollTop+100)+'px;'
+'left: '+windowWidth+'px;'
+'padding: 20px;'
+'z-index: 999;'
+'color: '+sl_tx_color+';';
document.body.innerHTML += '<div id="__sl_main__" style="'+sl_style_main+'">'+sl_patterns[0]+'</div>';
var sl_w = document.getElementById("__sl_main__").clientWidth;
var sl_h = document.getElementById("__sl_main__").clientHeight;
var sl_style_background
=sl_style_base
+'top: '+(scrollTop+100)+'px;'
+'left: 0px;'
+'width: '+windowWidth+'px;'
+'height: '+sl_h+'px;'
+'z-index: 998;'
+'background-color: '+sl_bg_color+';'
+'filter: alpha(opacity=0);'
+'-moz-opacity: 0.0;'
+'opacity: 0.0;';
document.body.innerHTML += '<div id="__sl_background__" style="'+sl_style_background+'"><br /></div>';
//------------------------------------------------------------
// Actions
//------------------------------------------------------------
var sl_bg_counter = 0;
/**
* sl_open (gradually open background)
*/
sl_open = function() {
var oid = "__sl_background__";
var op = sl_bg_counter;
var ua = navigator.userAgent
document.getElementById(oid).style.filter = 'alpha(opacity=' + (op * 10) + ')';
document.getElementById(oid).style.MozOpacity = op / 10;
document.getElementById(oid).style.opacity = op / 10;
if ( sl_bg_counter < 8 ) {
sl_bg_counter++;
setTimeout('sl_open()',100);
} else {
sl_run();
}
}
/**
* sl_run (move a train)
*/
sl_run = function() {
document.getElementById("__sl_main__").innerHTML = sl_patterns[sl_counter];
document.getElementById("__sl_main__").style.left = windowWidth - sl_position + "px";
if ( sl_counter < 5 ) {
sl_counter++;
} else {
sl_counter = 0;
}
sl_position += sl_pitch;
if ( sl_w + (windowWidth - sl_position) < 0 ) {
sl_counter = 0;
sl_position = 0;
document.body.removeChild(document.getElementById("__sl_main__"));
sl_close();
} else {
setTimeout('sl_run()',sl_speed);
}
}
/**
* sl_close (gradually close background)
*/
sl_close = function() {
var oid = "__sl_background__";
var op = sl_bg_counter;
var ua = navigator.userAgent
document.getElementById(oid).style.filter = 'alpha(opacity=' + (op * 10) + ')';
document.getElementById(oid).style.MozOpacity = op / 10;
document.getElementById(oid).style.opacity = op / 10;
if ( sl_bg_counter > 0 ) {
sl_bg_counter--;
setTimeout('sl_close()',100);
} else {
next();
document.body.removeChild(document.getElementById(oid));
}
}
// start actions !
sl_open();
})();
};
////////////////////////////////////////////////////////////////////////////////
// END OF SL
////////////////////////////////////////////////////////////////////////////////
let gv = liberator.globalVariables;
let defaults = {
methods: (gv.alert_default_methods || 'alert').split(/\W+/),
time: parseFloat(gv.alert_default_time || '3'),
message: gv.alert_default_message || 'Time out!',
};
let maxMeow = parseInt(liberator.globalVariables.alert_mex_meow || '60', 10);
let sound = Cc["@mozilla.org/sound;1"].createInstance(Ci.nsISound);
sound.init();
let gunsou = 'data:image/gif;base64,'+
'R0lGODlhYAB6AIQeAD8/P/j4+PDw8Ojo6ODg4NjY2NDQ0MjIyMDAwLi4uLCwsKioqKCgoJiYmJCQ'+
'kIiIiICAgHh4eHBwcGhoaGBgYFhYWFBQUEhISEBAQDg4ODAwMCgoKCAgIBkZGf///////yH+EUNy'+
'ZWF0ZWQgd2l0aCBHSU1QACH5BAEAAB8ALAAAAABgAHoAAAX+4CeOZCkGiBGYbOu+sCs4lhDfZIFV'+
'yYr/wFcgQcFoGL5gKxDJWDIQm3IKDDwwF4UCM6CaAoqMQvDQRKTeNCvA2CECAYwj6Q0QMovVUDNB'+
'q/9WGRNdHwEVGgV/AhYSSWAZEn5/VAJNkQQ9HwMZFJJBTBmEIwENG40wAQIBAwMCrqpwsHCzdC8C'+
'E1CpExpzVhwKtT9gGAaFBQU+ARK8takDBwoPFR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o2C'+
'vL0j9RFkQgLybe4xRLMJYaMLByqwgEYRk+4gj1y6KlCEWYW6Wk3t+tt2awF7170A4ooFfdTFBzAP'+
'lwMOQCAKPl53pBGTEHYYk6CToblnDQgJMltHbQAjKx3gVs3gcqJweYDXdltBDgwgelbhOR+XJc00'+
'erbgOXbCAPRngWCXFPgBONjFgU+zAQtoD+4mgiNwB+3BEhOAeCgYMtbAIGywgC+4Le5AIQhAXjUY'+
'J04QDASAfeIRAgA7';
function nop ()
undefined;
function singularize (fs, msg) {
if (!fs.length)
return nop;
let [f, arg] = fs[0];
return function () {
f(singularize(fs.slice(1), msg), msg, arg);
};
}
let alertMethods = {
alert: function (next, msg) {
window.alert(msg);
next();
},
pokimon: function (next, msg, arg) {
let times = parseInt(arg || '10', 10);
let colors = ['red', 'blue', 'yellow'];
let elem = content.document.body;
let indicator = elem.appendChild(elem.ownerDocument.createElement('div'));
let rect = elem.getBoundingClientRect();
indicator.id = 'nyantoro-element-indicator';
let style = 'background-color: ' + colors[0] + ';' +
'opacity: 0.5; z-index: 999;' +
'position: fixed;' +
'top: ' + 0 + 'px;' +
'height: ' + content.innerHeight + 'px;' +
'left: ' + 0 + 'px;' +
'width: ' + content.innerWidth + 'px';
indicator.setAttribute('style', style);
let (count = 0) {
let handle = setInterval(
function () {
if (count++ < times) {
indicator.style.backgroundColor = colors[count % colors.length];
} else {
clearInterval(handle);
elem.removeChild(indicator);
next();
}
},
100
);
}
},
gunsou: function (next, msg, arg) {
let sleep = parseFloat(arg || 3) * 1000;
let sz = innerWidth / msg.length / 1.5;
liberator.echo(
xml`<div style="background: white; color: black;">
<table>
<tr>
<td><img src={gunsou}/></td>
<td style={"font-size: " + sz + "px; white-space: nowrap;"}>{msg}</td>
</tr>
</table>
</div>`
);
setTimeout(next, sleep);
},
meow: function (next, msg, arg) {
let times = Math.min(parseInt(arg || '3', 10), maxMeow);
let handle = setInterval(
function () {
if (times--) {
sound.play(makeURI('http://www.kurinton.net/~snca/files/meow.wav'));
} else {
clearInterval(handle);
next();
}
},
1000
);
},
quit: function (next, msg) {
liberator.quit(true);
next();
},
SL: function (next, msg) {
sl(next);
}
};
defaults.methods = defaults.methods.map(
function (it) {
let [_, name, arg] = it.match(/^-?(\w+)(?:=(.*))?$/);
return [alertMethods[name] || nop, arg];
}
);
commands.addUserCommand(
['alert'],
'Timer alert (:alert [<TIME> | <METHOD> | <MESSAGE>] ...)',
function (args) {
let methods = [], time = null, message = '';
args.forEach(function (v) {
let m, f;
if ((m = v.match(/^-(\w+)(?:=(.*))?$/)) && (f = alertMethods[m[1]]))
methods.push([f, m[2]]);
else if (!time && v.match(/^\d+(\.\d+)?$/))
time = parseFloat(v);
else
message += ' ' + v;
});
if (!message)
message = defaults.message;
if (typeof time != 'number')
time = defaults.time;
if (!methods.length)
methods = defaults.methods;
setTimeout(singularize(methods, message), time * 60 * 1000);
},
{
argCount: '*',
completer: function (context, args) {
context.title = ['method', 'Description'];
context.completions = [
['-alert', 'JS alert'],
['-gunsou', 'Spawn horrible sergeant'],
['-meow', 'Meow'],
['-pokimon', 'Like a electric mouse'],
['-quit', 'Quit firefox'],
['-SL', 'Run SL'],
];
}
},
true
);
})();
// vim:sw=2 ts=2 et si fdm=marker: