mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-17 04:43:13 +00:00
chore: remove extension folder
This commit is contained in:
parent
0a811d2568
commit
07814ef606
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ web/dist
|
|||||||
build
|
build
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
extension
|
||||||
|
@ -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 });
|
|
||||||
});
|
|
@ -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");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
@ -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/*"]
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<h2>Shortify extension</h2>
|
|
||||||
<div>
|
|
||||||
<span>Domain</span>
|
|
||||||
<input id="domain-input" type="text" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span>OpenId</span>
|
|
||||||
<input id="openid-input" type="text" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button id="save-button">Save</button>
|
|
||||||
</div>
|
|
||||||
<script type="module" src="popup.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -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;
|
|
||||||
}
|
|
||||||
})();
|
|
Loading…
x
Reference in New Issue
Block a user