Improve JS detection

main
Elbert Alias 2 years ago
parent 4d6e1a04e8
commit 9bc44d8b63

@ -65,16 +65,25 @@ function getJs(page, technologies = Wappalyzer.technologies) {
chains.forEach((chain) => { chains.forEach((chain) => {
chain = chain.replace(/\[([^\]]+)\]/g, '.$1') chain = chain.replace(/\[([^\]]+)\]/g, '.$1')
const value = chain const parts = chain.split('.')
.split('.')
.reduce( const root = /^[a-z_$][a-z0-9_$]*$/i.test(parts[0])
? // eslint-disable-next-line no-new-func
new Function(
`return typeof ${
parts[0]
} === 'undefined' ? undefined : ${parts.shift()}`
)()
: window
const value = parts.reduce(
(value, method) => (value, method) =>
value && value &&
value instanceof Object && value instanceof Object &&
Object.prototype.hasOwnProperty.call(value, method) Object.prototype.hasOwnProperty.call(value, method)
? value[method] ? value[method]
: '__UNDEFINED__', : '__UNDEFINED__',
window root || '__UNDEFINED__'
) )
if (value !== '__UNDEFINED__') { if (value !== '__UNDEFINED__') {

Loading…
Cancel
Save