-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
25 lines (21 loc) · 924 Bytes
/
Copy pathpopup.js
File metadata and controls
25 lines (21 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Extract repo info from the current tab
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const url = tabs[0].url;
const match = url.match(/https:\/\/github\.com\/([^/]+)\/([^/]+)/);
if (match) {
const repoName = `${match[1]}/${match[2]}`;
document.getElementById("repoName").textContent = repoName;
document.getElementById("saveBtn").addEventListener("click", () => {
const notes = document.getElementById("notes").value;
chrome.storage.local.get(["bookmarks"], (result) => {
const bookmarks = result.bookmarks || [];
bookmarks.push({ repo: repoName, url, notes, timestamp: new Date() });
chrome.storage.local.set({ bookmarks }, () => {
alert("Bookmarked!");
});
});
});
} else {
document.getElementById("repoName").textContent = "Not a GitHub repo page.";
}
});