mirror of
https://github.com/benbusby/whoogle-search.git
synced 2026-05-24 00:22:32 -04:00
Added option to search only via GET request (#36)
This addresses #18, which brought up the issue of searching with Whoogle with the search instance set to always use a specific container in Firefox Container Tabs. Could also be useful if you want to share your search results or something, I guess. Though nobody likes when people do that.
This commit is contained in:
+14
-11
@@ -13,9 +13,16 @@ const setupSearchLayout = () => {
|
||||
searchBtn.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fillConfigValues = () => {
|
||||
// Establish all config value elements
|
||||
const near = document.getElementById("config-near");
|
||||
const noJS = document.getElementById("config-nojs");
|
||||
const dark = document.getElementById("config-dark");
|
||||
const url = document.getElementById("config-url");
|
||||
const getOnly = document.getElementById("config-get-only");
|
||||
|
||||
const fillConfigValues = (near, nojs, dark, url) => {
|
||||
// Request existing config info
|
||||
let xhrGET = new XMLHttpRequest();
|
||||
xhrGET.open("GET", "/config");
|
||||
@@ -29,15 +36,16 @@ const fillConfigValues = (near, nojs, dark, url) => {
|
||||
let configSettings = JSON.parse(xhrGET.responseText);
|
||||
|
||||
near.value = configSettings["near"] ? configSettings["near"] : "";
|
||||
nojs.checked = !!configSettings["nojs"];
|
||||
noJS.checked = !!configSettings["nojs"];
|
||||
dark.checked = !!configSettings["dark"];
|
||||
getOnly.checked = !!configSettings["get_only"];
|
||||
|
||||
// Addresses the issue of incorrect URL being used behind reverse proxy
|
||||
url.value = configSettings["url"] ? configSettings["url"] : "";
|
||||
};
|
||||
|
||||
xhrGET.send();
|
||||
}
|
||||
};
|
||||
|
||||
const setupConfigLayout = () => {
|
||||
// Setup whoogle config
|
||||
@@ -54,13 +62,8 @@ const setupConfigLayout = () => {
|
||||
content.classList.toggle("open");
|
||||
});
|
||||
|
||||
const near = document.getElementById("config-near");
|
||||
const noJS = document.getElementById("config-nojs");
|
||||
const dark = document.getElementById("config-dark");
|
||||
const url = document.getElementById("config-url");
|
||||
|
||||
fillConfigValues(near, noJS, dark, url);
|
||||
}
|
||||
fillConfigValues();
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
setTimeout(function() {
|
||||
|
||||
Reference in New Issue
Block a user