Skip to content

Commit

Permalink
Distinguish omnibox extension and webpage
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Jun 6, 2024
1 parent f3cf590 commit 85da5da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core
Submodule core updated 2 files
+2 −1 examples/index.html
+20 −10 src/omnibox.js
8 changes: 2 additions & 6 deletions extension/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ function getPlatformOs() {
});
}

async function start(el, icon, placeholder) {
const defaultSuggestion = `Search std <match>docs</match>, external <match>docs</match> (~,@), <match>crates</match> (!), <match>attributes</match> (#), <match>books</match> (%), clippy <match>lints</match> (>), and <match>error codes</match>, etc in your address bar instantly!`;
const omnibox = new Omnibox({ el, icon, defaultSuggestion: placeholder || defaultSuggestion, maxSuggestionSize: Compat.omniboxPageSize() });

async function start(omnibox) {
// All dynamic setting items. Those items will been updated
// in chrome.storage.onchange listener callback.
let isOfflineMode = await settings.isOfflineMode;
Expand Down Expand Up @@ -392,8 +389,7 @@ async function start(el, icon, placeholder) {

omnibox.addNoCacheQueries("/", "!", "@", ":");

// Skip following code if `el` provide, which mean this function run in webpage.
if (el) return;
if (!omnibox.extensionMode) return;

chrome.storage.onChanged.addListener(changes => {
for (let [key, { oldValue, newValue }] of Object.entries(changes)) {
Expand Down
Loading

0 comments on commit 85da5da

Please sign in to comment.