mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-20 20:04:26 +00:00
chore: rename to slash
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
@@ -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");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "Shortify",
|
||||
"name": "Slash",
|
||||
"description": "",
|
||||
"version": "0.1.0",
|
||||
"manifest_version": 3,
|
||||
|
@@ -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" />
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user