1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Do not fail if navigator is not available

This commit is contained in:
kkapsner 2024-08-15 22:11:11 +02:00
parent cee0f75293
commit e549267085

View File

@ -66,15 +66,24 @@ iframeAPI.forEachMethod(async function(windowToUse, name){
const navigator = windowToUse.navigator; const navigator = windowToUse.navigator;
const values = {}; const values = {};
const keys = Object.keys(navigator.__proto__); const keys = Object.keys(navigator.__proto__);
let hasPropertyError = false;
keys.forEach(function(property){ keys.forEach(function(property){
try {
const value = navigator[property]; const value = navigator[property];
if ((typeof value) === "string"){ if ((typeof value) === "string"){
values[property] = value; values[property] = value;
} }
}
catch (error){
hasPropertyError = true;
console.warn(name, error);
}
}); });
if (!hasPropertyError){
const storage = await navigator.storage.estimate(); const storage = await navigator.storage.estimate();
values.storage_quota = storage.quota.toString(10); values.storage_quota = storage.quota.toString(10);
keys.push("storage_quota"); keys.push("storage_quota");
}
console.log(name, values); console.log(name, values);
processNavigatorObject(values, keys, name); processNavigatorObject(values, keys, name);
}); });