diff --git a/src/SEQTA.js b/src/SEQTA.js index c6d4b19..f29f0cf 100644 --- a/src/SEQTA.js +++ b/src/SEQTA.js @@ -27,9 +27,7 @@ async function finishLoad() { } function SetDefaultValues() { - browser.storage.local.set({ - onoff: true, - }); + chrome.storage.local.set({ onoff: true }); } function waitForElm(selector) { @@ -67,8 +65,9 @@ function RunFunctionOnTrue(storedSetting) { if (storedSetting.onoff == undefined) { // Set the value to true, and rerun the function SetDefaultValues(); - var gettingStoredSettings = browser.storage.local.get(); - gettingStoredSettings.then(RunFunctionOnTrue, SetDefaultValues); + chrome.storage.local.get(null, function (items) { + RunFunctionOnTrue(items); + }); } // If the option is 'on', open BetterSEQTA if (storedSetting.onoff) { @@ -184,8 +183,9 @@ document.addEventListener( if (document.childNodes[1].textContent.includes("SEQTA") && !IsSEQTAPage) { IsSEQTAPage = true; console.log("seqta page"); - var gettingStoredSettings = browser.storage.local.get(); - gettingStoredSettings.then(RunFunctionOnTrue, SetDefaultValues); + chrome.storage.local.get(null, function (items) { + RunFunctionOnTrue(items); + }); } }, true diff --git a/src/inject/injected.js b/src/inject/injected.js index b745369..f7c5f9c 100644 --- a/src/inject/injected.js +++ b/src/inject/injected.js @@ -107,7 +107,9 @@ function CheckCurrentLesson(lesson, num) { } else { // Removes the activelesson class to ensure only the active lesson have the class var elementA = document.getElementById("lesson" + num); - elementA.classList.remove("activelesson"); + if (elementA != null) { + elementA.classList.remove("activelesson"); + } } } diff --git a/src/popup/info.js b/src/popup/info.js index f42e1ea..2eaf09f 100644 --- a/src/popup/info.js +++ b/src/popup/info.js @@ -15,10 +15,10 @@ function FindSEQTATab() { Store the currently selected settings using chrome.storage.local. */ function storeSettings() { - browser.storage.local.set({ - onoff: onoffselection.checked, + chrome.storage.local.set({ onoff: onoffselection.checked }, function () { + console.log("set the value"); + FindSEQTATab(); }); - FindSEQTATab(); } /* Update the options UI with the settings values retrieved from storage, @@ -38,8 +38,11 @@ function onError(e) { /* On opening the options page, fetch stored settings and update the UI with them. */ -const gettingStoredSettings = browser.storage.local.get(); -gettingStoredSettings.then(updateUI, onError); +chrome.storage.local.get(["onoff"], function (result) { + updateUI(result); +}); +// const gettingStoredSettings = browser.storage.local.get(); +// gettingStoredSettings.then(updateUI, onError); /* On blur, save the currently selected settings.