Skip to content

Commit a70d93b

Browse files
committed
Localized query when no active URL on toolbar icon click
1 parent 47caad6 commit a70d93b

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

brave-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const braveURL = 'https://search.brave.com'
1212
// Launch Brave Search on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${braveURL}/search?q=${query}&summary=1` })
1717
})
1818

brave-omnibox/firefox/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const braveURL = 'https://search.brave.com'
1212
// Launch Brave Search on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${braveURL}/search?q=${query}&summary=1` })
1717
})
1818

chatgpt-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const chatgptURL = 'https://chatgpt.com'
1212
// Launch ChatGPT on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${chatgptURL}/?q=${query}` })
1717
})
1818

chatgpt-omnibox/firefox/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const chatgptURL = 'https://chatgpt.com'
1212
// Launch ChatGPT on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${chatgptURL}/?q=${query}` })
1717
})
1818

deepseek-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function tabIsLoaded(tabId) {
1919
// Launch DeepSeek Chat on toolbar icon click
2020
chrome.action.onClicked.addListener(async () => {
2121
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
22-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi',
22+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi'),
2323
newTab = await chrome.tabs.create({ url: deepseekChatURL })
2424
tabIsLoaded(newTab.id).then(() => chrome.tabs.sendMessage(newTab.id, query))
2525
})

deepseek-omnibox/firefox/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function tabIsLoaded(tabId) {
1919
// Launch DeepSeek Chat on toolbar icon click
2020
chrome.action.onClicked.addListener(async () => {
2121
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
22-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi',
22+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi'),
2323
newTab = await chrome.tabs.create({ url: deepseekChatURL })
2424
tabIsLoaded(newTab.id).then(() => chrome.tabs.sendMessage(newTab.id, query))
2525
})

perplexity-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const perplexityURL = 'https://www.perplexity.ai'
1212
// Launch Perplexity on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${perplexityURL}/search/new?q=${query}` })
1717
})
1818

phind-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const phindURL = 'https://www.phind.com'
1212
// Launch Phind on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${phindURL}/search?q=${query}` })
1717
})
1818

phind-omnibox/firefox/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const phindURL = 'https://www.phind.com'
1212
// Launch Phind on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${phindURL}/search?q=${query}` })
1717
})
1818

you.com-omnibox/chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const youURL = 'https://you.com/'
1212
// Launch You.com on toolbar icon click
1313
chrome.action.onClicked.addListener(async () => {
1414
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }),
15-
query = activeTab.url ? new URL(activeTab.url).searchParams.get('q') || 'hi' : 'hi'
15+
query = new URL(activeTab?.url || 'about:blank').searchParams.get('q') || chrome.i18n.getMessage('query_hi')
1616
chrome.tabs.create({ url: `${youURL}/search?q=${query}&tbm=youchat` })
1717
})
1818

0 commit comments

Comments
 (0)