Skip to content

Commit

Permalink
Added GitHub bookmark Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
thevijayshankersharma committed May 18, 2024
1 parent b9ffc41 commit 5d63813
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
Binary file added Github Bookmark Extension/icons/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 Github Bookmark Extension/icons/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 Github Bookmark Extension/icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Github Bookmark Extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"manifest_version": 3,
"name": "GitHub Bookmark",
"version": "1.0",
"description": "Add bookmarks for GitHub repositories",
"permissions": [
"bookmarks",
"tabs",
"storage",
"activeTab"
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
},
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
}
28 changes: 28 additions & 0 deletions Github Bookmark Extension/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
body {
font-family: Arial, sans-serif;
}

.container {
width: 300px;
margin: 20px auto;
text-align: center;
}

input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
width: 90%;
}

button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}
21 changes: 21 additions & 0 deletions Github Bookmark Extension/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Bookmark Adder</title>
<link rel="stylesheet" href="popup.css">
</head>

<body>
<div class="container">
<h1>GitHub Bookmark Adder</h1>
<input type="text" id="githubUrl" placeholder="Enter GitHub URL">
<button id="addBookmark">Add Bookmark</button>
<p id="statusMessage"></p>
</div>
<script src="popup.js"></script>
</body>

</html>
41 changes: 41 additions & 0 deletions Github Bookmark Extension/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
document.addEventListener('DOMContentLoaded', function () {
var addBookmarkButton = document.getElementById('addBookmark');
var githubUrlInput = document.getElementById('githubUrl');
var statusMessage = document.getElementById('statusMessage');

addBookmarkButton.addEventListener('click', function () {
var url = githubUrlInput.value.trim();
if (url === '') {
setStatus('Please enter a GitHub URL.', 'red');
return;
}

if (!isValidUrl(url)) {
setStatus('Invalid GitHub URL.', 'red');
return;
}

saveBookmark(url);
setStatus('GitHub URL bookmarked successfully.', 'green');
githubUrlInput.value = '';
});

function setStatus(message, color) {
statusMessage.textContent = message;
statusMessage.style.color = color;
}

function isValidUrl(url) {
var regex = /^https?:\/\/github\.com\/.*$/;
return regex.test(url);
}

function saveBookmark(url) {
chrome.bookmarks.create({
title: 'GitHub Bookmark',
url: url
}, function () {
setStatus('GitHub URL bookmarked successfully.', 'green');
});
}
});

0 comments on commit 5d63813

Please sign in to comment.