feat: Open Conversation Window in any program (#32, #100, #101)

This commit is contained in:
josc146
2023-04-08 21:41:13 +08:00
parent fe5081d9ab
commit aed27f7e44
15 changed files with 81 additions and 5 deletions
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Funktionsseiten",
"Keyboard Shortcuts": "Tastenkombinationen",
"Open Conversation Page": "Konversationsseite öffnen",
"Open Conversation Window": "Konversationsfenster öffnen",
"Store to Independent Conversation Page": "Auf unabhängiger Konversationsseite speichern"
}
+3 -1
View File
@@ -96,5 +96,7 @@
"Feature Pages": "Feature Pages",
"Keyboard Shortcuts": "Keyboard Shortcuts",
"Open Conversation Page": "Open Conversation Page",
"Store to Independent Conversation Page": "Store to Independent Conversation Page"
"Open Conversation Window": "Open Conversation Window",
"Store to Independent Conversation Page": "Store to Independent Conversation Page",
"Keep Conversation Window in Background": "Keep conversation window in background, so that you can use shortcut keys to call it up in any program"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Páginas de características",
"Keyboard Shortcuts": "Atajos de teclado",
"Open Conversation Page": "Abrir página de conversación independiente",
"Open Conversation Window": "Abrir la ventana de conversación independiente",
"Store to Independent Conversation Page": "Guardar en página de conversación independiente"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Pages de fonctionnalités",
"Keyboard Shortcuts": "Raccourcis clavier",
"Open Conversation Page": "Ouvrir la page de conversation",
"Open Conversation Window": "Ouvrir la fenêtre de conversation",
"Store to Independent Conversation Page": "Enregistrer sur une page de conversation indépendante"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Pagine delle funzionalità",
"Keyboard Shortcuts": "Scorciatoie da tastiera",
"Open Conversation Page": "Apri la pagina della conversazione",
"Open Conversation Window": "Apri la finestra di conversazione",
"Store to Independent Conversation Page": "Salva alla pagina della conversazione indipendente"
}
+2 -1
View File
@@ -95,6 +95,7 @@
"Settings": "設定",
"Feature Pages": "機能ページ",
"Keyboard Shortcuts": "キーボードショートカット",
"Open Conversation Page": "独立した会話ページを開く",
"Open Conversation Page": "会話ページを開く",
"Open Conversation Window": "会話ウィンドウを開く",
"Store to Independent Conversation Page": "独立した会話ページに保存"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "기능 페이지",
"Keyboard Shortcuts": "키보드 단축키 설정",
"Open Conversation Page": "대화 페이지 열기",
"Open Conversation Window": "대화 창 열기",
"Store to Independent Conversation Page": "독립적인 대화 페이지에 저장"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Páginas de Recursos",
"Keyboard Shortcuts": "Atalhos de Teclado",
"Open Conversation Page": "Abrir Página de Conversa",
"Open Conversation Window": "Abrir Janela de Conversa",
"Store to Independent Conversation Page": "Armazenar em Página de Conversa Independente"
}
+1
View File
@@ -96,5 +96,6 @@
"Feature Pages": "Страницы функций",
"Keyboard Shortcuts": "Горячие клавиши",
"Open Conversation Page": "Открыть страницу бесед",
"Open Conversation Window": "Открыть окно бесед",
"Store to Independent Conversation Page": "Хранить на странице независимых разговоров"
}
+3 -1
View File
@@ -96,5 +96,7 @@
"Feature Pages": "功能页",
"Keyboard Shortcuts": "快捷键设置",
"Open Conversation Page": "打开独立对话页",
"Store to Independent Conversation Page": "收纳到独立对话页"
"Open Conversation Window": "打开独立对话窗口",
"Store to Independent Conversation Page": "收纳到独立对话页",
"Keep Conversation Window in Background": "保持对话窗口在后台, 以便在任何程序中使用快捷键呼出"
}
+3 -1
View File
@@ -96,5 +96,7 @@
"Feature Pages": "功能頁",
"Keyboard Shortcuts": "快速鍵設定",
"Open Conversation Page": "開啟獨立對話頁",
"Store to Independent Conversation Page": "收納到獨立對話頁"
"Open Conversation Window": "開啟獨立對話視窗",
"Store to Independent Conversation Page": "收納到獨立對話頁",
"Keep Conversation Window in Background": "保持對話窗口在後臺, 以便在任何程序中使用快捷鍵呼出"
}
+11
View File
@@ -21,4 +21,15 @@ export const config = {
openUrl(Browser.runtime.getURL('IndependentPanel.html'))
},
},
openConversationWindow: {
label: 'Open Conversation Window',
action: async () => {
Browser.windows.create({
url: Browser.runtime.getURL('IndependentPanel.html'),
type: 'popup',
width: 500,
height: 650,
})
},
},
}
+6
View File
@@ -21,6 +21,9 @@
"unlimitedStorage",
"tabs"
],
"optional_permissions": [
"background"
],
"background": {
"service_worker": "background.js"
},
@@ -78,6 +81,9 @@
"mac": "MacCtrl+Shift+H"
},
"description": "Open the independent conversation page"
},
"openConversationWindow": {
"description": "Open the independent conversation window"
}
}
}
+6
View File
@@ -19,6 +19,9 @@
"https://*.openai.com/",
"https://*.bing.com/"
],
"optional_permissions": [
"background"
],
"background": {
"scripts": [
"background.js"
@@ -71,6 +74,9 @@
"mac": "MacCtrl+Shift+H"
},
"description": "Open the independent conversation page"
},
"openConversationWindow": {
"description": "Open the independent conversation window"
}
}
}
+40 -1
View File
@@ -297,9 +297,15 @@ GeneralPart.propTypes = {
function FeaturePages() {
const { t } = useTranslation()
const [backgroundPermission, setBackgroundPermission] = useState(false)
if (!isMobile() && !isFirefox() && !isSafari())
Browser.permissions.contains({ permissions: ['background'] }).then((result) => {
setBackgroundPermission(result)
})
return (
<div style="display:flex;flex-direction:column;align-items:center;">
<div style="display:flex;flex-direction:column;align-items:left;">
{!isMobile() && !isFirefox() && !isSafari() && (
<button
type="button"
@@ -319,6 +325,39 @@ function FeaturePages() {
>
{t('Open Conversation Page')}
</button>
<button
type="button"
onClick={() => {
Browser.windows.create({
url: Browser.runtime.getURL('IndependentPanel.html'),
type: 'popup',
width: 500,
height: 650,
})
}}
>
{t('Open Conversation Window')}
</button>
{!isMobile() && !isFirefox() && !isSafari() && (
<label>
<input
type="checkbox"
checked={backgroundPermission}
onChange={(e) => {
const checked = e.target.checked
if (checked)
Browser.permissions.request({ permissions: ['background'] }).then((result) => {
setBackgroundPermission(result)
})
else
Browser.permissions.remove({ permissions: ['background'] }).then((result) => {
setBackgroundPermission(result)
})
}}
/>
{t('Keep Conversation Window in Background')}
</label>
)}
</div>
)
}