Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fixes:#148 Add Bookmark Manager Extension #258

Merged
merged 1 commit into from
May 17, 2024
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
27 changes: 27 additions & 0 deletions Bookmark Extension/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// background.js

// Listen for changes to bookmarks and update stored bookmarks
chrome.bookmarks.onCreated.addListener(updateStoredBookmarks);
chrome.bookmarks.onRemoved.addListener(updateStoredBookmarks);
chrome.bookmarks.onChanged.addListener(updateStoredBookmarks);

// Sync bookmarks across devices using Chrome Storage API
function syncBookmarks() {
chrome.bookmarks.getTree(function(bookmarkTreeNodes) {
chrome.storage.sync.set({ 'bookmarks': bookmarkTreeNodes }, function() {
console.log('Bookmarks synced successfully.');
});
});
}

// Update stored bookmarks when changes occur
function updateStoredBookmarks() {
syncBookmarks();
}

// Initialize bookmark syncing on extension install or update
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason === 'install' || details.reason === 'update') {
syncBookmarks();
}
});
Binary file added Bookmark Extension/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bookmark Extension/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bookmark Extension/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions Bookmark Extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"manifest_version": 3,
"name": "Enhanced Bookmark Manager",
"version": "1.0",
"description": "An extension to enhance bookmark management in the browser.",
"permissions": ["storage", "bookmarks"],
"action": {
"default_popup": "popup.html",
"default_icon": "icon16.png"
},
"background": {
"service_worker": "background.js"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"options_ui": {
"page": "options.html",
"open_in_tab": true
}
}

27 changes: 27 additions & 0 deletions Bookmark Extension/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Extension Options</title>
</head>
<body>
<h1>Extension Options</h1>
<p>This is where you can customize your extension settings.</p>

<h2>Bookmark Display Options</h2>
<label for="showTagsCheckbox">
<input type="checkbox" id="showTagsCheckbox"> Show tags with bookmarks
</label>

<h2>Sync Options</h2>
<label for="syncCheckbox">
<input type="checkbox" id="syncCheckbox"> Enable bookmark syncing across devices
</label>

<h2>Notification Options</h2>
<label for="notificationCheckbox">
<input type="checkbox" id="notificationCheckbox"> Enable notifications for new bookmarks
</label>
</body>
</html>
18 changes: 18 additions & 0 deletions Bookmark Extension/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Bookmark Manager</title>
<script src="popup.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Bookmark Manager</h1>
<img src="icon128.png" alt="Extension Logo">
<input type="text" id="bookmarkUrl" placeholder="Enter URL">
<input type="text" id="bookmarkTags" placeholder="Enter tags (comma-separated)">
<button class="btn" id="addBookmark">Add Bookmark</button>
<div id="status"></div>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions Bookmark Extension/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('addBookmark').addEventListener('click', function() {
var url = document.getElementById('bookmarkUrl').value;
var tags = document.getElementById('bookmarkTags').value.split(',').map(tag => tag.trim());

chrome.bookmarks.create({ 'title': url, 'url': url }, function(newBookmark) {
chrome.storage.sync.get('bookmarks', function(result) {
var bookmarks = result.bookmarks || [];
bookmarks.push({ id: newBookmark.id, url: url, tags: tags });
chrome.storage.sync.set({ 'bookmarks': bookmarks }, function() {
document.getElementById('status').textContent = 'Bookmark added successfully.';
});
});
});
});
});

20 changes: 20 additions & 0 deletions Bookmark Extension/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* styles.css */
.container {
text-align: center;
padding: 20px;
}

.btn {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #0056b3;
}

Loading