mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-03 20:37:55 +08:00
feat: add entry for Independent Panel and Keyboard Shortcuts
This commit is contained in:
@@ -92,5 +92,8 @@
|
||||
"Unpin": "Unpin",
|
||||
"Delete Conversation": "Delete Conversation",
|
||||
"Clear conversations": "Clear conversations",
|
||||
"Settings": "Settings"
|
||||
"Settings": "Settings",
|
||||
"Feature Pages": "Feature Pages",
|
||||
"Keyboard Shortcuts": "Keyboard Shortcuts",
|
||||
"Open Conversation Page": "Open Conversation Page"
|
||||
}
|
||||
|
||||
@@ -92,5 +92,8 @@
|
||||
"Unpin": "收缩侧边",
|
||||
"Delete Conversation": "删除对话",
|
||||
"Clear conversations": "清空记录",
|
||||
"Settings": "设置"
|
||||
"Settings": "设置",
|
||||
"Feature Pages": "功能页",
|
||||
"Keyboard Shortcuts": "快捷键设置",
|
||||
"Open Conversation Page": "打开独立对话页"
|
||||
}
|
||||
|
||||
@@ -92,5 +92,8 @@
|
||||
"Unpin": "收縮側邊",
|
||||
"Delete Conversation": "刪除對話",
|
||||
"Clear conversations": "清空記錄",
|
||||
"Settings": "設置"
|
||||
"Settings": "設置",
|
||||
"Feature Pages": "功能頁",
|
||||
"Keyboard Shortcuts": "快捷鍵設置",
|
||||
"Open Conversation Page": "打開獨立對話頁"
|
||||
}
|
||||
|
||||
@@ -156,6 +156,8 @@ Browser.commands.onCommand.addListener(async (command) => {
|
||||
selectionText: '',
|
||||
useMenuPosition: false,
|
||||
}
|
||||
console.debug('command triggered', message)
|
||||
if (menuConfig[command].action) menuConfig[command].action()
|
||||
Browser.tabs.sendMessage(currentTab.id, {
|
||||
type: 'CREATE_CHAT',
|
||||
data: message,
|
||||
@@ -208,6 +210,7 @@ function refreshMenu() {
|
||||
useMenuPosition: tab.id === currentTab.id,
|
||||
}
|
||||
console.debug('menu clicked', message)
|
||||
if (menuConfig[message.itemId].action) menuConfig[message.itemId].action()
|
||||
Browser.tabs.sendMessage(currentTab.id, {
|
||||
type: 'CREATE_CHAT',
|
||||
data: message,
|
||||
|
||||
@@ -241,7 +241,9 @@ async function prepareForRightClickMenu() {
|
||||
if (data.itemId in toolsConfig) {
|
||||
prompt = await toolsConfig[data.itemId].genPrompt(data.selectionText)
|
||||
} else if (data.itemId in menuConfig) {
|
||||
prompt = await menuConfig[data.itemId].genPrompt()
|
||||
const menuItem = menuConfig[data.itemId]
|
||||
if (!menuItem.genPrompt) return
|
||||
else prompt = await menuItem.genPrompt()
|
||||
if (prompt) prompt = cropText(`Reply in ${await getPreferredLanguage()}.\n` + prompt)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { getCoreContentText } from '../../utils/get-core-content-text'
|
||||
import { openUrl } from '../../utils/open-url'
|
||||
import Browser from 'webextension-polyfill'
|
||||
|
||||
export const config = {
|
||||
newChat: {
|
||||
@@ -13,4 +15,10 @@ export const config = {
|
||||
return `The following is the text content of a web page, analyze the core content and summarize:\n${getCoreContentText()}`
|
||||
},
|
||||
},
|
||||
openConversationPage: {
|
||||
label: 'Open Conversation Page',
|
||||
action: async () => {
|
||||
openUrl(Browser.runtime.getURL('IndependentPanel.html'))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+9
-1
@@ -17,7 +17,8 @@
|
||||
"commands",
|
||||
"cookies",
|
||||
"storage",
|
||||
"contextMenus"
|
||||
"contextMenus",
|
||||
"unlimitedStorage"
|
||||
],
|
||||
"background": {
|
||||
"service_worker": "background.js"
|
||||
@@ -69,6 +70,13 @@
|
||||
"mac": "Alt+B"
|
||||
},
|
||||
"description": "Summarize this page"
|
||||
},
|
||||
"openConversationPage": {
|
||||
"suggested_key": {
|
||||
"default": "Ctrl+Shift+H",
|
||||
"mac": "MacCtrl+Shift+H"
|
||||
},
|
||||
"description": "Open the independent conversation page"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
"cookies",
|
||||
"storage",
|
||||
"contextMenus",
|
||||
"unlimitedStorage",
|
||||
"https://*.openai.com/",
|
||||
"https://*.bing.com/"
|
||||
],
|
||||
@@ -62,6 +63,13 @@
|
||||
"mac": "Alt+B"
|
||||
},
|
||||
"description": "Summarize this page"
|
||||
},
|
||||
"openConversationPage": {
|
||||
"suggested_key": {
|
||||
"default": "Ctrl+Shift+H",
|
||||
"mac": "MacCtrl+Shift+H"
|
||||
},
|
||||
"description": "Open the independent conversation page"
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
-1
@@ -24,7 +24,7 @@ import wechatpay from './donation/wechatpay.jpg'
|
||||
import bugmeacoffee from './donation/bugmeacoffee.png'
|
||||
import { useWindowTheme } from '../hooks/use-window-theme.mjs'
|
||||
import { languageList } from '../config/language.mjs'
|
||||
import { isMobile, isSafari } from '../utils/index.mjs'
|
||||
import { isEdge, isFirefox, isMobile, isSafari, openUrl } from '../utils/index.mjs'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
function GeneralPart({ config, updateConfig }) {
|
||||
@@ -256,6 +256,34 @@ GeneralPart.propTypes = {
|
||||
updateConfig: PropTypes.func.isRequired,
|
||||
}
|
||||
|
||||
function FeaturePages() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div style="display:flex;flex-direction:column;align-items:center;">
|
||||
{!isMobile() && !isFirefox() && !isSafari() && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (isEdge()) openUrl('edge://extensions/shortcuts')
|
||||
else openUrl('chrome://extensions/shortcuts')
|
||||
}}
|
||||
>
|
||||
{t('Keyboard Shortcuts')}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
openUrl(Browser.runtime.getURL('IndependentPanel.html'))
|
||||
}}
|
||||
>
|
||||
{t('Open Conversation Page')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function AdvancedPart({ config, updateConfig }) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -514,6 +542,7 @@ function Popup() {
|
||||
<Tabs selectedTabClassName="popup-tab--selected">
|
||||
<TabList>
|
||||
<Tab className="popup-tab">{t('General')}</Tab>
|
||||
<Tab className="popup-tab">{t('Feature Pages')}</Tab>
|
||||
<Tab className="popup-tab">{t('Selection Tools')}</Tab>
|
||||
<Tab className="popup-tab">{t('Sites')}</Tab>
|
||||
<Tab className="popup-tab">{t('Advanced')}</Tab>
|
||||
@@ -523,6 +552,9 @@ function Popup() {
|
||||
<TabPanel>
|
||||
<GeneralPart config={config} updateConfig={updateConfig} />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<FeaturePages />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<SelectionTools config={config} updateConfig={updateConfig} />
|
||||
</TabPanel>
|
||||
|
||||
+3
-1
@@ -8,10 +8,12 @@ export * from './get-conversation-pairs'
|
||||
export * from './get-core-content-text'
|
||||
export * from './get-possible-element-by-query-selector'
|
||||
export * from './init-session'
|
||||
export * from './is-firefox.mjs'
|
||||
export * from './is-edge'
|
||||
export * from './is-firefox'
|
||||
export * from './is-mobile'
|
||||
export * from './is-safari'
|
||||
export * from './limited-fetch'
|
||||
export * from './open-url'
|
||||
export * from './set-element-position-in-viewport'
|
||||
export * from './stream-async-iterable'
|
||||
export * from './update-ref-height'
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export function isEdge() {
|
||||
return navigator.userAgent.toLowerCase().includes('edg')
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Browser from 'webextension-polyfill'
|
||||
|
||||
export function openUrl(url) {
|
||||
Browser.tabs.query({ url }).then((tabs) => {
|
||||
if (tabs.length > 0) {
|
||||
Browser.tabs.update(tabs[0].id, { active: true })
|
||||
} else {
|
||||
Browser.tabs.create({ url })
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user