parent
aa75a43286
commit
ff3284e81d
@ -0,0 +1,67 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
;(function () {
|
||||
try {
|
||||
const onMessage = ({ data }) => {
|
||||
if (!data.wappalyzer || !data.wappalyzer.technologies) {
|
||||
return
|
||||
}
|
||||
|
||||
const { technologies } = data.wappalyzer
|
||||
|
||||
const toScalar = (value) =>
|
||||
typeof value === 'string' || typeof value === 'number' ? value : !!value
|
||||
|
||||
removeEventListener('message', onMessage)
|
||||
|
||||
postMessage({
|
||||
wappalyzer: {
|
||||
dom: technologies.reduce((technologies, { name, dom }) => {
|
||||
Object.keys(dom).forEach((selector) => {
|
||||
let nodes = []
|
||||
|
||||
try {
|
||||
nodes = document.querySelectorAll(selector)
|
||||
} catch (error) {
|
||||
// Continue
|
||||
}
|
||||
|
||||
if (!nodes.length) {
|
||||
return
|
||||
}
|
||||
|
||||
nodes.forEach((node) => {
|
||||
dom[selector].forEach(({ properties }) => {
|
||||
if (properties) {
|
||||
Object.keys(properties).forEach((property) => {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(node, property)
|
||||
) {
|
||||
const value = node[property]
|
||||
|
||||
if (typeof value !== 'undefined') {
|
||||
technologies.push({
|
||||
name,
|
||||
selector,
|
||||
property,
|
||||
value: toScalar(value),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return technologies
|
||||
}, []),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
addEventListener('message', onMessage)
|
||||
} catch (e) {
|
||||
// Fail quietly
|
||||
}
|
||||
})()
|
Reference in new issue