mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-07 13:42:34 +00:00
feat: rename to shortify
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { getCorgiData } from "./common.js";
|
||||
import { getShortifyData } from "./common.js";
|
||||
|
||||
const urlRegex = /https?:\/\/o\/(.+)/;
|
||||
|
||||
@ -6,16 +6,16 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
|
||||
if (typeof tab.url === "string") {
|
||||
const matchResult = urlRegex.exec(tab.url);
|
||||
if (matchResult) {
|
||||
const corgiData = await getCorgiData();
|
||||
const shortifyData = await getShortifyData();
|
||||
const name = matchResult[1];
|
||||
const url = `${corgiData.domain}/api/shortcut?openId=${corgiData.openId}&name=${name}&redirect=true`;
|
||||
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 corgiData = await getCorgiData();
|
||||
const url = `${corgiData.domain}/api/shortcut?openId=${corgiData.openId}&name=${text}&redirect=true`;
|
||||
const shortifyData = await getShortifyData();
|
||||
const url = `${shortifyData.domain}/api/shortcut?openId=${shortifyData.openId}&name=${text}&redirect=true`;
|
||||
return chrome.tabs.update({ url });
|
||||
});
|
||||
|
@ -1,10 +1,10 @@
|
||||
export const getCorgiData = () => {
|
||||
export const getShortifyData = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
chrome.storage.local.get(["corgi"], (data) => {
|
||||
if (data?.corgi) {
|
||||
resolve(data.corgi);
|
||||
chrome.storage.local.get(["shortify"], (data) => {
|
||||
if (data?.shortify) {
|
||||
resolve(data.shortify);
|
||||
} else {
|
||||
reject("corgi data not found");
|
||||
reject("shortify data not found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Corgi",
|
||||
"description": "Corgi is an URL manager.",
|
||||
"name": "Shortify",
|
||||
"description": "",
|
||||
"version": "0.0.1",
|
||||
"manifest_version": 3,
|
||||
"omnibox": {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h2>Corgi extension</h2>
|
||||
<h2>Shortify extension</h2>
|
||||
<div>
|
||||
<span>Domain</span>
|
||||
<input id="domain-input" type="text" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getCorgiData } from "./common.js";
|
||||
import { getShortifyData } from "./common.js";
|
||||
|
||||
const saveButton = document.body.querySelector("#save-button");
|
||||
const domainInput = document.body.querySelector("#domain-input");
|
||||
@ -6,7 +6,7 @@ const openIdInput = document.body.querySelector("#openid-input");
|
||||
|
||||
saveButton.addEventListener("click", () => {
|
||||
chrome.storage.local.set({
|
||||
corgi: {
|
||||
shortify: {
|
||||
domain: domainInput.value,
|
||||
openId: openIdInput.value,
|
||||
},
|
||||
@ -14,9 +14,9 @@ saveButton.addEventListener("click", () => {
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const corgiData = await getCorgiData();
|
||||
if (corgiData) {
|
||||
domainInput.value = corgiData.domain;
|
||||
openIdInput.value = corgiData.openId;
|
||||
const shortifyData = await getShortifyData();
|
||||
if (shortifyData) {
|
||||
domainInput.value = shortifyData.domain;
|
||||
openIdInput.value = shortifyData.openId;
|
||||
}
|
||||
})();
|
||||
|
Reference in New Issue
Block a user