Skip to content

Instantly share code, notes, and snippets.

@danhyun
Last active December 29, 2015 18:57
Show Gist options
  • Save danhyun/67269a5b4bf24194d700 to your computer and use it in GitHub Desktop.
Save danhyun/67269a5b4bf24194d700 to your computer and use it in GitHub Desktop.
hax.html
<script>
var CONST = {
terminalWidth: 72
};
var STYLE = {
terminal: 'font-family: monospace; background: black; color: green; font-size: 20px; padding-left: 25px; padding-top: 200px; padding-bottom: 200px;'
};
function frameRunner(frames) {
var frameIndex = 0;
return {
play: play
};
function play() {
playNextFrame();
}
function incrementFrameIndex() {
if (frameIndex === frames.length - 1) {
frameIndex = 0;
}
else {
frameIndex++;
}
}
function playNextFrame() {
console.clear();
var frame = frames[frameIndex];
frame(playNextFrame);
incrementFrameIndex();
}
}
function terminalType(input, durationPerCharacter, done) {
var charIndex = 0;
var displayContent = function() {
console.log('\n'.repeat(50));
var message = input.substring(0, charIndex);
if (message.length < CONST.terminalWidth){
message += " ".repeat(CONST.terminalWidth - message.length);
}
console.log('%c' + message, STYLE.terminal);
charIndex++;
if (charIndex <= input.length) {
setTimeout(displayContent, durationPerCharacter);
}
else if (done) {
setTimeout(done, durationPerCharacter);
}
};
displayContent();
}
function speechManager() {
var synth = window.speechSynthesis;
var voicesLoaded = false;
synth.onvoiceschanged = function() {
voicesLoaded = true;
};
return {
say: say
};
function say(content, voiceName, done) {
if (!voicesLoaded) {
setTimeout(function() { say(content, voiceName, done); }, 1000);
}
else {
var utterance = new SpeechSynthesisUtterance(content);
utterance.voice = synth.getVoices().filter(function(voice) { return voice.name == voiceName; })[0];
if (done) {
utterance.onend = done;
}
synth.speak(utterance);
}
}
}
var speaker = speechManager()
var frames = [
function(done) {
speaker.say("Ok time for me to own some fucking noobs", 'Bad News', done);
terminalType("EXECUTING C:\\virus.exe...", 100);
},
function(done) {
speaker.say("I just need to get past this firewall encryption password database and then I'm in.", 'Alex', done);
terminalType("10100101FIREWALLHACK!!00011110100101FIREWALLHACK", 50);
},
function(done) {
speaker.say("Boom. Child's play motherfucker. You are totally hacked.", 'Alex', done);
terminalType("HACKING COMPLETE!! YOU'RE FUCKED!", 100);
}
];
var runner = frameRunner(frames);
runner.play();
</script>
<script type="text/javascript">
var CONST = {
terminalWidth: 72
};
var STYLE = {
terminal: 'font-family: monospace; background: black; color: green; font-size: 20px; padding-left: 25px; padding-top: 200px; padding-bottom: 200px;'
};
function frameRunner(frames) {
var frameIndex = 0;
return {
play: play
};
function play() {
playNextFrame();
}
function incrementFrameIndex() {
frameIndex = (frameIndex + 1) % frames.length;
}
function playNextFrame() {
console.clear();
var frame = frames[frameIndex];
frame(playNextFrame);
incrementFrameIndex();
}
}
function terminalType(input, durationPerCharacter, done) {
var charIndex = 0;
var displayContent = function() {
console.log('\n'.repeat(50));
var message = input.substring(0, charIndex);
if (message.length < CONST.terminalWidth){
message += " ".repeat(CONST.terminalWidth - message.length);
}
console.log('%c' + message, STYLE.terminal);
charIndex++;
if (charIndex <= input.length) {
setTimeout(displayContent, durationPerCharacter);
}
else {
setTimeout(done, durationPerCharacter);
}
};
displayContent();
}
var frames = [
function(done) { terminalType("EXECUTING C:\\virus.exe...", 100, done); },
function(done) { terminalType("10100101FIREWALLHACK!!00011110100101FIREWALLHACK", 50, done); },
function(done) {
terminalType("HACKING COMPLETE!! YOU'RE FUCKED!", 100, function() { setTimeout(done, 1000); });
}
];
var runner = frameRunner(frames);
runner.play();
</script>
<script>
var CONST = {
terminalWidth: 72
};
var STYLE = {
terminal: 'font-family: monospace; background: black; color: green; font-size: 20px; padding-left: 25px; padding-top: 200px; padding-bottom: 200px;'
};
function frameRunner(frames) {
var frameIndex = 0;
return {
play: play
};
function play() {
playNextFrame();
}
function incrementFrameIndex() {
if (frameIndex === frames.length - 1) {
frameIndex = 0;
}
else {
frameIndex++;
}
}
function playNextFrame() {
console.clear();
var frame = frames[frameIndex]();
incrementFrameIndex();
Promise.all(frame).then(playNextFrame);
}
}
function terminalType(input, durationPerCharacter) {
var charIndex = 0;
return new Promise(displayContent);
function displayContent(resolve, reject) {
console.log('\n'.repeat(50));
var message = input.substring(0, charIndex);
if (message.length < CONST.terminalWidth) {
message += " ".repeat(CONST.terminalWidth - message.length);
}
console.log('%c' + message, STYLE.terminal);
charIndex++;
if (charIndex <= input.length) {
setTimeout(function() { displayContent(resolve, reject); } , durationPerCharacter);
}
else {
setTimeout(resolve, durationPerCharacter);
}
}
}
function speechManager() {
var synth = window.speechSynthesis;
var voicesLoaded = false;
synth.onvoiceschanged = function() {
voicesLoaded = true;
};
return {
say: say
};
function say(content, voiceName) {
var speak = function(resolve, reject) {
if (!voicesLoaded) {
setTimeout(function() { speak(resolve, reject); }, 1000);
}
else {
var utterance = new SpeechSynthesisUtterance(content);
utterance.voice = synth.getVoices().filter(function(voice) { return voice.name == voiceName; })[0];
synth.speak(utterance);
utterance.onend = function(e) { resolve(); };
}
};
return new Promise(speak);
}
}
var speaker = speechManager()
var frames = [
function() { return [
speaker.say("Ok time for me to own some fucking noobs", 'Albert'),
terminalType("EXECUTING C:\\virus.exe...", 150)
];
},
function() { return [
speaker.say("I just need to get past this firewall encryption password database and then I'm in.", 'Albert'),
terminalType("10100101FIREWALLHACK!!00011110100101FIREWALLHACK", 150)
];
},
function() {
return [
speaker.say("Boom. Child's play motherfucker. You are totally hacked.", 'Albert'),
terminalType("HACKING COMPLETE!! YOU'RE FUCKED!", 150)
];
}
];
var runner = frameRunner(frames);
runner.play();
</script>
<script>
var CONST = {
terminalWidth: 72
};
var STYLE = {
terminal: 'font-family: monospace; background: black; color: green; font-size: 20px; padding-left: 25px; padding-top: 50px; padding-bottom: 500px;'
};
function frameRunner(frames) {
var frameIndex = 0;
return {
play: play
};
function play() {
playNextFrame();
}
function incrementFrameIndex() {
if (frameIndex === frames.length - 1) {
frameIndex = 0;
}
else {
frameIndex++;
}
}
function playNextFrame() {
console.clear();
var frame = frames[frameIndex]();
Promise.all(frame).then(function() {
incrementFrameIndex();
playNextFrame();
});
}
}
function terminalType(input, durationPerCharacter) {
var charIndex = 0;
return new Promise(displayContent);
function displayContent(resolve, reject) {
var message = input.substring(0, charIndex);
if (message.length < CONST.terminalWidth) {
message += " ".repeat(CONST.terminalWidth - message.length);
}
console.log('%c' + message, STYLE.terminal);
charIndex++;
if (charIndex <= input.length) {
setTimeout(function() { displayContent(resolve, reject); } , durationPerCharacter);
}
else {
setTimeout(resolve, durationPerCharacter);
}
}
}
function speechManager() {
var synth = window.speechSynthesis;
var voicesLoaded = false;
synth.onvoiceschanged = function() {
voicesLoaded = true;
};
return {
say: say
};
function say(content, voiceName) {
var speak = function(resolve, reject) {
if (!voicesLoaded) {
setTimeout(function() { speak(resolve, reject); }, 1000);
}
else {
var utterance = new SpeechSynthesisUtterance(content);
utterance.voice = synth.getVoices().filter(function(voice) { return voice.name == voiceName; })[0];
synth.speak(utterance);
utterance.onend = function(e) { resolve(); };
}
};
return new Promise(speak);
}
}
var speaker = speechManager()
var frames = [
function() { return [
speaker.say("Ok time for me to own some fucking noobs", 'Albert'),
terminalType("EXECUTING C:\\virus.exe...", 100)
];
},
function() { return [
speaker.say("I just need to get past this firewall encryption password database and then I'm in.", 'Albert'),
terminalType("10100101FIREWALLHACK!!00011110100101FIREWALLHACK", 50)
];
},
function() {
return [
speaker.say("Boom. Child's play motherfucker. You are totally hacked.", 'Albert'),
terminalType("HACKING COMPLETE!! YOU'RE FUCKED!", 100)
];
}
];
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment