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

[Improvement] Adding Context-Menu option for Generating Quiz #18

Open
wants to merge 1 commit 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
9 changes: 8 additions & 1 deletion extension/js/text_input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const textInput = document.getElementById("text-input");
chrome.storage.local.get(["key"]).then((result) => {
if(result.key)
{
textInput.value = result.key;
chrome.storage.local.set({ key: "" }).then(() => { console.log("Value is set"); });
}
});
document.addEventListener("DOMContentLoaded", function () {
const nextButton = document.getElementById("next-button");
const backButton = document.getElementById("back-button");
const textInput = document.getElementById("text-input");
const fileInput = document.getElementById("file-upload");
const loadingScreen = document.getElementById("loading-screen");

Expand Down
13 changes: 10 additions & 3 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "EduAid: AI Quiz Generator",
"version": "1.0",
"description": "Generate quizzes with AI-powered questions.",
"permissions": ["activeTab", "storage"],
"permissions": ["activeTab", "storage","contextMenus"],
"host_permissions":["http://127.0.0.1:8000/*"],
"icons": {
"16": "./assets/aossie_logo.png"
Expand All @@ -28,9 +28,16 @@
"./js/text_input.js",
".js/view_questions.js",
"./js/question_generation.js",
"./assets/aossie_logo.png"
"./assets/aossie_logo.png",
"./js/pdf-lib.js",
"/js/pdfjsLib.js",
"/js/pdfjsLib.worker.js",
"./js/download.js"
],
"matches": ["<all_urls>"]
}
]
],
"background": {
"service_worker": "service_worker.js"
}
}
15 changes: 15 additions & 0 deletions extension/service_worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function setupContextMenu() {
chrome.contextMenus.create({
id: 'quiz',
title: 'Generate the Quiz',
contexts: ['selection']
});
}
chrome.runtime.onInstalled.addListener(() => {
setupContextMenu();
});

chrome.contextMenus.onClicked.addListener((data) => {
chrome.storage.local.set({ key: data.selectionText }).then(() => { console.log("Value is set"); });
});