These days you can see many dancing videos on YouTube and those dances are called Harlem Shake. I wonder if there’s others things that can dance the Harlem Shake.

Based on the idea of Vir Ascabano, He has created a little script that can do the Harlem Shake on websites! However, it’s not very perfect, so I create another one which is better in some circumstances.

It’s been reported that this doesn’t work on Facebook. It’s because Facebook limits what scripts can be loaded by using the Content Security Policy headers. To make it work on Facebook, we need to use the long script below instead of the one above.

1

(function(){functionl(a){varc=a.offsetHeight;a=a.offsetWidth;returnc&gt;q&amp;&amp;c&lt;r&amp;&amp;a&gt;s&amp;&amp;a&lt;t}functionm(){for(vara=document.getElementsByClassName(f),c=RegExp("\\b"+f+"\\b");0&lt;a.length;)a[0].className=a[0].className.replace(c,"")}varq=10,s=10,r=1E3,t=1E3,f="mw-harlem_shake_me",n=["im_drunk","im_baked","im_trippin","im_blown","im_hanging"],p,b=document.documentElement;p=window.innerWidth?window.innerHeight:b&amp;&amp;!isNaN(b.clientHeight)?b.clientHeight:0;varg;g=window.pageYOffset?window.pageYOffset:Math.max(document.documentElement.scrollTop,document.body.scrollTop);for(varb=document.getElementsByTagName("*"),h=null,e=0;e&lt;b.length;e++){vara=b[e];if(l(a)){vard;d=a;for(varj=0;d;)j+=d.offsetTop,d=d.offsetParent;d=j;if(d&gt;=g&amp;&amp;d&lt;=p+g){h=a;break}}}if(null===a)a=b;else{a=document.createElement("link");a.setAttribute("type","text/css");a.setAttribute("rel","stylesheet");a.setAttribute("href","//dl.dropboxusercontent.com/s/nt5iljw2e0iac44/harlem-shake.css");a.setAttribute("class","mw_added_css");document.body.appendChild(a);a=document.createElement("audio");a.setAttribute("class","mw_added_css");a.src="//dl.dropboxusercontent.com/s/vyk1ctygfanj78p/harlem-shake.mp3";a.loop=!1;a.addEventListener("canplay",function(){setTimeout(function(){h.className+=" "+f+" im_first"},500);setTimeout(function(){m();vara=document.createElement("div");a.setAttribute("class","mw-strobe_light");document.body.appendChild(a);setTimeout(function(){document.body.removeChild(a)},100);for(varc=0;c&lt;k.length;c++){varb=k[c];b.className+=" "+f+" "+n[Math.floor(Math.random()*n.length)]}},15500)},!0);a.addEventListener("ended",function(){m();for(vara=document.getElementsByClassName("mw_added_css"),b=0;b&lt;a.length;b++)document.body.removeChild(a[b])},!0);a.innerHTML=" &lt;p&gt;If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.&lt;/p&gt; &lt;p&gt;";document.body.appendChild(a);a.play();for(vark=[],e=0;e&lt;b.length;e++)a=b[e],l(a)&amp;&amp;k.push(a)}})();