Created
December 29, 2014 15:52
-
-
Save yongzhihuang/4b2f54f827dda55f6fa6 to your computer and use it in GitHub Desktop.
Make slack play sound on new message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:function playSound(b,a){b.mp3?b.mp3.paused?b.mp3.play():b.mp3.pause():(b.mp3=new Audio(a),b.mp3.play())} | |
setInterval(function(){if(localStorage.lastMessage)b=$(".message").last().find(".message_sender").text().trim(),a=$(".message").last().find(".message_content").text().trim(),a!==localStorage.lastMessage&&(c=/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/,a.match(c)&&a.match(c)[0]&&(a=a.replace(a.match(c)[0],b+" shared a link")),playSound(this,"https://mansueto.campfirenow.com/sounds/incoming.mp3"),localStorage.lastMessage=a);else{var b=$(".message").last().find(".message_sender").text().trim(), | |
a=$(".message").last().find(".message_content").text().trim(),c=/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;a.match(c)&&a.match(c)[0]&&(a=a.replace(a.match(c)[0],b+" shared a link"));playSound(this,"https://mansueto.campfirenow.com/sounds/incoming.mp3");localStorage.lastMessage=a}},2500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment