From 305a567f9d5b5452011d26bf519343cbcc11ae3f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 12 Mar 2012 14:16:26 +0100 Subject: [PATCH] Finish Quote Resurrection. Close #253. --- 4chan_x.user.js | 23 +++++++++++++++-------- script.coffee | 21 +++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1ce29da85..3ec108e96 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3363,7 +3363,7 @@ href = "#" + id; className = 'quotelink'; } else { - href = "#"; + href = Redirect.thread(board, id, 'post'); className = null; } nodes.push($.el('a', { @@ -3550,8 +3550,11 @@ return "http://archive.foolz.us/" + href[3] + "/full_image/" + href[5]; } }, - thread: function() { - if (!conf['404 Redirect']) return; + thread: function(board, id, mode) { + if (board == null) board = g.BOARD; + if (id == null) id = g.THREAD_ID; + if (mode == null) mode = 'thread'; + if (!(conf['404 Redirect'] || mode === 'post')) return; switch (g.BOARD) { case 'a': case 'jp': @@ -3561,13 +3564,13 @@ case 'u': case 'v': case 'vg': - return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID + "/"; + return "http://archive.foolz.us/" + board + "/thread/" + id + "/"; case 'lit': - return "http://fuuka.warosu.org/" + g.BOARD + "/thread/" + g.THREAD_ID; + return "http://fuuka.warosu.org/" + board + "/" + mode + "/" + id; case 'diy': case 'g': case 'sci': - return "http://archive.installgentoo.net/" + g.BOARD + "/thread/" + g.THREAD_ID; + return "http://archive.installgentoo.net/" + board + "/" + mode + "/" + id; case '3': case 'adv': case 'an': @@ -3590,9 +3593,13 @@ case 'trv': case 'vp': case 'x': - return "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID; + return "http://archive.no-ip.org/" + board + "/" + mode + "/" + id; default: - return "http://boards.4chan.org/" + g.BOARD + "/"; + if (mode === 'thread') { + return "http://boards.4chan.org/" + board + "/"; + } else { + return null; + } } } }; diff --git a/script.coffee b/script.coffee index 12cf34303..3c21b0046 100644 --- a/script.coffee +++ b/script.coffee @@ -2806,9 +2806,7 @@ Quotify = href = "##{id}" className = 'quotelink' else - # TODO manage links if board is archived - # Here be archive link - href = "#" + href = Redirect.thread board, id, 'post' className = null nodes.push $.el 'a', @@ -2982,19 +2980,22 @@ Redirect = switch href[3] when 'a', 'jp', 'm', 'tg', 'u', 'vg' "http://archive.foolz.us/#{href[3]}/full_image/#{href[5]}" - thread: -> - return unless conf['404 Redirect'] + thread: (board=g.BOARD, id=g.THREAD_ID, mode='thread') -> + return unless conf['404 Redirect'] or mode is 'post' switch g.BOARD when 'a', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg' - "http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}/" + "http://archive.foolz.us/#{board}/thread/#{id}/" when 'lit' - "http://fuuka.warosu.org/#{g.BOARD}/thread/#{g.THREAD_ID}" + "http://fuuka.warosu.org/#{board}/#{mode}/#{id}" when 'diy', 'g', 'sci' - "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" + "http://archive.installgentoo.net/#{board}/#{mode}/#{id}" when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'r9k', 'soc', 'sp', 'toy', 'trv', 'vp', 'x' - "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}" + "http://archive.no-ip.org/#{board}/#{mode}/#{id}" else - "http://boards.4chan.org/#{g.BOARD}/" + if mode is 'thread' + "http://boards.4chan.org/#{board}/" + else + null ImageHover = init: ->