diff --git a/4chan_x.user.js b/4chan_x.user.js index ad8177618..f20ab7e2a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -528,15 +528,16 @@ regexps: {}, callbacks: [], init: function() { - var filter, key, m, _i, _len; + var f, filter, key, m, _i, _len; for (key in config.filter) { - if (!(m = conf[key].match(/^(\/.+\/\w{0,})$/gm))) { + if (!(m = conf[key].match(/^\/.+\/\w*$/gm))) { continue; } this.regexps[key] = []; for (_i = 0, _len = m.length; _i < _len; _i++) { filter = m[_i]; - this.regexps[key].push(Function("return " + filter)()); + f = filter.match(/^\/(.+)\/(\w*)$/); + this.regexps[key].push(RegExp(f[1], f[2])); } if (this.regexps[key].length) { this.callbacks.push(this[key]); diff --git a/script.coffee b/script.coffee index 55ec87894..e6d206747 100644 --- a/script.coffee +++ b/script.coffee @@ -386,11 +386,12 @@ filter = callbacks: [] init: -> for key of config.filter - unless m = conf[key].match /^(\/.+\/\w{0,})$/gm + unless m = conf[key].match /^\/.+\/\w*$/gm continue @regexps[key] = [] for filter in m - @regexps[key].push Function("return #{filter}")() + f = filter.match /^\/(.+)\/(\w*)$/ + @regexps[key].push RegExp f[1], f[2] #only execute what's filterable @callbacks.push @[key] if @regexps[key].length