From fd07b37bc7f8465643d031eadc4a219317ef82d4 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 30 Mar 2016 04:43:55 +0300 Subject: [PATCH] Video support plugin with support for mp3 and wav --- Plugins/mediaSupport.js | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Plugins/mediaSupport.js diff --git a/Plugins/mediaSupport.js b/Plugins/mediaSupport.js new file mode 100644 index 0000000..80aad8d --- /dev/null +++ b/Plugins/mediaSupport.js @@ -0,0 +1,61 @@ +//META{"name":"mediaSupport"}*// + +var mediaSupport = function () {}; + +mediaSupport.prototype.convert = function () { + $(".message a").each(function() { + var t = $(this); + var href = t.attr("href"); + if(href == undefined) return true; + href = href.replace("http:", "https:"); + if(!href.endsWith(".mp4") && !href.endsWith(".webm") && !href.endsWith(".ogg") && !href.endsWith(".mp3") && !href.endsWith(".wav")) return true; + var video = true; + var type = "webm"; + if(href.endsWith(".mp4")) type = "mp4"; + if(href.endsWith(".ogg")) type = "ogg"; + if(href.endsWith(".mp3")) { + type = "mpeg"; + video = false; + } + if(href.endsWith(".wav")) { + type = "wav"; + video = false; + } + + if(video) { + t.replaceWith(''); + } else { + t.replaceWith(''); + } + }); +}; + +mediaSupport.prototype.onMessage = function () { + setTimeout(this.convert(), 2000); +}; +mediaSupport.prototype.onSwitch = function () { + this.convert(); +}; +mediaSupport.prototype.start = function () { + this.convert(); +}; + +mediaSupport.prototype.load = function () {}; +mediaSupport.prototype.unload = function () {}; +mediaSupport.prototype.stop = function () {}; +mediaSupport.prototype.getSettingsPanel = function () { + return ""; +}; + +mediaSupport.prototype.getName = function () { + return "Video Support"; +}; +mediaSupport.prototype.getDescription = function () { + return "Add support for html5 video"; +}; +mediaSupport.prototype.getVersion = function () { + return "0.1.0"; +}; +mediaSupport.prototype.getAuthor = function () { + return "Jiiks"; +}; \ No newline at end of file