Skip to content

Instantly share code, notes, and snippets.

@cha0s
Last active August 29, 2015 14:15
Show Gist options
  • Save cha0s/cf07a59f689101d8298f to your computer and use it in GitHub Desktop.
Save cha0s/cf07a59f689101d8298f to your computer and use it in GitHub Desktop.
Reddichat sound hax :3
angular.element(document.body).injector().invoke(['$rootScope', 'shrub-socket', 'shrub-ui/notifications', function($rootScope, socket, notifications) {
if (window.playMessageSound) {
window.playMessageSound = false;
notifications.add({text: 'Message sound disabled'});
}
else {
window.playMessageSound = true;
if (!window.messageSound) {
window.messageSound = document.createElement('audio');
window.messageSound.src = 'http://reddichat.com/chat-message.mp3';
socket.on('reddichat.chat.message', function() {
if (window.playMessageSound) window.messageSound.play();
});
}
notifications.add({text: 'Message sound enabled'});
}
$rootScope.$digest();
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment