Include rolls and fortunes in filterable text but continue removing them from notifications and thread excerpts.
This commit is contained in:
parent
e7eb5fd2ab
commit
6484f461d0
@ -83,8 +83,6 @@ Build =
|
|||||||
html = html
|
html = html
|
||||||
.replace(/<br\b[^<]*>/gi, '\n')
|
.replace(/<br\b[^<]*>/gi, '\n')
|
||||||
.replace(/\n\n<span\b[^<]* class="abbr"[^]*$/i, '') # EXIF data (/p/)
|
.replace(/\n\n<span\b[^<]* class="abbr"[^]*$/i, '') # EXIF data (/p/)
|
||||||
.replace(/^<b\b[^<]*>Rolled [^<]*<\/b>/i, '') # Rolls (/tg/)
|
|
||||||
.replace(/<span\b[^<]* class="fortune"[^]*$/i, '') # Fortunes (/s4s/)
|
|
||||||
.replace(/<[^>]*>/g, '')
|
.replace(/<[^>]*>/g, '')
|
||||||
Build.unescape html
|
Build.unescape html
|
||||||
|
|
||||||
@ -93,6 +91,9 @@ Build =
|
|||||||
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
|
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
|
||||||
while (html2 = html.replace /<s>(?:(?!<\/?s>).)*<\/s>/g, '[spoiler]') isnt html
|
while (html2 = html.replace /<s>(?:(?!<\/?s>).)*<\/s>/g, '[spoiler]') isnt html
|
||||||
html = html2
|
html = html2
|
||||||
|
html = html
|
||||||
|
.replace(/^<b\b[^<]*>Rolled [^<]*<\/b>/i, '') # Rolls (/tg/, /qst/)
|
||||||
|
.replace(/<span\b[^<]* class="fortune"[^]*$/i, '') # Fortunes (/s4s/)
|
||||||
# Remove preceding and following new lines, trailing spaces.
|
# Remove preceding and following new lines, trailing spaces.
|
||||||
Build.parseComment(html).trim().replace(/\s+$/gm, '')
|
Build.parseComment(html).trim().replace(/\s+$/gm, '')
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ Get =
|
|||||||
{OP} = thread
|
{OP} = thread
|
||||||
excerpt = ("/#{thread.board}/ - ") + (
|
excerpt = ("/#{thread.board}/ - ") + (
|
||||||
OP.info.subject?.trim() or
|
OP.info.subject?.trim() or
|
||||||
OP.info.commentDisplay.replace(/\n+/g, ' // ') or
|
OP.commentDisplay().replace(/\n+/g, ' // ') or
|
||||||
OP.file?.name or
|
OP.file?.name or
|
||||||
"No.#{OP}")
|
"No.#{OP}")
|
||||||
return "#{excerpt[...70]}..." if excerpt.length > 73
|
return "#{excerpt[...70]}..." if excerpt.length > 73
|
||||||
|
|||||||
@ -132,7 +132,7 @@ Unread =
|
|||||||
openNotification: (post) ->
|
openNotification: (post) ->
|
||||||
return unless Header.areNotificationsEnabled
|
return unless Header.areNotificationsEnabled
|
||||||
notif = new Notification "#{post.info.nameBlock} replied to you",
|
notif = new Notification "#{post.info.nameBlock} replied to you",
|
||||||
body: post.info.commentDisplay
|
body: post.commentDisplay()
|
||||||
icon: Favicon.logo
|
icon: Favicon.logo
|
||||||
notif.onclick = ->
|
notif.onclick = ->
|
||||||
Header.scrollToIfNeeded post.nodes.root, true
|
Header.scrollToIfNeeded post.nodes.root, true
|
||||||
|
|||||||
@ -107,29 +107,22 @@ class Post
|
|||||||
# Remove:
|
# Remove:
|
||||||
# 'Comment too long'...
|
# 'Comment too long'...
|
||||||
# EXIF data. (/p/)
|
# EXIF data. (/p/)
|
||||||
# Rolls. (/tg/)
|
@nodes.commentClean = bq = @nodes.comment.cloneNode true
|
||||||
# Fortunes. (/s4s/)
|
@cleanComment bq
|
||||||
bq = @nodes.comment.cloneNode true
|
|
||||||
for node in $$ '.abbr + br, .exif, b, .fortune', bq
|
|
||||||
$.rm node
|
|
||||||
if abbr = $ '.abbr', bq
|
|
||||||
$.rm abbr
|
|
||||||
@info.comment = @nodesToText bq
|
@info.comment = @nodesToText bq
|
||||||
if abbr
|
|
||||||
@info.comment = @info.comment.replace /\n\n$/, ''
|
|
||||||
|
|
||||||
# Hide spoilers.
|
commentDisplay: ->
|
||||||
# Remove:
|
# Get the comment's text for display purposes (e.g. notifications, excerpts).
|
||||||
|
# In addition to what's done in generating `@info.comment`, remove:
|
||||||
|
# Spoilers. (filter to '[spoiler]')
|
||||||
|
# Rolls. (/tg/, /qst/)
|
||||||
|
# Fortunes. (/s4s/)
|
||||||
# Preceding and following new lines.
|
# Preceding and following new lines.
|
||||||
# Trailing spaces.
|
# Trailing spaces.
|
||||||
commentDisplay = @info.comment
|
bq = @nodes.commentClean.cloneNode true
|
||||||
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
|
@cleanSpoilers bq unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
|
||||||
spoilers = $$ 's', bq
|
@cleanCommentDisplay bq
|
||||||
if spoilers.length
|
@nodesToText(bq).trim().replace(/\s+$/gm, '')
|
||||||
for node in spoilers
|
|
||||||
$.replace node, $.tn '[spoiler]'
|
|
||||||
commentDisplay = @nodesToText bq
|
|
||||||
@info.commentDisplay = commentDisplay.trim().replace /\s+$/gm, ''
|
|
||||||
|
|
||||||
nodesToText: (bq) ->
|
nodesToText: (bq) ->
|
||||||
text = ""
|
text = ""
|
||||||
@ -139,6 +132,24 @@ class Post
|
|||||||
text += node.data or '\n'
|
text += node.data or '\n'
|
||||||
text
|
text
|
||||||
|
|
||||||
|
cleanComment: (bq) ->
|
||||||
|
if (abbr = $ '.abbr', bq) # 'Comment too long' or 'EXIF data available'
|
||||||
|
for node in $$ '.abbr + br, .exif', bq
|
||||||
|
$.rm node
|
||||||
|
for i in [0...2]
|
||||||
|
$.rm br if (br = abbr.previousSibling) and br.nodeName is 'BR'
|
||||||
|
$.rm abbr
|
||||||
|
|
||||||
|
cleanSpoilers: (bq) ->
|
||||||
|
spoilers = $$ 's', bq
|
||||||
|
for node in spoilers
|
||||||
|
$.replace node, $.tn '[spoiler]'
|
||||||
|
return
|
||||||
|
|
||||||
|
cleanCommentDisplay: (bq) ->
|
||||||
|
$.rm b if (b = $ 'b', bq) and /^Rolled /.test(b.textContent)
|
||||||
|
$.rm $('.fortune', bq)
|
||||||
|
|
||||||
parseQuotes: ->
|
parseQuotes: ->
|
||||||
@quotes = []
|
@quotes = []
|
||||||
# XXX https://github.com/4chan/4chan-JS/issues/77
|
# XXX https://github.com/4chan/4chan-JS/issues/77
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user