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:
parent
cee0f75293
commit
e549267085
@ -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){
|
||||||
const value = navigator[property];
|
try {
|
||||||
if ((typeof value) === "string"){
|
const value = navigator[property];
|
||||||
values[property] = value;
|
if ((typeof value) === "string"){
|
||||||
|
values[property] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error){
|
||||||
|
hasPropertyError = true;
|
||||||
|
console.warn(name, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const storage = await navigator.storage.estimate();
|
if (!hasPropertyError){
|
||||||
values.storage_quota = storage.quota.toString(10);
|
const storage = await navigator.storage.estimate();
|
||||||
keys.push("storage_quota");
|
values.storage_quota = storage.quota.toString(10);
|
||||||
|
keys.push("storage_quota");
|
||||||
|
}
|
||||||
console.log(name, values);
|
console.log(name, values);
|
||||||
processNavigatorObject(values, keys, name);
|
processNavigatorObject(values, keys, name);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user