|
|
@ -1,6 +1,24 @@
|
|
|
|
(() => {
|
|
|
|
(() => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
addEventListener('message', onMessage);
|
|
|
|
const detectJs = chain => {
|
|
|
|
|
|
|
|
const properties = chain.split('.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = properties.length ? window : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( let i = 0; i < properties.length; i ++ ) {
|
|
|
|
|
|
|
|
let property = properties[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( value && value.hasOwnProperty(property) ) {
|
|
|
|
|
|
|
|
value = value[property];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return typeof value === 'string' || typeof value === 'number' ? value : !!value;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const onMessage = event => {
|
|
|
|
const onMessage = event => {
|
|
|
|
if ( event.data.id !== 'patterns' ) {
|
|
|
|
if ( event.data.id !== 'patterns' ) {
|
|
|
@ -36,25 +54,7 @@
|
|
|
|
postMessage({ id: 'js', js }, '*');
|
|
|
|
postMessage({ id: 'js', js }, '*');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const detectJs = chain => {
|
|
|
|
addEventListener('message', onMessage);
|
|
|
|
const properties = chain.split('.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = properties.length ? window : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( let i = 0; i < properties.length; i ++ ) {
|
|
|
|
|
|
|
|
let property = properties[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( value && value.hasOwnProperty(property) ) {
|
|
|
|
|
|
|
|
value = value[property];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return typeof value === 'string' || typeof value === 'number' ? value : !!value;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
// Fail quietly
|
|
|
|
// Fail quietly
|
|
|
|
}
|
|
|
|
}
|
|
|
|