Fix #33 (I think...)

This commit is contained in:
Jordan Bates 2013-04-30 05:37:03 -07:00
parent 63a380b8c7
commit 878690131e
6 changed files with 57 additions and 89 deletions

View File

@ -1,3 +1,6 @@
seaweedchan:
- Fix various embedding issues
### 1.1.4 - 2013-04-29 ### 1.1.4 - 2013-04-29
seaweedchan: seaweedchan:
- Change ESC functionality in QR to autohide if Persistent QR is enabled - Change ESC functionality in QR to autohide if Persistent QR is enabled

View File

@ -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. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE

View File

@ -18,7 +18,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.1.4 - 2013-04-29 * 4chan X - Version 1.1.4 - 2013-04-30
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -4199,7 +4199,7 @@
} }
}, },
toggle: function() { toggle: function() {
var el, embed, items, style, type, url; var el, embed, style, type, url;
embed = this.previousElementSibling; embed = this.previousElementSibling;
if (this.className.contains("embedded")) { if (this.className.contains("embedded")) {
@ -4213,17 +4213,7 @@
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this);
if (style = type.style) { el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
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";
});
}
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
$.replace(embed, el); $.replace(embed, el);
@ -4291,6 +4281,7 @@
}, },
SoundCloud: { SoundCloud: {
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
style: 'height: auto; width: 500px; display: inline-block;',
el: function() { el: function() {
var div; var div;
@ -4298,22 +4289,21 @@
className: "soundcloud", className: "soundcloud",
name: "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, div: div,
onloadend: function() { onloadend: function() {
return this.div.innerHTML = JSON.parse(this.responseText).html; return this.div.innerHTML = JSON.parse(this.responseText).html;
} }
}, false); }, false);
} return div;
}, },
pastebin: { title: {
regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, api: function() {
el: function() { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name;
var div; },
text: function() {
return div = $.el('iframe', { return JSON.parse(this.responseText).title;
src: "http://pastebin.com/embed_iframe.php?i=" + this.name }
});
} }
} }
}, },

View File

@ -18,7 +18,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.1.4 - 2013-04-29 * 4chan X - Version 1.1.4 - 2013-04-30
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -4195,7 +4195,7 @@
} }
}, },
toggle: function() { toggle: function() {
var el, embed, items, style, type, url; var el, embed, style, type, url;
embed = this.previousElementSibling; embed = this.previousElementSibling;
if (this.className.contains("embedded")) { if (this.className.contains("embedded")) {
@ -4209,17 +4209,7 @@
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this);
if (style = type.style) { el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
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";
});
}
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
$.replace(embed, el); $.replace(embed, el);
@ -4287,6 +4277,7 @@
}, },
SoundCloud: { SoundCloud: {
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
style: 'height: auto; width: 500px; display: inline-block;',
el: function() { el: function() {
var div; var div;
@ -4294,22 +4285,21 @@
className: "soundcloud", className: "soundcloud",
name: "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, div: div,
onloadend: function() { onloadend: function() {
return this.div.innerHTML = JSON.parse(this.responseText).html; return this.div.innerHTML = JSON.parse(this.responseText).html;
} }
}, false); }, false);
} return div;
}, },
pastebin: { title: {
regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, api: function() {
el: function() { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name;
var div; },
text: function() {
return div = $.el('iframe', { return JSON.parse(this.responseText).title;
src: "http://pastebin.com/embed_iframe.php?i=" + this.name }
});
} }
} }
}, },

View File

@ -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. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -4198,7 +4198,7 @@
} }
}, },
toggle: function() { toggle: function() {
var el, embed, items, style, type, url; var el, embed, style, type, url;
embed = this.previousElementSibling; embed = this.previousElementSibling;
if (this.className.contains("embedded")) { if (this.className.contains("embedded")) {
@ -4212,17 +4212,7 @@
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this);
if (style = type.style) { el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
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";
});
}
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
$.replace(embed, el); $.replace(embed, el);
@ -4290,6 +4280,7 @@
}, },
SoundCloud: { SoundCloud: {
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
style: 'height: auto; width: 500px; display: inline-block;',
el: function() { el: function() {
var div; var div;
@ -4297,22 +4288,21 @@
className: "soundcloud", className: "soundcloud",
name: "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, div: div,
onloadend: function() { onloadend: function() {
return this.div.innerHTML = JSON.parse(this.responseText).html; return this.div.innerHTML = JSON.parse(this.responseText).html;
} }
}, false); }, false);
} return div;
}, },
pastebin: { title: {
regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/, api: function() {
el: function() { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name;
var div; },
text: function() {
return div = $.el('iframe', { return JSON.parse(this.responseText).title;
src: "http://pastebin.com/embed_iframe.php?i=" + this.name }
});
} }
} }
}, },

View File

@ -126,20 +126,15 @@ Linkify =
@textContent = '(embed)' @textContent = '(embed)'
# Embed
else else
# We create an element to embed # We create an element to embed
el = (type = Linkify.types[@getAttribute("data-service")]).el.call @ el = (type = Linkify.types[@getAttribute("data-service")]).el.call @
# Set style values. # Set style values.
if style = type.style el.style.cssText = if style = type.style
el.style.cssText = style style
else else
items = "border: 0; width: 640px; height: 390px"
'embedWidth': Config['embedWidth']
'embedHeight': Config['embedHeight']
$.get items, (items) ->
el.style.cssText = "border: 0; width: #{items['embedWidth']}px; height: #{items['embedHeight']}px"
@textContent = '(unembed)' @textContent = '(unembed)'
@ -188,22 +183,22 @@ Linkify =
SoundCloud: SoundCloud:
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/ regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/
style: 'height: auto; width: 500px; display: inline-block;'
el: -> el: ->
div = $.el 'div', div = $.el 'div',
className: "soundcloud" className: "soundcloud"
name: "soundcloud" name: "soundcloud"
$.ajax( $.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 div: div
onloadend: -> onloadend: ->
@div.innerHTML = JSON.parse(@responseText).html @div.innerHTML = JSON.parse(@responseText).html
false) 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) -> embedder: (a) ->
return [a] unless Conf['Embedding'] return [a] unless Conf['Embedding']