From 07814ef6060692b28e86a3ba43dd6ae5b018ff27 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 24 Jun 2023 14:03:52 +0800 Subject: [PATCH] chore: remove extension folder --- .gitignore | 2 ++ extension/background.js | 21 --------------------- extension/common.js | 11 ----------- extension/manifest.json | 18 ------------------ extension/popup.html | 18 ------------------ extension/popup.js | 22 ---------------------- 6 files changed, 2 insertions(+), 90 deletions(-) delete mode 100644 extension/background.js delete mode 100644 extension/common.js delete mode 100644 extension/manifest.json delete mode 100644 extension/popup.html delete mode 100644 extension/popup.js diff --git a/.gitignore b/.gitignore index 99d0edd..db92a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ web/dist build .DS_Store + +extension diff --git a/extension/background.js b/extension/background.js deleted file mode 100644 index ed96bf9..0000000 --- a/extension/background.js +++ /dev/null @@ -1,21 +0,0 @@ -import { getShortifyData } from "./common.js"; - -const urlRegex = /https?:\/\/o\/(.+)/; - -chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { - if (typeof tab.url === "string") { - const matchResult = urlRegex.exec(tab.url); - if (matchResult) { - const shortifyData = await getShortifyData(); - const name = matchResult[1]; - const url = `${shortifyData.domain}/api/shortcut?openId=${shortifyData.openId}&name=${name}&redirect=true`; - return chrome.tabs.update({ url }); - } - } -}); - -chrome.omnibox.onInputEntered.addListener(async (text) => { - const shortifyData = await getShortifyData(); - const url = `${shortifyData.domain}/api/shortcut?openId=${shortifyData.openId}&name=${text}&redirect=true`; - return chrome.tabs.update({ url }); -}); diff --git a/extension/common.js b/extension/common.js deleted file mode 100644 index 124a240..0000000 --- a/extension/common.js +++ /dev/null @@ -1,11 +0,0 @@ -export const getShortifyData = () => { - return new Promise((resolve, reject) => { - chrome.storage.local.get(["shortify"], (data) => { - if (data?.shortify) { - resolve(data.shortify); - } else { - reject("shortify data not found"); - } - }); - }); -}; diff --git a/extension/manifest.json b/extension/manifest.json deleted file mode 100644 index 49a8e6d..0000000 --- a/extension/manifest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "Shortify", - "description": "", - "version": "0.0.1", - "manifest_version": 3, - "omnibox": { - "keyword": "go/" - }, - "action": { - "default_popup": "popup.html" - }, - "background": { - "service_worker": "background.js", - "type": "module" - }, - "permissions": ["tabs", "activeTab", "storage"], - "host_permissions": ["*://go/*"] -} diff --git a/extension/popup.html b/extension/popup.html deleted file mode 100644 index 38071c1..0000000 --- a/extension/popup.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -

Shortify extension

-
- Domain - -
-
- OpenId - -
-
- -
- - - diff --git a/extension/popup.js b/extension/popup.js deleted file mode 100644 index 5e6e337..0000000 --- a/extension/popup.js +++ /dev/null @@ -1,22 +0,0 @@ -import { getShortifyData } from "./common.js"; - -const saveButton = document.body.querySelector("#save-button"); -const domainInput = document.body.querySelector("#domain-input"); -const openIdInput = document.body.querySelector("#openid-input"); - -saveButton.addEventListener("click", () => { - chrome.storage.local.set({ - shortify: { - domain: domainInput.value, - openId: openIdInput.value, - }, - }); -}); - -(async () => { - const shortifyData = await getShortifyData(); - if (shortifyData) { - domainInput.value = shortifyData.domain; - openIdInput.value = shortifyData.openId; - } -})();