From 60e718bc9fc6cb44ba0fc51c96a71815345735f2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 28 May 2011 11:34:34 -0700 Subject: [PATCH] op backlinks --- 4chan_x.user.js | 8 +++++--- script.coffee | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2cb9ee6c7..b29845e22 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -91,6 +91,7 @@ }, quote: { 'Quote Backlinks': [true, 'Add quote backlinks'], + 'OP Backlinks': [false, 'Add backlinks to the OP'], 'Quote Inline': [true, 'Show quoted post inline on quote click'], 'Quote Preview': [true, 'Show quote content on hover'], 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] @@ -1711,8 +1712,8 @@ return g.callbacks.push(quoteBacklink.node); }, node: function(root) { - var container, el, id, link, qid, quote, quotes, tid, _i, _len, _ref, _results; - if (root.className) { + var container, el, id, link, opbl, qid, quote, quotes, tid, _i, _len, _ref, _results; + if (/inline/.test(root.className)) { return; } container = $.el('span', { @@ -1722,13 +1723,14 @@ id = root.id || $('td[id]', root).id; quotes = {}; tid = g.THREAD_ID || root.parentNode.firstChild.id; + opbl = $.config('OP Backlinks'); _ref = $$('a.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; if (!(qid = quote.hash.slice(1))) { continue; } - if (qid === tid) { + if (!opbl && qid === tid) { continue; } quotes[qid] = quote; diff --git a/script.coffee b/script.coffee index e65fbc8c3..a7c2ceeb0 100644 --- a/script.coffee +++ b/script.coffee @@ -31,6 +31,7 @@ config = 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] quote: 'Quote Backlinks': [true, 'Add quote backlinks'] + 'OP Backlinks': [false, 'Add backlinks to the OP'] 'Quote Inline': [true, 'Show quoted post inline on quote click'] 'Quote Preview': [true, 'Show quote content on hover'] 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] @@ -1380,17 +1381,18 @@ quoteBacklink = init: -> g.callbacks.push quoteBacklink.node node: (root) -> - return if root.className + return if /inline/.test root.className container = $.el 'span', className: 'container' $.before $('br, blockquote', root), container id = root.id or $('td[id]', root).id quotes = {} tid = g.THREAD_ID or root.parentNode.firstChild.id + opbl = $.config 'OP Backlinks' for quote in $$ 'a.quotelink', root continue unless qid = quote.hash[1..] #don't backlink the op - continue if qid == tid + continue if !opbl and qid is tid #duplicate quotes get overwritten quotes[qid] = quote for qid, quote of quotes