Refactor bot. (#8)

This commit is contained in:
dada513 2022-06-07 11:08:49 +02:00 committed by GitHub
parent e0374bea36
commit 259d540e6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 491 additions and 300 deletions

View file

@ -1,38 +0,0 @@
import { FiltersEngine, Request } from '@cliqz/adblocker';
import fetch from 'node-fetch';
let engine: FiltersEngine;
const init = async () => {
if (engine) return;
console.log('initializing FiltersEngine');
engine = await FiltersEngine.fromLists(
fetch,
[
'https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badware.txt',
'https://malware-filter.gitlab.io/malware-filter/phishing-filter.txt',
],
{
enableInMemoryCache: true,
enableOptimizations: true,
enableCompression: true,
}
);
};
export const isBad = async (url: string) => {
await init();
const { match } = engine.match(
Request.fromRawDetails({
type: 'mainFrame',
url,
})
);
console.log('Testing URL', url, match);
return match;
};