From a715f0d465cc752580d3478ff95803586db87c64 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 8 Dec 2023 07:18:04 +0000 Subject: [PATCH] feat: offscreen page --- package.json | 9 +++++++-- pnpm-lock.yaml | 8 ++++---- src/background.ts | 2 -- src/background/index.ts | 8 ++++++++ src/contents/{plasmo.ts => index.tsx} | 2 +- src/sandboxes/index.ts | 3 +++ src/tabs/offscreen.tsx | 9 +++++++++ 7 files changed, 32 insertions(+), 9 deletions(-) delete mode 100644 src/background.ts create mode 100644 src/background/index.ts rename src/contents/{plasmo.ts => index.tsx} (83%) create mode 100644 src/sandboxes/index.ts create mode 100644 src/tabs/offscreen.tsx diff --git a/package.json b/package.json index 250828a..ac91428 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "devDependencies": { "@ianvs/prettier-plugin-sort-imports": "4.1.1", "@iconify/tailwind": "^0.1.4", - "@types/chrome": "0.0.251", + "@types/chrome": "^0.0.254", "@types/node": "20.9.0", "@types/react": "18.2.37", "@types/react-dom": "18.2.15", @@ -35,7 +35,12 @@ "https://*/*" ], "permissions": [ - "tabs" + "tabs", + "offscreen", + "storage", + "notifications", + "alarms", + "idle" ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94af145..580535f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,8 +29,8 @@ devDependencies: specifier: ^0.1.4 version: 0.1.4 '@types/chrome': - specifier: 0.0.251 - version: 0.0.251 + specifier: ^0.0.254 + version: 0.0.254 '@types/node': specifier: 20.9.0 version: 20.9.0 @@ -2638,8 +2638,8 @@ packages: engines: {node: '>=10.13.0'} dev: false - /@types/chrome@0.0.251: - resolution: {integrity: sha512-UF+yr0LEKWWGsKxQ5A3XOSF5SNoU1ctW3pXcWJPpT8OOUTEspYeaLU8spDKe+6xalXeMTS0TBrX1g0b6qlWmkw==} + /@types/chrome@0.0.254: + resolution: {integrity: sha512-svkOGKwA+6ZZuk9xtrYun8MYpNY/9hD17rgZ19v3KunhsK1ZOKaMESw12/1AXLh1u3UPA8jQIRi2370DXv9wgw==} dependencies: '@types/filesystem': 0.0.35 '@types/har-format': 1.2.15 diff --git a/src/background.ts b/src/background.ts deleted file mode 100644 index 500cff8..0000000 --- a/src/background.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {} -console.log("HELLO WORLD FROM BGSCRIPTS") diff --git a/src/background/index.ts b/src/background/index.ts new file mode 100644 index 0000000..4d06a11 --- /dev/null +++ b/src/background/index.ts @@ -0,0 +1,8 @@ +export { } +console.log("HELLO WORLD FROM BGSCRIPTS") + +chrome.offscreen.createDocument({ + url: chrome.runtime.getURL("tabs/offscreen.html"), + reasons: [chrome.offscreen.Reason.IFRAME_SCRIPTING], + justification: 'Get RSS in the sandbox for enhanced security.', +}); diff --git a/src/contents/plasmo.ts b/src/contents/index.tsx similarity index 83% rename from src/contents/plasmo.ts rename to src/contents/index.tsx index e2e5dc1..ed9302f 100644 --- a/src/contents/plasmo.ts +++ b/src/contents/index.tsx @@ -1,7 +1,7 @@ import type { PlasmoCSConfig } from "plasmo" export const config: PlasmoCSConfig = { - matches: ["https://www.plasmo.com/*"] + matches: ["https://docs.plasmo.com/*"] } window.addEventListener("load", () => { diff --git a/src/sandboxes/index.ts b/src/sandboxes/index.ts new file mode 100644 index 0000000..4c61490 --- /dev/null +++ b/src/sandboxes/index.ts @@ -0,0 +1,3 @@ +export { } + +console.log("HELLO WORLD FROM SANDBOXES") \ No newline at end of file diff --git a/src/tabs/offscreen.tsx b/src/tabs/offscreen.tsx new file mode 100644 index 0000000..4d05de6 --- /dev/null +++ b/src/tabs/offscreen.tsx @@ -0,0 +1,9 @@ +function OffscreenPage() { + console.log("HELLO WORLD FROM OFFSCREEN") + + return ( + + ); +} + +export default OffscreenPage; \ No newline at end of file