Show icon when no technologies are identified, add htmlMaxCols and htmlMaxRows options in NPM driver

main
Elbert Alias 7 years ago
parent 2b57a2c97b
commit dc0031e917

@ -27,14 +27,16 @@ node index.js [url] [options]
### Options
```
--chunk-size=num Process links in chunks.
--debug=0|1 Output debug messages.
--delay=ms Wait for ms milliseconds between requests.
--max-depth=num Don't analyse pages more than num levels deep.
--max-urls=num Exit when num URLs have been analysed.
--max-wait=ms Wait no more than ms milliseconds for page resources to load.
--recursive=0|1 Follow links on pages (crawler).
--user-agent=str Set the user agent string.
--chunk-size=num Process links in chunks.
--debug=0|1 Output debug messages.
--delay=ms Wait for ms milliseconds between requests.
--max-depth=num Don't analyse pages more than num levels deep.
--max-urls=num Exit when num URLs have been analysed.
--max-wait=ms Wait no more than ms milliseconds for page resources to load.
--recursive=0|1 Follow links on pages (crawler).
--user-agent=str Set the user agent string.
--html-max-cols=num Limit the number of HTML characters per line processed.
--html-max-rows=num Limit the number of HTML lines processed.
```
@ -49,6 +51,8 @@ const options = {
maxWait: 5000,
recursive: true,
userAgent: 'Wappalyzer',
htmlMaxCols: 2000,
htmlMaxRows: 2000,
};
const wappalyzer = new Wappalyzer('https://www.wappalyzer.com', options);

@ -21,6 +21,8 @@ class Driver {
maxWait: 5000,
recursive: false,
userAgent: 'Mozilla/5.0 (compatible; Wappalyzer)',
htmlMaxCols: 2000,
htmlMaxRows: 2000,
}, options || {});
this.options.debug = Boolean(this.options.debug);
@ -28,6 +30,8 @@ class Driver {
this.options.maxDepth = parseInt(this.options.maxDepth, 10);
this.options.maxUrls = parseInt(this.options.maxUrls, 10);
this.options.maxWait = parseInt(this.options.maxWait, 10);
this.options.htmlMaxCols = parseInt(this.options.htmlMaxCols, 10);
this.options.htmlMaxRows = parseInt(this.options.htmlMaxRows, 10);
this.options.recursive = Boolean(this.options.recursive);
this.origPageUrl = url.parse(pageUrl);
@ -216,11 +220,11 @@ class Driver {
let html = '';
try {
html = browser.html();
if ( html.length > 50000 ) {
html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length);
}
html = browser.html()
.split('\n')
.slice(0, this.options.htmlMaxRows / 2).concat(html.slice(html.length - this.options.htmlMaxRows / 2))
.map(line => line.substring(0, this.options.htmlMaxCols))
.join('\n');
} catch ( error ) {
this.wappalyzer.log(error.message, 'browser', 'error');
}

@ -148,7 +148,7 @@ body {
.empty {
display: flex;
height: 16rem;
height: 14.5rem;
align-items: center;
justify-content: center;
}

@ -240,47 +240,45 @@ wappalyzer.driver.displayApps = (detected, meta, context) => {
tabCache[tab.id].detected = detected;
if ( Object.keys(detected).length ) {
var appName, found = false;
var appName, found = false;
// Find the main application to display
[ options.pinnedCategory ].concat(categoryOrder).forEach(match => {
Object.keys(detected).forEach(appName => {
var app = detected[appName];
// Find the main application to display
[ options.pinnedCategory ].concat(categoryOrder).forEach(match => {
Object.keys(detected).forEach(appName => {
var app = detected[appName];
app.props.cats.forEach(category => {
if ( category === match && !found ) {
var icon = app.props.icon || 'default.svg';
app.props.cats.forEach(category => {
if ( category === match && !found ) {
var icon = app.props.icon || 'default.svg';
if ( !options.dynamicIcon ) {
icon = 'default.svg';
}
if ( /\.svg$/i.test(icon) ) {
icon = 'converted/' + icon.replace(/\.svg$/, '.png');
}
if ( !options.dynamicIcon ) {
icon = 'default.svg';
}
try {
browser.pageAction.setIcon({
tabId: tab.id,
path: '../images/icons/' + icon
});
} catch(e) {
// Firefox for Android does not support setIcon see https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
}
if ( /\.svg$/i.test(icon) ) {
icon = 'converted/' + icon.replace(/\.svg$/, '.png');
}
found = true;
try {
browser.pageAction.setIcon({
tabId: tab.id,
path: '../images/icons/' + icon
});
} catch(e) {
// Firefox for Android does not support setIcon see https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
}
});
found = true;
}
});
});
});
if ( typeof chrome !== 'undefined' ) {
// Browser polyfill doesn't seem to work here
chrome.pageAction.show(tab.id);
} else {
browser.pageAction.show(tab.id);
}
if ( typeof chrome !== 'undefined' ) {
// Browser polyfill doesn't seem to work here
chrome.pageAction.show(tab.id);
} else {
browser.pageAction.show(tab.id);
}
};

@ -72,5 +72,3 @@
],
"content_security_policy": "script-src 'self'; object-src 'self'"
}