mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-09-11 12:00:52 +08:00
support for chromium side panel (#111)
This commit is contained in:
@@ -2,7 +2,7 @@ import Browser from 'webextension-polyfill'
|
||||
import { config as menuConfig } from '../content-script/menu-tools/index.mjs'
|
||||
|
||||
export function registerCommands() {
|
||||
Browser.commands.onCommand.addListener(async (command) => {
|
||||
Browser.commands.onCommand.addListener(async (command, tab) => {
|
||||
const message = {
|
||||
itemId: command,
|
||||
selectionText: '',
|
||||
@@ -12,7 +12,7 @@ export function registerCommands() {
|
||||
|
||||
if (command in menuConfig) {
|
||||
if (menuConfig[command].action) {
|
||||
menuConfig[command].action(true)
|
||||
menuConfig[command].action(true, tab)
|
||||
}
|
||||
|
||||
if (menuConfig[command].genPrompt) {
|
||||
|
||||
@@ -279,6 +279,16 @@ try {
|
||||
},
|
||||
['requestHeaders'],
|
||||
)
|
||||
|
||||
Browser.tabs.onUpdated.addListener(async (tabId, info, tab) => {
|
||||
if (!tab.url) return
|
||||
// eslint-disable-next-line no-undef
|
||||
await chrome.sidePanel.setOptions({
|
||||
tabId,
|
||||
path: 'IndependentPanel.html',
|
||||
enabled: true,
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export function refreshMenu() {
|
||||
})
|
||||
} else if (message.itemId in menuConfig) {
|
||||
if (menuConfig[message.itemId].action) {
|
||||
menuConfig[message.itemId].action(true)
|
||||
menuConfig[message.itemId].action(true, tab)
|
||||
}
|
||||
|
||||
if (menuConfig[message.itemId].genPrompt) {
|
||||
|
||||
Reference in New Issue
Block a user