os0x (owner)

Revisions

gist: 140580 Download_button fork
public
Public Clone URL: git://gist.github.com/140580.git
Embed All Files: show embed
tailf.user.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
// ==UserScript==
// @name tailf
// @namespace http://ss-o.net/
// @include file://*.log
// ==/UserScript==
 
// via http://orera.g.hatena.ne.jp/miya2000/20090704/p0
(function(){
var pre = document.getElementsByTagName('pre')[0]
if (!pre) return;
tailf();
 
function tailf(prevText){
var xhr = new XMLHttpRequest();
try {
xhr.open('GET',location.href+'?'+new Date*1,false);
xhr.send(null);
if (!prevText || xhr.responseText !== prevText) {
//location.reload(true);
var end = false;
if (Math.abs(document.body.scrollHeight - (window.pageYOffset + window.innerHeight)) < 50) end = true;
pre.textContent = xhr.responseText;
if (end) document.documentElement.scrollIntoView(false);
}
setTimeout(tailf, 1000, xhr.responseText);
} catch (e) {
alert(e);
}
}
document.documentElement.scrollIntoView(false);
})();