From 6f17e5cdf4bb0374156a04a3d48b95515eee91f1 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 31 May 2024 15:24:20 +0800 Subject: [PATCH] improve NotificationForChatGPTWeb (#710) --- src/components/MarkdownRender/Hyperlink.jsx | 4 +++- src/components/NotificationForChatGPTWeb/index.jsx | 2 +- src/content-script/index.jsx | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/MarkdownRender/Hyperlink.jsx b/src/components/MarkdownRender/Hyperlink.jsx index 88ba67c..6805590 100644 --- a/src/components/MarkdownRender/Hyperlink.jsx +++ b/src/components/MarkdownRender/Hyperlink.jsx @@ -12,10 +12,12 @@ export function Hyperlink({ href, children }) { { + const url = new URL(href) + url.searchParams.set('chatgptbox_notification', 'true') Browser.runtime.sendMessage({ type: 'NEW_URL', data: { - url: href, + url: url.toString(), pinned: false, saveAsChatgptConfig: true, }, diff --git a/src/components/NotificationForChatGPTWeb/index.jsx b/src/components/NotificationForChatGPTWeb/index.jsx index c32c97d..cd2505c 100644 --- a/src/components/NotificationForChatGPTWeb/index.jsx +++ b/src/components/NotificationForChatGPTWeb/index.jsx @@ -71,7 +71,7 @@ const NotificationForChatGPTWeb = () => { style={{ width: '440px', }} - position="top-right" + position="top-center" autoClose={7000} newestOnTop={false} closeOnClick={false} diff --git a/src/content-script/index.jsx b/src/content-script/index.jsx index eb2ab85..e8ecf74 100644 --- a/src/content-script/index.jsx +++ b/src/content-script/index.jsx @@ -324,7 +324,11 @@ async function prepareForForegroundRequests() { if (!chatgptWebModelKeys.some((model) => userConfig.activeApiModes.includes(model))) return - if (chatgptWebModelKeys.includes(userConfig.modelName)) { + const url = new URL(window.location.href) + if ( + url.searchParams.has('chatgptbox_notification') && + chatgptWebModelKeys.includes(userConfig.modelName) + ) { const div = document.createElement('div') document.body.append(div) render(, div)