Merge branch 'v3'

Conflicts:
	LICENSE
	builds/crx/script.js
This commit is contained in:
Zixaphir 2013-08-12 00:36:07 -07:00
commit 758a0e2e56
5 changed files with 113 additions and 103 deletions

View File

@ -1,5 +1,5 @@
/* /*
* appchan x - Version 2.3.1 - 2013-08-11 * appchan x - Version 2.3.1 - 2013-08-12
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -19,7 +19,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.2.25 - 2013-08-10 * 4chan X - Version 1.2.25 - 2013-08-12
* *
* 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
@ -4375,7 +4375,7 @@
if (g.VIEW === 'catalog' || !Conf['Linkify']) { if (g.VIEW === 'catalog' || !Conf['Linkify']) {
return; return;
} }
this.regString = Conf['Allow False Positives'] ? /(\b([a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi; this.regString = Conf['Allow False Positives'] ? /(\b([-a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[\d]+\.[\d]+\.[\d]+\.[\d]+\/|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi;
if (Conf['Comment Expansion']) { if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node); ExpandComment.callbacks.push(this.node);
} }
@ -4388,7 +4388,7 @@
}); });
}, },
node: function() { node: function() {
var data, el, i, items, node, range, snapshot; var data, el, i, items, links, node, range, snapshot, _i, _len, _ref;
if (this.isClone) { if (this.isClone) {
if (Conf['Embedding']) { if (Conf['Embedding']) {
@ -4403,16 +4403,21 @@
} }
return; return;
} }
snapshot = $.X('.//text()', this.nodes.comment); snapshot = $.X('.//br|.//text()', this.nodes.comment);
i = 0; i = 0;
while (node = snapshot.snapshotItem(i++)) { while (node = snapshot.snapshotItem(i++)) {
if (node.parentElement.nodeName === "A") { if (node.parentElement.nodeName === "A") {
continue; continue;
} }
data = node.data; links = [];
if (Linkify.regString.test(data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(node, this); Linkify.gatherLinks(snapshot, this, node, links, i);
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
this.nodes.links.push(Linkify.makeLink(range, this));
} }
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { if (!(Conf['Embedding'] || Conf['Link Title'])) {
@ -4431,12 +4436,11 @@
} }
} }
}, },
gatherLinks: function(node, post) { gatherLinks: function(snapshot, post, node, links, i) {
var data, index, len, len2, link, links, match, range, _i, _len, _ref; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
len = data.length; len = data.length;
links = [];
while ((match = Linkify.regString.exec(data))) { while ((match = Linkify.regString.exec(data))) {
index = match.index; index = match.index;
link = match[0]; link = match[0];
@ -4451,34 +4455,32 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { if (match) {
Linkify.seek(match, node, post); links.push(Linkify.seek(snapshot, post, node, links, match, i));
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
} }
}, },
seek: function(match, node, post) { seek: function(snapshot, post, node, links, match, i) {
var data, index, link, next, range, result; var data, index, link, next, range, result;
index = match.index;
link = match[0]; link = match[0];
range = document.createRange(); range = document.createRange();
range.setStart(node, index); range.setStart(node, match.index);
while ((next = node.nextSibling) && next.nodeName !== 'BR') { while ((next = snapshot.snapshotItem(i++)) && next.nodeName !== 'BR') {
node = next; node = next;
data = node.data; data = node.data;
if (result = /[\s'"]/.exec(data)) { if (result = /[\s'"]/.exec(data)) {
range.setEnd(node, result.index); index = result.index;
range.setEnd(node, index);
Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, links, i);
return range;
} }
} }
if (range.collapsed) { if (range.collapsed) {
range.setEndAfter(node); range.setEnd(node, node.data.length);
} }
return Linkify.makeLink(range, post); return range;
}, },
makeLink: function(range, post) { makeLink: function(range) {
var a, link; var a, link;
link = range.toString(); link = range.toString();
@ -4489,8 +4491,9 @@
target: '_blank', target: '_blank',
href: link href: link
}); });
range.surroundContents(a); $.add(a, range.extractContents());
post.nodes.links.push(a); range.insertNode(a);
return a;
}, },
services: function(link) { services: function(link) {
var href, key, match, type, _ref; var href, key, match, type, _ref;

View File

@ -18,7 +18,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* appchan x - Version 2.3.1 - 2013-08-11 * appchan x - Version 2.3.1 - 2013-08-12
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -6674,7 +6674,7 @@
if (g.VIEW === 'catalog' || !Conf['Linkify']) { if (g.VIEW === 'catalog' || !Conf['Linkify']) {
return; return;
} }
this.regString = Conf['Allow False Positives'] ? /(\b([a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi; this.regString = Conf['Allow False Positives'] ? /(\b([-a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[\d]+\.[\d]+\.[\d]+\.[\d]+\/|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi;
if (Conf['Comment Expansion']) { if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node); ExpandComment.callbacks.push(this.node);
} }
@ -6687,7 +6687,7 @@
}); });
}, },
node: function() { node: function() {
var data, el, i, items, node, range, snapshot; var data, el, i, items, links, node, range, snapshot, _i, _len, _ref;
if (this.isClone) { if (this.isClone) {
if (Conf['Embedding']) { if (Conf['Embedding']) {
@ -6702,16 +6702,21 @@
} }
return; return;
} }
snapshot = $.X('.//text()', this.nodes.comment); snapshot = $.X('.//br|.//text()', this.nodes.comment);
i = 0; i = 0;
while (node = snapshot.snapshotItem(i++)) { while (node = snapshot.snapshotItem(i++)) {
if (node.parentElement.nodeName === "A") { if (node.parentElement.nodeName === "A") {
continue; continue;
} }
data = node.data; links = [];
if (Linkify.regString.test(data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(node, this); Linkify.gatherLinks(snapshot, this, node, links, i);
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
this.nodes.links.push(Linkify.makeLink(range, this));
} }
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { if (!(Conf['Embedding'] || Conf['Link Title'])) {
@ -6730,12 +6735,11 @@
} }
} }
}, },
gatherLinks: function(node, post) { gatherLinks: function(snapshot, post, node, links, i) {
var data, index, len, len2, link, links, match, range, _i, _len, _ref; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
len = data.length; len = data.length;
links = [];
while ((match = Linkify.regString.exec(data))) { while ((match = Linkify.regString.exec(data))) {
index = match.index; index = match.index;
link = match[0]; link = match[0];
@ -6750,34 +6754,32 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { if (match) {
Linkify.seek(match, node, post); links.push(Linkify.seek(snapshot, post, node, links, match, i));
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
} }
}, },
seek: function(match, node, post) { seek: function(snapshot, post, node, links, match, i) {
var data, index, link, next, range, result; var data, index, link, next, range, result;
index = match.index;
link = match[0]; link = match[0];
range = document.createRange(); range = document.createRange();
range.setStart(node, index); range.setStart(node, match.index);
while ((next = node.nextSibling) && next.nodeName !== 'BR') { while ((next = snapshot.snapshotItem(i++)) && next.nodeName !== 'BR') {
node = next; node = next;
data = node.data; data = node.data;
if (result = /[\s'"]/.exec(data)) { if (result = /[\s'"]/.exec(data)) {
range.setEnd(node, result.index); index = result.index;
range.setEnd(node, index);
Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, links, i);
return range;
} }
} }
if (range.collapsed) { if (range.collapsed) {
range.setEndAfter(node); range.setEnd(node, node.data.length);
} }
return Linkify.makeLink(range, post); return range;
}, },
makeLink: function(range, post) { makeLink: function(range) {
var a, link; var a, link;
link = range.toString(); link = range.toString();
@ -6788,8 +6790,9 @@
target: '_blank', target: '_blank',
href: link href: link
}); });
range.surroundContents(a); $.add(a, range.extractContents());
post.nodes.links.push(a); range.insertNode(a);
return a;
}, },
services: function(link) { services: function(link) {
var href, key, match, type, _ref; var href, key, match, type, _ref;

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* appchan x - Version 2.3.1 - 2013-08-11 * appchan x - Version 2.3.1 - 2013-08-12
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -6681,7 +6681,7 @@
if (g.VIEW === 'catalog' || !Conf['Linkify']) { if (g.VIEW === 'catalog' || !Conf['Linkify']) {
return; return;
} }
this.regString = Conf['Allow False Positives'] ? /(\b([a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi; this.regString = Conf['Allow False Positives'] ? /(\b([-a-z]+:\/\/|[a-z]{3,}\.[-a-z0-9]+\.[a-z]|[-a-z0-9]+\.[a-z]|[\d]+\.[\d]+\.[\d]+\.[\d]+\/|[a-z]{3,}:[a-z0-9?]|[^\s@]+@[a-z0-9.-]+\.[a-z0-9])[^\s'"]+)/gi : /(((magnet|mailto)\:|(www\.)|(news|(ht|f)tp(s?))\:\/\/){1}\S+)/gi;
if (Conf['Comment Expansion']) { if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node); ExpandComment.callbacks.push(this.node);
} }
@ -6694,7 +6694,7 @@
}); });
}, },
node: function() { node: function() {
var data, el, i, items, node, range, snapshot; var data, el, i, items, links, node, range, snapshot, _i, _len, _ref;
if (this.isClone) { if (this.isClone) {
if (Conf['Embedding']) { if (Conf['Embedding']) {
@ -6709,16 +6709,21 @@
} }
return; return;
} }
snapshot = $.X('.//text()', this.nodes.comment); snapshot = $.X('.//br|.//text()', this.nodes.comment);
i = 0; i = 0;
while (node = snapshot.snapshotItem(i++)) { while (node = snapshot.snapshotItem(i++)) {
if (node.parentElement.nodeName === "A") { if (node.parentElement.nodeName === "A") {
continue; continue;
} }
data = node.data; links = [];
if (Linkify.regString.test(data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(node, this); Linkify.gatherLinks(snapshot, this, node, links, i);
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
this.nodes.links.push(Linkify.makeLink(range, this));
} }
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { if (!(Conf['Embedding'] || Conf['Link Title'])) {
@ -6737,12 +6742,11 @@
} }
} }
}, },
gatherLinks: function(node, post) { gatherLinks: function(snapshot, post, node, links, i) {
var data, index, len, len2, link, links, match, range, _i, _len, _ref; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
len = data.length; len = data.length;
links = [];
while ((match = Linkify.regString.exec(data))) { while ((match = Linkify.regString.exec(data))) {
index = match.index; index = match.index;
link = match[0]; link = match[0];
@ -6757,34 +6761,32 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { if (match) {
Linkify.seek(match, node, post); links.push(Linkify.seek(snapshot, post, node, links, match, i));
}
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
} }
}, },
seek: function(match, node, post) { seek: function(snapshot, post, node, links, match, i) {
var data, index, link, next, range, result; var data, index, link, next, range, result;
index = match.index;
link = match[0]; link = match[0];
range = document.createRange(); range = document.createRange();
range.setStart(node, index); range.setStart(node, match.index);
while ((next = node.nextSibling) && next.nodeName !== 'BR') { while ((next = snapshot.snapshotItem(i++)) && next.nodeName !== 'BR') {
node = next; node = next;
data = node.data; data = node.data;
if (result = /[\s'"]/.exec(data)) { if (result = /[\s'"]/.exec(data)) {
range.setEnd(node, result.index); index = result.index;
range.setEnd(node, index);
Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, links, i);
return range;
} }
} }
if (range.collapsed) { if (range.collapsed) {
range.setEndAfter(node); range.setEnd(node, node.data.length);
} }
return Linkify.makeLink(range, post); return range;
}, },
makeLink: function(range, post) { makeLink: function(range) {
var a, link; var a, link;
link = range.toString(); link = range.toString();
@ -6795,8 +6797,9 @@
target: '_blank', target: '_blank',
href: link href: link
}); });
range.surroundContents(a); $.add(a, range.extractContents());
post.nodes.links.push(a); range.insertNode(a);
return a;
}, },
services: function(link) { services: function(link) {
var href, key, match, type, _ref; var href, key, match, type, _ref;

View File

@ -5,13 +5,13 @@ Linkify =
@regString = if Conf['Allow False Positives'] @regString = if Conf['Allow False Positives']
///( ///(
\b( \b(
[a-z]+:// [-a-z]+://
| |
[a-z]{3,}\.[-a-z0-9]+\.[a-z] [a-z]{3,}\.[-a-z0-9]+\.[a-z]
| |
[-a-z0-9]+\.[a-z] [-a-z0-9]+\.[a-z]
| |
[0-9]+\.[0-9]+\.[0-9]+\.[0-9] [\d]+\.[\d]+\.[\d]+\.[\d]+/
| |
[a-z]{3,}:[a-z0-9?] [a-z]{3,}:[a-z0-9?]
| |
@ -43,17 +43,19 @@ Linkify =
return return
snapshot = $.X './/text()', @nodes.comment snapshot = $.X './/br|.//text()', @nodes.comment
i = 0 i = 0
while node = snapshot.snapshotItem i++ while node = snapshot.snapshotItem i++
continue if node.parentElement.nodeName is "A" continue if node.parentElement.nodeName is "A"
links = []
data = node.data if Linkify.regString.test node.data
if Linkify.regString.test data
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
Linkify.gatherLinks node, @ Linkify.gatherLinks snapshot, @, node, links, i
for range in links.reverse()
@nodes.links.push Linkify.makeLink range, @
return unless Conf['Embedding'] or Conf['Link Title'] return unless Conf['Embedding'] or Conf['Link Title']
@ -66,10 +68,9 @@ Linkify =
return return
gatherLinks: (node, post) -> gatherLinks: (snapshot, post, node, links, i) ->
{data} = node {data} = node
len = data.length len = data.length
links = []
while (match = Linkify.regString.exec data) while (match = Linkify.regString.exec data)
{index} = match {index} = match
@ -86,31 +87,31 @@ Linkify =
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
if match if match
Linkify.seek match, node, post links.push Linkify.seek snapshot, post, node, links, match, i
for range in links.reverse()
Linkify.makeLink range, post
return return
seek: (match, node, post) -> seek: (snapshot, post, node, links, match, i) ->
{index} = match
link = match[0] link = match[0]
range = document.createRange() range = document.createRange()
range.setStart node, index range.setStart node, match.index
while (next = node.nextSibling) and next.nodeName isnt 'BR' while (next = snapshot.snapshotItem i++) and next.nodeName isnt 'BR'
node = next node = next
data = node.data data = node.data
if result = /[\s'"]/.exec data if result = /[\s'"]/.exec data
range.setEnd node, result.index {index} = result
range.setEnd node, index
Linkify.regString.lastIndex = index
Linkify.gatherLinks snapshot, post, node, links, i
return range
if range.collapsed if range.collapsed
range.setEndAfter node range.setEnd node, node.data.length
Linkify.makeLink range, post range
makeLink: (range, post) -> makeLink: (range) ->
link = range.toString() link = range.toString()
link = link =
if link.contains ':' if link.contains ':'
@ -127,9 +128,9 @@ Linkify =
rel: 'nofollow noreferrer' rel: 'nofollow noreferrer'
target: '_blank' target: '_blank'
href: link href: link
range.surroundContents a $.add a, range.extractContents()
post.nodes.links.push a range.insertNode a
return a
services: (link) -> services: (link) ->
href = link.href href = link.href