diff --git a/extension/js/text_input.js b/extension/js/text_input.js index bf65bb9..77d0c84 100644 --- a/extension/js/text_input.js +++ b/extension/js/text_input.js @@ -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"); diff --git a/extension/manifest.json b/extension/manifest.json index dabae1a..8672f11 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -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" @@ -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": [""] } - ] + ], + "background": { + "service_worker": "service_worker.js" + } } diff --git a/extension/service_worker.js b/extension/service_worker.js new file mode 100644 index 0000000..54a2d23 --- /dev/null +++ b/extension/service_worker.js @@ -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"); }); + }); +