diff --git a/background.ts b/background.ts index df8d1b2c..c262fff8 100644 --- a/background.ts +++ b/background.ts @@ -47,12 +47,14 @@ async function onBeforeRequest( const tab = await browser.tabs.get(request.tabId); const sourceUrl = tab.url ? new URL(tab.url) : undefined; + const tabContainerName = (await browser.contextualIdentities.get(tab.cookieStoreId)).name; + const interpreter = new Sval({ ecmaVer: "latest", sourceType: "script", sandBox: true, }); - interpreter.import({ url: new URL(request.url), sourceUrl }); + interpreter.import({ url: new URL(request.url), sourceUrl, containerName: tabContainerName }); interpreter.run(program); const info = toContainerInfo(interpreter.exports.end); diff --git a/ui.html b/ui.html index 31862682..40230da1 100644 --- a/ui.html +++ b/ui.html @@ -106,6 +106,7 @@

Container Script

The code is executed using Sval due to CSP restrictions. diff --git a/ui.ts b/ui.ts index de742a49..bbcb781e 100644 --- a/ui.ts +++ b/ui.ts @@ -21,6 +21,10 @@ async function main() { " * The URL of the page that initiated the navigation (may be undefined for new tabs)", " */", "declare const sourceUrl: URL | undefined", + "/**", + " * The name of the current container of the tab", + " */", + "declare const containerName: string | undefined", ].join("\n"); const libUri = "ts:filename/ContainerScript.d.ts"; monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);