Skip to content
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
1 change: 1 addition & 0 deletions Domains/AI-ML/MiniProjects/Yt_chatbot_extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
Empty file.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"manifest_version": 3,
"name": "YouTube AI Q&A",
"version": "1.0",
"description": "Ask questions about YouTube videos using AI",
"permissions": ["tabs"],
"action": {
"default_popup": "popup.html",
"default_icon": "icon.png"
},
"host_permissions": ["<all_urls>"]
}
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>YouTube AI Q&A</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="container">
<h1 class="title">🎥 YouTube AI Q&A</h1>
<input type="text" id="question" placeholder="Ask about the video..." />
<button id="askBtn">Ask</button>
<div id="loading">
<img src="spinner.svg" alt="Loading..." />
</div>
<div id="answer"></div>
</div>
<script src="popup.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions Domains/AI-ML/MiniProjects/Yt_chatbot_extension/extension/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
document.getElementById("askBtn").addEventListener("click", async () => {
const question = document.getElementById("question").value.trim();
const answerBox = document.getElementById("answer");
const loadingEl = document.getElementById("loading");

answerBox.textContent = "";
loadingEl.style.display = "block";

const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const urlParams = new URLSearchParams(new URL(tab.url).search);
const videoId = urlParams.get("v");

if (!videoId) {
loadingEl.style.display = "none";
answerBox.textContent = "Not a valid YouTube video.";
return;
}

try {
const response = await fetch("http://localhost:8000/ask", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ video_id: videoId, question })
});

const data = await response.json();
answerBox.textContent = response.ok ? data.answer : "Error: " + data.detail;
} catch (err) {
answerBox.textContent = "Failed to connect to backend.";
}

loadingEl.style.display = "none";
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
:root {
--bg: #f9f9f9;
--text: #1f1f1f;
--card: #ffffff;
--border: #ddd;
--primary: #007bff;
}

@media (prefers-color-scheme: dark) {
:root {
--bg: #121212;
--text: #f0f0f0;
--card: #1e1e1e;
--border: #444;
--primary: #4e9eff;
}
}

body {
margin: 0;
background-color: var(--bg);
color: var(--text);
font-family: 'Segoe UI', sans-serif;
width: 320px;
}

.container {
padding: 16px;
}

.title {
font-size: 18px;
margin-bottom: 10px;
}

input {
width: 100%;
padding: 10px;
margin-bottom: 8px;
border-radius: 5px;
border: 1px solid var(--border);
background-color: var(--card);
color: var(--text);
}

button {
width: 100%;
padding: 10px;
background-color: var(--primary);
color: white;
font-weight: bold;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#loading {
text-align: center;
display: none;
margin-top: 10px;
}

#loading img {
width: 24px;
height: 24px;
}

#answer {
margin-top: 12px;
background-color: var(--card);
border: 1px solid var(--border);
border-radius: 6px;
padding: 10px;
font-size: 14px;
white-space: pre-wrap;
min-height: 40px;
}
Loading
Loading