diff --git a/www/assets/js/channelsettings.js b/www/assets/js/channelsettings.js index c7919efe..714b91be 100644 --- a/www/assets/js/channelsettings.js +++ b/www/assets/js/channelsettings.js @@ -142,4 +142,60 @@ $("#newfilter_flags").val("g"); $("#newfilter_replace").val(""); }); + function splitreEntry(str) { + var split = []; + var current = []; + for(var i = 0; i < str.length; i++) { + if(str[i] == "\\" && i+1 < str.length && str[i+1].match(/\s/)) { + current.push(str[i+1]); + i++; + continue; + } + else if(str[i].match(/\s/)) { + split.push(current.join("")); + current = []; + } + else { + current.push(str[i]); + } + } + split.push(current.join("")); + return split; + } + + $("#multifiltersubmit").click(function () { + var lines = $("#multifiltereditor").val().split("\n"); + for(var i in lines) { + var ln = lines[i]; + var fields = splitreEntry(ln); + if(fields.length < 3 || fields.length > 4) { + makeAlert("Error on line "+(parseInt(i)+1)+". Format: name regex flags replacement", "alert-error") + .insertBefore($("#multifiltereditor")); + return; + } + + var name = "", re = "", f = "", replace = ""; + if(fields.length == 3) { + name = fields[0]; + re = fields[0]; + f = fields[1]; + replace = fields[2]; + } + else if(fields.length == 4) { + name = fields[0]; + re = fields[1]; + f = fields[2]; + replace = fields[3]; + } + + socket.emit("updateFilter", { + name: name, + source: re, + flags: f, + replace: replace, + filterlinks: false, + active: true + }); + } + }); })(); diff --git a/www/channeloptions.html b/www/channeloptions.html index b3df2ebe..4af0e432 100644 --- a/www/channeloptions.html +++ b/www/channeloptions.html @@ -114,19 +114,6 @@

Filters will be processed in the order that they are listed here. Click and drag a row to rearrange the order. Click a regex, flags, or replacement field to edit a filter. Changes are automatically saved when you finish editing.

- - - - - - - - - - - - -
DeleteNameRegexFlagsReplacementAffects LinksActive
Add Filter
@@ -175,6 +162,22 @@
+ + + + + + + + + + + + +
DeleteNameRegexFlagsReplacementAffects LinksActive
+

Multi-Filter Editor (format: name regex flags replacement). Only use this if you know what you are doing

+ +

Max 20KB. If you need more space, host the file externally and use the External CSS option