Skip to content

Instantly share code, notes, and snippets.

@jpwilliams
Created September 20, 2017 10:04
Show Gist options
  • Save jpwilliams/b9e0f9cc270b88350e3ebf6c8c41785b to your computer and use it in GitHub Desktop.
Save jpwilliams/b9e0f9cc270b88350e3ebf6c8c41785b to your computer and use it in GitHub Desktop.
javascript:(function () {
if (typeof crugoSalesScript !== 'undefined') {
return;
}
socketIoScript = document.createElement('script');
socketIoScript.type = 'text/javascript';
socketIoScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.slim.js';
document.getElementsByTagName('head')[0].appendChild(socketIoScript);
crugoSalesScript = document.createElement('script');
crugoSalesScript.type = 'text/javascript';
crugoSalesScript.innerHTML = 'function playSound(o){return soundPools[o]||(soundPools[o]=createSoundPool(o)),playSoundPool(soundPools[o])}function createSoundPool(o){for(var n={next:0,items:[]},t=0;t<3;t++)n.items.push(new Audio("http://192.168.1.102:3026/sounds/"+o+".mp3"));return n}function playSoundPool(o){o.items[o.next].currentTime=0,o.items[o.next].play(),++o.next>o.items.length-1&&(o.next=0)}var soundPools={};console.log("Waiting for IO..."),setTimeout(function(){console.log("Attempting");var o=io("http://192.168.1.102:6001");console.log("socket",o),o.on("connect",function(){console.log("CONNECTED")}),o.on("playSound",playSound)},5e3);';
document.getElementsByTagName('head')[0].appendChild(crugoSalesScript)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment