From 70cee9ca8b4a1109cf965d34df3f0dc28a8557b2 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 21 Feb 2012 04:41:40 +0100 Subject: [PATCH] You can specify a highlight class. Defaults to filter_highlight. --- 4chan_x.user.js | 8 +++++--- script.coffee | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 071de23c1..319323e16 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -534,7 +534,7 @@ filter = { filters: {}, init: function() { - var boards, filter, hl, key, op, regexp, _i, _len, _ref, _ref2, _ref3; + var boards, filter, hl, key, op, regexp, _i, _len, _ref, _ref2, _ref3, _ref4; for (key in config.filter) { this.filters[key] = []; _ref = conf[key].split('\n'); @@ -554,7 +554,9 @@ continue; } op = ((_ref3 = filter.match(/op:(yes|no|only)/)) != null ? _ref3[1].toLowerCase() : void 0) || 'no'; - hl = /highlight/.test(filter); + if (hl = /highlight/.test(filter)) { + hl = ((_ref4 = filter.match(/highlight:(\w+)/)) != null ? _ref4[1].toLowerCase() : void 0) || 'filter_highlight'; + } this.filters[key].push(this.createFilter(regexp, op, hl)); } if (!this.filters[key].length) delete this.filters[key]; @@ -566,7 +568,7 @@ if (isOP && op === 'no' || !isOP && op === 'only') return false; if (!regexp.test(value)) return false; if (hl) { - $.addClass(root, 'filter_highlight'); + $.addClass(root, hl); } else if (isOP) { if (!g.REPLY) threadHiding.hideHide(root.parentNode); } else { diff --git a/script.coffee b/script.coffee index 68d23c7fa..c1aa05e8f 100644 --- a/script.coffee +++ b/script.coffee @@ -441,8 +441,10 @@ filter = op = filter.match(/op:(yes|no|only)/)?[1].toLowerCase() or 'no' # Highlight the post, or hide it. + # If not specified, the highlight class will be filter_highlight. # Defaults to post hiding. - hl = /highlight/.test filter + if hl = /highlight/.test filter + hl = filter.match(/highlight:(\w+)/)?[1].toLowerCase() or 'filter_highlight' @filters[key].push @createFilter regexp, op, hl @@ -460,7 +462,7 @@ filter = unless regexp.test value return false if hl - $.addClass root, 'filter_highlight' + $.addClass root, hl else if isOP unless g.REPLY threadHiding.hideHide root.parentNode