From 878690131ed8e4f297bb2be6646e5fc113fb3ae4 Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Tue, 30 Apr 2013 05:37:03 -0700 Subject: [PATCH] Fix #33 (I think...) --- CHANGELOG.md | 3 +++ LICENSE | 2 +- builds/4chan-X.js | 38 ++++++++++++-------------------- builds/4chan-X.user.js | 38 ++++++++++++-------------------- builds/crx/script.js | 38 ++++++++++++-------------------- src/Linkification/Linkify.coffee | 27 +++++++++-------------- 6 files changed, 57 insertions(+), 89 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42a13fdee..95a7e2056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +seaweedchan: +- Fix various embedding issues + ### 1.1.4 - 2013-04-29 seaweedchan: - Change ESC functionality in QR to autohide if Persistent QR is enabled diff --git a/LICENSE b/LICENSE index ba119d4f8..197aec549 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.4 - 2013-04-29 +* 4chan X - Version 1.1.4 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 5f3f9b93b..8832fd096 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.4 - 2013-04-29 +* 4chan X - Version 1.1.4 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4199,7 +4199,7 @@ } }, toggle: function() { - var el, embed, items, style, type, url; + var el, embed, style, type, url; embed = this.previousElementSibling; if (this.className.contains("embedded")) { @@ -4213,17 +4213,7 @@ this.textContent = '(embed)'; } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); - if (style = type.style) { - el.style.cssText = style; - } else { - items = { - 'embedWidth': Config['embedWidth'], - 'embedHeight': Config['embedHeight'] - }; - $.get(items, function(items) { - return el.style.cssText = "border: 0; width: " + items['embedWidth'] + "px; height: " + items['embedHeight'] + "px"; - }); - } + el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; this.textContent = '(unembed)'; } $.replace(embed, el); @@ -4291,6 +4281,7 @@ }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, + style: 'height: auto; width: 500px; display: inline-block;', el: function() { var div; @@ -4298,22 +4289,21 @@ className: "soundcloud", name: "soundcloud" }); - return $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=" + (this.getAttribute('data-originalURL')) + "&color=" + (Style.colorToHex(Themes[Conf['theme']]['Background Color'])), { + $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name, { div: div, onloadend: function() { return this.div.innerHTML = JSON.parse(this.responseText).html; } }, false); - } - }, - pastebin: { - regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, - el: function() { - var div; - - return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.name - }); + return div; + }, + title: { + api: function() { + return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name; + }, + text: function() { + return JSON.parse(this.responseText).title; + } } } }, diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 6b0984f10..8e098335b 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.4 - 2013-04-29 +* 4chan X - Version 1.1.4 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4195,7 +4195,7 @@ } }, toggle: function() { - var el, embed, items, style, type, url; + var el, embed, style, type, url; embed = this.previousElementSibling; if (this.className.contains("embedded")) { @@ -4209,17 +4209,7 @@ this.textContent = '(embed)'; } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); - if (style = type.style) { - el.style.cssText = style; - } else { - items = { - 'embedWidth': Config['embedWidth'], - 'embedHeight': Config['embedHeight'] - }; - $.get(items, function(items) { - return el.style.cssText = "border: 0; width: " + items['embedWidth'] + "px; height: " + items['embedHeight'] + "px"; - }); - } + el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; this.textContent = '(unembed)'; } $.replace(embed, el); @@ -4287,6 +4277,7 @@ }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, + style: 'height: auto; width: 500px; display: inline-block;', el: function() { var div; @@ -4294,22 +4285,21 @@ className: "soundcloud", name: "soundcloud" }); - return $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=" + (this.getAttribute('data-originalURL')) + "&color=" + (Style.colorToHex(Themes[Conf['theme']]['Background Color'])), { + $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name, { div: div, onloadend: function() { return this.div.innerHTML = JSON.parse(this.responseText).html; } }, false); - } - }, - pastebin: { - regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, - el: function() { - var div; - - return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.name - }); + return div; + }, + title: { + api: function() { + return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name; + }, + text: function() { + return JSON.parse(this.responseText).title; + } } } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index d54892ed9..e303a2ef6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.4 - 2013-04-29 +* 4chan X - Version 1.1.4 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4198,7 +4198,7 @@ } }, toggle: function() { - var el, embed, items, style, type, url; + var el, embed, style, type, url; embed = this.previousElementSibling; if (this.className.contains("embedded")) { @@ -4212,17 +4212,7 @@ this.textContent = '(embed)'; } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); - if (style = type.style) { - el.style.cssText = style; - } else { - items = { - 'embedWidth': Config['embedWidth'], - 'embedHeight': Config['embedHeight'] - }; - $.get(items, function(items) { - return el.style.cssText = "border: 0; width: " + items['embedWidth'] + "px; height: " + items['embedHeight'] + "px"; - }); - } + el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; this.textContent = '(unembed)'; } $.replace(embed, el); @@ -4290,6 +4280,7 @@ }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, + style: 'height: auto; width: 500px; display: inline-block;', el: function() { var div; @@ -4297,22 +4288,21 @@ className: "soundcloud", name: "soundcloud" }); - return $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=" + (this.getAttribute('data-originalURL')) + "&color=" + (Style.colorToHex(Themes[Conf['theme']]['Background Color'])), { + $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name, { div: div, onloadend: function() { return this.div.innerHTML = JSON.parse(this.responseText).html; } }, false); - } - }, - pastebin: { - regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, - el: function() { - var div; - - return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.name - }); + return div; + }, + title: { + api: function() { + return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name; + }, + text: function() { + return JSON.parse(this.responseText).title; + } } } }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 2ed8f00de..151585bf2 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -126,20 +126,15 @@ Linkify = @textContent = '(embed)' - # Embed else # We create an element to embed el = (type = Linkify.types[@getAttribute("data-service")]).el.call @ # Set style values. - if style = type.style - el.style.cssText = style + el.style.cssText = if style = type.style + style else - items = - 'embedWidth': Config['embedWidth'] - 'embedHeight': Config['embedHeight'] - $.get items, (items) -> - el.style.cssText = "border: 0; width: #{items['embedWidth']}px; height: #{items['embedHeight']}px" + "border: 0; width: 640px; height: 390px" @textContent = '(unembed)' @@ -187,23 +182,23 @@ Linkify = src: @name SoundCloud: - regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/ + regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/ + style: 'height: auto; width: 500px; display: inline-block;' el: -> div = $.el 'div', className: "soundcloud" - name: "soundcloud" + name: "soundcloud" $.ajax( - "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=#{@getAttribute 'data-originalURL'}&color=#{Style.colorToHex Themes[Conf['theme']]['Background Color']}" + "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@name}" div: div onloadend: -> @div.innerHTML = JSON.parse(@responseText).html false) + div + title: + api: -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@name}" + text: -> JSON.parse(@responseText).title - pastebin: - regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/ - el: -> - div = $.el 'iframe', - src: "http://pastebin.com/embed_iframe.php?i=#{@name}" embedder: (a) -> return [a] unless Conf['Embedding']