contextualIdentities.remove()

根據提供的 cookie 儲存 ID,移除一個上下文身份。

這是一個非同步函式,返回一個 Promise

語法

js
let removeContext = browser.contextualIdentities.remove(
  cookieStoreId                  // string
)

引數

cookieStoreId

string。上下文身份的 cookie 儲存 ID。由於每個上下文身份都有自己的 cookie 儲存,因此這充當了上下文身份本身的識別符號。

返回值

一個 Promise,它將被解析為一個 ContextualIdentity 物件,該物件描述了已被移除的身份。如果找不到該身份或上下文身份功能未啟用,則 Promise 將被拒絕。

示例

此示例嘗試移除 ID 為“firefox-container-1”的上下文身份。

js
function onRemoved(context) {
  if (!context) {
    console.error("Context not found");
  } else {
    console.log(`Removed identity: ${context.cookieStoreId}.`);
  }
}

function onError(e) {
  console.error(e);
}

browser.contextualIdentities
  .remove("firefox-container-1")
  .then(onRemoved, onError);

瀏覽器相容性