Add option to filter only posts with files.

This commit is contained in:
ccd0 2019-03-22 02:26:57 -07:00
parent 6dd3150d2b
commit f823b73a40
2 changed files with 17 additions and 7 deletions

View File

@ -59,9 +59,13 @@ Filter =
], 60
continue
# Filter OPs along with their threads, replies only, or both.
# Defaults to both.
op = filter.match(/[^t]op:(yes|no|only)/)?[1] or 'yes'
# Filter OPs along with their threads or replies only.
op = filter.match(/[^t]op:(no|only)/)?[1] or ''
mask = {'no': 1, 'only': 2}[op] or 0
# Filter only posts with/without files.
file = filter.match(/file:(no|only)/)?[1] or ''
mask = mask | ({'no': 4, 'only': 8}[file] or 0)
# Overrule the `Show Stubs` setting.
# Defaults to stub showing.
@ -96,7 +100,7 @@ Filter =
# Hide the post (default case).
hide = !(hl or noti)
filter = {isstring, regexp, boards, excludes, op, hide, stub, hl, top, noti}
filter = {isstring, regexp, boards, excludes, mask, hide, stub, hl, top, noti}
if key is 'general'
for type in types
(@filters[type] or= []).push filter
@ -117,13 +121,15 @@ Filter =
noti = false
if QuoteYou.isYou(post)
hideable = false
mask = (if post.isReply then 2 else 1)
mask = (mask | (if post.file then 4 else 8))
for key of Filter.filters when ((value = Filter[key] post)?)
# Continue if there's nothing to filter (no tripcode for example).
for filter in Filter.filters[key]
continue if (
(filter.boards and !filter.boards[post.boardID]) or
(filter.excludes and filter.excludes[post.boardID]) or
filter.op is (if post.isReply then 'only' else 'no') or
(filter.mask & mask) or
(if filter.isstring then (filter.regexp isnt value) else !filter.regexp.test(value))
)
if filter.hide

View File

@ -15,8 +15,12 @@
For example: <code>exclude:vg,v;</code>.
</li>
<li>
Filter OPs only along with their threads (`only`), replies only (`no`), or both (`yes`, this is default).<br>
For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.
Filter OPs only along with their threads (`only`) or replies only (`no`).<br>
For example: <code>op:only;</code> or <code>op:no;</code>.
</li>
<li>
Filter only posts with files (`only`) or only posts without files (`no`).<br>
For example: <code>file:only;</code> or <code>file:no;</code>.
</li>
<li>
Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>