Add proxy switcher to the mix
This commit is contained in:
parent
5b808afae5
commit
4ea7ab5e11
4 changed files with 14 additions and 5 deletions
|
|
@ -53,7 +53,6 @@ Object.keys(SearchEngines).forEach((k) => SearchEngineOptions.push(
|
||||||
}
|
}
|
||||||
|
|
||||||
const transport = async (opts: Options) => {
|
const transport = async (opts: Options) => {
|
||||||
console.log('t');
|
|
||||||
const transportEl = document.getElementById("dropdownBox-tSwitcher") as HTMLSelectElement;
|
const transportEl = document.getElementById("dropdownBox-tSwitcher") as HTMLSelectElement;
|
||||||
transportEl.value = opts.storageManager.getVal("transport") || "libcurl";
|
transportEl.value = opts.storageManager.getVal("transport") || "libcurl";
|
||||||
transportEl.addEventListener("change", async () => {
|
transportEl.addEventListener("change", async () => {
|
||||||
|
|
@ -61,7 +60,13 @@ Object.keys(SearchEngines).forEach((k) => SearchEngineOptions.push(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxy = async (opts: Options) => {}
|
const proxy = async (opts: Options) => {
|
||||||
|
const proxyEl = document.getElementById("dropdownBox-pSwitcher") as HTMLSelectElement;
|
||||||
|
proxyEl.value = opts.storageManager.getVal("proxy") || "uv";
|
||||||
|
proxyEl.addEventListener("change", async () => {
|
||||||
|
opts.settings.proxy(proxyEl.value as "uv" | "sj");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener("astro:page-load", async () => {
|
document.addEventListener("astro:page-load", async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -69,6 +74,7 @@ Object.keys(SearchEngines).forEach((k) => SearchEngineOptions.push(
|
||||||
const sw = SW.getInstance().next().value!;
|
const sw = SW.getInstance().next().value!;
|
||||||
const storageManager = new StoreManager<"radius||settings">("radius||settings");
|
const storageManager = new StoreManager<"radius||settings">("radius||settings");
|
||||||
await transport({settings, sw, storageManager});
|
await transport({settings, sw, storageManager});
|
||||||
|
await proxy({settings, sw, storageManager});
|
||||||
} catch (err) { console.log(err) }
|
} catch (err) { console.log(err) }
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ const randomSplash = genSplash();
|
||||||
const settings = await Settings.getInstance();
|
const settings = await Settings.getInstance();
|
||||||
await sw.setTransport();
|
await sw.setTransport();
|
||||||
iframe.classList.remove("hidden");
|
iframe.classList.remove("hidden");
|
||||||
iframe.src = sw.encodeURL(input.value, 'scram');
|
iframe.src = sw.encodeURL(input.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ class SW {
|
||||||
return template.replace("%s", encodeURIComponent(input));
|
return template.replace("%s", encodeURIComponent(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeURL(string: string, proxy: 'uv' | 'sj'): string {
|
encodeURL(string: string): string {
|
||||||
|
const proxy = this.#storageManager.getVal("proxy") as 'uv' | 'sj';
|
||||||
const input = this.#search(string, "https://google.com/search?q=%s");
|
const input = this.#search(string, "https://google.com/search?q=%s");
|
||||||
return proxy === 'uv' ? `${__uv$config.prefix}${__uv$config.encodeUrl!(input)}` : this.#scramjetController!.encodeUrl(input)
|
return proxy === 'uv' ? `${__uv$config.prefix}${__uv$config.encodeUrl!(input)}` : this.#scramjetController!.encodeUrl(input)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,9 @@ class Settings {
|
||||||
: document.documentElement.className = theme || this.#storageManager.getVal('theme');
|
: document.documentElement.className = theme || this.#storageManager.getVal('theme');
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy(prox: 'uv' | 'sj') {}
|
proxy(prox: 'uv' | 'sj') {
|
||||||
|
this.#storageManager.setVal('proxy', prox);
|
||||||
|
}
|
||||||
|
|
||||||
async *#init() {
|
async *#init() {
|
||||||
yield this.theme(this.#storageManager.getVal('theme') || 'default');
|
yield this.theme(this.#storageManager.getVal('theme') || 'default');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue