cobalt/sidepanel.js
google-labs-jules[bot] 42f2bbf6a6 feat: Create Chrome extension for Cobalt video downloader
This commit introduces a Chrome extension that provides a side panel interface to facilitate video downloads using Cobalt.

Key features:
- A side panel UI with an input field for video URLs and a download button.
- Redirects you to the Cobalt website (cobalt.tools) with the video URL for processing.
- Basic URL validation and error handling for your input.
- Includes necessary manifest.json, HTML, CSS, and JavaScript files.
- Placeholder icons are included.

The extension allows you to quickly send video URLs to Cobalt directly from your browser's side panel.
2025-06-11 20:11:49 +00:00

32 lines
1.1 KiB
JavaScript

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.');
}
}
});