Make up for how limited Fanfiction.net's result filtering is
< 腳本Fanfiction.net Unwanted Result Filter的回應
Thanks. The script's innards are already getting a bit unwieldy, so I'll probably refactor that code to reduce duplication before I merge it, but it does look correct at first glance.
I was actually thinking about description filtering so things like "HP/DM" (Harry Potter - Draco Malfoy pairing) could be filtered out.
where would I patch this code in?
It's in diff format so, unless I changed the source too much since then, the UNIX patch
tool (or anything else compatible) should figure that out for you if you name the script old.js (see line 1) and then apply the patch against it.
I'll see if I can find time tomorrow to get you a better answer.
OK, today didn't go as expected and I've been having trouble finding a nice, simple GUI for applying diff patches on Windows, but I can at least explain how to apply one of these manually.
A unified diff file is broken up into a series of chunks, each with a @@
line at the top. (In this case, six chunks.)
Inside a chunk, lines prefixed with +
should be added and lines starting with -
should be removed.
So, for example, this chunk...
@@ -305,6 +352,7 @@
var not_slash_re = new RegExp(GM_config.get('not_slash_pat'), 'i');
var cats_re = new RegExp("(?:^|- )(.*(" + bad_cats.join('|') + ').*) - Rated:.*');
var cat_link_re = new RegExp(bad_cats.join('|'));
+ var words_re = new RegExp(bad_words.join('|'), 'i');
// Clean up after any previous run
$(".filter_placeholder").remove();
says to find this in the file (which should be near line 305
according to the @@
line)...
var not_slash_re = new RegExp(GM_config.get('not_slash_pat'), 'i');
var cats_re = new RegExp("(?:^|- )(.*(" + bad_cats.join('|') + ').*) - Rated:.*');
var cat_link_re = new RegExp(bad_cats.join('|'));
// Clean up after any previous run
$(".filter_placeholder").remove();
...and turn it into this:
var not_slash_re = new RegExp(GM_config.get('not_slash_pat'), 'i');
var cats_re = new RegExp("(?:^|- )(.*(" + bad_cats.join('|') + ').*) - Rated:.*');
var cat_link_re = new RegExp(bad_cats.join('|'));
var words_re = new RegExp(bad_words.join('|'), 'i');
// Clean up after any previous run
$(".filter_placeholder").remove();
That is, add the var words_re
line after the var cat_link_re
line.
Quick hack to (if I've got it right) filter by a word list.