2024-03-30 13:58:09 +01:00
|
|
|
(async function(){
|
2020-04-13 10:10:44 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const values = {};
|
2020-04-15 00:25:24 +02:00
|
|
|
let nestedValues = false;
|
2020-04-13 10:10:44 +02:00
|
|
|
const navigator = self.navigator;
|
|
|
|
Object.keys(navigator.__proto__).sort().forEach(function(property){
|
|
|
|
const value = navigator[property];
|
|
|
|
if ((typeof value) === "string"){
|
|
|
|
values[property] = value;
|
|
|
|
}
|
|
|
|
});
|
2024-03-30 13:58:09 +01:00
|
|
|
const storage = await navigator.storage.estimate();
|
|
|
|
values.storage_quota = storage.quota.toString(10);
|
2020-04-15 00:25:24 +02:00
|
|
|
|
|
|
|
const ports = [];
|
|
|
|
const sources = [];
|
|
|
|
let sendDelayed = false;
|
|
|
|
function sendData(){
|
|
|
|
sendDelayed = true;
|
|
|
|
if (self.postMessage){
|
|
|
|
self.postMessage({values, nestedValues});
|
|
|
|
}
|
|
|
|
ports.forEach(function(port){
|
|
|
|
port.postMessage({values, nestedValues});
|
|
|
|
});
|
|
|
|
sources.forEach(function(source){
|
|
|
|
source.postMessage({values, nestedValues});
|
|
|
|
});
|
2020-04-13 10:10:44 +02:00
|
|
|
}
|
|
|
|
self.addEventListener("connect", function(event){
|
|
|
|
event.ports.forEach(function(port){
|
2020-04-15 00:25:24 +02:00
|
|
|
ports.push(port);
|
2020-04-13 10:10:44 +02:00
|
|
|
});
|
2020-04-15 00:25:24 +02:00
|
|
|
if (sendDelayed){
|
|
|
|
sendData();
|
|
|
|
}
|
2020-04-13 10:10:44 +02:00
|
|
|
});
|
|
|
|
self.addEventListener("message", function(event){
|
2020-04-15 00:25:24 +02:00
|
|
|
sources.push(event.source);
|
|
|
|
if (sendDelayed){
|
|
|
|
sendData();
|
|
|
|
}
|
2020-04-13 10:10:44 +02:00
|
|
|
});
|
2020-04-15 00:25:24 +02:00
|
|
|
|
|
|
|
if (
|
|
|
|
!(self.name && self.name.startsWith("nested nested")) &&
|
|
|
|
self.Worker
|
|
|
|
){
|
|
|
|
const worker = new Worker(self.location, {name: "nested " + (self.name || "")});
|
|
|
|
worker.addEventListener("message", function(event){
|
|
|
|
nestedValues = event.data;
|
|
|
|
worker.terminate();
|
|
|
|
sendData();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sendData();
|
|
|
|
}
|
2020-04-13 10:10:44 +02:00
|
|
|
}());
|