From e603f40925048aee22e4b07b09f9ba013b0c7c24 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 10 Sep 2012 17:40:32 +0200 Subject: [PATCH] Don't create the subject element when it's empty. --- 4chan_x.user.js | 9 +++++++-- script.coffee | 14 +++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 202d8f359..c42d21a9d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -703,7 +703,11 @@ return false; }, subject: function(post) { - return $('.postInfo .subject', post.el).textContent || false; + var subject; + if (subject = $('.postInfo .subject', post.el)) { + return subject.textContent; + } + return false; }, comment: function(post) { var data, i, nodes, text, _i, _ref; @@ -3752,6 +3756,7 @@ emailStart = ''; emailEnd = ''; } + subject = subject ? "" + subject + "" : ''; userID = !capcode && uniqueID ? (" (ID: ") + ("" + uniqueID + ") ") : ''; switch (capcode) { case 'admin': @@ -3818,7 +3823,7 @@ container = $.el('div', { id: "pc" + postID, className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' + innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' }); _ref = $$('.quotelink', container); for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/script.coffee b/script.coffee index bb4bff7ed..a0f1fd855 100644 --- a/script.coffee +++ b/script.coffee @@ -557,7 +557,9 @@ Filter = return decodeURIComponent mail.href[7..] false subject: (post) -> - $('.postInfo .subject', post.el).textContent or false + if subject = $ '.postInfo .subject', post.el + return subject.textContent + false comment: (post) -> text = [] # XPathResult.ORDERED_NODE_SNAPSHOT_TYPE is 7 @@ -2965,6 +2967,12 @@ Build = emailStart = '' emailEnd = '' + subject = + if subject + "#{subject}" + else + '' + userID = if !capcode and uniqueID " (ID: " + @@ -3097,7 +3105,7 @@ Build = "" + "#{name}" + tripcode + capcodeStart + capcode + userID + flag + sticky + closed + - "
#{subject}" + + "
#{subject}" + "
#{date}" + '
' + "No." + @@ -3114,7 +3122,7 @@ Build = "