From bbc8899cf19e6fc63a72e3b826f5c143500c5a6b Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 30 Mar 2014 18:24:42 -0700 Subject: [PATCH] Lets just build that so that we don't have to do so many logic checks --- builds/4chan-X.user.js | 15 ++++----------- builds/crx/script.js | 15 ++++----------- src/Linkification/Linkify.coffee | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 2e88dfa75..8e58d25f6 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -8494,6 +8494,9 @@ if (Conf['Comment Expansion']) { ExpandComment.callbacks.push(this.node); } + if (Conf['Embedding'] || Conf['Link Title']) { + this.embedProcess = Function('link', "var data = this.services(link); if (data) { " + ((Conf['Embedding'] ? 'this.embed(data);\n' : '') + (Conf['Title Link'] ? 'this.title(data);' : '')) + " }"); + } return Post.callbacks.push({ name: 'Linkify', cb: this.node @@ -8563,17 +8566,7 @@ Linkify.embedProcess(Linkify.makeLink(link, this)); } }, - embedProcess: function(link) { - var data; - if (data = Linkify.services(link)) { - if (Conf['Embedding']) { - Linkify.embed(data); - } - if (Conf['Link Title']) { - return Linkify.title(data); - } - } - }, + embedProcess: function() {}, regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})([:\/]|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, makeRange: function(startNode, endNode, startOffset, endOffset) { var range; diff --git a/builds/crx/script.js b/builds/crx/script.js index 9ad18c9e4..ed5b198c7 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -8511,6 +8511,9 @@ if (Conf['Comment Expansion']) { ExpandComment.callbacks.push(this.node); } + if (Conf['Embedding'] || Conf['Link Title']) { + this.embedProcess = Function('link', "var data = this.services(link); if (data) { " + ((Conf['Embedding'] ? 'this.embed(data);\n' : '') + (Conf['Title Link'] ? 'this.title(data);' : '')) + " }"); + } return Post.callbacks.push({ name: 'Linkify', cb: this.node @@ -8580,17 +8583,7 @@ Linkify.embedProcess(Linkify.makeLink(link, this)); } }, - embedProcess: function(link) { - var data; - if (data = Linkify.services(link)) { - if (Conf['Embedding']) { - Linkify.embed(data); - } - if (Conf['Link Title']) { - return Linkify.title(data); - } - } - }, + embedProcess: function() {}, regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})([:\/]|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, makeRange: function(startNode, endNode, startOffset, endOffset) { var range; diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 3b92d062f..95cd2f03a 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -5,6 +5,17 @@ Linkify = if Conf['Comment Expansion'] ExpandComment.callbacks.push @node + if Conf['Embedding'] or Conf['Link Title'] + @embedProcess = Function 'link', + "var data = this.services(link); + if (data) { + #{ + (if Conf['Embedding'] then 'this.embed(data);\n' else '') + + if Conf['Title Link'] then 'this.title(data);' else '' + } + } + " + Post.callbacks.push name: 'Linkify' cb: @node @@ -63,10 +74,7 @@ Linkify = Linkify.embedProcess Linkify.makeLink link, @ return - embedProcess: (link) -> - if data = Linkify.services link - Linkify.embed data if Conf['Embedding'] - Linkify.title data if Conf['Link Title'] + embedProcess: -> return regString: ///( # http, magnet, ftp, etc