mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
feat: add omnibox to extension
This commit is contained in:
parent
6f26523a11
commit
f1e3eace1a
@ -47,6 +47,9 @@
|
|||||||
"typescript": "5.1.6"
|
"typescript": "5.1.6"
|
||||||
},
|
},
|
||||||
"manifest": {
|
"manifest": {
|
||||||
|
"omnibox": {
|
||||||
|
"keyword": "s"
|
||||||
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"tabs",
|
"tabs",
|
||||||
"storage"
|
"storage"
|
||||||
|
@ -20,6 +20,15 @@ chrome.tabs.onUpdated.addListener(async (tabId, _, tab) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
chrome.omnibox.onInputEntered.addListener(async (text) => {
|
||||||
|
const shortcuts = (await storage.getItem<Shortcut[]>("shortcuts")) || [];
|
||||||
|
const shortcut = shortcuts.find((shortcut) => shortcut.name === text);
|
||||||
|
if (!shortcut) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return chrome.tabs.update({ url: shortcut.link });
|
||||||
|
});
|
||||||
|
|
||||||
const getShortcutNameFromUrl = (urlString: string) => {
|
const getShortcutNameFromUrl = (urlString: string) => {
|
||||||
const matchResult = urlRegex.exec(urlString);
|
const matchResult = urlRegex.exec(urlString);
|
||||||
if (matchResult === null) {
|
if (matchResult === null) {
|
||||||
|
@ -110,7 +110,7 @@ const IndexOptions = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isInitialized && shortcuts.length > 0 && (
|
{isInitialized && (
|
||||||
<>
|
<>
|
||||||
<Divider className="!my-6" />
|
<Divider className="!my-6" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user