On 14.11.24 17:34, Max Nikulin wrote:
> On 14/11/2024 20:24, Jan Riechers wrote:
>> I want to request, by using a helper set/get function[1], Object based
>> values of the "storage.local.get" - but the culprit (I have not yet
>> found a useful workaround) - always returns the "request Object with
>> request keys/values" if nothing is found.
>>
>> This does, for my understanding, not make much sense
>
> My guess is that the API method is optimized for getting multiple keys
> at once and so minimizing number of async calls.
>
This might reduce calls yes - but I store a lot of custom settings. At
the bottom of this email, there is a example json output.
>> If I request some information of the "storage" - I want to either get
>> the value or nothing at all if nothing is found/matching.
>>
>> The helper "get" function can be found here:
>>
https://github.com/jrie/flagCookies/blob/
>> aa31a2a06f0f9bfe54de27d199aa360003468529/cookies.js#L37
>
> For me it is not clear what you are trying to achieve, perhaps I just
> have not spent enough time in attempts to figure out your data scheme.
> Certainly you are fetching values one by one instead of requesting the
> whole bunch.
>
> At first glance the following simple wrapper matches your description
>
> async function inefficientGet(key, defaultValue) {
> const { [key]: retval = defaultValue }
> = await chrome.storage.local.get(key);
> return retval;
> }
>
Yes, this might be inefficient at first glance, but retrieving a exact
"Object with keys" - allows to pull out only needed data for a
particular case.
Not "single string" value which returns "null" or "undefined".
----------
Here is a JSON of the output of the settings - basically everything that
is stored here is for "
google.com" (cookies) only. Just imagine you have
50 more domains or tabs and for every little "data" (cookie) change, the
whole storage.local is pulled out - which I do right now and it slows
down dramatically.
Sample data:
{
"default": {
"
www.google.com": {
".
google.com": {
"SIDCC": true,
"__Secure-1PSIDCC": true,
"__Secure-1PSIDTS": false,
"__Secure-3PAPISID": false,
"__Secure-3PSIDCC": false
},
".
support.google.com": {
"_ga_H30R9PNQFN": true
},
"
accounts.google.com": {
"ACCOUNT_CHOOSER": true,
"LSID": false,
"__Host-1PLSID": false,
"__Host-3PLSID": true
}
}
},
"flagCookies_accountMode": {
"default": {
"
www.google.com": true
}
},
"flagCookies_autoFlag": {
"default": {
"
www.google.com": true
}
},
"flagCookies_logged": {
"default": {
"
www.google.com": {
".
chromewebstore.google.com": {
"_ga": true,
"_ga_KHZNC1Q6K0": true
},
".
google.com": {
"AEC": true,
"APISID": true,
"HSID": true,
"NID": true,
"SAPISID": true,
"SID": true,
"SIDCC": true,
"SOCS": true,
"SSID": true,
"__Secure-1PAPISID": true,
"__Secure-1PSID": true,
"__Secure-1PSIDCC": true,
"__Secure-1PSIDTS": true,
"__Secure-3PAPISID": true,
"__Secure-3PSID": true,
"__Secure-3PSIDCC": true,
"__Secure-3PSIDTS": true,
"__Secure-ENID": true
},
"
chromewebstore.google.com": {
"OSID": true
}
}
}
}
}