Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "PinBack Extension",
"version": "0.1.0",
"name": "Pinback - 북마크 관리와 리마인드 도구",
"version": "1.0.1",
"action": { "default_popup": "popup.html" },
"icons": {
"128": "icon.png",
Expand Down
14 changes: 0 additions & 14 deletions apps/extension/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@
<meta charset="UTF-8" />
<title>PinBack</title>
</head>
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-847ZNSCC3J"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());

gtag('config', 'G-847ZNSCC3J');
</script>
<body>
<div id="root"></div>
<script type="module" src="/src/popup.tsx"></script>
Expand Down
2 changes: 0 additions & 2 deletions apps/extension/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MainPop from './pages/MainPop';
import { useState, useEffect } from 'react';
import { useGetArticleSaved } from '@apis/query/queries';
import { usePageMeta } from './hooks/usePageMeta';
import { sendGAEvent } from '@pinback/design-system/ui';
const App = () => {
const { url } = usePageMeta();
const { data: isSaved } = useGetArticleSaved(url);
Expand All @@ -24,7 +23,6 @@ const App = () => {
};

const handleDuplicateRightClick = () => {
sendGAEvent('extension', 'extension', '1-extension-dashBoard-clickBtn');
chrome.tabs.create({ url: 'https://www.pinback.today/' });
};

Expand Down
62 changes: 52 additions & 10 deletions apps/extension/src/hooks/useSaveBookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const useSaveBookmark = () => {
createdAt: new Date().toISOString(),
};

// --- 기존 북마크 local 저장
const result = await new Promise<{ bookmarks?: any[] }>((resolve) => {
chrome.storage.local.get(['bookmarks'], (items) => resolve(items));
});
Expand All @@ -29,16 +30,57 @@ export const useSaveBookmark = () => {
chrome.storage.local.set({ bookmarks }, resolve);
});

chrome.bookmarks.create(
{
parentId: '1',
title: params.title || params.url,
url: params.url,
},
(newBookmark) => {
console.log('크롬 북마크바에 저장 완료: ', newBookmark);
}
);
// --- 📂 'PinBack' 폴더 찾기
const pinbackFolder =
await new Promise<chrome.bookmarks.BookmarkTreeNode | null>(
(resolve) => {
chrome.bookmarks.search({ title: 'PinBack' }, (results) => {
const folder = results.find((r) => r.url === undefined); // 폴더만
resolve(folder || null);
});
}
);

// --- 📂 폴더 없으면 '기타 북마크(3)' 아래 새로 만들기
const folderId = pinbackFolder
? pinbackFolder.id
: await new Promise<string>((resolve, reject) => {
chrome.bookmarks.create(
{
parentId: '2', // 기타 북마크
title: 'PinBack',
},
(newFolder) => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
return;
}
console.log('새 폴더 생성됨 👉', newFolder);
resolve(newFolder.id);
}
);
});

// --- 📑 북마크 생성
await new Promise<void>((resolve, reject) => {
chrome.bookmarks.create(
{
parentId: folderId,
title: params.title || params.url,
url: params.url,
},
(newBookmark) => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
return;
}
console.log('📌 PinBack 폴더에 북마크 저장 완료:', newBookmark);
resolve();
}
);
});

// window 닫기
window.close();
} catch (error) {
console.error('저장 중 오류:', error);
Expand Down
5 changes: 1 addition & 4 deletions apps/extension/src/pages/MainPop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const MainPop = ({ type, savedData }: MainPopProps) => {
date: isRemindOn ? currentDate : date,
time: isRemindOn ? currentTime : time,
});
window.close();
//window.close();
},
}
);
Expand All @@ -247,9 +247,6 @@ const MainPop = ({ type, savedData }: MainPopProps) => {
},
}
);
// setTimeout(() => {
// window.close();
// }, 1000);
}
};

Expand Down
Loading