From 3a483c3fb1b6b6ba53017d6e833b03f1abfe472d Mon Sep 17 00:00:00 2001 From: Stanislav Popov Date: Thu, 11 Mar 2021 12:25:03 +0500 Subject: [PATCH] feat: --disable-plugins command line argument --- README.md | 3 +++ src/program.js | 4 +++- src/registry.js | 3 +++ src/scrap-site.js | 3 +++ src/server.js | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0342361..1c2e8dd 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,9 @@ npm install site-audit-seo-readability npm install site-audit-seo-yake ``` +#### Disable plugins: +You can add argument such: `--disable-plugins readability,yake`. It more faster, but less data extracted. + ## Credentials Based on [headless-chrome-crawler](https://github.com/yujiosaka/headless-chrome-crawler) (puppeteer). Used forked version [@popstas/headless-chrome-crawler](https://github.com/popstas/headless-chrome-crawler). diff --git a/src/program.js b/src/program.js index 9237a86..45f7eb1 100644 --- a/src/program.js +++ b/src/program.js @@ -218,6 +218,7 @@ program.option('-u --urls ', 'Comma separated url list for scan', list). getConfigVal('openFile', undefined)). option('--no-open-file', `Don't open file after scan`). option('--no-console-validate', `Don't output validate messages in console`). + option('--disable-plugins ', `Comma-separated plugin list`, list). name('site-audit-seo'). version(packageJson.version). usage('-u https://example.com --upload') @@ -253,7 +254,8 @@ program.getOptions = () => { consoleValidate: program.consoleValidate, // выводить данные валидации в консоль obeyRobotsTxt: !program.ignoreRobotsTxt, // chrome-crawler, не учитывать блокировки в robots.txt influxdb: program.influxdb, // конфиг influxdb - urls: program.urls // адреса для одиночного сканирования + urls: program.urls, // адреса для одиночного сканирования + disablePlugins: program.disablePlugins }; return opts; } diff --git a/src/registry.js b/src/registry.js index 3cbaa36..2f81407 100644 --- a/src/registry.js +++ b/src/registry.js @@ -78,6 +78,9 @@ async function execPlugins(jsonPath, options, type = 'any') { if (!plugins) return; // console.log(`\n${color.white}exec plugins (${type}):${color.reset}`); for (let plugin of plugins) { + if (options.disablePlugins.includes(plugin.name)){ + continue; + } if (type !== 'any' && plugin.type != type) continue; // console.log(`exec plugin ${plugin.name} (type ${type}):`); diff --git a/src/scrap-site.js b/src/scrap-site.js index 9a5299e..d5705ff 100644 --- a/src/scrap-site.js +++ b/src/scrap-site.js @@ -116,6 +116,9 @@ module.exports = async (baseUrl, options = {}) => { // plugins fields const plugins = registry.getPlugins(); for (let plugin of plugins) { + if (options.disablePlugins.includes(plugin.name)){ + continue; + } if (plugin.fields) for(let field of plugin.fields) { if (typeof field === 'string') { fields.push(field); diff --git a/src/server.js b/src/server.js index e241287..4aa5143 100644 --- a/src/server.js +++ b/src/server.js @@ -95,6 +95,7 @@ async function onScan(url, args, socket) { delete(program.consoleValidate); delete(program.influxdb); delete(program.urls); + program.disablePlugins = []; program.exitOverride(); try {