diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index a3961ea86..0fb24d79d 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -158,6 +158,29 @@ Filter = filesize: (post) -> post.file?.size MD5: (post) -> post.file?.MD5 + addFilter: (type, re, cb) -> + $.get type, Conf[type], (item) -> + save = item[type] + # Add a new line before the regexp unless the text is empty. + save = + if save + "#{save}\n#{re}" + else + re + $.set type, save, cb + + quickFilterMD5: -> + post = Get.postFromNode @ + Filter.addFilter 'MD5', "/#{post.file.MD5}/" + origin = post.origin or post + if origin.isReply + PostHiding.hide origin + else if g.VIEW is 'index' + ThreadHiding.hide origin.thread + # If post is still visible, give an indication that the MD5 was filtered. + if post.nodes.post.getBoundingClientRect().height + new Notice 'info', 'MD5 filtered.', 2 + menu: init: -> return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter'] @@ -240,16 +263,7 @@ Filter = else "/^#{re}$/" - # Add a new line before the regexp unless the text is empty. - $.get type, Conf[type], (item) -> - save = item[type] - save = - if save - "#{save}\n#{re}" - else - re - $.set type, save - + Filter.addFilter type, re, -> # Open the settings and display & focus the relevant filter textarea. Settings.open 'Filter' section = $ '.section-container' diff --git a/src/General/Settings/Advanced.html b/src/General/Settings/Advanced.html index 324e5e55c..3934d557e 100644 --- a/src/General/Settings/Advanced.html +++ b/src/General/Settings/Advanced.html @@ -77,6 +77,7 @@
Link: %l (truncated), %L (untruncated), %T (4chan filename)
Filename: %n (truncated), %N (untruncated), %t (4chan filename)
Download button: %d
+
Quick filter MD5: %f
Spoiler indicator: %p
Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)
Resolution: %r (Displays 'PDF' for PDF files)
diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index 1820b153d..4f3a9b36a 100644 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -11,6 +11,8 @@ FileInfo = if @isClone for a in $$ '.file-info .download-button', @file.text $.on a, 'click', ImageCommon.download + for a in $$ '.file-info .quick-filter-md5', @file.text + $.on a, 'click', Filter.quickFilterMD5 return oldInfo = $.el 'span', {className: 'fileText-original'} @@ -32,6 +34,8 @@ FileInfo = $.extend outputNode, <%= html('@{output}') %> for a in $$ '.download-button', outputNode $.on a, 'click', ImageCommon.download + for a in $$ '.quick-filter-md5', outputNode + $.on a, 'click', Filter.quickFilterMD5 return formatters: @@ -48,6 +52,7 @@ FileInfo = <%= html('${shortname}${fullname}') %> N: -> <%= html('${this.file.name}') %> d: -> <%= html('') %> + f: -> <%= html('') %> p: -> <%= html('?{this.file.isSpoiler}{Spoiler, }') %> s: -> <%= html('${this.file.size}') %> B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>