Fix sauces to work with inlined archived posts.
This commit is contained in:
parent
1a078f6a0e
commit
4f7de6d3b5
@ -2825,33 +2825,35 @@
|
||||
link = link.replace(/(\$\d)/g, function(parameter) {
|
||||
switch (parameter) {
|
||||
case '$1':
|
||||
return "http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '";
|
||||
return "' + (isArchived ? img.firstChild.src : 'http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg')) + '";
|
||||
case '$2':
|
||||
return "' + img.href + '";
|
||||
case '$3':
|
||||
return "' + encodeURIComponent(img.firstChild.dataset.md5) + '";
|
||||
case '$4':
|
||||
return g.BOARD;
|
||||
default:
|
||||
return parameter;
|
||||
}
|
||||
});
|
||||
domain = (m = link.match(/;text:(.+)$/)) ? m[1] : link.match(/(\w+)\.\w+\//)[1];
|
||||
href = link.replace(/;text:.+$/, '');
|
||||
href = Function('img', "return '" + href + "'");
|
||||
href = Function('img', 'isArchived', "return '" + href + "'");
|
||||
el = $.el('a', {
|
||||
target: '_blank',
|
||||
textContent: domain
|
||||
});
|
||||
return function(img) {
|
||||
return function(img, isArchived) {
|
||||
var a;
|
||||
a = el.cloneNode(true);
|
||||
a.href = href(img);
|
||||
a.href = href(img, isArchived);
|
||||
return a;
|
||||
};
|
||||
},
|
||||
node: function(post) {
|
||||
var img, link, nodes, _i, _len, _ref;
|
||||
img = post.img;
|
||||
if (post.isInlined && !post.isCrosspost || post.isArchived || !img) {
|
||||
if (post.isInlined && !post.isCrosspost || !img) {
|
||||
return;
|
||||
}
|
||||
img = img.parentNode;
|
||||
@ -2859,7 +2861,7 @@
|
||||
_ref = Sauce.links;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
link = _ref[_i];
|
||||
nodes.push($.tn('\u00A0'), link(img));
|
||||
nodes.push($.tn('\u00A0'), link(img, post.isArchived));
|
||||
}
|
||||
return $.add(post.fileInfo, nodes);
|
||||
}
|
||||
|
||||
@ -2212,32 +2212,34 @@ Sauce =
|
||||
link = link.replace /(\$\d)/g, (parameter) ->
|
||||
switch parameter
|
||||
when '$1'
|
||||
"http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '"
|
||||
"' + (isArchived ? img.firstChild.src : 'http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg')) + '"
|
||||
when '$2'
|
||||
"' + img.href + '"
|
||||
when '$3'
|
||||
"' + encodeURIComponent(img.firstChild.dataset.md5) + '"
|
||||
when '$4'
|
||||
g.BOARD
|
||||
else
|
||||
parameter
|
||||
domain = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)[1]
|
||||
href = link.replace /;text:.+$/, ''
|
||||
href = Function 'img', "return '#{href}'"
|
||||
href = Function 'img', 'isArchived', "return '#{href}'"
|
||||
el = $.el 'a',
|
||||
target: '_blank'
|
||||
textContent: domain
|
||||
(img) ->
|
||||
(img, isArchived) ->
|
||||
a = el.cloneNode true
|
||||
a.href = href img
|
||||
a.href = href img, isArchived
|
||||
a
|
||||
|
||||
node: (post) ->
|
||||
{img} = post
|
||||
return if post.isInlined and not post.isCrosspost or post.isArchived or not img
|
||||
return if post.isInlined and not post.isCrosspost or not img
|
||||
img = img.parentNode
|
||||
nodes = []
|
||||
for link in Sauce.links
|
||||
# \u00A0 is nbsp
|
||||
nodes.push $.tn('\u00A0'), link img
|
||||
nodes.push $.tn('\u00A0'), link img, post.isArchived
|
||||
$.add post.fileInfo, nodes
|
||||
|
||||
RevealSpoilers =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user