Skip to content

feat: Create Chrome extension for Cobalt video downloader #1344

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Empty file added images/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added images/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added images/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"manifest_version": 3,
"name": "Cobalt Side Panel",
"version": "1.0",
"description": "A Chrome extension that provides a side panel interface for Cobalt.",
"permissions": [
"sidePanel"
],
"side_panel": {
"default_path": "sidepanel.html"
},
"action": {
"default_title": "Open Cobalt Side Panel"
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
}
}
44 changes: 44 additions & 0 deletions sidepanel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
body {
font-family: sans-serif;
padding: 10px;
background-color: #f0f0f0;
min-width: 250px; /* Ensure sidepanel has some minimum width */
}

h1 {
color: #333;
font-size: 1.2em; /* Slightly smaller h1 for a side panel */
text-align: center;
margin-bottom: 15px;
}

p {
color: #555;
font-size: 0.9em; /* Slightly smaller p for a side panel */
margin-bottom: 5px;
}

#videoUrl {
width: calc(100% - 22px); /* Adjust width considering padding/border */
padding: 8px 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Important for width calculation */
}

#downloadButton {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%; /* Make button full width */
font-size: 1em;
margin-top: 5px; /* Added margin-top */
}

#downloadButton:hover {
background-color: #0056b3;
}
15 changes: 15 additions & 0 deletions sidepanel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Cobalt Side Panel</title>
<link rel="stylesheet" href="sidepanel.css">
</head>
<body>
<h1>Cobalt Video Downloader</h1>
<p>Enter the URL of the video you want to download:</p>
<input type="text" id="videoUrl" placeholder="e.g., https://www.youtube.com/watch?v=..." style="width: 90%; margin-bottom: 10px;">
<button id="downloadButton">Download with Cobalt</button>

<script src="sidepanel.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions sidepanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
document.addEventListener('DOMContentLoaded', function() {
// New Cobalt download button listener
const downloadButton = document.getElementById('downloadButton');
const videoUrlInput = document.getElementById('videoUrl');

if (downloadButton && videoUrlInput) {
downloadButton.addEventListener('click', function() {
const videoUrl = videoUrlInput.value.trim();
if (videoUrl) {
// Basic URL validation (optional, but good practice)
try {
new URL(videoUrl); // Check if it's a valid URL format
const cobaltUrl = `https://cobalt.tools/?url=${encodeURIComponent(videoUrl)}`;
chrome.tabs.create({ url: cobaltUrl });
} catch (error) {
alert('Please enter a valid URL.');
console.error('Invalid URL:', error);
}
} else {
alert('Please enter a video URL.');
}
});
} else {
if (!downloadButton) {
console.error('Button with ID "downloadButton" not found.');
}
if (!videoUrlInput) {
console.error('Input field with ID "videoUrl" not found.');
}
}
});