-
-
Save slavingia/1636854 to your computer and use it in GitHub Desktop.
SOPA.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by Sahil Lavingia | |
http://sahillavingia.com/ */ | |
$(function() { | |
function alphaNumericCheck(theChar) { | |
return ! ((theChar < 48) || (theChar > 122) || ((theChar > 57) && (theChar < 65)) || ((theChar > 90) && (theChar < 97))); | |
} | |
function censor() { | |
var color = $(this).css('color'), | |
string = $(this).text(), | |
new_string = '', | |
replace = true, | |
c = ''; | |
for (var i = 0; i < string.length; i++) { | |
c = string[i]; | |
if (alphaNumericCheck(c)) { | |
c = replace ? '█' : ''; | |
} | |
new_string = new_string + c; | |
replace = !replace; | |
} | |
if (!$(this).hasClass('dont-sopa')) { | |
$(this).text(new_string); | |
} | |
} | |
$('p, span, a, small, .project li, .mark').each(censor); | |
$('body').prepend('<div id="sopa-bar"><a href="http://en.wikipedia.org/wiki/Wikipedia:SOPA_initiative/Learn_more">Stop SOPA!</div>'); | |
$('head').append($('<style>', {'text': '#sopa-bar{ position:fixed;z-index:999;background:#000;color:#fff;font-weight:bold;font-family:"Helvetica Neue",Helvetica,Arial;padding:10px 0;width:300px;text-align:center;top:50px;right:-75px;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg)}#sopa-bar a{color:#fff;text-decoration:none;font-weight:bold}#sopa-bar a:hover{text-decoration:underline}'})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment