From f74b7ff3483020d8072d0bfd63b366da86b94081 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 19 May 2011 13:42:48 +0200 Subject: [PATCH] Add (OP) to op quotes, fix label title with 's. close #97 --- 4chan_x.js | 26 +++++++++++++++++++++++--- script.coffee | 15 ++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index e245129bc..76b0c996a 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -59,7 +59,7 @@ */ (function() { - var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref; + var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref; var __slice = Array.prototype.slice; if (typeof console !== "undefined" && console !== null) { log = function(arg) { @@ -91,7 +91,8 @@ quote: { 'Quote Backlinks': [false, 'Add quote backlinks'], 'Quote Inline': [false, 'Show quoted post inline on quote click'], - 'Quote Preview': [false, 'Show quote content on hover'] + 'Quote Preview': [false, 'Show quote content on hover'], + 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] }, hide: { 'Reply Hiding': [true, 'Hide single replies'], @@ -947,7 +948,7 @@ title = conf[name][1]; checked = $.config(name) ? "checked" : ""; li = $.el('li', { - innerHTML: "" + innerHTML: "" }); _results.push($.append(id, li)); } @@ -1884,6 +1885,22 @@ return qp.innerHTML = html; } }; + quoteOP = { + init: function() { + return g.callbacks.push(quoteOP.node); + }, + node: function(root) { + var quote, tid, _i, _len, _ref, _results; + tid = g.THREAD_ID || root.parentNode.firstChild.id; + _ref = $$('a.quotelink', root); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + _results.push(quote.hash.slice(1) === tid ? quote.textContent += ' (OP)' : void 0); + } + return _results; + } + }; reportButton = { init: function() { return g.callbacks.push(reportButton.cb.node); @@ -2345,6 +2362,9 @@ if ($.config('Quote Preview')) { quotePreview.init(); } + if ($.config('Indicate OP quote')) { + quoteOP.init(); + } if ($.config('Thread Watcher')) { watcher.init(); } diff --git a/script.coffee b/script.coffee index 9b526ddff..9e75a7665 100644 --- a/script.coffee +++ b/script.coffee @@ -32,6 +32,7 @@ config = 'Quote Backlinks': [false, 'Add quote backlinks'] 'Quote Inline': [false, 'Show quoted post inline on quote click'] 'Quote Preview': [false, 'Show quote content on hover'] + 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] hide: 'Reply Hiding': [true, 'Hide single replies'] 'Thread Hiding': [true, 'Hide entire threads'] @@ -733,7 +734,7 @@ options = title = conf[name][1] checked = if $.config name then "checked" else "" li = $.el 'li', - innerHTML: "" + innerHTML: "" $.append id, li flavors: -> @@ -1489,6 +1490,15 @@ quotePreview = break qp.innerHTML = html +quoteOP = + init: -> + g.callbacks.push quoteOP.node + node: (root) -> + tid = g.THREAD_ID or root.parentNode.firstChild.id + for quote in $$ 'a.quotelink', root + if quote.hash[1..] is tid + quote.textContent += ' (OP)' + reportButton = init: -> g.callbacks.push reportButton.cb.node @@ -1820,6 +1830,9 @@ main = if $.config 'Quote Preview' quotePreview.init() + if $.config 'Indicate OP quote' + quoteOP.init() + if $.config 'Thread Watcher' watcher.init()