mirror of
https://github.com/Dasemu/X-GeoBlock.git
synced 2026-11-26 23:36:11 +00:00
feat: redesign controls and configure cloud cache
This commit is contained in:
1 parent
070e07845c
commit
e12164c312
15 files changed
+178
-78
No files matched your search
+5
-16
@@ -4,11 +4,11 @@ const form = document.querySelector("#settings");
|
||||
const enabled = document.querySelector("#enabled");
|
||||
const placeholder = document.querySelector("#placeholder");
|
||||
const debugMode = document.querySelector("#debug-mode");
|
||||
const skipFollowed = document.querySelector("#skip-followed");
|
||||
const status = document.querySelector("#status");
|
||||
const countryList = document.querySelector("#country-list");
|
||||
const countrySearch = document.querySelector("#country-search");
|
||||
const selectionCount = document.querySelector("#selection-count");
|
||||
const cloudEndpoint = document.querySelector("#cloud-endpoint");
|
||||
const cloudContribute = document.querySelector("#cloud-contribute");
|
||||
|
||||
renderCountries();
|
||||
@@ -19,7 +19,7 @@ async function load() {
|
||||
enabled.checked = value.enabled;
|
||||
placeholder.checked = value.showPlaceholder;
|
||||
debugMode.checked = value.debugMode === true;
|
||||
cloudEndpoint.value = value.cloudCacheEndpoint || "";
|
||||
skipFollowed.checked = value.skipFollowed !== false;
|
||||
cloudContribute.checked = value.contributeCloudCache === true;
|
||||
const selected = new Set(value.blacklist.map(XGeoConfig.normalizeCountry));
|
||||
countryList.querySelectorAll("input").forEach((input) => {
|
||||
@@ -70,25 +70,14 @@ document.querySelector("#clear-selection").addEventListener("click", () => {
|
||||
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const endpoint = XGeoCloud.normalizeEndpoint(cloudEndpoint.value);
|
||||
if (cloudEndpoint.value.trim() && !endpoint) {
|
||||
status.textContent = "Enter a valid HTTPS Worker URL.";
|
||||
return;
|
||||
}
|
||||
if (endpoint) {
|
||||
const granted = await extensionApi.permissions.request({ origins: [`${endpoint}/*`] });
|
||||
if (!granted) {
|
||||
status.textContent = "Host permission is required to use the cloud cache.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
await extensionApi.storage.sync.set({
|
||||
enabled: enabled.checked,
|
||||
blacklist: Array.from(countryList.querySelectorAll("input:checked"), (input) => input.value),
|
||||
showPlaceholder: placeholder.checked,
|
||||
debugMode: debugMode.checked,
|
||||
cloudCacheEndpoint: endpoint,
|
||||
contributeCloudCache: Boolean(endpoint) && cloudContribute.checked
|
||||
skipFollowed: skipFollowed.checked,
|
||||
cloudCacheEndpoint: XGeoConfig.CLOUD_CACHE_ENDPOINT,
|
||||
contributeCloudCache: cloudContribute.checked
|
||||
});
|
||||
status.textContent = "Settings saved.";
|
||||
setTimeout(() => status.textContent = "", 2000);
|
||||
|
||||
Reference in new issue
Block a user