chore: rename to slash

This commit is contained in:
Steven
2023-07-11 23:51:17 +08:00
parent fcd72e1f98
commit b36572c5be
43 changed files with 97 additions and 97 deletions

View File

@@ -1,4 +1,4 @@
import { getShortifyData } from "./common.js";
import { getSlashData } from "./common.js";
const urlRegex = /https?:\/\/s\/(.+)/;
@@ -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 shortifyData = await getShortifyData();
const slashData = await getSlashData();
const name = matchResult[1];
const url = `${shortifyData.domain}/s/${name}`;
return chrome.tabs.update({ url });
const url = `${slashData.domain}/s/${name}`;
return chrome.tabs.update(tab.id, { url });
}
}
});
chrome.omnibox.onInputEntered.addListener(async (text) => {
const shortifyData = await getShortifyData();
const url = `${shortifyData.domain}/s/${text}`;
const slashData = await getSlashData();
const url = `${slashData.domain}/s/${text}`;
return chrome.tabs.update({ url });
});

View File

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

View File

@@ -1,5 +1,5 @@
{
"name": "Shortify",
"name": "Slash",
"description": "",
"version": "0.1.0",
"manifest_version": 3,

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<h2>Shortify extension</h2>
<h2>Slash extension</h2>
<div>
<span>Domain</span>
<input id="domain-input" type="text" />

View File

@@ -1,11 +1,11 @@
import { getShortifyData } from "./common.js";
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({
shortify: {
slash: {
domain: domainInput.value,
},
});
@@ -13,9 +13,9 @@ saveButton.addEventListener("click", () => {
(async () => {
try {
const shortifyData = await getShortifyData();
if (shortifyData) {
domainInput.value = shortifyData.domain;
const slashData = await getSlashData();
if (slashData) {
domainInput.value = slashData.domain;
}
} catch (error) {
// do nothing.