Skip to content

Commit 0ccbb9c

Browse files
committed
Add background service worker to fix options page and update version
Signed-off-by: Anvay Mathur <[email protected]>
1 parent e51f8af commit 0ccbb9c

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

manifest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@ export default defineManifest(async (env) => ({
5050
"matches": ["https://powerschool.sas.edu.sg/*"],
5151
"resources": ["public/icon.png"]
5252
}
53-
]
53+
],
54+
"background": {
55+
"service_worker": "src/background.ts",
56+
}
5457
}))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "saspes",
33
"private": true,
4-
"version": "2.0.0-alpha",
4+
"version": "2.0.0",
55
"description": "SAS Powerschool Enhancement Suite",
66
"type": "module",
77
"scripts": {

src/background.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
chrome.runtime.onMessage.addListener(function (message) {
2+
switch (message.action) {
3+
case "openOptionsPage":
4+
openOptionsPage();
5+
break;
6+
default:
7+
break;
8+
}
9+
});
10+
11+
function openOptionsPage() {
12+
chrome.runtime.openOptionsPage();
13+
}

src/content_script/home/Home.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@
6464
<a
6565
href="#"
6666
on:click={() => {
67-
if (chrome.runtime.openOptionsPage) {
68-
chrome.runtime.openOptionsPage();
69-
} else {
70-
window.open(chrome.runtime.getURL("src/options/index.html"));
71-
}
67+
chrome.runtime.sendMessage({ action: "openOptionsPage" });
7268
}}>Options</a
7369
>
7470
</p>

0 commit comments

Comments
 (0)