Download popup.js from rise112/ai_forms: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/rise112/ai_forms/resolve/main/popup.js
- Command line
-
hf download hf://rise112/ai_forms/popup.js
-
curl -L -o popup.js https://huggingface.co/rise112/ai_forms/resolve/main/popup.js
1.61 kB
| document.getElementById('findAnswers').addEventListener('click', async () => { | |
| const statusDiv = document.getElementById('status'); | |
| statusDiv.textContent = "Analyzing the page..."; | |
| try { | |
| // Get the active tab | |
| const [tab] = await chrome.tabs.query({active: true, currentWindow: true}); | |
| // Check if we're on a Microsoft Forms page | |
| if (!tab.url.includes("forms.office.com")) { | |
| statusDiv.textContent = "Error: Not a Microsoft Forms page. Please use this extension on a Microsoft Forms page."; | |
| return; | |
| } | |
| // Send message to content script | |
| chrome.tabs.sendMessage(tab.id, {action: "findAnswers"}, (response) => { | |
| if (chrome.runtime.lastError) { | |
| console.error(chrome.runtime.lastError); | |
| statusDiv.textContent = "Error: Could not connect to the page. Try refreshing the page and trying again."; | |
| return; | |
| } | |
| if (response && response.success) { | |
| if (response.questions.length > 0) { | |
| statusDiv.textContent = `Found ${response.questions.length} questions. Searching for answers...`; | |
| } else { | |
| statusDiv.textContent = "Could not find any questions on this page. This might not be a standard Microsoft Form, or the form structure is not recognized."; | |
| } | |
| } else { | |
| statusDiv.textContent = "Failed to find questions on this page."; | |
| } | |
| }); | |
| } catch (error) { | |
| console.error(error); | |
| statusDiv.textContent = "Error: " + error.message; | |
| } | |
| }); |