From b47aea7055db7dcecd1512f1c41aa20387954f8e Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 19:47:23 -0700 Subject: [PATCH 1/8] Restore node to previous state instead of replacing node with url --- builds/4chan-X.user.js | 10 +++++----- builds/crx/script.js | 10 +++++----- src/Linkification/Linkify.coffee | 9 +++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index dc1509a81..5274289fc 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4469,6 +4469,7 @@ value = _ref[name]; embed.dataset[name] = value; } + embed.dataset.nodedata = link.innerHTML; $.addClass(link, "" + embed.dataset.key); $.on(embed, 'click', Linkify.cb.toggle); $.after(link, [$.tn(' '), embed]); @@ -4523,18 +4524,17 @@ return el; }, unembed: function(a) { - var el, href; + var el; - href = a.dataset.href; el = $.el('a', { rel: 'nofollow noreferrer', target: 'blank', className: 'linkify', - href: href, - textContent: a.dataset.title || href + href: a.dataset.href, + innerHTML: a.dataset.title || a.dataset.nodedata }); a.textContent = '(embed)'; - $.addClass(el, "" + a.dataset.key); + $.addClass(el, a.dataset.key); return el; }, title: function(data) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 38cada217..d2295bea6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4474,6 +4474,7 @@ value = _ref[name]; embed.dataset[name] = value; } + embed.dataset.nodedata = link.innerHTML; $.addClass(link, "" + embed.dataset.key); $.on(embed, 'click', Linkify.cb.toggle); $.after(link, [$.tn(' '), embed]); @@ -4528,18 +4529,17 @@ return el; }, unembed: function(a) { - var el, href; + var el; - href = a.dataset.href; el = $.el('a', { rel: 'nofollow noreferrer', target: 'blank', className: 'linkify', - href: href, - textContent: a.dataset.title || href + href: a.dataset.href, + innerHTML: a.dataset.title || a.dataset.nodedata }); a.textContent = '(embed)'; - $.addClass(el, "" + a.dataset.key); + $.addClass(el, a.dataset.key); return el; }, title: function(data) { diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index ba46a0c58..25742786e 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -146,6 +146,8 @@ Linkify = for name, value of {key, href, uid, options} embed.dataset[name] = value + + embed.dataset.nodedata = link.innerHTML $.addClass link, "#{embed.dataset.key}" @@ -205,16 +207,15 @@ Linkify = unembed: (a) -> # Recreate the original link. - {href} = a.dataset el = $.el 'a', rel: 'nofollow noreferrer' target: 'blank' className: 'linkify' - href: href - textContent: a.dataset.title or href + href: a.dataset.href + innerHTML: a.dataset.title or a.dataset.nodedata a.textContent = '(embed)' - $.addClass el, "#{a.dataset.key}" + $.addClass el, a.dataset.key return el From 4ff97f9435202325c408909f977877b3eb47ad4a Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 20:10:50 -0700 Subject: [PATCH 2/8] Fix issues with clones, re-add auto-embed --- builds/4chan-X.user.js | 39 ++++++++++++++--------------- builds/crx/script.js | 39 ++++++++++++++--------------- src/Linkification/Linkify.coffee | 42 +++++++++++++++----------------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 5274289fc..b9e7014aa 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4335,21 +4335,22 @@ }); }, node: function() { - var data, embedder, i, len, node, range, snapshot, _i, _j, _len, _len1, _ref, _ref1; + var data, el, i, items, node, range, snapshot, _i, _len, _ref; - if (this.isClone && Conf['Embedding']) { - _ref = $$('.embedder', this.nodes.comment); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - embedder = _ref[_i]; - $.on(embedder, "click", Linkify.cb.toggle); + if (this.isClone) { + if (Conf['Embedding']) { + i = 0; + items = $$('.embedded', this.nodes.comment); + while (el = items[i++]) { + $.on(el, "click", Linkify.cb.toggle); + Linkify.cb.toggle.call(el); + } } return; } snapshot = $.X('.//text()', this.nodes.comment); - i = -1; - len = snapshot.snapshotLength; - while (++i < len) { - node = snapshot.snapshotItem(i); + i = 0; + while (node = snapshot.snapshotItem(i++)) { if (node.parentElement.nodeName === "A") { continue; } @@ -4362,9 +4363,9 @@ if (!(Conf['Embedding'] || Conf['Link Title'])) { return; } - _ref1 = this.nodes.links; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - range = _ref1[_j]; + _ref = this.nodes.links; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + range = _ref[_i]; if (data = Linkify.services(range)) { if (Conf['Embedding']) { Linkify.embed(data); @@ -4473,6 +4474,9 @@ $.addClass(link, "" + embed.dataset.key); $.on(embed, 'click', Linkify.cb.toggle); $.after(link, [$.tn(' '), embed]); + if (Conf['Auto-embed']) { + Linkify.cb.toggle.call(embed); + } }, title: function(data) { var err, key, link, options, service, title, titles, uid; @@ -4508,11 +4512,10 @@ }, cb: { toggle: function() { - var el, embed; + var string, _ref; - embed = this.previousElementSibling; - el = !this.className.contains("embedded") ? Linkify.cb.embed(this) : Linkify.cb.unembed(this); - $.replace(embed, el); + _ref = $.hasClass(this, "embedded") ? ['unembed', '(embed)'] : ['embed', '(unembed)'], string = _ref[0], this.textContent = _ref[1]; + $.replace(this.previousElementSibling, Linkify.cb[string](this)); return $.toggleClass(this, 'embedded'); }, embed: function(a) { @@ -4520,7 +4523,6 @@ el = (type = Linkify.types[a.dataset.key]).el.call(a); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; - a.textContent = '(unembed)'; return el; }, unembed: function(a) { @@ -4533,7 +4535,6 @@ href: a.dataset.href, innerHTML: a.dataset.title || a.dataset.nodedata }); - a.textContent = '(embed)'; $.addClass(el, a.dataset.key); return el; }, diff --git a/builds/crx/script.js b/builds/crx/script.js index d2295bea6..c74ca4489 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4340,21 +4340,22 @@ }); }, node: function() { - var data, embedder, i, len, node, range, snapshot, _i, _j, _len, _len1, _ref, _ref1; + var data, el, i, items, node, range, snapshot, _i, _len, _ref; - if (this.isClone && Conf['Embedding']) { - _ref = $$('.embedder', this.nodes.comment); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - embedder = _ref[_i]; - $.on(embedder, "click", Linkify.cb.toggle); + if (this.isClone) { + if (Conf['Embedding']) { + i = 0; + items = $$('.embedded', this.nodes.comment); + while (el = items[i++]) { + $.on(el, "click", Linkify.cb.toggle); + Linkify.cb.toggle.call(el); + } } return; } snapshot = $.X('.//text()', this.nodes.comment); - i = -1; - len = snapshot.snapshotLength; - while (++i < len) { - node = snapshot.snapshotItem(i); + i = 0; + while (node = snapshot.snapshotItem(i++)) { if (node.parentElement.nodeName === "A") { continue; } @@ -4367,9 +4368,9 @@ if (!(Conf['Embedding'] || Conf['Link Title'])) { return; } - _ref1 = this.nodes.links; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - range = _ref1[_j]; + _ref = this.nodes.links; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + range = _ref[_i]; if (data = Linkify.services(range)) { if (Conf['Embedding']) { Linkify.embed(data); @@ -4478,6 +4479,9 @@ $.addClass(link, "" + embed.dataset.key); $.on(embed, 'click', Linkify.cb.toggle); $.after(link, [$.tn(' '), embed]); + if (Conf['Auto-embed']) { + Linkify.cb.toggle.call(embed); + } }, title: function(data) { var err, key, link, options, service, title, titles, uid; @@ -4513,11 +4517,10 @@ }, cb: { toggle: function() { - var el, embed; + var string, _ref; - embed = this.previousElementSibling; - el = !this.className.contains("embedded") ? Linkify.cb.embed(this) : Linkify.cb.unembed(this); - $.replace(embed, el); + _ref = $.hasClass(this, "embedded") ? ['unembed', '(embed)'] : ['embed', '(unembed)'], string = _ref[0], this.textContent = _ref[1]; + $.replace(this.previousElementSibling, Linkify.cb[string](this)); return $.toggleClass(this, 'embedded'); }, embed: function(a) { @@ -4525,7 +4528,6 @@ el = (type = Linkify.types[a.dataset.key]).el.call(a); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; - a.textContent = '(unembed)'; return el; }, unembed: function(a) { @@ -4538,7 +4540,6 @@ href: a.dataset.href, innerHTML: a.dataset.title || a.dataset.nodedata }); - a.textContent = '(embed)'; $.addClass(el, a.dataset.key); return el; }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 25742786e..9f4a7eaf2 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -33,20 +33,22 @@ Linkify = cb: @node node: -> - if @isClone and Conf['Embedding'] - for embedder in $$ '.embedder', @nodes.comment - $.on embedder, "click", Linkify.cb.toggle + if @isClone + if Conf['Embedding'] + i = 0 + items = $$ '.embedded', @nodes.comment + while el = items[i++] + $.on el, "click", Linkify.cb.toggle + Linkify.cb.toggle.call el + return snapshot = $.X './/text()', @nodes.comment - i = -1 - len = snapshot.snapshotLength + i = 0 + while node = snapshot.snapshotItem i++ - while ++i < len - node = snapshot.snapshotItem i - continue if node.parentElement.nodeName is "A" - + data = node.data if Linkify.regString.test data @@ -146,13 +148,17 @@ Linkify = for name, value of {key, href, uid, options} embed.dataset[name] = value - + embed.dataset.nodedata = link.innerHTML $.addClass link, "#{embed.dataset.key}" $.on embed, 'click', Linkify.cb.toggle $.after link, [$.tn(' '), embed] + + if Conf['Auto-embed'] + Linkify.cb.toggle.call embed + return title: (data) -> @@ -179,16 +185,11 @@ Linkify = cb: toggle: -> - # We setup the link to be replaced by the embedded video - embed = @previousElementSibling - - # Unembed. - el = unless @className.contains "embedded" - Linkify.cb.embed @ + [string, @textContent] = if $.hasClass @, "embedded" + ['unembed', '(embed)'] else - Linkify.cb.unembed @ - - $.replace embed, el + ['embed', '(unembed)'] + $.replace @previousElementSibling, Linkify.cb[string] @ $.toggleClass @, 'embedded' embed: (a) -> @@ -201,8 +202,6 @@ Linkify = else "border: 0; width: 640px; height: 390px" - a.textContent = '(unembed)' - return el unembed: (a) -> @@ -214,7 +213,6 @@ Linkify = href: a.dataset.href innerHTML: a.dataset.title or a.dataset.nodedata - a.textContent = '(embed)' $.addClass el, a.dataset.key return el From 463d6607f6a4f000b751176bdd5a679f5b40a3c4 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 21:14:47 -0700 Subject: [PATCH 3/8] My recent preference of while loops is because of _len --- builds/4chan-X.user.js | 8 ++++---- builds/crx/script.js | 8 ++++---- src/Linkification/Linkify.coffee | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b9e7014aa..9afb4a7e5 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4335,7 +4335,7 @@ }); }, node: function() { - var data, el, i, items, node, range, snapshot, _i, _len, _ref; + var data, el, i, items, node, range, snapshot; if (this.isClone) { if (Conf['Embedding']) { @@ -4363,9 +4363,9 @@ if (!(Conf['Embedding'] || Conf['Link Title'])) { return; } - _ref = this.nodes.links; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - range = _ref[_i]; + items = this.nodes.links; + i = 0; + while (range = items[i++]) { if (data = Linkify.services(range)) { if (Conf['Embedding']) { Linkify.embed(data); diff --git a/builds/crx/script.js b/builds/crx/script.js index c74ca4489..5ef176a20 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4340,7 +4340,7 @@ }); }, node: function() { - var data, el, i, items, node, range, snapshot, _i, _len, _ref; + var data, el, i, items, node, range, snapshot; if (this.isClone) { if (Conf['Embedding']) { @@ -4368,9 +4368,9 @@ if (!(Conf['Embedding'] || Conf['Link Title'])) { return; } - _ref = this.nodes.links; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - range = _ref[_i]; + items = this.nodes.links; + i = 0; + while (range = items[i++]) { if (data = Linkify.services(range)) { if (Conf['Embedding']) { Linkify.embed(data); diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 9f4a7eaf2..963a70d7f 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -57,7 +57,10 @@ Linkify = return unless Conf['Embedding'] or Conf['Link Title'] - for range in @nodes.links + items = @nodes.links + i = 0 + + while range = items[i++] if data = Linkify.services range Linkify.embed data if Conf['Embedding'] Linkify.title data if Conf['Link Title'] From 1c4f4cea241bae2dac3772cb4f84f94488f2f0e3 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 21:54:14 -0700 Subject: [PATCH 4/8] Fix some conflicts with auto-embed and link title Also, less `Function.call(this)` --- builds/4chan-X.user.js | 128 ++++++++++++++++--------------- builds/crx/script.js | 128 ++++++++++++++++--------------- src/Linkification/Linkify.coffee | 96 ++++++++++++----------- 3 files changed, 186 insertions(+), 166 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 9afb4a7e5..52583ed31 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4477,28 +4477,33 @@ if (Conf['Auto-embed']) { Linkify.cb.toggle.call(embed); } + data.push(embed); }, title: function(data) { - var err, key, link, options, service, title, titles, uid; + var embed, err, key, link, options, service, title, titles, uid; - key = data[0], uid = data[1], options = data[2], link = data[3]; + key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4]; if (!(service = Linkify.types[key].title)) { return; } titles = Conf['CachedTitles']; if (title = titles[uid]) { - link.textContent = title[0]; + if (link) { + link.textContent = title[0]; + } if (Conf['Embedding']) { - return link.nextElementSibling.dataset.title = title[0]; + return embed.dataset.title = title[0]; } } else { try { $.cache(service.api(uid), function() { - return title = Linkify.cb.title.apply(this, [data]); + return title = Linkify.cb.title(this, data); }); } catch (_error) { err = _error; - link.innerHTML = "[" + key + "] Title Link Blocked (are you using NoScript?)"; + if (link) { + link.innerHTML = "[" + key + "] Title Link Blocked (are you using NoScript?)"; + } return; } if (title) { @@ -4521,7 +4526,7 @@ embed: function(a) { var el, style, type; - el = (type = Linkify.types[a.dataset.key]).el.call(a); + el = (type = Linkify.types[a.dataset.key]).el(a); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; return el; }, @@ -4538,58 +4543,61 @@ $.addClass(el, a.dataset.key); return el; }, - title: function(data) { - var key, link, options, service, text, uid; + title: function(response, data) { + var embed, key, link, options, service, text, uid; - key = data[0], uid = data[1], options = data[2], link = data[3]; + key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4]; service = Linkify.types[key].title; - return link.textContent = (function() { - switch (this.status) { - case 200: - case 304: - text = "" + (service.text.call(this)); - if (Conf['Embedding']) { - link.nextElementSibling.dataset.title = text; - } - return text; - case 404: - return "[" + key + "] Not Found"; - case 403: - return "[" + key + "] Forbidden or Private"; - default: - return "[" + key + "] " + this.status + "'d"; - } - }).call(this); + switch (response.status) { + case 200: + case 304: + text = "" + (service.text(JSON.parse(response.responseText))); + if (Conf['Embedding']) { + embed.dataset.title = text; + } + break; + case 404: + text = "[" + key + "] Not Found"; + break; + case 403: + text = "[" + key + "] Forbidden or Private"; + break; + default: + text = "[" + key + "] " + this.status + "'d"; + } + if (link) { + return link.textContent = text; + } } }, types: { audio: { regExp: /(.*\.(mp3|ogg|wav))$/, - el: function() { + el: function(a) { return $.el('audio', { controls: 'controls', preload: 'auto', - src: this.dataset.uid + src: a.dataset.uid }); } }, gist: { regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, - el: function() { + el: function(a) { var div; return div = $.el('iframe', { - src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js" + src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js" }); }, title: { api: function(uid) { return "https://api.github.com/gists/" + uid; }, - text: function() { + text: function(data) { var file, response; - response = JSON.parse(this.responseText).files; + response = data.files; for (file in response) { if (response.hasOwnProperty(file)) { return file; @@ -4601,49 +4609,49 @@ image: { regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, style: 'border: 0; width: auto; height: auto;', - el: function() { + el: function(a) { return $.el('div', { - innerHTML: "" + innerHTML: "" }); } }, InstallGentoo: { regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid + src: "http://paste.installgentoo.com/view/embed/" + a.dataset.uid }); } }, LiveLeak: { regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, - el: function() { + el: function(a) { return $.el('object', { - innerHTML: "" + innerHTML: "" }); } }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, - el: function() { + el: function(a) { var div; return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid + src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid }); } }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, style: 'height: auto; width: 500px; display: inline-block;', - el: function() { + el: function(a) { var div; div = $.el('div', { className: "soundcloud", name: "soundcloud" }); - $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, { + $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, { div: div, onloadend: function() { return this.div.innerHTML = JSON.parse(this.responseText).html; @@ -4655,25 +4663,25 @@ api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; }, - text: function() { - return JSON.parse(this.responseText).title; + text: function(data) { + return data.title; } } }, TwitchTV: { regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/, style: "border: none; width: 640px; height: 360px;", - el: function() { + el: function(a) { var channel, chapter, result, _; - if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.dataset.uid)) { + if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) { _ = result[0], channel = result[1], chapter = result[2]; return $.el('object', { data: 'http://www.twitch.tv/widgets/archive_embed_player.swf', innerHTML: "\n" }); } else { - channel = (/(\w+)/.exec(this.dataset.uid))[0]; + channel = (/(\w+)/.exec(a.dataset.uid))[0]; return $.el('object', { data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel, innerHTML: "\n\n" @@ -4684,50 +4692,50 @@ Vocaroo: { regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, style: 'border: 0; width: 150px; height: 45px;', - el: function() { + el: function(a) { return $.el('object', { - innerHTML: "" + innerHTML: "" }); } }, Vimeo: { regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque" + src: "//player.vimeo.com/video/" + a.dataset.uid + "?wmode=opaque" }); }, title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, - text: function() { - return JSON.parse(this.responseText).title; + text: function(data) { + return data.title; } } }, Vine: { regExp: /.*(?:vine.co\/)([^#\&\?]*).*/, style: 'border: none; width: 500px; height: 500px;', - el: function() { + el: function(a) { return $.el('iframe', { - src: "https://vine.co/" + this.dataset.uid + "/card" + src: "https://vine.co/" + a.dataset.uid + "/card" }); } }, YouTube: { regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque" + src: "//www.youtube.com/embed/" + a.dataset.uid + (a.dataset.option ? '#' + a.dataset.option : '') + "?wmode=opaque" }); }, title: { api: function(uid) { return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; }, - text: function() { - return JSON.parse(this.responseText).entry.title.$t; + text: function(data) { + return data.entry.title.$t; } } } diff --git a/builds/crx/script.js b/builds/crx/script.js index 5ef176a20..da265f148 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4482,28 +4482,33 @@ if (Conf['Auto-embed']) { Linkify.cb.toggle.call(embed); } + data.push(embed); }, title: function(data) { - var err, key, link, options, service, title, titles, uid; + var embed, err, key, link, options, service, title, titles, uid; - key = data[0], uid = data[1], options = data[2], link = data[3]; + key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4]; if (!(service = Linkify.types[key].title)) { return; } titles = Conf['CachedTitles']; if (title = titles[uid]) { - link.textContent = title[0]; + if (link) { + link.textContent = title[0]; + } if (Conf['Embedding']) { - return link.nextElementSibling.dataset.title = title[0]; + return embed.dataset.title = title[0]; } } else { try { $.cache(service.api(uid), function() { - return title = Linkify.cb.title.apply(this, [data]); + return title = Linkify.cb.title(this, data); }); } catch (_error) { err = _error; - link.innerHTML = "[" + key + "] Title Link Blocked (are you using NoScript?)"; + if (link) { + link.innerHTML = "[" + key + "] Title Link Blocked (are you using NoScript?)"; + } return; } if (title) { @@ -4526,7 +4531,7 @@ embed: function(a) { var el, style, type; - el = (type = Linkify.types[a.dataset.key]).el.call(a); + el = (type = Linkify.types[a.dataset.key]).el(a); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; return el; }, @@ -4543,58 +4548,61 @@ $.addClass(el, a.dataset.key); return el; }, - title: function(data) { - var key, link, options, service, text, uid; + title: function(response, data) { + var embed, key, link, options, service, text, uid; - key = data[0], uid = data[1], options = data[2], link = data[3]; + key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4]; service = Linkify.types[key].title; - return link.textContent = (function() { - switch (this.status) { - case 200: - case 304: - text = "" + (service.text.call(this)); - if (Conf['Embedding']) { - link.nextElementSibling.dataset.title = text; - } - return text; - case 404: - return "[" + key + "] Not Found"; - case 403: - return "[" + key + "] Forbidden or Private"; - default: - return "[" + key + "] " + this.status + "'d"; - } - }).call(this); + switch (response.status) { + case 200: + case 304: + text = "" + (service.text(JSON.parse(response.responseText))); + if (Conf['Embedding']) { + embed.dataset.title = text; + } + break; + case 404: + text = "[" + key + "] Not Found"; + break; + case 403: + text = "[" + key + "] Forbidden or Private"; + break; + default: + text = "[" + key + "] " + this.status + "'d"; + } + if (link) { + return link.textContent = text; + } } }, types: { audio: { regExp: /(.*\.(mp3|ogg|wav))$/, - el: function() { + el: function(a) { return $.el('audio', { controls: 'controls', preload: 'auto', - src: this.dataset.uid + src: a.dataset.uid }); } }, gist: { regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, - el: function() { + el: function(a) { var div; return div = $.el('iframe', { - src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js" + src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js" }); }, title: { api: function(uid) { return "https://api.github.com/gists/" + uid; }, - text: function() { + text: function(data) { var file, response; - response = JSON.parse(this.responseText).files; + response = data.files; for (file in response) { if (response.hasOwnProperty(file)) { return file; @@ -4606,49 +4614,49 @@ image: { regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, style: 'border: 0; width: auto; height: auto;', - el: function() { + el: function(a) { return $.el('div', { - innerHTML: "" + innerHTML: "" }); } }, InstallGentoo: { regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid + src: "http://paste.installgentoo.com/view/embed/" + a.dataset.uid }); } }, LiveLeak: { regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, - el: function() { + el: function(a) { return $.el('object', { - innerHTML: "" + innerHTML: "" }); } }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, - el: function() { + el: function(a) { var div; return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid + src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid }); } }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, style: 'height: auto; width: 500px; display: inline-block;', - el: function() { + el: function(a) { var div; div = $.el('div', { className: "soundcloud", name: "soundcloud" }); - $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, { + $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, { div: div, onloadend: function() { return this.div.innerHTML = JSON.parse(this.responseText).html; @@ -4660,25 +4668,25 @@ api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; }, - text: function() { - return JSON.parse(this.responseText).title; + text: function(data) { + return data.title; } } }, TwitchTV: { regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/, style: "border: none; width: 640px; height: 360px;", - el: function() { + el: function(a) { var channel, chapter, result, _; - if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.dataset.uid)) { + if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) { _ = result[0], channel = result[1], chapter = result[2]; return $.el('object', { data: 'http://www.twitch.tv/widgets/archive_embed_player.swf', innerHTML: "\n" }); } else { - channel = (/(\w+)/.exec(this.dataset.uid))[0]; + channel = (/(\w+)/.exec(a.dataset.uid))[0]; return $.el('object', { data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel, innerHTML: "\n\n" @@ -4689,50 +4697,50 @@ Vocaroo: { regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, style: 'border: 0; width: 150px; height: 45px;', - el: function() { + el: function(a) { return $.el('object', { - innerHTML: "" + innerHTML: "" }); } }, Vimeo: { regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque" + src: "//player.vimeo.com/video/" + a.dataset.uid + "?wmode=opaque" }); }, title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, - text: function() { - return JSON.parse(this.responseText).title; + text: function(data) { + return data.title; } } }, Vine: { regExp: /.*(?:vine.co\/)([^#\&\?]*).*/, style: 'border: none; width: 500px; height: 500px;', - el: function() { + el: function(a) { return $.el('iframe', { - src: "https://vine.co/" + this.dataset.uid + "/card" + src: "https://vine.co/" + a.dataset.uid + "/card" }); } }, YouTube: { regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, - el: function() { + el: function(a) { return $.el('iframe', { - src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque" + src: "//www.youtube.com/embed/" + a.dataset.uid + (a.dataset.option ? '#' + a.dataset.option : '') + "?wmode=opaque" }); }, title: { api: function(uid) { return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; }, - text: function() { - return JSON.parse(this.responseText).entry.title.$t; + text: function(data) { + return data.entry.title.$t; } } } diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 963a70d7f..acef93011 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -59,7 +59,6 @@ Linkify = items = @nodes.links i = 0 - while range = items[i++] if data = Linkify.services range Linkify.embed data if Conf['Embedding'] @@ -162,22 +161,27 @@ Linkify = if Conf['Auto-embed'] Linkify.cb.toggle.call embed + data.push embed + return title: (data) -> - [key, uid, options, link] = data + [key, uid, options, link, embed] = data return unless service = Linkify.types[key].title titles = Conf['CachedTitles'] if title = titles[uid] - link.textContent = title[0] + # Auto-embed may destroy our links. + if link + link.textContent = title[0] if Conf['Embedding'] - link.nextElementSibling.dataset.title = title[0] + embed.dataset.title = title[0] else try $.cache service.api(uid), -> - title = Linkify.cb.title.apply @, [data] + title = Linkify.cb.title @, data catch err - link.innerHTML = "[#{key}] Title Link Blocked (are you using NoScript?)" + if link + link.innerHTML = "[#{key}] Title Link Blocked (are you using NoScript?)" return if title titles[uid] = [title, Date.now()] @@ -197,7 +201,7 @@ Linkify = embed: (a) -> # We create an element to embed - el = (type = Linkify.types[a.dataset.key]).el.call a + el = (type = Linkify.types[a.dataset.key]).el a # Set style values. el.style.cssText = if style = type.style @@ -220,77 +224,77 @@ Linkify = return el - title: (data) -> - [key, uid, options, link] = data + title: (response, data) -> + [key, uid, options, link, embed] = data service = Linkify.types[key].title - link.textContent = switch @status + switch response.status when 200, 304 - text = "#{service.text.call @}" + text = "#{service.text JSON.parse response.responseText}" if Conf['Embedding'] - link.nextElementSibling.dataset.title = text - text + embed.dataset.title = text when 404 - "[#{key}] Not Found" + text = "[#{key}] Not Found" when 403 - "[#{key}] Forbidden or Private" + text = "[#{key}] Forbidden or Private" else - "[#{key}] #{@status}'d" + text = "[#{key}] #{@status}'d" + link.textContent = text if link types: audio: regExp: /(.*\.(mp3|ogg|wav))$/ - el: -> + el: (a) -> $.el 'audio', controls: 'controls' preload: 'auto' - src: @dataset.uid + src: a.dataset.uid gist: regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/ - el: -> + el: (a) -> div = $.el 'iframe', # Github doesn't allow embedding straight from the site, so we use an external site to bypass that. - src: "http://www.purplegene.com/script?url=https://gist.github.com/#{@dataset.uid}.js" + src: "http://www.purplegene.com/script?url=https://gist.github.com/#{a.dataset.uid}.js" title: api: (uid) -> "https://api.github.com/gists/#{uid}" - text: -> - response = JSON.parse(@responseText).files + text: (data) -> + response = data.files return file for file of response when response.hasOwnProperty file image: regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ style: 'border: 0; width: auto; height: auto;' - el: -> + el: (a) -> $.el 'div', - innerHTML: "" + innerHTML: "" InstallGentoo: regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/ - el: -> + el: (a) -> $.el 'iframe', - src: "http://paste.installgentoo.com/view/embed/#{@dataset.uid}" + src: "http://paste.installgentoo.com/view/embed/#{a.dataset.uid}" LiveLeak: regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/ - el: -> + el: (a) -> $.el 'object', - innerHTML: "" + innerHTML: "" pastebin: regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/ - el: -> + el: (a) -> div = $.el 'iframe', - src: "http://pastebin.com/embed_iframe.php?i=#{@dataset.uid}" + src: "http://pastebin.com/embed_iframe.php?i=#{a.dataset.uid}" SoundCloud: regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/ style: 'height: auto; width: 500px; display: inline-block;' - el: -> + el: (a) -> div = $.el 'div', className: "soundcloud" name: "soundcloud" $.ajax( - "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@dataset.uid}" + "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{a.dataset.uid}" div: div onloadend: -> @div.innerHTML = JSON.parse(@responseText).html @@ -298,13 +302,13 @@ Linkify = div title: api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}" - text: -> JSON.parse(@responseText).title + text: (data) -> data.title TwitchTV: regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/ style: "border: none; width: 640px; height: 360px;" - el: -> - if result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec @dataset.uid + el: (a) -> + if result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec a.dataset.uid [_, channel, chapter] = result $.el 'object', @@ -315,7 +319,7 @@ Linkify = """ else - channel = (/(\w+)/.exec @dataset.uid)[0] + channel = (/(\w+)/.exec a.dataset.uid)[0] $.el 'object', data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=#{channel}" @@ -328,31 +332,31 @@ Linkify = Vocaroo: regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/ style: 'border: 0; width: 150px; height: 45px;' - el: -> + el: (a) -> $.el 'object', - innerHTML: "" + innerHTML: "" Vimeo: regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/ - el: -> + el: (a) -> $.el 'iframe', - src: "//player.vimeo.com/video/#{@dataset.uid}?wmode=opaque" + src: "//player.vimeo.com/video/#{a.dataset.uid}?wmode=opaque" title: api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" - text: -> JSON.parse(@responseText).title + text: (data) -> data.title Vine: regExp: /.*(?:vine.co\/)([^#\&\?]*).*/ style: 'border: none; width: 500px; height: 500px;' - el: -> + el: (a) -> $.el 'iframe', - src: "https://vine.co/#{@dataset.uid}/card" + src: "https://vine.co/#{a.dataset.uid}/card" YouTube: regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/ - el: -> + el: (a) -> $.el 'iframe', - src: "//www.youtube.com/embed/#{@dataset.uid}#{if @dataset.option then '#' + @dataset.option else ''}?wmode=opaque" + src: "//www.youtube.com/embed/#{a.dataset.uid}#{if a.dataset.option then '#' + a.dataset.option else ''}?wmode=opaque" title: api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode" - text: -> JSON.parse(@responseText).entry.title.$t \ No newline at end of file + text: (data) -> data.entry.title.$t \ No newline at end of file From 3384c1b362a919bb5c6ada4a4cdb304a984f298c Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 22:03:04 -0700 Subject: [PATCH 5/8] Unneeded. --- builds/4chan-X.user.js | 3 +-- builds/crx/script.js | 3 +-- src/Linkification/Linkify.coffee | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 52583ed31..5c81fea31 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4652,9 +4652,8 @@ name: "soundcloud" }); $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, { - div: div, onloadend: function() { - return this.div.innerHTML = JSON.parse(this.responseText).html; + return div.innerHTML = JSON.parse(this.responseText).html; } }, false); return div; diff --git a/builds/crx/script.js b/builds/crx/script.js index da265f148..78397cd07 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4657,9 +4657,8 @@ name: "soundcloud" }); $.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, { - div: div, onloadend: function() { - return this.div.innerHTML = JSON.parse(this.responseText).html; + return div.innerHTML = JSON.parse(this.responseText).html; } }, false); return div; diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index acef93011..109ff8d8b 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -295,9 +295,8 @@ Linkify = name: "soundcloud" $.ajax( "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{a.dataset.uid}" - div: div onloadend: -> - @div.innerHTML = JSON.parse(@responseText).html + div.innerHTML = JSON.parse(@responseText).html false) div title: From c325b9eeda1837dfa363b2c8a281b7604a1716f5 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 22:07:21 -0700 Subject: [PATCH 6/8] Let's just add some CoffeeScript flavor where possible <3 --- builds/4chan-X.user.js | 24 +++++++++++++++--------- builds/crx/script.js | 24 +++++++++++++++--------- src/Linkification/Linkify.coffee | 9 ++++----- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 5c81fea31..b9b1f506a 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4594,12 +4594,12 @@ api: function(uid) { return "https://api.github.com/gists/" + uid; }, - text: function(data) { - var file, response; + text: function(_arg) { + var file, files; - response = data.files; - for (file in response) { - if (response.hasOwnProperty(file)) { + files = _arg.files; + for (file in files) { + if (files.hasOwnProperty(file)) { return file; } } @@ -4662,8 +4662,11 @@ api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; }, - text: function(data) { - return data.title; + text: function(_arg) { + var title; + + title = _arg.title; + return title; } } }, @@ -4708,8 +4711,11 @@ api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, - text: function(data) { - return data.title; + text: function(_arg) { + var title; + + title = _arg.title; + return title; } } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 78397cd07..bdff208f6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4599,12 +4599,12 @@ api: function(uid) { return "https://api.github.com/gists/" + uid; }, - text: function(data) { - var file, response; + text: function(_arg) { + var file, files; - response = data.files; - for (file in response) { - if (response.hasOwnProperty(file)) { + files = _arg.files; + for (file in files) { + if (files.hasOwnProperty(file)) { return file; } } @@ -4667,8 +4667,11 @@ api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; }, - text: function(data) { - return data.title; + text: function(_arg) { + var title; + + title = _arg.title; + return title; } } }, @@ -4713,8 +4716,11 @@ api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, - text: function(data) { - return data.title; + text: function(_arg) { + var title; + + title = _arg.title; + return title; } } }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 109ff8d8b..1ede82f6b 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -257,9 +257,8 @@ Linkify = src: "http://www.purplegene.com/script?url=https://gist.github.com/#{a.dataset.uid}.js" title: api: (uid) -> "https://api.github.com/gists/#{uid}" - text: (data) -> - response = data.files - return file for file of response when response.hasOwnProperty file + text: ({files}) -> + return file for file of files when files.hasOwnProperty file image: regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ @@ -301,7 +300,7 @@ Linkify = div title: api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}" - text: (data) -> data.title + text: ({title}) -> title TwitchTV: regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/ @@ -342,7 +341,7 @@ Linkify = src: "//player.vimeo.com/video/#{a.dataset.uid}?wmode=opaque" title: api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" - text: (data) -> data.title + text: ({title}) -> title Vine: regExp: /.*(?:vine.co\/)([^#\&\?]*).*/ From 14d9bbaeff4acf9d039c1a0937a6df77218dda0a Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 22:13:13 -0700 Subject: [PATCH 7/8] We're allowed to be funny. --- builds/4chan-X.user.js | 18 ++++++------------ builds/crx/script.js | 18 ++++++------------ src/Linkification/Linkify.coffee | 3 +-- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b9b1f506a..feb77829d 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4327,6 +4327,12 @@ ExpandComment.callbacks.push(this.node); } if (Conf['Title Link']) { + this.types.Vimeo.api.text = this.types.SoundCould.api.text = function(_arg) { + var title; + + title = _arg.title; + return title; + }; $.sync('CachedTitles', Linkify.titleSync); } return Post.prototype.callbacks.push({ @@ -4661,12 +4667,6 @@ title: { api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; - }, - text: function(_arg) { - var title; - - title = _arg.title; - return title; } } }, @@ -4710,12 +4710,6 @@ title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; - }, - text: function(_arg) { - var title; - - title = _arg.title; - return title; } } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index bdff208f6..aa7abc0da 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4332,6 +4332,12 @@ ExpandComment.callbacks.push(this.node); } if (Conf['Title Link']) { + this.types.Vimeo.api.text = this.types.SoundCould.api.text = function(_arg) { + var title; + + title = _arg.title; + return title; + }; $.sync('CachedTitles', Linkify.titleSync); } return Post.prototype.callbacks.push({ @@ -4666,12 +4672,6 @@ title: { api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; - }, - text: function(_arg) { - var title; - - title = _arg.title; - return title; } } }, @@ -4715,12 +4715,6 @@ title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; - }, - text: function(_arg) { - var title; - - title = _arg.title; - return title; } } }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 1ede82f6b..b18037368 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -26,6 +26,7 @@ Linkify = ExpandComment.callbacks.push @node if Conf['Title Link'] + @types.Vimeo.api.text = @types.SoundCould.api.text = ({title}) -> title $.sync 'CachedTitles', Linkify.titleSync Post::callbacks.push @@ -300,7 +301,6 @@ Linkify = div title: api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}" - text: ({title}) -> title TwitchTV: regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/ @@ -341,7 +341,6 @@ Linkify = src: "//player.vimeo.com/video/#{a.dataset.uid}?wmode=opaque" title: api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" - text: ({title}) -> title Vine: regExp: /.*(?:vine.co\/)([^#\&\?]*).*/ From 2234d9141f846f6643d756ddd25ecf22b75b2c39 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 23:47:56 -0700 Subject: [PATCH 8/8] I don't like it. --- builds/4chan-X.user.js | 12 ++++++------ builds/crx/script.js | 12 ++++++------ src/Linkification/Linkify.coffee | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index feb77829d..159f0fbb0 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4327,12 +4327,6 @@ ExpandComment.callbacks.push(this.node); } if (Conf['Title Link']) { - this.types.Vimeo.api.text = this.types.SoundCould.api.text = function(_arg) { - var title; - - title = _arg.title; - return title; - }; $.sync('CachedTitles', Linkify.titleSync); } return Post.prototype.callbacks.push({ @@ -4667,6 +4661,9 @@ title: { api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; + }, + text: function(_) { + return _.title; } } }, @@ -4710,6 +4707,9 @@ title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; + }, + text: function(_) { + return _.title; } } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index aa7abc0da..d191b5e49 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4332,12 +4332,6 @@ ExpandComment.callbacks.push(this.node); } if (Conf['Title Link']) { - this.types.Vimeo.api.text = this.types.SoundCould.api.text = function(_arg) { - var title; - - title = _arg.title; - return title; - }; $.sync('CachedTitles', Linkify.titleSync); } return Post.prototype.callbacks.push({ @@ -4672,6 +4666,9 @@ title: { api: function(uid) { return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid; + }, + text: function(_) { + return _.title; } } }, @@ -4715,6 +4712,9 @@ title: { api: function(uid) { return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; + }, + text: function(_) { + return _.title; } } }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index b18037368..b2151e945 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -26,7 +26,6 @@ Linkify = ExpandComment.callbacks.push @node if Conf['Title Link'] - @types.Vimeo.api.text = @types.SoundCould.api.text = ({title}) -> title $.sync 'CachedTitles', Linkify.titleSync Post::callbacks.push @@ -301,6 +300,7 @@ Linkify = div title: api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}" + text: (_) -> _.title TwitchTV: regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/ @@ -341,6 +341,7 @@ Linkify = src: "//player.vimeo.com/video/#{a.dataset.uid}?wmode=opaque" title: api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" + text: (_) -> _.title Vine: regExp: /.*(?:vine.co\/)([^#\&\?]*).*/