From f74b7ff3483020d8072d0bfd63b366da86b94081 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 19 May 2011 13:42:48 +0200 Subject: [PATCH 1/4] 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() From f5662ef46d79a1a6a9f663bbe822378a2f315d2d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 19 May 2011 22:16:43 +0200 Subject: [PATCH 2/4] Don't double the (OP) on inlined quotes. --- 4chan_x.js | 3 +++ script.coffee | 1 + 2 files changed, 4 insertions(+) diff --git a/4chan_x.js b/4chan_x.js index 76b0c996a..87419709e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1891,6 +1891,9 @@ }, node: function(root) { var quote, tid, _i, _len, _ref, _results; + if (root.className) { + return; + } tid = g.THREAD_ID || root.parentNode.firstChild.id; _ref = $$('a.quotelink', root); _results = []; diff --git a/script.coffee b/script.coffee index 9e75a7665..90ae99260 100644 --- a/script.coffee +++ b/script.coffee @@ -1494,6 +1494,7 @@ quoteOP = init: -> g.callbacks.push quoteOP.node node: (root) -> + return if root.className tid = g.THREAD_ID or root.parentNode.firstChild.id for quote in $$ 'a.quotelink', root if quote.hash[1..] is tid From f9832bfd3be4688e6057ecfd28e96fc5e8fe891b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 19 May 2011 22:24:40 +0200 Subject: [PATCH 3/4] Fix for the .0001% inlined quotes quoting the current thread's OP. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 87419709e..14afa617e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1891,7 +1891,7 @@ }, node: function(root) { var quote, tid, _i, _len, _ref, _results; - if (root.className) { + if (root.className === 'inline') { return; } tid = g.THREAD_ID || root.parentNode.firstChild.id; diff --git a/script.coffee b/script.coffee index 90ae99260..b8c56dd71 100644 --- a/script.coffee +++ b/script.coffee @@ -1494,7 +1494,7 @@ quoteOP = init: -> g.callbacks.push quoteOP.node node: (root) -> - return if root.className + return if root.className is 'inline' tid = g.THREAD_ID or root.parentNode.firstChild.id for quote in $$ 'a.quotelink', root if quote.hash[1..] is tid From 3caa9bb3364d8c91ccdb2958152c8ed16015115c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 19 May 2011 22:28:48 +0200 Subject: [PATCH 4/4] Fix for something that you will never experience. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 14afa617e..71d848f0e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1894,7 +1894,7 @@ if (root.className === 'inline') { return; } - tid = g.THREAD_ID || root.parentNode.firstChild.id; + tid = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', this).id; _ref = $$('a.quotelink', root); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/script.coffee b/script.coffee index b8c56dd71..1b5864a7d 100644 --- a/script.coffee +++ b/script.coffee @@ -1495,7 +1495,7 @@ quoteOP = g.callbacks.push quoteOP.node node: (root) -> return if root.className is 'inline' - tid = g.THREAD_ID or root.parentNode.firstChild.id + tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', this).id for quote in $$ 'a.quotelink', root if quote.hash[1..] is tid quote.textContent += ' (OP)'