From 08e7a8a6c43ccf82d43ade20e08652050ee4a4aa Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 10 Aug 2013 02:04:41 -0700 Subject: [PATCH] This will get better when MediaCrush's API improves? --- LICENSE | 2 +- builds/4chan-X.user.js | 19 +++++++++++++---- builds/crx/script.js | 19 +++++++++++++---- src/Linkification/Linkify.coffee | 36 +++++++++++++++++++++++++++++--- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index b6e66b546..a98499ab6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index eccc4fea7..d10334602 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4385,10 +4385,12 @@ if (this.isClone) { if (Conf['Embedding']) { i = 0; - items = $$('.embedded', this.nodes.comment); + items = $$('.embed', this.nodes.comment); while (el = items[i++]) { - $.on(el, "click", Linkify.cb.toggle); - Linkify.cb.toggle.call(el); + $.on(el, 'click', Linkify.cb.toggle); + if ($.hasClass(el, 'embedded')) { + Linkify.cb.toggle.call(el); + } } } return; @@ -4676,6 +4678,15 @@ }); } }, + MediaCrush: { + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i, + style: 'border: 0; width: 640px; height: 480px; resize: both;', + el: function(a) { + return $.el('iframe', { + src: "https://mediacru.sh/" + a.dataset.uid + }); + } + }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, el: function(a) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 0ff3f6cf7..233ab106b 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4390,10 +4390,12 @@ if (this.isClone) { if (Conf['Embedding']) { i = 0; - items = $$('.embedded', this.nodes.comment); + items = $$('.embed', this.nodes.comment); while (el = items[i++]) { - $.on(el, "click", Linkify.cb.toggle); - Linkify.cb.toggle.call(el); + $.on(el, 'click', Linkify.cb.toggle); + if ($.hasClass(el, 'embedded')) { + Linkify.cb.toggle.call(el); + } } } return; @@ -4681,6 +4683,15 @@ }); } }, + MediaCrush: { + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i, + style: 'border: 0; width: 640px; height: 480px; resize: both;', + el: function(a) { + return $.el('iframe', { + src: "https://mediacru.sh/" + a.dataset.uid + }); + } + }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, el: function(a) { diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index b2151e945..b935fba66 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -36,10 +36,10 @@ Linkify = if @isClone if Conf['Embedding'] i = 0 - items = $$ '.embedded', @nodes.comment + items = $$ '.embed', @nodes.comment while el = items[i++] - $.on el, "click", Linkify.cb.toggle - Linkify.cb.toggle.call el + $.on el, 'click', Linkify.cb.toggle + Linkify.cb.toggle.call el if $.hasClass el, 'embedded' return @@ -279,6 +279,36 @@ Linkify = $.el 'object', innerHTML: "" + MediaCrush: + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i + style: 'border: 0; width: 640px; height: 480px; resize: both;' + el: (a) -> + $.el 'iframe', + src: "https://mediacru.sh/#{a.dataset.uid}" +# MediaCrush CORS When? +# +# el = $.el 'div' +# $.cache "https://mediacru.sh/#{a.dataset.uid}.json", -> +# {status} = @ +# return unless [200, 304].contains status +# {files} = JSON.parse req.response +# file = file for file of files when files.hasOwnProperty file +# el.innerHTML = switch file.type +# when 'video/mp4', 'video/ogv' +# """ +#""" +# when 'image/png', 'image/gif', 'image/jpeg' +# "" +# when 'image/svg', 'image/svg+xml' +# "" +# when 'audio/mpeg' +# "" +# el + + pastebin: regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/ el: (a) ->