개발 공부를 하다보면 탭이 30~40개씩 띄워져 있는 경우가 있습니다. 크롬이 메모리도 엄청 잡아먹고 배터리가 빨리 닳는 것 같기도 해서 탭 관리를 해주는 앱이 있으면 좋겠다 싶었습니다. 제가 생각한 앱의 용도는 아래와 같습니다.
하루 이상 지나면 정리를 해야 한다는 빨간 원을 보여줌으로써 사용자가 인지하고 한 번더 공부하고 정리할 수 있게 해줍니다. 그 과정에서 시간이 부족한 경우 요약하기
버튼을 통해 약식으로 정리하고 탭을 닫을 수 있습니다.
popup.js, background.js, contentScript.js
를 dist
폴더 안에 번들링할 수 있도록 아래와 같이 세팅했습니다.export default defineConfig({
plugins: [react()],
build: {
rollupOptions: {
input: {
popup: "/popup.html",
background: "/src/background.ts",
contentScript: "/src/contentScript.ts",
},
output: {
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`,
},
},
},
});
map
을 사용해 리스트를 보여줍니다.몇 분 전
의 형태로 보여줍니다.const summarizeWithGPT = async (tabId: number, text: string) => {
try {
const completion = await openai.chat.completions.create({
messages: [
{
role: "system",
content: `You are a summary expert. Summarize the text into 3 sentences in English. '''${text}'''`,
},
],
model: "gpt-4-turbo-preview",
max_tokens: 100,
});
setSummaries((prev) => ({
...prev,
[tabId]: completion.choices[0].message.content!,
}));
} catch (err) {
console.error(err);
}
};
const handleSummarize = async (tabId: number, url: string) => {
setLoadingStates((prev) => ({
...prev,
[tabId]: { type: "read", state: true },
}));
try {
const textContet = await handleCrawl(url);
setLoadingStates((prev) => ({
...prev,
[tabId]: { type: "summarize", state: true },
}));
if (textContet) {
await summarizeWithGPT(tabId, textContet);
} else {
console.error("No text content");
}
} catch (error) {
console.error("Summarize failed:", error);
} finally {
setLoadingStates((prev) => ({
...prev,
[tabId]: { type: "finish", state: false },
}));
}
};
id: tab.id,
title: tab.title,
url: tab.url,
favicon: tab.favIconUrl,
createdAt: Date.now(),
번들링 결과인 dist 폴더를 압축해 크롬 개발자 대시보드에서 검토 요청을 합니다. 2-3일 후 거부, 혹은 게시 결과를 보내줍니다.