From d8f13d1129821e01ab53be196e442d8eecc1f8de Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 29 May 2011 23:06:17 -0700 Subject: [PATCH] fix quoting --- 4chan_x.user.js | 22 +++++++++++++--------- script.coffee | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index cd552762b..9a43d342c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1731,7 +1731,8 @@ _ref = $$('a.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (!(qid = quote.hash.slice(1))) { + qid = quote.hash.slice(1) || quote.getAttribute('data-href').match(/\d+$/)[0]; + if (!qid) { continue; } if (!opbl && qid === tid) { @@ -1774,7 +1775,7 @@ _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (!quote.hash) { + if (!(quote.hash || quote.getAttribute('data-href'))) { continue; } quote.removeAttribute('onclick'); @@ -1876,11 +1877,13 @@ _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (!quote.hash) { + if (!(quote.hash || quote.getAttribute('data-href'))) { continue; } - quote.setAttribute('data-href', quote.href); - quote.removeAttribute('href'); + if (quote.href) { + quote.setAttribute('data-href', quote.href); + quote.removeAttribute('href'); + } $.bind(quote, 'mouseover', quotePreview.mouseover); $.bind(quote, 'mousemove', ui.hover); $.bind(quote, 'mouseout', ui.hoverend); @@ -1911,7 +1914,7 @@ _ref2 = $$('a.quotelink', qp); for (_i = 0, _len = _ref2.length; _i < _len; _i++) { quote = _ref2[_i]; - if (quote.hash.slice(1) === replyID) { + if (quote.getAttribute('data-href').match(/\d+$/)[0] === replyID) { quote.className = 'forwardlink'; } } @@ -1960,7 +1963,7 @@ return g.callbacks.push(quoteOP.node); }, node: function(root) { - var quote, tid, _i, _len, _ref, _results; + var qid, quote, tid, _i, _len, _ref, _results; if (root.className === 'inline') { return; } @@ -1969,7 +1972,8 @@ _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - _results.push(quote.hash.slice(1) === tid ? quote.innerHTML += ' (OP)' : void 0); + qid = quote.hash.slice(1) || quote.getAttribute('data-href').match(/\d+/)[0]; + _results.push(qid === tid ? quote.innerHTML += ' (OP)' : void 0); } return _results; } @@ -2559,7 +2563,7 @@ cursor: pointer;\ }\ \ - .backlink, .quotelink {\ + .backlink, .quotelink, .forwardlink {\ text-decoration: underline;\ }\ .new {\ diff --git a/script.coffee b/script.coffee index a1b9fdb4d..e50f0e3e0 100644 --- a/script.coffee +++ b/script.coffee @@ -1387,7 +1387,8 @@ quoteBacklink = 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..] + qid = quote.hash[1..] or quote.getAttribute('data-href').match(/\d+$/)[0] + continue unless qid #don't backlink the op continue if !opbl and qid is tid #duplicate quotes get overwritten @@ -1412,7 +1413,7 @@ quoteInline = g.callbacks.push quoteInline.node node: (root) -> for quote in $$ 'a.quotelink, a.backlink', root - continue unless quote.hash + continue unless quote.hash or quote.getAttribute 'data-href' quote.removeAttribute 'onclick' $.bind quote, 'click', quoteInline.toggle toggle: (e) -> @@ -1479,11 +1480,12 @@ quotePreview = $.append d.body, preview node: (root) -> for quote in $$ 'a.quotelink, a.backlink', root - continue unless quote.hash - # XXX dataset requires firefox 6.0+ - # quote.dataset.href = quote.href - quote.setAttribute 'data-href', quote.href - quote.removeAttribute 'href' + continue unless quote.hash or quote.getAttribute 'data-href' + if quote.href + # XXX dataset requires firefox 6.0+ + # quote.dataset.href = quote.href + quote.setAttribute 'data-href', quote.href + quote.removeAttribute 'href' $.bind quote, 'mouseover', quotePreview.mouseover $.bind quote, 'mousemove', ui.hover $.bind quote, 'mouseout', ui.hoverend @@ -1502,7 +1504,7 @@ quotePreview = if @className is 'backlink' replyID = $.x('ancestor::*[@id][1]', @)?.id.match(/\d+/)[0] for quote in $$ 'a.quotelink', qp - if quote.hash[1..] is replyID + if quote.getAttribute('data-href').match(/\d+$/)[0] is replyID quote.className = 'forwardlink' else qp.innerHTML = "Loading #{id}..." @@ -1537,7 +1539,8 @@ quoteOP = return if root.className is 'inline' tid = g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]/div', root).id for quote in $$ 'a.quotelink', root - if quote.hash[1..] is tid + qid = quote.hash[1..] or quote.getAttribute('data-href').match(/\d+/)[0] + if qid is tid quote.innerHTML += ' (OP)' reportButton = @@ -1969,7 +1972,7 @@ main = cursor: pointer; } - .backlink, .quotelink { + .backlink, .quotelink, .forwardlink { text-decoration: underline; } .new {