From 40d1b4808fbcdc944b5f875533915b9ee1567451 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 06:03:52 +0200 Subject: [PATCH 1/2] Fix links in expanded threads. Close #198 --- 4chan_x.user.js | 21 ++++++++++++++------- changelog | 2 ++ script.coffee | 10 +++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 17a4b7555..5584fc49a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -624,7 +624,7 @@ } }, parse: function(req, pathname, thread, a) { - var body, br, next, quote, table, tables, _i, _j, _len, _len2, _ref, _results; + var body, br, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; $.unbind(a, 'click', expandThread.cb.toggle); @@ -638,18 +638,25 @@ body = $.el('body', { innerHTML: req.responseText }); - _ref = $$('a.quotelink', body); + _ref = $$('td[id]', body); for (_i = 0, _len = _ref.length; _i < _len; _i++) { - quote = _ref[_i]; - if (quote.getAttribute('href') === quote.hash) { - quote.pathname = pathname; + reply = _ref[_i]; + _ref2 = $$('a.quotelink', reply); + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + quote = _ref2[_j]; + if (quote.getAttribute('href') === quote.hash) { + quote.pathname = pathname; + } } + link = $('a.quotejs', reply); + link.href = "res/" + thread.firstChild.id + "#" + reply.id; + link.nextSibling.href = "res/" + thread.firstChild.id + "#q" + reply.id; } tables = $$('form[name=delform] table', body); tables.pop(); _results = []; - for (_j = 0, _len2 = tables.length; _j < _len2; _j++) { - table = tables[_j]; + for (_k = 0, _len3 = tables.length; _k < _len3; _k++) { + table = tables[_k]; _results.push($.before(br, table)); } return _results; diff --git a/changelog b/changelog index de150fb47..1ad01c264 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ github +- mayhem: + - fix post links in expanded threads - aeosynth: - only auto scroll focused tabs - quote inlining: only work on unmodified left-click diff --git a/script.coffee b/script.coffee index 56fd50708..fcef6bc94 100644 --- a/script.coffee +++ b/script.coffee @@ -452,9 +452,13 @@ expandThread = body = $.el 'body', innerHTML: req.responseText - for quote in $$ 'a.quotelink', body - if quote.getAttribute('href') is quote.hash - quote.pathname = pathname + for reply in $$ 'td[id]', body + for quote in $$ 'a.quotelink', reply + if quote.getAttribute('href') is quote.hash + quote.pathname = pathname + link = $ 'a.quotejs', reply + link.href = "res/#{thread.firstChild.id}##{reply.id}" + link.nextSibling.href = "res/#{thread.firstChild.id}#q#{reply.id}" tables = $$ 'form[name=delform] table', body tables.pop() for table in tables From 7d4fda2f56a94a277ca799c87bef7eddbfa0c911 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 1 Aug 2011 06:38:19 +0200 Subject: [PATCH 2/2] Scroll only when you're supposed to. --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6bf688ba0..063b26e9f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2731,7 +2731,7 @@ $.bind(form, 'submit', qr.submit); } threading.init(); - if ((id = location.hash.slice(1)) && !$.id(id)) { + if ((id = location.hash.slice(1)) && !$.id(id) && !/\D/.test(id)) { scrollTo(0, d.body.scrollHeight); } if (conf['Auto Noko']) { diff --git a/script.coffee b/script.coffee index fe1afb090..a6d83d699 100644 --- a/script.coffee +++ b/script.coffee @@ -2117,7 +2117,7 @@ main = # scroll to bottom if post isn't found # thumbnail generation takes time - if (id = location.hash[1..]) and !$.id id + if (id = location.hash[1..]) and !$.id(id) and !/\D/.test id scrollTo 0, d.body.scrollHeight if conf['Auto Noko']