From 21dedba555d700d84ae56c683c9490644075a68e Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 16 May 2018 19:20:16 +0300 Subject: [PATCH] feat(filtering): negative name filter --- src/app/filters-page.js | 13 +++++++++++++ src/background/config.js | 1 + src/background/spider.js | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/filters-page.js b/src/app/filters-page.js index a831e2b..6a60cdd 100644 --- a/src/app/filters-page.js +++ b/src/app/filters-page.js @@ -108,8 +108,21 @@ export default class ConfigPage extends Page { > \u0400-\u04FF]+$`} primaryText="Russian + English only (With symbols)" /> ]+$'} primaryText="English only (With symbols)" /> + + { + if(!this.options.filters) + return + + this.options.filters.namingRegExpNegative = checked + this.forceUpdate() + }} + />
* - clean string means disabled
diff --git a/src/background/config.js b/src/background/config.js index d89c421..8827284 100644 --- a/src/background/config.js +++ b/src/background/config.js @@ -40,6 +40,7 @@ let config = { filters: { maxFiles: 0, namingRegExp: '', + namingRegExpNegative: false, adultFilter: false, }, diff --git a/src/background/spider.js b/src/background/spider.js index c3c43d2..0de3a22 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -404,11 +404,16 @@ const checkTorrent = (torrent) => { if(nameRX && nameRX.length > 0) { const rx = new RegExp(nameRX) - if(!rx.test(torrent.name)) + if(!config.filters.namingRegExpNegative && !rx.test(torrent.name)) { console.log('ignore', torrent.name, 'by naming rx') return false } + else if(config.filters.namingRegExpNegative && rx.test(torrent.name)) + { + console.log('ignore', torrent.name, 'by naming rx negative') + return false + } } if(torrent.contentType === 'bad')