diff --git a/js/plugins.js b/js/plugins.js
index a151128..c8fa5c6 100644
--- a/js/plugins.js
+++ b/js/plugins.js
@@ -27,7 +27,7 @@ var Plugin = function(contentForMessage) {
* to display when messages are received.
*
*/
-plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
+plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
var nsfwRegexp = new RegExp('nsfw', 'i');
@@ -129,10 +129,12 @@ plugins.factory('userPlugins', function() {
var youtubePlugin = new Plugin(function(message) {
- if (message.indexOf('youtube.com') != -1) {
- var index = message.indexOf("?v=");
- var token = message.substr(index+3);
- return ''
+ var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
+ var match = message.match(regExp);
+ if (match && match[7].length==11){
+ var token = match[7];
+ var embedurl = "http://www.youtube.com/embed/" + token+ "?html5=1&autoplay=0&theme=dark&color=black&iv_load_policy=3";
+ return '';
}
return null;