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

浏览器兼容性