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): void
Parameters
Section titled “Parameters”message
- The message to send.
runtime.onMessage.addListener()
Section titled “runtime.onMessage.addListener()”browser.runtime.onMessage.addListener(callback: (message: unknown) => void): void
Listens 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:
frameId
Send 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:
tabId
The 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(): void
browserAction.closePopup()
Section titled “browserAction.closePopup()”Close the extension popup.
browser.browserAction.closePopup(): void
browserAction.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): void
Parameters
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 with UI controls.
browser.browserAction.detachPopup()
browserAction.attachPopup()
Section titled “browserAction.attachPopup()”Attach the extension popup back to the browser action button to make it non-draggable and restores its original position.
browser.browserAction.attachPopup()