-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvore.com.js
More file actions
62 lines (52 loc) · 1.81 KB
/
Copy pathconvore.com.js
File metadata and controls
62 lines (52 loc) · 1.81 KB
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
if(window.jQuery) {
$ = jQuery;
var _history = [];
var _limit = 5;
var current = 0;
var scripts = $("script");
var conv = scripts[scripts.length - 1].innerHTML;
var user = conv.split("\n")[3].split(" = ")[1].replace(/'/g,"").replace(";","");
var last = $("span.username").filter(function(arr,i){ return $(i)[0].innerText == user;});
var len = last.length - 1;
// Add previously found messages in the DOM of the list.
for(var i = len; i >= len - _limit + 1; i--) {
try {
var message = $(last[i]).parent().parent().find(".message-body").html();
if(message == "") { continue; }
var pos = Math.abs(_limit - i) - 1;
_history[pos] = message;
current = _limit - current;
} catch(err) {}
}
$("#id-message").keydown(function(){
var UP = 38;
var DOWN = 40;
var ENTER = 13;
var MIN = 0;
var MAX = _history.length - 1;
var msg = $(this);
switch(event.which) {
case UP:
if(current == MIN) {
msg.val(_history[0]?_history[0]:"");
return;
}
msg.val(_history[--current]);
break;
case DOWN:
if(current == _limit || current == MAX + 1) {
msg.val("");
return;
}
msg.val(_history[++current]);
break;
case ENTER:
if(_history.length == _limit) {
_history = _history.slice(1, _history.length);
}
_history.push(msg.val());
current = _history.length;
break;
}
});
}