From 7b20be3a913b1a9e597456d8805aa6f804121093 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 30 Apr 2012 14:55:43 +0200 Subject: [PATCH] Fix preParsing of inserted posts. Ha ha, back to Tera. --- 4chan_x.user.js | 19 ++++++++++--------- script.coffee | 17 +++++++++-------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 328463c9d..d0aeb4da8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4072,7 +4072,7 @@ } board = $('.board'); nodes = []; - _ref1 = $$('.post', board); + _ref1 = $$('.postContainer', board); for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { node = _ref1[_j]; nodes.push(Main.preParse(node)); @@ -4117,21 +4117,22 @@ } }, preParse: function(node) { - var fileInfo, img, klass, post; - klass = node.className; + var el, fileInfo, img, klass, post; + el = $('.post', node); + klass = el.className; post = { - root: node.parentNode, - el: node, + root: node, + el: el, "class": klass, - id: node.id.slice(1), + id: el.id.slice(1), threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1), isInlined: /\binline\b/.test(klass), - quotes: node.getElementsByClassName('quotelink'), - backlinks: node.getElementsByClassName('backlink'), + quotes: el.getElementsByClassName('quotelink'), + backlinks: el.getElementsByClassName('backlink'), fileInfo: false, img: false }; - if (fileInfo = $('.fileInfo', node)) { + if (fileInfo = $('.fileInfo', el)) { img = fileInfo.nextElementSibling.firstElementChild; if (img.alt !== 'File deleted.') { post.fileInfo = fileInfo; diff --git a/script.coffee b/script.coffee index 87de1ef6f..0ae63ce9f 100644 --- a/script.coffee +++ b/script.coffee @@ -3137,7 +3137,7 @@ Main = board = $ '.board' nodes = [] - for node in $$ '.post', board + for node in $$ '.postContainer', board nodes.push Main.preParse node Main.node nodes, true @@ -3172,19 +3172,20 @@ Main = window.location = "https://raw.github.com/mayhemydg/4chan-x/#{version}/4chan_x.user.js" preParse: (node) -> - klass = node.className + el = $ '.post', node + klass = el.className post = - root: node.parentNode - el: node + root: node + el: el class: klass - id: node.id[1..] + id: el.id[1..] threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).id[1..] isInlined: /\binline\b/.test klass - quotes: node.getElementsByClassName 'quotelink' - backlinks: node.getElementsByClassName 'backlink' + quotes: el.getElementsByClassName 'quotelink' + backlinks: el.getElementsByClassName 'backlink' fileInfo: false img: false - if fileInfo = $ '.fileInfo', node + if fileInfo = $ '.fileInfo', el img = fileInfo.nextElementSibling.firstElementChild if img.alt isnt 'File deleted.' post.fileInfo = fileInfo