Performance improvements

main
Elbert Alias 2 years ago
parent d837d9421c
commit c7417f1b89

@ -131,7 +131,20 @@ function getDom(page, technologies = Wappalyzer.technologies) {
dom[selector].forEach(({ exists, text, properties, attributes }) => { dom[selector].forEach(({ exists, text, properties, attributes }) => {
nodes.forEach((node) => { nodes.forEach((node) => {
if (exists) { if (
technologies.filter(({ name: _name }) => _name === name)
.length >= 50
) {
return
}
if (
exists &&
technologies.findIndex(
({ name: _name, selector: _selector, exists }) =>
name === _name && selector === _selector && exists === ''
) === -1
) {
technologies.push({ technologies.push({
name, name,
selector, selector,
@ -140,9 +153,18 @@ function getDom(page, technologies = Wappalyzer.technologies) {
} }
if (text) { if (text) {
const value = node.textContent.trim() // eslint-disable-next-line unicorn/prefer-text-content
const value = (
if (value) { node.textContent ? node.textContent.trim() : ''
).slice(0, 1000000)
if (
value &&
technologies.findIndex(
({ name: _name, selector: _selector, text }) =>
name === _name && selector === _selector && text === value
) === -1
) {
technologies.push({ technologies.push({
name, name,
selector, selector,
@ -153,7 +175,21 @@ function getDom(page, technologies = Wappalyzer.technologies) {
if (properties) { if (properties) {
Object.keys(properties).forEach((property) => { Object.keys(properties).forEach((property) => {
if (Object.prototype.hasOwnProperty.call(node, property)) { if (
Object.prototype.hasOwnProperty.call(node, property) &&
technologies.findIndex(
({
name: _name,
selector: _selector,
property: _property,
value,
}) =>
name === _name &&
selector === _selector &&
property === _property &&
value === toScalar(value)
) === -1
) {
const value = node[property] const value = node[property]
if (typeof value !== 'undefined') { if (typeof value !== 'undefined') {
@ -170,7 +206,21 @@ function getDom(page, technologies = Wappalyzer.technologies) {
if (attributes) { if (attributes) {
Object.keys(attributes).forEach((attribute) => { Object.keys(attributes).forEach((attribute) => {
if (node.hasAttribute(attribute)) { if (
node.hasAttribute(attribute) &&
technologies.findIndex(
({
name: _name,
selector: _selector,
attribute: _atrribute,
value,
}) =>
name === _name &&
selector === _selector &&
attribute === _atrribute &&
value === toScalar(value)
) === -1
) {
const value = node.getAttribute(attribute) const value = node.getAttribute(attribute)
technologies.push({ technologies.push({

@ -13,7 +13,7 @@
"software" "software"
], ],
"homepage": "https://www.wappalyzer.com/", "homepage": "https://www.wappalyzer.com/",
"version": "6.10.45", "version": "6.10.46",
"author": "Wappalyzer", "author": "Wappalyzer",
"license": "MIT", "license": "MIT",
"repository": { "repository": {

@ -71,9 +71,22 @@ async function getDom(technologies) {
return return
} }
dom[selector].forEach(({ exists, text, attributes }) => { dom[selector].forEach(({ exists, text, properties, attributes }) => {
nodes.forEach((node) => { nodes.forEach((node) => {
if (exists) { if (
technologies.filter(({ name: _name }) => _name === name).length >=
50
) {
return
}
if (
exists &&
technologies.findIndex(
({ name: _name, selector: _selector, exists }) =>
name === _name && selector === _selector && exists === ''
) === -1
) {
technologies.push({ technologies.push({
name, name,
selector, selector,
@ -83,9 +96,18 @@ async function getDom(technologies) {
if (text) { if (text) {
// eslint-disable-next-line unicorn/prefer-text-content // eslint-disable-next-line unicorn/prefer-text-content
const value = node.innerText ? node.innerText.trim() : '' const value = (node.innerText ? node.innerText.trim() : '').slice(
0,
1000000
)
if (value) { if (
value &&
technologies.findIndex(
({ name: _name, selector: _selector, text }) =>
name === _name && selector === _selector && text === value
) === -1
) {
technologies.push({ technologies.push({
name, name,
selector, selector,
@ -94,9 +116,54 @@ async function getDom(technologies) {
} }
} }
if (properties) {
Object.keys(properties).forEach((property) => {
if (
Object.prototype.hasOwnProperty.call(node, property) &&
technologies.findIndex(
({
name: _name,
selector: _selector,
property: _property,
value,
}) =>
name === _name &&
selector === _selector &&
property === _property &&
value === toScalar(value)
) === -1
) {
const value = node[property]
if (typeof value !== 'undefined') {
technologies.push({
name,
selector,
property,
value: toScalar(value),
})
}
}
})
}
if (attributes) { if (attributes) {
Object.keys(attributes).forEach((attribute) => { Object.keys(attributes).forEach((attribute) => {
if (node.hasAttribute(attribute)) { if (
node.hasAttribute(attribute) &&
technologies.findIndex(
({
name: _name,
selector: _selector,
attribute: _atrribute,
value,
}) =>
name === _name &&
selector === _selector &&
attribute === _atrribute &&
value === toScalar(value)
) === -1
) {
const value = node.getAttribute(attribute) const value = node.getAttribute(attribute)
technologies.push({ technologies.push({

@ -286,8 +286,6 @@ const Popup = {
return templates return templates
}, {}) }, {})
Popup.onGetDetections()
// Disabled domains // Disabled domains
const dynamicIcon = await getOption('dynamicIcon', false) const dynamicIcon = await getOption('dynamicIcon', false)

@ -4,7 +4,7 @@
"author": "Wappalyzer", "author": "Wappalyzer",
"homepage_url": "https://www.wappalyzer.com/", "homepage_url": "https://www.wappalyzer.com/",
"description": "Identify web technologies", "description": "Identify web technologies",
"version": "6.10.45", "version": "6.10.46",
"default_locale": "en", "default_locale": "en",
"manifest_version": 2, "manifest_version": 2,
"icons": { "icons": {

@ -4,7 +4,7 @@
"author": "Wappalyzer", "author": "Wappalyzer",
"homepage_url": "https://www.wappalyzer.com/", "homepage_url": "https://www.wappalyzer.com/",
"description": "Identify web technologies", "description": "Identify web technologies",
"version": "6.10.45", "version": "6.10.46",
"default_locale": "en", "default_locale": "en",
"manifest_version": 3, "manifest_version": 3,
"icons": { "icons": {

@ -13,7 +13,7 @@
"software" "software"
], ],
"homepage": "https://www.wappalyzer.com/", "homepage": "https://www.wappalyzer.com/",
"version": "6.10.45", "version": "6.10.46",
"author": "Wappalyzer", "author": "Wappalyzer",
"license": "MIT", "license": "MIT",
"repository": { "repository": {

@ -2307,4 +2307,4 @@
"implies": "Python", "implies": "Python",
"website": "http://gunicorn.org" "website": "http://gunicorn.org"
} }
} }

@ -1616,4 +1616,4 @@
"scriptSrc": "merchant\\.cdn\\.hoolah\\.co/", "scriptSrc": "merchant\\.cdn\\.hoolah\\.co/",
"website": "https://www.hoolah.co" "website": "https://www.hoolah.co"
} }
} }

@ -344,9 +344,9 @@
"js": { "js": {
"OktaAuth": "", "OktaAuth": "",
"isOktaEnabled": "", "isOktaEnabled": "",
"oktaCurrentSessionUrl": "",
"okta.cdnUrlHostname": "", "okta.cdnUrlHostname": "",
"okta.locale": "" "okta.locale": "",
"oktaCurrentSessionUrl": ""
}, },
"pricing": [ "pricing": [
"poa", "poa",
@ -1777,4 +1777,4 @@
}, },
"website": "https://owncloud.org" "website": "https://owncloud.org"
} }
} }