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

Appending question set file name to the message #3

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
1 change: 1 addition & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ loadButton.addEventListener("click", async () => {
fileReader.onload = async function (fileLoadedEvent) {
var textFromFileLoaded = fileToArray(fileLoadedEvent.target.result);
chrome.storage.local.set({ questions: textFromFileLoaded });
chrome.storage.local.set({ fileName });
//console.log(textFromFileLoaded);
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
chrome.scripting.executeScript({
Expand Down
31 changes: 18 additions & 13 deletions showQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ var converter = new showdown.Converter();
async function showInstructions() {
var elements = document.getElementsByTagName("div");
var noteText = "Upload the questions before you hit start";
chrome.storage.local.get("questions", ({questions}) => {
if (questions && questions.length>2) {
noteText = "There is already a loaded set of questions in the browser cache. Re-upload if you want to be sure, and click start."
}
for (item of elements) {
try {
if (item.className === "cell w99 h10") {
item.id = "42";
const instructionsElement = getInstructionsElement(noteText);
item.append(instructionsElement);
}
} catch (e) {}
const {questions} = await chrome.storage.local.get("questions");
if (questions && questions.length > 2) {
const {fileName} = await chrome.storage.local.get("fileName");
noteText = "There is already a loaded set of questions in the browser cache. ";
if (fileName !== "") {
noteText += `Question set name: "${fileName}". `;
}
});
noteText += "Re-upload if you want to be sure, and click start.";
}
for (item of elements) {
try {
if (item.className === "cell w99 h10") {
item.id = "42";
const instructionsElement = getInstructionsElement(noteText);
item.append(instructionsElement);
}
} catch (e) {}
}
}


/* ----------------------------------------- */
//showQuestion must be called each time a button is clicked
async function updateButtons() {
Expand Down