diff --git a/4chan_x.user.js b/4chan_x.user.js index 7692da4b6..8fb3c2153 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2810,15 +2810,12 @@ return g.callbacks.push(this.node); }, node: function(post) { - var name, trip; + var name, node; name = $('.commentpostername, .postername', post.el); name.textContent = 'Anonymous'; - if (trip = $('.postertrip', post.el)) { - if (trip.parentNode.nodeName === 'A') { - return $.rm(trip.parentNode); - } else { - return $.rm(trip); - } + node = name.nextElementSibling; + if (node.className === 'postertrip' || node.nodeName === 'A') { + return $.rm(node); } } }; @@ -3412,16 +3409,17 @@ ReportButton = { init: function() { + this.a = $.el('a', { + className: 'reportbutton', + innerHTML: '[ ! ]', + href: 'javascript:;' + }); return g.callbacks.push(this.node); }, node: function(post) { var a; if (!(a = $('.reportbutton', post.el))) { - a = $.el('a', { - className: 'reportbutton', - innerHTML: '[ ! ]', - href: 'javascript:;' - }); + a = ReportButton.a.cloneNode(true); $.after($('span[id]', post.el), [$.tn(' '), a]); } return $.on(a, 'click', ReportButton.report); @@ -3506,7 +3504,7 @@ if (!g.REPLY) return; count = this.replies.length; if (conf['Unread Count']) d.title = "(" + count + ") " + this.title; - if (!(conf['Unread Favicon'] && count < 2 || forceUpdate)) return; + if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return; Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"]; return $.add(d.head, Favicon.el); } @@ -3679,7 +3677,7 @@ a = post.img.parentNode; $.on(a, 'click', ImageExpand.cb.toggle); if (ImageExpand.on && !post.root.hidden && post["class"] !== 'inline') { - return ImageExpand.expand(a.firstChild); + return ImageExpand.expand(post.img); } }, cb: { diff --git a/script.coffee b/script.coffee index 37ed65d13..89bba420a 100644 --- a/script.coffee +++ b/script.coffee @@ -2367,11 +2367,9 @@ Anonymize = node: (post) -> name = $ '.commentpostername, .postername', post.el name.textContent = 'Anonymous' - if trip = $ '.postertrip', post.el - if trip.parentNode.nodeName is 'A' - $.rm trip.parentNode - else - $.rm trip + node = name.nextElementSibling + if node.className is 'postertrip' or node.nodeName is 'A' + $.rm node Sauce = init: -> @@ -2806,13 +2804,14 @@ QuoteCT = ReportButton = init: -> + @a = $.el 'a', + className: 'reportbutton' + innerHTML: '[ ! ]' + href: 'javascript:;' g.callbacks.push @node node: (post) -> - if not a = $ '.reportbutton', post.el - a = $.el 'a', - className: 'reportbutton' - innerHTML: '[ ! ]' - href: 'javascript:;' + unless a = $ '.reportbutton', post.el + a = ReportButton.a.cloneNode true $.after $('span[id]', post.el), [$.tn(' '), a] $.on a, 'click', ReportButton.report report: -> @@ -2882,7 +2881,7 @@ Unread = if conf['Unread Count'] d.title = "(#{count}) #{@title}" - unless conf['Unread Favicon'] and count < 2 or forceUpdate + unless conf['Unread Favicon'] and (count < 2 or forceUpdate) return Favicon.el.href = @@ -3012,7 +3011,7 @@ ImageExpand = a = post.img.parentNode $.on a, 'click', ImageExpand.cb.toggle if ImageExpand.on and !post.root.hidden and post.class isnt 'inline' - ImageExpand.expand a.firstChild + ImageExpand.expand post.img cb: toggle: (e) -> return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0