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()- …
Runtime Scope
Section titled “Runtime Scope”The runtime namespace targets the browser in general.
runtime.sendMessage()
Section titled “runtime.sendMessage()”Sends a message to the following components of the extension: Popup, Background, Newtab page.
browser.runtime.sendMessage(message: unknown): voidParameters
Section titled “Parameters”message
- The message to send.
runtime.onMessage.addListener()
Section titled “runtime.onMessage.addListener()”browser.runtime.onMessage.addListener(callback: (message: unknown) => void): voidListens for messages from the extension.
Parameters
Section titled “Parameters”callback
- The callback function to handle the message.
Example
Section titled “Example”browser.runtime.onMessage.addListener((message, sender) => {});Tabs Scope
Section titled “Tabs Scope”The tabs namespace contains methods for managing tabs, overriding standard Chrome APIs to work with Webfuse sessions.
tabs.sendMessage()
Section titled “tabs.sendMessage()”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.
Parameters
Section titled “Parameters”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:
frameIdSend the message to a specific frame within the tab.
Returns
Section titled “Returns”Returns a promise that resolves with the response from the content script’s message handler.
Frame Targeting
Section titled “Frame Targeting”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 framebrowser.tabs.sendMessage(tabId, { greeting: "Hello frame" }, { frameId: 123 });webNavigation.getAllFrames()
Section titled “webNavigation.getAllFrames()”browser.webNavigation.getAllFrames(details: { tabId: number;})Retrieves information about all frames in a tab.
Parameters
Section titled “Parameters”details
- Query details:
tabIdThe ID of the tab to query.
Returns
Section titled “Returns”Returns a Promise that resolves with an array of frame objects:
[ { frameId: 123, parentFrameId: 0, url: "https://example.com/iframe.html" }]browserAction
Section titled “browserAction”The browserAction namespace contains methods for managing the extension popup.
browserAction.openPopup()
Section titled “browserAction.openPopup()”Open the extension popup.
browser.browserAction.openPopup(): voidbrowserAction.closePopup()
Section titled “browserAction.closePopup()”Close the extension popup.
browser.browserAction.closePopup(): voidbrowserAction.resizePopup()
Section titled “browserAction.resizePopup()”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): voidParameters
Section titled “Parameters”width
- The width of the popup.
height
- The height of the popup.
browserAction.detachPopup()
Section titled “browserAction.detachPopup()”Detach the extension popup from the browser action button to make it draggable (desktop only) and non-closable on a click outside.
browser.browserAction.detachPopup()browserAction.attachPopup()
Section titled “browserAction.attachPopup()”Attach the extension popup back to the browser action button to make it non-draggable (desktop only) and closable on a click outside.
browser.browserAction.attachPopup()browserAction.setPopupStyles()
Section titled “browserAction.setPopupStyles()”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>): voidParameters
Section titled “Parameters”styles
- An object containing CSS properties and values to set. List of allowed properties:
backgroundColor,direction,position,top,right,bottom,left,zIndex,minWidth,maxWidth,minHeight,maxHeight,padding,paddingTop,paddingRight,paddingBottom,paddingLeft,margin,marginTop,marginRight,marginBottom,marginLeft,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,boxShadow,overflow,overflowX,overflowY,resize.
Other properties will be ignored.
Example
Section titled “Example”browser.browserAction.setPopupStyles({ backgroundColor: 'transparent', direction: 'rtl' });