contextualIdentities.get()

Liefert Informationen über eine kontextuelle Identität basierend auf ihrer Cookie-Store-ID.

Dies ist eine asynchrone Funktion, die ein Promise zurückgibt.

Syntax

js
let getContext = browser.contextualIdentities.get(
  cookieStoreId                  // string
)

Parameter

cookieStoreId

string. Die ID des Cookie-Stores dieser kontextuellen Identität. Da kontextuelle Identitäten jeweils ihren eigenen Cookie-Store haben, dient dies als Identifikator 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 die Funktionalität für kontextuelle Identitäten nicht aktiviert ist, wird das Promise abgelehnt.

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
get

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

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);