Last active
August 29, 2015 14:17
-
-
Save ungikim/809d2b628eabcd8b34f4 to your computer and use it in GitHub Desktop.
KiwiIRC Media Auto Open
This file contains 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
conf.client_plugins = [ | |
"/kiwi/assets/plugins/toggle_media.html" | |
// "http://server.com/kiwi/plugins/myplugin.html" | |
]; |
This file contains 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
<script> | |
var MediaToggler = Backbone.Model.extend({ | |
initialize: function() { | |
this.on('applet_loaded', this.appletLoaded, this); | |
}, | |
appletLoaded: function() { | |
var that = this; | |
var net = kiwi.components.Network(); | |
var input = kiwi.components.ControlInput(); | |
net.on('message', function (message) { | |
if (message.type === "message") { | |
var found_a_url = false; | |
message_words = message.msg.split(' '); | |
for (var i = 0; i < message_words.length; i++) { | |
if (message_words[i].match(/^(([A-Za-z][A-Za-z0-9\-]*\:\/\/)|(www\.))([\w.\-]+)([a-zA-Z]{2,6})(:[0-9]+)?(\/[\w!:.?$'()[\]*,;~+=&%@!\-\/]*)?(#.*)?$/gi)) { | |
found_a_url = true; | |
} | |
} | |
if (found_a_url) { | |
var media = $('.msg+.privmsg:last .media .open'); | |
for (var i = 0; i < media.length; i++) { | |
media[i].click(); | |
} | |
} | |
} | |
}); | |
} | |
}); | |
kiwi.components.Applet.register('media_toggler', MediaToggler); | |
kiwi.components.Applet.loadOnce('media_toggler'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment