|
- import {
- remoteFunction,
- makeRemotelyCallable,
- injectRpcInfo,
- } from 'webextension-rpc';
- // Only import the *types* of the remote script’s functions.
- import type { backgroundScriptRemoteFunctions } from './background-script';
-
- // From background to content script.
- export const contentScriptRemoteFunctions = makeRemotelyCallable({
- async setColour(colour: string) {
- document.body.style.backgroundColor = colour;
- },
- });
-
- // From content to background script.
- const duplicateMe =
- remoteFunction<typeof backgroundScriptRemoteFunctions.duplicateTab>(
- 'duplicateTab',
- );
- // The injectRpcInfo placeholder will be replaced by actual info.
- const newTabId = await duplicateMe(injectRpcInfo, true);
|