Index

Variables

Const ContainerColor

ContainerColor: string[] = ["blue","turquoise","green","yellow","orange","red","pink","purple",]

Const ContainerIcon

ContainerIcon: string[] = ["fingerprint","briefcase","dollar","cart","circle","gift","vacation","food","fruit","pet","tree","chill",]

Const DefaultContainer

DefaultContainer: object = Object.freeze(fromString("default", "invisible", "noicond", "firefox-default"),)

Type declaration

Const logger

logger: Logger = new Logging.Logger("containers")

Functions

chooseRandomColor

  • chooseRandomColor(): string
  • Helper function for create, returns a random valid IdentityColor for use if no color is applied at creation.

    Returns string

create

  • create(name: string, color?: string, icon?: string): Promise<string>
  • Creates a container from the specified parameters.Does not allow multiple containers with the same name.

    Parameters

    • name: string

      The container name.

    • Default value color: string = "random"

      The container color, must be one of: "blue", "turquoise", "green", "yellow", "orange", "red", "pink" or "purple". If nothing is supplied, it selects one at random.

    • Default value icon: string = "fingerprint"

      The container icon, must be one of: "fingerprint", "briefcase", "dollar", "cart", "circle", "gift", "vacation", "food", "fruit", "pet", "tree", "chill"

    Returns Promise<string>

exists

  • exists(cname: string): Promise<boolean>
  • Fetches all containers from Firefox's contextual identities API and checks if one exists with the specified name. Note: This operation is entirely case-insensitive.

    Parameters

    • cname: string

    Returns Promise<boolean>

    boolean Returns true when cname matches an existing container or on query error.

fromString

  • fromString(name: string, color: string, icon: string, id?: string): object
  • Takes string parameters and returns them as a pseudo container object for use in other functions in the library.

    Parameters

    • name: string
    • color: string
    • icon: string
    • Default value id: string = ""

    Returns object

    • color: IdentityColor
    • cookieStoreId: string
    • icon: IdentityIcon
    • name: string

fuzzyMatch

  • fuzzyMatch(partialName: string): Promise<string>
  • Tries some simple ways to match containers to your input. Fuzzy matching is entirely case-insensitive.

    Parameters

    • partialName: string

      The (partial) name of the container.

    Returns Promise<string>

getAll

  • getAll(): Promise<any[]>

getFromId

  • getFromId(containerId: string): Promise<browser.contextualIdentities.ContextualIdentity>
  • Gets a container object from a supplied container id string. If no container corresponds to containerId, returns a default empty container.

    Parameters

    • containerId: string

      Expects a cookieStringId e.g. "firefox-container-n"

    Returns Promise<browser.contextualIdentities.ContextualIdentity>

getId

  • getId(name: string): Promise<string>
  • Fetches the cookieStoreId of a given container

    Note: all checks are case insensitive.

    Parameters

    • name: string

      The container name

    Returns Promise<string>

    The cookieStoreId of the first match of the query.

isValidColor

  • isValidColor(color: string): boolean

isValidIcon

  • isValidIcon(icon: string): boolean

remove

  • remove(name: string): Promise<void>
  • Removes specified container. No fuzzy matching is intentional here. If there are multiple containers with the same name (allowed by other container plugins), it chooses the one with the lowest cookieStoreId

    Parameters

    • name: string

      The container name

    Returns Promise<void>

update

  • update(containerId: string, updateObj: object): Promise<void>
  • Updates the specified container. TODO: pass an object to this when tridactyl gets proper flag parsing NOTE: while browser.contextualIdentities.create does check for valid color/icon combos, browser.contextualIdentities.update does not.

    Parameters

    • containerId: string

      Expects a cookieStringId e.g. "firefox-container-n".

    • updateObj: object
      • color: browser.contextualIdentities.IdentityColor
      • icon: browser.contextualIdentities.IdentityIcon
      • name: string

    Returns Promise<void>