From 60b5494f916127280056d272bdd6874a000c19dc Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 25 Sep 2011 18:56:45 +0200 Subject: [PATCH] Read & store RegExps --- 4chan_x.user.js | 23 ++++++++++++++++++++--- script.coffee | 15 +++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1a78e95e4..b5c7ed548 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -528,11 +528,28 @@ }; filter = { init: function() { - return HTMLBlockquoteElement.prototype.toString = function() { + var filter, filters, key, m, regx, _i, _len; + HTMLBlockquoteElement.prototype.toString = function() { return ($.el('span', { innerHTML: this.innerHTML.replace(/
/g, '\n') })).textContent; }; + filters = {}; + for (key in config.filter) { + filters[key] = []; + if (!(m = conf[key].match(/(.+)/g))) { + continue; + } + for (_i = 0, _len = m.length; _i < _len; _i++) { + filter = m[_i]; + try { + if ((regx = eval(filter)).constructor === RegExp) { + filters[key].push(regx); + } + } catch (_e) {} + } + } + return log(filters); } }; expandComment = { @@ -1164,8 +1181,8 @@ \ \
\ - Filters are case-insensitive. One filter per line.
\ - You can use regular expressions, without opening and ending `/`, and without flags.\ + Use regular expressions, one per line.
\ + For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive.\

Name:

\

Tripcode:

\

E-mail:

\ diff --git a/script.coffee b/script.coffee index 43cf7be14..3af106d67 100644 --- a/script.coffee +++ b/script.coffee @@ -388,6 +388,17 @@ filter = HTMLBlockquoteElement.prototype.toString = -> return ($.el 'span', innerHTML: @innerHTML.replace /
/g, '\n').textContent + filters = {} + for key of config.filter + filters[key] = [] + unless m = conf[key].match /(.+)/g + continue + for filter in m + try if (regx = eval filter).constructor is RegExp + filters[key].push regx + + log filters + expandComment = init: -> for a in $$ 'span.abbr a' @@ -835,8 +846,8 @@ options =
- Filters are case-insensitive. One filter per line.
- You can use regular expressions, without opening and ending `/`, and without flags. + Use regular expressions, one per line.
+ For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive.

Name:

Tripcode:

E-mail: