contextualIdentities.get()
Ermittelt Informationen über eine kontextuelle Identität anhand ihrer Cookie-Store-ID.
Dies ist eine asynchrone Funktion, die ein Promise
zurückgibt.
Syntax
js
let getContext = browser.contextualIdentities.get(
cookieStoreId // string
)
Parameter
-
string
. Die ID des Cookie-Stores dieser kontextuellen Identität. Da kontextuelle Identitäten jeweils ihren eigenen Cookie-Store haben, dient dies als Kennung für die kontextuelle Identität selbst.
Rückgabewert
Ein Promise
, das mit einer ContextualIdentity
erfüllt wird, die die Identität beschreibt. Wenn die Identität nicht gefunden werden konnte oder das Feature für kontextuelle Identitäten nicht aktiviert ist, wird das Promise abgelehnt.
Beispiele
Dieses Beispiel versucht, die kontextuelle Identität abzurufen, deren ID "firefox-container-1" ist:
js
function onGot(context) {
if (!context) {
console.error("Context not found");
} else {
console.log(`Name: ${context.name}`);
}
}
function onError(e) {
console.error(e);
}
browser.contextualIdentities.get("firefox-container-1").then(onGot, onError);
Browser-Kompatibilität
Loading…