public
Created

Go SOPA Yourself

  • Download Gist
go_sopa_yourself.js
JavaScript
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
(function (w, d, a) {
var $ = w[a.k] = {
"a": a, "w": w, "d": d,
"s": {},
"v": {'el': []},
"f": ( function () {
return {
listen : function (el, ev, fn) {
if(typeof $.w.addEventListener !== 'undefined') {
el.addEventListener(ev, fn, false);
} else if(typeof $.w.attachEvent !== 'undefined') {
el.attachEvent('on' + ev, fn);
}
},
redact: function (str) {
var n = str.length;
var r = ~~(Math.random() * n);
var f = str.substr(0, r - 1);
var b = str.substr(r, n);
return f + '\u2588' + b;
},
loop: function () {
$.w.setTimeout( function () {
var el = $.v.el[~~(Math.random() * $.v.el.length)];
var t = '';
if (el.textContent) {
el.textContent = $.f.redact(el.textContent);
} else {
if (el.innerText) {
el.innerText = $.f.redact(el.innerText);
}
}
$.f.loop();
}, 10);
},
init : function () {
var i = 0, j = 0, k = $.a.t.length, el = [], n = 0;
for (j = 0; j < k; j = j + 1) {
el = $.d.getElementsByTagName($.a.t[j]);
for (i = 0, n = el.length; i < n; i = i + 1) {
if (el[i].className !== 'nokilli') {
$.v.el.push(el[i]);
}
}
}
$.f.loop();
}
};
}())
};
$.f.listen($.w, 'load', $.f.init);
}(window, document, {
'k': 'X' + '_' + new Date().getTime(),
't': [
'p', 'a'
]
}
));

This little guy will gradually black out individual words appearing in the HTML tags listed in $.a.r. Quick, dirty, and non-standard-compliant, but then again: so is SOPA.

To run, add this SCRIPT tag:

<script src="go_sopa_yourself.js" type="text/javascript"></script>

... at the very bottom of your BODY tag, with the path to the script set appropriately.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.