chore: update extension pnpm lock file

This commit is contained in:
Steven 2023-08-08 22:01:07 +08:00
parent 2264b64007
commit 07365fda73
3 changed files with 304 additions and 279 deletions

View File

@ -47,10 +47,12 @@
}, },
"manifest": { "manifest": {
"host_permissions": [ "host_permissions": [
"http://*/*",
"https://*/*" "https://*/*"
], ],
"permissions": [ "permissions": [
"tabs", "tabs",
"activeTab",
"scripting", "scripting",
"storage" "storage"
] ]

561
extension/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -5,16 +5,18 @@ const storage = new Storage();
const urlRegex = /https?:\/\/s\/(.+)/; const urlRegex = /https?:\/\/s\/(.+)/;
chrome.tabs.onUpdated.addListener(async (tabId, _, tab) => { chrome.tabs.onUpdated.addListener(async (tabId, _, tab) => {
if (typeof tab.url === "string") { if (!tab.url) {
const shortcutName = getShortcutNameFromUrl(tab.url); return;
if (shortcutName) { }
const shortcuts = (await storage.getItem<Shortcut[]>("shortcuts")) || [];
const shortcut = shortcuts.find((shortcut) => shortcut.name === shortcutName); const shortcutName = getShortcutNameFromUrl(tab.url);
if (!shortcut) { if (shortcutName) {
return; const shortcuts = (await storage.getItem<Shortcut[]>("shortcuts")) || [];
} const shortcut = shortcuts.find((shortcut) => shortcut.name === shortcutName);
return chrome.tabs.update(tabId, { url: shortcut.link }); if (!shortcut) {
return;
} }
return chrome.tabs.update(tabId, { url: shortcut.link });
} }
}); });