Fix merge, WebExtension performance improvement

main
Elbert Alias 6 years ago
commit 9ce95a665d

File diff suppressed because it is too large Load Diff

@ -288,20 +288,22 @@ class Driver {
this.wappalyzer.log(error.message, 'browser', 'error'); this.wappalyzer.log(error.message, 'browser', 'error');
} }
const chunks = []; if (this.options.htmlMaxCols || this.options.htmlMaxRows) {
const maxCols = this.options.htmlMaxCols; const chunks = [];
const maxRows = this.options.htmlMaxRows; const maxCols = this.options.htmlMaxCols;
const rows = html.length / maxCols; const maxRows = this.options.htmlMaxRows;
const rows = html.length / maxCols;
let i; let i;
for (i = 0; i < rows; i += 1) { for (i = 0; i < rows; i += 1) {
if (i < maxRows / 2 || i > rows - maxRows / 2) { if (i < maxRows / 2 || i > rows - maxRows / 2) {
chunks.push(html.slice(i * maxCols, (i + 1) * maxCols)); chunks.push(html.slice(i * maxCols, (i + 1) * maxCols));
}
} }
}
html = chunks.join('\n'); html = chunks.join('\n');
}
return html; return html;
} }

@ -68,6 +68,6 @@
"categoryName55": { "message": "Buchhaltung" }, "categoryName55": { "message": "Buchhaltung" },
"categoryName56": { "message": "Cryptominer" }, "categoryName56": { "message": "Cryptominer" },
"categoryName57": { "message": "Statischer Seitengenerator" }, "categoryName57": { "message": "Statischer Seitengenerator" },
"categoryName58": { "message": "User Onboarding" }, "categoryName58": { "message": "Benutzer-Einbindung" },
"categoryName59": { "message": "JavaScript Libraries" } "categoryName59": { "message": "JavaScript Bibliotheken" }
} }

@ -17,14 +17,22 @@ if (typeof browser !== 'undefined' && typeof document.body !== 'undefined') {
sendMessage('init', {}); sendMessage('init', {});
// HTML // HTML
let html = new XMLSerializer().serializeToString(document) let html = new XMLSerializer().serializeToString(document);
.replace(new RegExp('(.{1000,}[^>]*>)<', 'g'), (match, p1) => `${p1}\n<`)
.split('\n'); const chunks = [];
const maxCols = 2000;
html = html const maxRows = 3000;
.slice(0, 1000).concat(html.slice(html.length - 1000)) const rows = html.length / maxCols;
.map(line => line.substring(0, 1000))
.join('\n'); let i;
for (i = 0; i < rows; i += 1) {
if (i < maxRows / 2 || i > rows - maxRows / 2) {
chunks.push(html.slice(i * maxCols, (i + 1) * maxCols));
}
}
html = chunks.join('\n');
// Scripts // Scripts
const scripts = Array.prototype.slice const scripts = Array.prototype.slice

@ -1,3 +1,5 @@
/* eslint-env browser */
(() => { (() => {
try { try {
const detectJs = (chain) => { const detectJs = (chain) => {

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 902 B

@ -0,0 +1 @@
<svg height="700pt" preserveAspectRatio="xMidYMid meet" viewBox="0 0 700 700" width="700pt" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(.1 0 0 -.1 0 700)"><path d="m3322 4704c-466-78-816-447-903-952-37-220-23-482 38-692 118-409 436-694 848-761 112-18 330-16 440 5 496 93 807 421 902 951 25 141 23 410-6 553-96 491-414 817-875 897-109 19-329 18-444-1zm288-415c280-45 468-323 487-719 14-297-58-542-204-700-106-115-245-169-398-156-192 15-336 119-431 311-149 302-131 759 41 1025 83 129 189 205 327 235 79 17 97 17 178 4z"/><path d="m5617 4704c-289-52-501-199-602-419-43-92-55-154-55-281 0-122 26-218 85-310 102-160 255-265 540-374 244-93 335-147 380-223 76-130 15-276-141-338-54-21-74-23-219-23-146 1-170 3-277 32-64 17-156 47-203 67-47 21-89 35-92 31-3-3-29-103-58-221l-53-216 57-25c73-33 199-69 314-91 134-25 480-25 595 0 349 77 548 239 633 517 27 88 32 259 10 350-46 191-193 356-417 468-34 17-126 57-205 88-341 134-423 204-406 350 5 51 41 103 95 139 119 78 388 73 619-10 54-20 102-37 107-38 6-1 37 94 69 212 49 173 57 215 46 222-35 22-210 71-315 89-139 24-386 26-507 4z"/><path d="m1299 4050c-77-12-173-46-238-82-63-36-166-130-206-189-25-35-30-38-36-22-4 10-8 63-8 118-2 158 11 146-150 143l-136-3 3-25c2-14 6-550 9-1192l5-1168h154 154v456 457l40-51c82-102 233-180 391-202 334-46 663 154 788 479 91 235 97 563 14 794-85 240-260 413-479 471-73 20-230 28-305 16zm193-270c165-62 277-210 323-425 43-206-1-472-104-624-217-319-716-245-840 126-19 56-21 86-21 284 0 247 8 300 63 404 65 122 177 213 308 250 73 20 196 14 271-15z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256"><path fill="#8759F2" d="M128.928 163.067L81.066 80.152H32.898c-19.702.055-31.987 21.368-22.187 38.44L82.65 243.22c9.787 16.957 34.5 17.13 44.415-.023l46.277-80.15c-9.912 17.165-34.637 16.953-44.415.02z"/><path fill="#FF3E80" d="M176.806 80.152h-95.75l47.862 82.918c9.788 16.96 34.5 17.13 44.415-.023l25.665-44.422c9.908-17.17-2.642-38.475-22.192-38.473z"/><path fill="#FFC300" d="M223.083 0H79.176C59.473.055 47.188 21.367 56.988 38.44c0 .02 24.078 41.71 24.078 41.71h95.75c19.775 0 32 21.485 22.185 38.475l46.277-80.15C255.101 21.445 242.808 0 223.083 0z"/><path fill="#00D4E6" d="M56.998 38.442a25.638 25.638 0 0 1 .025-25.612L10.748 92.977A25.638 25.638 0 0 1 32.911 80.15h48.165L56.998 38.442z"/></svg>

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@ -0,0 +1 @@
<svg class="mx-auto block h-24 mb-3" viewBox="0 0 90 90" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><circle id="b" cx="40" cy="40" r="40"></circle><filter x="-8.8%" y="-6.2%" width="117.5%" height="117.5%" filterUnits="objectBoundingBox" id="a"><feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset><feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" in="shadowBlurOuter1"></feColorMatrix></filter><linearGradient x1="0%" y1="0%" y2="100%" id="c"><stop stop-color="#2383AE" offset="0%"></stop><stop stop-color="#6DD7B9" offset="100%"></stop></linearGradient></defs><g fill="none" fill-rule="evenodd"><g transform="translate(5 5)"><use fill="#000" filter="url(#a)" xlink:href="#b"></use><use fill="#FFF" xlink:href="#b"></use></g><path d="M25.6 33.92C27.52 26.24 32.32 22.4 40 22.4c11.52 0 12.96 8.64 18.72 10.08 3.84.96 7.2-.48 10.08-4.32-1.92 7.68-6.72 11.52-14.4 11.52-11.52 0-12.96-8.64-18.72-10.08-3.84-.96-7.2.48-10.08 4.32zM11.2 51.2c1.92-7.68 6.72-11.52 14.4-11.52 11.52 0 12.96 8.64 18.72 10.08 3.84.96 7.2-.48 10.08-4.32-1.92 7.68-6.72 11.52-14.4 11.52-11.52 0-12.96-8.64-18.72-10.08-3.84-.96-7.2.48-10.08 4.32z" fill="url(#c)" transform="translate(5 5)"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

@ -160,6 +160,8 @@ class Wappalyzer {
this.detected[url.canonical] = {}; this.detected[url.canonical] = {};
} }
const metas = [];
// Additional information // Additional information
let language = null; let language = null;
@ -171,6 +173,20 @@ class Wappalyzer {
const matches = data.html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i); const matches = data.html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i);
language = matches && matches.length ? matches[1] : null; language = matches && matches.length ? matches[1] : null;
// grab metas
const regex = /<meta[^>]+>/ig;
let metaMatches;
do {
metaMatches = regex.exec(html);
if (!metaMatches) {
break;
}
const [match] = metaMatches;
metas.push(match);
} while (metaMatches);
} }
Object.keys(this.apps).forEach((appName) => { Object.keys(this.apps).forEach((appName) => {
@ -184,7 +200,7 @@ class Wappalyzer {
if (html) { if (html) {
promises.push(this.analyzeHtml(app, html)); promises.push(this.analyzeHtml(app, html));
promises.push(this.analyzeMeta(app, html)); promises.push(this.analyzeMeta(app, metas));
} }
if (scripts) { if (scripts) {
@ -556,8 +572,7 @@ class Wappalyzer {
/** /**
* Analyze meta tag * Analyze meta tag
*/ */
analyzeMeta(app, html) { analyzeMeta(app, metas) {
const regex = /<meta[^>]+>/ig;
const patterns = this.parsePatterns(app.props.meta); const patterns = this.parsePatterns(app.props.meta);
const promises = []; const promises = [];
@ -565,17 +580,7 @@ class Wappalyzer {
return Promise.resolve(); return Promise.resolve();
} }
let matches; metas.forEach((match) => {
do {
matches = regex.exec(html);
if (!matches) {
break;
}
const [match] = matches;
Object.keys(patterns).forEach((meta) => { Object.keys(patterns).forEach((meta) => {
const r = new RegExp(`(?:name|property)=["']${meta}["']`, 'i'); const r = new RegExp(`(?:name|property)=["']${meta}["']`, 'i');
@ -589,7 +594,7 @@ class Wappalyzer {
})); }));
} }
}); });
} while (matches); });
return Promise.all(promises); return Promise.all(promises);
} }