Skip to content

Commit

Permalink
Add support for omnibox search with Yomitan (#1822)
Browse files Browse the repository at this point in the history
* Add support for omnibox search with Yomitan

* Change keyword to "yomi"

* Catch errors on omnibox listener
  • Loading branch information
Kuuuube authored Feb 24, 2025
1 parent 57b0538 commit 4f109a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dev/data/manifest-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"service_worker": "sw.js",
"type": "module"
},
"omnibox": {
"keyword": "yomi"
},
"content_scripts": [
{
"run_at": "document_idle",
Expand Down
14 changes: 14 additions & 0 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ export class Backend {

this._setupContextMenu(options);

this._attachOmniboxListener();

void this._accessibilityController.update(this._getOptionsFull(false));

this._sendMessageAllTabsIgnoreResponse({action: 'applicationOptionsUpdated', params: {source}});
Expand Down Expand Up @@ -1404,6 +1406,18 @@ export class Backend {
}
}

/** */
_attachOmniboxListener() {
try {
chrome.omnibox.onInputEntered.addListener((text) => {
const newURL = 'search.html?query=' + encodeURIComponent(text);
void chrome.tabs.create({url: newURL});
});
} catch (e) {
log.error(e);
}
}

/**
* @param {boolean} useSchema
* @returns {import('settings').Options}
Expand Down

0 comments on commit 4f109a9

Please sign in to comment.