hide spoilers in desktop notifications

This commit is contained in:
ccd0 2014-07-04 14:45:15 -07:00
parent a08823eae9
commit 7d14a5395f
2 changed files with 14 additions and 5 deletions

View File

@ -92,16 +92,25 @@ class Post
# Preceding and following new lines. # Preceding and following new lines.
# Trailing spaces. # Trailing spaces.
bq = @nodes.comment.cloneNode true bq = @nodes.comment.cloneNode true
nodes = $$ '.abbr, .exif, b', bq for node in $$ '.abbr, .exif, b', bq
i = 0
while node = nodes[i++]
$.rm node $.rm node
@info.comment = @nodesToText bq
# Hide spoilers.
spoilers = $$ 's', bq
@info.commentSpoilered = if spoilers.length
for node in spoilers
$.replace node, $.tn '[spoiler]'
@nodesToText bq
else
@info.comment
nodesToText: (bq) ->
text = "" text = ""
nodes = $.X './/br|.//text()', bq nodes = $.X './/br|.//text()', bq
i = 0 i = 0
while node = nodes.snapshotItem i++ while node = nodes.snapshotItem i++
text += node.data or '\n' text += node.data or '\n'
@info.comment = text.trim().replace /\s+$/gm, '' text.trim().replace /\s+$/gm, ''
parseQuotes: -> parseQuotes: ->
@quotes = [] @quotes = []

View File

@ -100,7 +100,7 @@ Unread =
else else
$('.nameBlock', post.nodes.info).textContent.trim() $('.nameBlock', post.nodes.info).textContent.trim()
notif = new Notification "#{name} replied to you", notif = new Notification "#{name} replied to you",
body: post.info.comment body: post.info[if Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] then 'comment' else 'commentSpoilered']
icon: Favicon.logo icon: Favicon.logo
notif.onclick = -> notif.onclick = ->
Header.scrollToIfNeeded post.nodes.root, true Header.scrollToIfNeeded post.nodes.root, true