Add try/catch in dom.js

main
Elbert Alias 3 years ago
parent 19822bcdf8
commit f977f42bf8

@ -17,42 +17,46 @@
postMessage({ postMessage({
wappalyzer: { wappalyzer: {
dom: technologies.reduce((technologies, { name, dom }) => { dom: technologies.reduce((technologies, { name, dom }) => {
Object.keys(dom).forEach((selector) => { try {
let nodes = [] Object.keys(dom).forEach((selector) => {
let nodes = []
try { try {
nodes = document.querySelectorAll(selector) nodes = document.querySelectorAll(selector)
} catch (error) { } catch (error) {
// Continue // Continue
} }
if (!nodes.length) { if (!nodes.length) {
return return
} }
nodes.forEach((node) => { nodes.forEach((node) => {
dom[selector].forEach(({ properties }) => { dom[selector].forEach(({ properties }) => {
if (properties) { if (properties) {
Object.keys(properties).forEach((property) => { Object.keys(properties).forEach((property) => {
if ( if (
Object.prototype.hasOwnProperty.call(node, property) Object.prototype.hasOwnProperty.call(node, property)
) { ) {
const value = node[property] const value = node[property]
if (typeof value !== 'undefined') { if (typeof value !== 'undefined') {
technologies.push({ technologies.push({
name, name,
selector, selector,
property, property,
value: toScalar(value), value: toScalar(value),
}) })
}
} }
} })
}) }
} })
}) })
}) })
}) } catch (error) {
// Fail quietly
}
return technologies return technologies
}, []), }, []),