Skip to content

Instantly share code, notes, and snippets.

@benaubin
Last active November 3, 2016 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benaubin/d969bd1c55e67dcd535b345805309ecb to your computer and use it in GitHub Desktop.
Save benaubin/d969bd1c55e67dcd535b345805309ecb to your computer and use it in GitHub Desktop.
Hide a secret
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script type="text/javascript" src="//code.jquery.com/jquery-3.1.1.js"></script>
<style type="text/css">
#text {
width: 400px;
line-height: 20px;
font-size: 16px; }
#text span.old {
letter-spacing: 0.1em; }
</style>
<title>Hide a Secret by penne12</title>
<script>
window.newLink = function(text) {
return window.parent.location.origin + window.parent.location.pathname + "#" + btoa(text);
};
window.promptNew = function(text) {
return prompt('Copy & Paste:', window.newLink(text));
};
window.shoutNew = function(text) {
location.href="http://shoutkey.com/new?url=" + encodeURIComponent(window.newLink(text));
};
$(function(){
if(window.parent.location.hash == '#new') return shoutNew(prompt("Your text (seperate parts with semicolons):"));
var hover, hoverListener, message, moreParts, nextPart;
message = atob(window.parent.location.hash.substr(1)).split(';');
location.hash = '';
nextPart = function() {
return message.shift();
};
moreParts = function() {
return message.length > 0;
};
hover = false;
hoverListener = function() {
return $(this).off('mouseenter mouseleave').on('mouseleave', function() {
var boxed, r, span;
$(this).off('mouseenter mouseleave');
r = new RegExp("\\S{1," + (Math.floor(Math.random() * 3) + 1) + "}", 'g');
boxed = $(this).text().replace(r, '█');
$(this).text(boxed).addClass('old');
span = $('<span>').text(nextPart()).appendTo($(this).parent());
if ($(this).parent().height() > parseInt('16px') * 1.5) {
return $(this).parent().find('.old').hide("fast", function() {
$(this).remove();
if (moreParts()) {
return span.on('mouseenter', hoverListener);
}
});
} else {
if (moreParts()) {
return span.on('mouseenter', hoverListener);
}
}
});
};
$('#text span#hover').on('mouseenter', hoverListener);
});
</script>
</head>
<body>
<div id="text">
<span id="hover">Hover to read message: </span>
<span class="old">███</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment