From 4f7de6d3b57532accf2b2465376ab47823182f32 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 17 Jun 2012 22:36:21 +0200 Subject: [PATCH] Fix sauces to work with inlined archived posts. --- 4chan_x.user.js | 14 ++++++++------ script.coffee | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f72f4ff44..16d756510 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -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); } diff --git a/script.coffee b/script.coffee index 363bfa32a..4e18c0e74 100644 --- a/script.coffee +++ b/script.coffee @@ -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 =