Skip to content

Instantly share code, notes, and snippets.

@jbt
Created April 1, 2016 08:46
Show Gist options
  • Save jbt/4b2b55252a7120362780b487bea8fe5e to your computer and use it in GitHub Desktop.
Save jbt/4b2b55252a7120362780b487bea8fe5e to your computer and use it in GitHub Desktop.
GoSquared Embedded Live Cat
function embedLiveCatTM() {
var πŸ“„ = document, πŸ’… = "style", β¬… = "left", ⬇ = "bottom", πŸ‘ = "translateX(-50%)", 🐳 = window,
↕ = "innerHeight", ↔ = "innerWidth", 😺 = 0, 🐈 = 🐳[↔] / 2, πŸ–– = 0, 🎺 = 0, πŸ‘» = "px",
πŸ”’ = Math, ⏲ = setInterval, πŸ’©, 🐱 = πŸ“„.createElement("img");
🐱.setAttribute("src", "//static.gosquared.com/images/april/nes/cat_02.png");
🐱[πŸ’…].height = 🐳[↕] / 20 * 10 + πŸ‘»;
🐱[πŸ’…].position = "fixed";
🐱[πŸ’…].transform = πŸ‘;
πŸ“„.body.appendChild(🐱);
(function πŸ–Œ(){
requestAnimationFrame(πŸ–Œ);
πŸ’© = 0.01;
🎺 = 🐈 * πŸ’© + 🎺 * (1 - πŸ’©);
πŸ’© = 0.1;
πŸ–– = 😺 * πŸ’© + πŸ–– * (1 - πŸ’©);
🐱[πŸ’…][⬇] = πŸ–– + πŸ‘»;
🐱[πŸ’…][β¬…] = 🎺 + πŸ‘»;
})();
⏲(function(){
🐈 = 🐳[↔] * (0.2 + πŸ”’.random() * 0.6);
🐱[πŸ’…].transform = 🐈 < 🎺 ? πŸ‘ + " scaleX(-1)" : πŸ‘;
}, 3000);
⏲(function(){
var ❌ = 0.065 * 🐳[↕];
😺 = -❌ - ❌ * πŸ”’.random();
}, 200);
}
// now just call embedLiveCatTM() whenever you want a Live Cat on your site
@jbt
Copy link
Author

jbt commented Apr 1, 2016

For boring browsers that don't support emoji as JS identifiers, try something like this instead:

<code id="livecat"> function embedLiveCatTM(){ ... }</code>
<script>
  eval(document.getElementById('livecat').innerText.replace(/[\u1000-\uffff]/g, function(s){ return 'u'+s.charCodeAt(0); }));
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment