diff --git a/4chan_x.user.js b/4chan_x.user.js index d4c055183..f6042ce4e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -675,8 +675,9 @@ return text.join(''); }, filename: function(post) { - var file; - if (file = $('span', post.filesize)) return file.title; + var file, filesize; + filesize = post.filesize; + if (filesize && (file = $('span', filesize))) return file.title; return false; }, dimensions: function(post) { @@ -887,22 +888,21 @@ ReplyHiding = { init: function() { - return g.callbacks.push(this.node); - }, - node: function(post) { - var a, dd, id, reply; - if (post["class"]) return; - dd = $('.doubledash', post.root); - dd.className = 'replyhider'; - a = $.el('a', { + this.a = $.el('a', { textContent: '[ - ]', href: 'javascript:;' }); + return g.callbacks.push(this.node); + }, + node: function(post) { + var a, dd; + if (post["class"]) return; + dd = post.el.previousSibling; + dd.className = 'replyhider'; + a = ReplyHiding.a.cloneNode(true); $.on(a, 'click', ReplyHiding.cb.hide); $.replace(dd.firstChild, a); - reply = dd.nextSibling; - id = reply.id; - if (id in g.hiddenReplies) return ReplyHiding.hide(reply); + if (post.id in g.hiddenReplies) return ReplyHiding.hide(post.el); }, cb: { hide: function() { @@ -2811,6 +2811,7 @@ }, node: function(post) { var name, node; + if (post["class"] === 'inline') return; name = $('.commentpostername, .postername', post.el); name.textContent = 'Anonymous'; node = name.nextElementSibling; diff --git a/script.coffee b/script.coffee index 46deb2075..df251a9fe 100644 --- a/script.coffee +++ b/script.coffee @@ -593,7 +593,8 @@ Filter = text.push if data = nodes.snapshotItem(i).data then data else '\n' text.join '' filename: (post) -> - if file = $ 'span', post.filesize + {filesize} = post + if filesize and file = $ 'span', filesize return file.title false dimensions: (post) -> @@ -745,22 +746,21 @@ ExpandThread = ReplyHiding = init: -> + @a = $.el 'a', + textContent: '[ - ]' + href: 'javascript:;' g.callbacks.push @node node: (post) -> return if post.class - dd = $ '.doubledash', post.root + dd = post.el.previousSibling dd.className = 'replyhider' - a = $.el 'a', - textContent: '[ - ]' - href: 'javascript:;' + a = ReplyHiding.a.cloneNode true $.on a, 'click', ReplyHiding.cb.hide $.replace dd.firstChild, a - reply = dd.nextSibling - id = reply.id - if id of g.hiddenReplies - ReplyHiding.hide reply + if post.id of g.hiddenReplies + ReplyHiding.hide post.el cb: hide: -> @@ -2365,6 +2365,7 @@ Anonymize = init: -> g.callbacks.push @node node: (post) -> + return if post.class is 'inline' name = $ '.commentpostername, .postername', post.el name.textContent = 'Anonymous' node = name.nextElementSibling