parent
28d2afaa61
commit
66c703c2fa
@ -1,43 +1,43 @@
|
|||||||
(function() {
|
(function() {
|
||||||
try {
|
try {
|
||||||
var i, environmentVars = '', eEnv = document.createEvent('Events'), container = document.getElementById('wappalyzerData');
|
addEventListener('message', (event => {
|
||||||
|
if ( event.data.id !== 'patterns' ) {
|
||||||
eEnv.initEvent('wappalyzerEnvEvent', true, false);
|
return;
|
||||||
|
}
|
||||||
for ( i in window ) {
|
|
||||||
environmentVars += i + ' ';
|
const patterns = event.data.patterns || {};
|
||||||
}
|
|
||||||
container.appendChild(document.createComment(environmentVars));
|
const js = {};
|
||||||
container.dispatchEvent(eEnv);
|
|
||||||
|
Object.keys(patterns).forEach(appName => {
|
||||||
window.addEventListener('message', (event => {
|
js[appName] = {};
|
||||||
if (event.data.patterns === undefined)
|
|
||||||
return;
|
Object.keys(patterns[appName]).forEach(chain => {
|
||||||
var properties = event.data.patterns;
|
js[appName][chain] = {};
|
||||||
var js = {};
|
|
||||||
Object.keys(properties).forEach(appname => {
|
patterns[appName][chain].forEach((pattern, index) => {
|
||||||
Object.keys(properties[appname]).forEach(property => {
|
const value = detect(chain);
|
||||||
var content = false;
|
|
||||||
if( content = JSdetection(property) ){
|
if ( value ) {
|
||||||
if ( js[appname] === undefined )
|
js[appName][chain][index] = value;
|
||||||
js[appname] = {};
|
}
|
||||||
js[appname][property] = properties[appname][property];
|
});
|
||||||
js[appname][property]["content"] = content;
|
});
|
||||||
}
|
});
|
||||||
});
|
|
||||||
});
|
postMessage({ id: 'js', js }, '*');
|
||||||
window.postMessage({js: js}, "*");
|
}), false);
|
||||||
}), false);
|
} catch(e) {
|
||||||
} catch(e) {
|
// Fail quietly
|
||||||
// Fail quietly
|
}
|
||||||
}
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
function JSdetection(p){
|
function detect(chain) {
|
||||||
const objects = p.split('.');
|
const properties = chain.split('.');
|
||||||
const value = objects.reduce((parent, property) => {
|
|
||||||
return parent && parent.hasOwnProperty(property) ? parent[property] : null;
|
const value = properties.reduce((parent, property) => {
|
||||||
}, window);
|
return parent && parent.hasOwnProperty(property) ? parent[property] : null;
|
||||||
|
}, window);
|
||||||
|
|
||||||
return typeof value === 'string' ? value : !!value;
|
return typeof value === 'string' ? value : !!value;
|
||||||
}
|
}
|
||||||
|
Reference in new issue