negipo (owner)

Revisions

gist: 124794 Download_button fork
public
Public Clone URL: git://gist.github.com/124794.git
Embed All Files: show embed
tinyikeda.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
33
34
35
36
37
38
39
40
41
42
43
44
45
// ==UserScript==
// @name TinyIkeda
// @namespace http://polog.org/
// @include http://*
// @include https://*
// ==/UserScript==
 
GM_addStyle('body{margin:0;padding:0;color:black;background-color:white;line-height:1;margin:0;padding:0;font-family:Gill Sans;font-size:10px;width: 100%;text-align: center;height:1em;overflow:hidden;}div.ikeda_box{line-height:1;}');
var cols = 500;
var rows = 100;
 
var char_codes = document.body.innerHTML.slice(0, cols).split('').map(function(e){
    var char_code = ("" + e.charCodeAt());
    return char_code.slice(char_code.length - 1);
}).join('');
 
var charsAt = function(){
    var cache = {};
    return function(i){
        if(!!cache[i])
            return cache[i];
        return cache[i] = char_codes.slice(i) + char_codes.slice(0,i);
    }
}();
 
var ats = [];
for(var j = 0; j <= rows; j++){
    ats.push(Math.floor(Math.random() * cols));
}
 
setInterval(function(){
    var i = 0;
    var html = '';
    for(var j = 0; j <= rows; j++){
        i++;
        ats[j] += (i % 2 == 0) ? 1 : -1;
        if(ats[j] > cols)
            ats[j] = 0;
        if(ats[j] < 0)
            ats[j] = cols - 1;
        html += '<div class="ikeda_box">' + charsAt(ats[j]) + '</div>';
    }
    document.body.innerHTML = html;
}, 10);