Skip to content

Instantly share code, notes, and snippets.

@jkohlin
Last active April 20, 2023 11:52
Show Gist options
  • Save jkohlin/ccbf33fe9fc1fd5682045b136d4ffb2f to your computer and use it in GitHub Desktop.
Save jkohlin/ccbf33fe9fc1fd5682045b136d4ffb2f to your computer and use it in GitHub Desktop.
harlem-shake-you-page
!function () { function e(e) { var t = { height: e.offsetHeight, width: e.offsetWidth }; return t.height > r && t.height < s && t.width > i && t.width < d; } function t() { for (var e = document.getElementsByClassName(m), t = RegExp("\\b" + m + "\\b"); 0 < e.length;)e[0].className = e[0].className.replace(t, ""); } for (var n, o, a, r = 30, i = 30, s = 350, d = 350, m = "mw-harlem_shake_me", l = ["im_drunk", "im_baked", "im_trippin", "im_blown"], u = "mw_added_css", c = (n = document.documentElement, window.innerWidth ? window.innerHeight : n && !isNaN(n.clientHeight) ? n.clientHeight : 0), h = window.pageYOffset ? window.pageYOffset : Math.max(document.documentElement.scrollTop, document.body.scrollTop), f = document.getElementsByTagName("*"), p = null, g = 0; g < f.length; g++) { var b = f[g]; if (e(b) && function (e) { var t = function (e) { for (var t = e, n = 0; t;)n += t.offsetTop, t = t.offsetParent; return n; }(e); return t >= h && t <= c + h; }(b)) { p = b; break; } } if (null === b) { console.warn("Could not find a node of the right size. Please try a different page."); return; } (o = document.createElement("link")).setAttribute("type", "text/css"), o.setAttribute("rel", "stylesheet"), o.setAttribute("href", "https://s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css"), o.setAttribute("class", u), document.body.appendChild(o), (a = document.createElement("audio")).setAttribute("class", u), a.src = "https://s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3", a.loop = !1, a.addEventListener("canplay", function () { setTimeout(function () { var e; e = p, e.className += " " + m + " im_first"; }, 500), setTimeout(function () { t(), (e = document.createElement("div")).setAttribute("class", "mw-strobe_light"), document.body.appendChild(e), setTimeout(function () { document.body.removeChild(e); }, 100); for (var e, n, o = 0; o < w.length; o++)n = w[o], n.className += " " + m + " " + l[Math.floor(Math.random() * l.length)]; }, 15500); }, !0), a.addEventListener("ended", function () { t(), function () { for (var e = document.getElementsByClassName(u), t = 0; t < e.length; t++)document.body.removeChild(e[t]); }(); }, !0), a.innerHTML = " <p>Dude, old browser</p> <p>", document.body.appendChild(a), a.play(); for (var w = [], g = 0; g < f.length; g++) { var b = f[g]; e(b) && w.push(b); } }();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment