Skip to content

Extension API

All the APIs documented are available through the browser namespace.

webfuseSession Scope Webfuse Exclusive

Section titled “webfuseSession Scope ”

The webfuseSession namespace contains methods specific to Webfuse sessions. This is the primary API for interacting with Webfuse functionality from within an extension. The webfuseSession namespace acts as a proxy to the Session API and exposes the following methods for convenience, for example:

  • browser.webfuseSession.log()
  • browser.webfuseSession.getParticipants()
  • browser.webfuseSession.getSessionInfo()
  • browser.webfuseSession.end()

The runtime namespace targets the browser in general.

Sends a message to the following components of the extension: Popup, Background, Newtab page.

browser.runtime.sendMessage(message: unknown): void

message

  • The message to send.
browser.runtime.onMessage.addListener(callback: (message: unknown) => void): void

Listens for messages from the extension.

callback

  • The callback function to handle the message.
browser.runtime.onMessage.addListener((message, sender) => {});

The tabs namespace contains methods for managing tabs, overriding standard Chrome APIs to work with Webfuse sessions.

browser.tabs.sendMessage(tabId: number, message: unknown, options: {
frameId?: number;
}): Promise<unknown | null>

Sends a message from any component to the content script of that specific tab.

tabId

  • The tabId to send the message to. Can be queried via getTabs() method. Passing null will send the message to all tabs.

message

  • The message to send. Must be a JSON-serializable object.

options

  • Additional options for message delivery:
  • frameId Send the message to a specific frame within the tab.

Returns a promise that resolves with the response from the content script’s message handler.

By default, messages are sent to the main frame of the tab. Use the frameId option to target specific frames:

// Send to main frame (default)
browser.tabs.sendMessage(tabId, { greeting: "Hello main frame" });
// Send to specific frame
browser.tabs.sendMessage(tabId, { greeting: "Hello frame" }, { frameId: 123 });
browser.webNavigation.getAllFrames(details: {
tabId: number;
})

Retrieves information about all frames in a tab.

details

  • Query details:
  • tabId The ID of the tab to query.

Returns a Promise that resolves with an array of frame objects:

[
{
frameId: 123,
parentFrameId: 0,
url: "https://example.com/iframe.html"
}
]

The browserAction namespace contains methods for managing the extension popup.

Open the extension popup.

browser.browserAction.openPopup(): void

Close the extension popup.

browser.browserAction.closePopup(): void

Resize the extension popup. If no parameters are provided, the popup will be resized to its default size.

browser.browserAction.resizePopup(width: number, height: number): void

width

  • The width of the popup.

height

  • The height of the popup.

Set the styles of the extension popup. Default styles are background: white, minWidth: 300px, minHeight: 200px and can be overridden.

browser.browserAction.setPopupStyles(styles: Record<string, string | number>): void

styles

  • An object containing CSS properties and values to set. Allowed properties:
    • Background & Direction: backgroundColor, direction
    • Spacing: padding, paddingTop, paddingRight, paddingBottom, paddingLeft, margin, marginTop, marginRight, marginBottom, marginLeft
    • Borders: border, borderWidth, borderColor, borderStyle, borderRadius, borderTop, borderTopWidth, borderTopColor, borderTopStyle, borderRight, borderRightWidth, borderRightColor, borderRightStyle, borderBottom, borderBottomWidth, borderBottomColor, borderBottomStyle, borderLeft, borderLeftWidth, borderLeftColor, borderLeftStyle, borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius
    • Visual Effects: boxShadow, overflow, overflowX, overflowY, resize

Other properties will be ignored.

// Set background and direction
browser.browserAction.setPopupStyles({
backgroundColor: 'transparent',
direction: 'rtl'
});
// Add padding and borders
browser.browserAction.setPopupStyles({
padding: '20px',
border: '2px solid #3b82f6',
borderRadius: '12px'
});
// Add shadow and overflow
browser.browserAction.setPopupStyles({
boxShadow: '0 10px 25px rgba(0, 0, 0, 0.3)',
overflow: 'auto'
});

Set the position of the extension popup on the screen. The popup will be positioned with position: fixed.

browser.browserAction.setPopupPosition(position: {
top?: string;
bottom?: string;
left?: string;
right?: string;
}): void

position

  • An object containing CSS positioning properties. Allowed properties: top, right, bottom, left. Values should be strings with CSS units (e.g., '20px', '10%', 'calc(100vh - 50px)', etc.).

Other properties will be ignored.

// Position at top-right corner
browser.browserAction.setPopupPosition({ top: '20px', right: '50px' });
// Position at bottom-left corner
browser.browserAction.setPopupPosition({ bottom: '40px', left: '60px' });
// Position at top-left corner
browser.browserAction.setPopupPosition({ top: '10px', left: '10px' });

Get the current position of the extension popup.

browser.browserAction.getPopupPosition(): Promise<{
top?: string;
bottom?: string;
left?: string;
right?: string;
}>

Returns a promise that resolves with an object containing the current popup position properties (top, bottom, left, right). Returns an empty object {} if no position has been set via setPopupPosition() or if the popup has not been opened yet.