diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index bea416866..db60047f5 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -4328,6 +4328,9 @@
len = snapshot.snapshotLength;
while (++i < len) {
node = snapshot.snapshotItem(i);
+ if (node.parentElement.nodeName === "A") {
+ continue;
+ }
data = node.data;
if (Linkify.regString.test(data)) {
Linkify.regString.lastIndex = 0;
@@ -4360,7 +4363,7 @@
index = match.index;
link = match[0];
len2 = index + link.length;
- if (len - len2 === 0) {
+ if (len === len2) {
break;
}
range = document.createRange();
@@ -4393,10 +4396,7 @@
}
}
if (range.collapsed) {
- if (node.nodeName === 'WBR') {
- node = node.previousSibling;
- }
- range.setEnd(node, node.length);
+ range.setEndAfter(node);
}
return Linkify.makeLink(range, post);
},
@@ -4637,6 +4637,27 @@
}
}
},
+ TwitchTV: {
+ regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
+ style: "border: none; width: 640px; height: 360px;",
+ el: function() {
+ var channel, chapter, result, _;
+
+ if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.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];
+ return $.el('object', {
+ data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
+ innerHTML: "\n\n"
+ });
+ }
+ }
+ },
Vocaroo: {
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
style: 'border: 0; width: 150px; height: 45px;',
diff --git a/builds/crx/script.js b/builds/crx/script.js
index a41e296df..aee40189e 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -4333,6 +4333,9 @@
len = snapshot.snapshotLength;
while (++i < len) {
node = snapshot.snapshotItem(i);
+ if (node.parentElement.nodeName === "A") {
+ continue;
+ }
data = node.data;
if (Linkify.regString.test(data)) {
Linkify.regString.lastIndex = 0;
@@ -4365,7 +4368,7 @@
index = match.index;
link = match[0];
len2 = index + link.length;
- if (len - len2 === 0) {
+ if (len === len2) {
break;
}
range = document.createRange();
@@ -4398,10 +4401,7 @@
}
}
if (range.collapsed) {
- if (node.nodeName === 'WBR') {
- node = node.previousSibling;
- }
- range.setEnd(node, node.length);
+ range.setEndAfter(node);
}
return Linkify.makeLink(range, post);
},
@@ -4642,6 +4642,27 @@
}
}
},
+ TwitchTV: {
+ regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
+ style: "border: none; width: 640px; height: 360px;",
+ el: function() {
+ var channel, chapter, result, _;
+
+ if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.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];
+ return $.el('object', {
+ data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
+ innerHTML: "\n\n"
+ });
+ }
+ }
+ },
Vocaroo: {
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
style: 'border: 0; width: 150px; height: 45px;',
diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee
index 34f46a4f9..ba46a0c58 100644
--- a/src/Linkification/Linkify.coffee
+++ b/src/Linkification/Linkify.coffee
@@ -44,6 +44,9 @@ Linkify =
while ++i < len
node = snapshot.snapshotItem i
+
+ continue if node.parentElement.nodeName is "A"
+
data = node.data
if Linkify.regString.test data
@@ -69,7 +72,7 @@ Linkify =
link = match[0]
len2 = index + link.length
- break if len - len2 is 0
+ break if len is len2
range = document.createRange();
range.setStart node, index
@@ -99,9 +102,7 @@ Linkify =
range.setEnd node, result.index
if range.collapsed
- if node.nodeName is 'WBR'
- node = node.previousSibling
- range.setEnd node, node.length
+ range.setEndAfter node
Linkify.makeLink range, post
@@ -297,19 +298,30 @@ Linkify =
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
-# WIP
-#
-# TwitchTV:
-# regExp: /twitch\.tv\/(\w+)\/(?:b\/)?(\d+)/i
-# style: "border: none; width: 640px; height: 360px;"
-# el: ->
-# [_, channel, archive] = @result
-# el = $.el 'object',
-# data: 'http://www.twitch.tv/widgets/archive_embed_player.swf'
-# innerHTML: """
-#
-#
-#"""
+ TwitchTV:
+ regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/
+ style: "border: none; width: 640px; height: 360px;"
+ el: ->
+ if result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec @dataset.uid
+ [_, channel, chapter] = result
+
+ $.el 'object',
+ data: 'http://www.twitch.tv/widgets/archive_embed_player.swf'
+ innerHTML: """
+
+
+"""
+
+ else
+ channel = (/(\w+)/.exec @dataset.uid)[0]
+
+ $.el 'object',
+ data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=#{channel}"
+ innerHTML: """
+
+
+
+"""
Vocaroo:
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/