From be2afe55ff1a0f1fd9e2fff23ac67814930dc374 Mon Sep 17 00:00:00 2001
From: Keo Cheung
Date: Fri, 10 Oct 2025 00:00:42 +0800
Subject: [PATCH] Add option to send browser notifications
---
src/background/main.ts | 4 ++--
src/models/index.ts | 1 +
src/options/App.vue | 11 +++++++++++
src/popup/pages/PopupMain.vue | 2 +-
src/stores/index.ts | 1 +
5 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/background/main.ts b/src/background/main.ts
index 52db4c1..cefa1d5 100644
--- a/src/background/main.ts
+++ b/src/background/main.ts
@@ -125,12 +125,12 @@ async function uploadPost(data: PostUploadCommandData) {
}
}
- if (browser.notifications) {
+ if (data.sendNotifications && browser.notifications) {
const createdPostUrl = getUrl(data.selectedSite.domain, "post", createdPost.id.toString());
browser.notifications.create(createdPostUrl, {
type: "basic",
iconUrl: browser.runtime.getURL("assets/icon-128.png"),
- title: "SzuruChrome",
+ title: data.selectedSite.domain,
message: `Uploaded ${data.post.contentUrl}`,
});
}
diff --git a/src/models/index.ts b/src/models/index.ts
index cb3ecdd..6d086fe 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -148,6 +148,7 @@ export class PostUploadCommandData {
constructor(
public readonly post: ScrapedPostDetails,
public readonly selectedSite: SzuruSiteConfig,
+ public readonly sendNotifications: boolean,
) { }
}
diff --git a/src/options/App.vue b/src/options/App.vue
index 3db145e..6e9acac 100644
--- a/src/options/App.vue
+++ b/src/options/App.vue
@@ -150,6 +150,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
+
+
+
+ This will send a browser notification after a successful upload. Clicking the notification will open
+ the uploaded post in a new tab.
+
+
+
{{ versionInfo }}
diff --git a/src/popup/pages/PopupMain.vue b/src/popup/pages/PopupMain.vue
index bfa9788..a00606f 100644
--- a/src/popup/pages/PopupMain.vue
+++ b/src/popup/pages/PopupMain.vue
@@ -171,7 +171,7 @@ async function upload() {
await ensurePostHasContentToken(szuru.value!, post, cfg);
}
- const cmdData = new PostUploadCommandData(post, cloneDeep(selectedSite.value));
+ const cmdData = new PostUploadCommandData(post, cloneDeep(selectedSite.value), cfg.value.sendUploadNotifications);
const cmd = new BrowserCommand("upload_post", cmdData);
await browser.runtime.sendMessage(cmd);
} catch (ex: any) {
diff --git a/src/stores/index.ts b/src/stores/index.ts
index 0febb92..d1ecc46 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -15,6 +15,7 @@ export const cfg = useStorageLocal(
version: 0,
addPageUrlToSource: true,
alwaysUploadAsContent: false,
+ sendUploadNotifications: true,
autoSearchSimilar: false,
loadTagCounts: true,
fetchPostInfo: true,