chore: remove extension folder

This commit is contained in:
Steven 2023-08-01 20:07:04 +08:00
parent 0c4ed55a76
commit 47e0fcd43c
5 changed files with 0 additions and 87 deletions

View File

@ -1,21 +0,0 @@
import { getSlashData } from "./common.js";
const urlRegex = /https?:\/\/s\/(.+)/;
chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
if (typeof tab.url === "string") {
const matchResult = urlRegex.exec(tab.url);
if (matchResult) {
const slashData = await getSlashData();
const name = matchResult[1];
const url = `${slashData.domain}/s/${name}`;
return chrome.tabs.update(tab.id, { url });
}
}
});
chrome.omnibox.onInputEntered.addListener(async (text) => {
const slashData = await getSlashData();
const url = `${slashData.domain}/s/${text}`;
return chrome.tabs.update({ url });
});

View File

@ -1,11 +0,0 @@
export const getSlashData = () => {
return new Promise((resolve, reject) => {
chrome.storage.local.get(["slash"], (data) => {
if (data?.slash) {
resolve(data.slash);
} else {
reject("slash data not found");
}
});
});
};

View File

@ -1,18 +0,0 @@
{
"name": "Slash",
"description": "",
"version": "0.1.0",
"manifest_version": 3,
"omnibox": {
"keyword": "s/"
},
"action": {
"default_popup": "popup.html"
},
"background": {
"service_worker": "background.js",
"type": "module"
},
"permissions": ["tabs", "activeTab", "storage"],
"host_permissions": ["*://s/*"]
}

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<h2>Slash extension</h2>
<div>
<span>Domain</span>
<input id="domain-input" type="text" />
</div>
<div>
<button id="save-button">Save</button>
</div>
<script type="module" src="popup.js"></script>
</body>
</html>

View File

@ -1,23 +0,0 @@
import { getSlashData } from "./common.js";
const saveButton = document.body.querySelector("#save-button");
const domainInput = document.body.querySelector("#domain-input");
saveButton.addEventListener("click", () => {
chrome.storage.local.set({
slash: {
domain: domainInput.value,
},
});
});
(async () => {
try {
const slashData = await getSlashData();
if (slashData) {
domainInput.value = slashData.domain;
}
} catch (error) {
// do nothing.
}
})();