diff --git a/src/alu.d.ts b/src/alu.d.ts index 41100c8..be7b4be 100644 --- a/src/alu.d.ts +++ b/src/alu.d.ts @@ -1,6 +1,7 @@ export declare global { namespace Alu { let store: AluStore; + let loadedContentStorage: Record; type DefaultKeys = { [key: string]: AluKey; diff --git a/src/components/SettingsContent/ProxyTab.astro b/src/components/SettingsContent/ProxyTab.astro index bc325bb..3ee2bd2 100644 --- a/src/components/SettingsContent/ProxyTab.astro +++ b/src/components/SettingsContent/ProxyTab.astro @@ -13,8 +13,11 @@ const proxyList = [ const searchEngineList = [ { name: "Google", value: "https://google.com/search?q=" }, + { name: "DuckDuckGo", value: "https://duckduckgo.com/?q=" }, { name: "Bing", value: "https://bing.com/search?q=" }, { name: "Brave", value: "https://search.brave.com/search?q=" }, + // Ecosia for some reason doesn't work with the proxy, hopefully I'll be able to add it eventually. + // { name: "Ecosia", value: "https://ecosia.org/search?q=" }, { name: "Searx", value: "https://searxng.site/?q=" }, ]; @@ -38,19 +41,19 @@ const wispURLList = [
- +
- +
- +
- +
@@ -58,11 +61,11 @@ const wispURLList = [
- +
- +
diff --git a/src/components/ts/Alu.ts b/src/components/ts/Alu.ts new file mode 100644 index 0000000..58ddabf --- /dev/null +++ b/src/components/ts/Alu.ts @@ -0,0 +1,11 @@ +import AluStore from "./AluStore"; + +function instantiateAlu() { + if (globalThis.Alu) return; + globalThis.Alu = { + store: new AluStore(), + loadedContentStorage: {}, + }; +} + +export default instantiateAlu; \ No newline at end of file diff --git a/src/components/ts/AluStore.ts b/src/components/ts/AluStore.ts index c2b4b9c..2059aa1 100644 --- a/src/components/ts/AluStore.ts +++ b/src/components/ts/AluStore.ts @@ -63,6 +63,4 @@ class AluStore { } } -globalThis.Alu = { - store: new AluStore(), -}; +export default AluStore; diff --git a/src/components/ts/settings.ts b/src/components/ts/settings.ts index 78dc3ff..c29a038 100644 --- a/src/components/ts/settings.ts +++ b/src/components/ts/settings.ts @@ -82,6 +82,11 @@ function getLocalStorageValue(localStorageItem: Alu.ValidStoreKeys, dropdownID: // I was kinda dumb for not doing this earlier. const dropdown = document.getElementById(dropdownID); const dropdownMenu = document.getElementById(dropdownID + "-menu") as HTMLElement; + // Janky hack :D + if (dropdownID == "dropdown__search-engine") { + console.log(localStorageItem, dropdownID) + return Alu.store.get(localStorageItem).name; + } if (dropdown && dropdownMenu) { // Now we find the child that matches localStorageItem.value. @@ -90,17 +95,20 @@ function getLocalStorageValue(localStorageItem: Alu.ValidStoreKeys, dropdownID: return Alu.store.get(localStorageItem).value == itemEl.dataset.setting; }) as HTMLElement; // Now set the inner text to the name in the dropdownItem. - return dropdownItem.innerText; + if (dropdownItem) { + return dropdownItem.innerText; + } else { + console.error("Dropdown item not found! " + dropdownID); + } + } } function applySavedLocalStorage(localStorageItem: Alu.ValidStoreKeys, dropdownID: string) { - if (Alu.store.get(localStorageItem)) { - const dropdown_toggle = document.getElementById(dropdownID) as HTMLElement; - if (dropdown_toggle) { + const dropdown_toggle = document.getElementById(dropdownID) as HTMLElement; + if (dropdown_toggle && Alu.store.get(localStorageItem)) { dropdown_toggle.innerText = getLocalStorageValue(localStorageItem, dropdownID)!; } - } } function applyDropdownEventListeners(dropdown: HTMLElement, optionalCallback?: () => void) { @@ -129,6 +137,12 @@ function applyInputListeners(input: HTMLInputElement, localStorageItem: Alu.Vali }); } +function searxngURLInputListener(input: HTMLInputElement) { + input.addEventListener("input", () => { + Alu.store.set("search", { name: "Searx", value: input.value + "?q=" }); + }); +} + function addThemeToDropdown(extension: ExtensionMetadata) { const dropdown = document.getElementById("dropdown__selected-theme-menu"); if (dropdown) { @@ -174,7 +188,7 @@ function setupProxySettings() { applyDropdownEventListeners(searchEngineDropdown!, checkSearxng); checkSearxng(); - applyInputListeners(searxngUrlInput, "search"); + searxngURLInputListener(searxngUrlInput); applyInputListeners(bareURLInput, "bareUrl"); } @@ -261,7 +275,6 @@ function setupCloakingSettings() { icon: cloakIcon, isCustom: true, }; - // @ts-expect-error - Need to make cloak typing more standardized. Alu.store.set("cloak", cloakItem); if (cloakName == "None") { Alu.store.remove("cloak"); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 149e525..7c57959 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -57,7 +57,11 @@ const { title, optionalPreloads } = Astro.props; gtag("config", "G-P1JX4G9KSF");