Add proxy switcher to the mix
This commit is contained in:
@@ -53,7 +53,6 @@ Object.keys(SearchEngines).forEach((k) => SearchEngineOptions.push(
|
||||
}
|
||||
|
||||
const transport = async (opts: Options) => {
|
||||
console.log('t');
|
||||
const transportEl = document.getElementById("dropdownBox-tSwitcher") as HTMLSelectElement;
|
||||
transportEl.value = opts.storageManager.getVal("transport") || "libcurl";
|
||||
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 () => {
|
||||
try {
|
||||
@@ -69,6 +74,7 @@ Object.keys(SearchEngines).forEach((k) => SearchEngineOptions.push(
|
||||
const sw = SW.getInstance().next().value!;
|
||||
const storageManager = new StoreManager<"radius||settings">("radius||settings");
|
||||
await transport({settings, sw, storageManager});
|
||||
await proxy({settings, sw, storageManager});
|
||||
} catch (err) { console.log(err) }
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -56,7 +56,7 @@ const randomSplash = genSplash();
|
||||
const settings = await Settings.getInstance();
|
||||
await sw.setTransport();
|
||||
iframe.classList.remove("hidden");
|
||||
iframe.src = sw.encodeURL(input.value, 'scram');
|
||||
iframe.src = sw.encodeURL(input.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-1
@@ -48,7 +48,8 @@ class SW {
|
||||
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");
|
||||
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');
|
||||
}
|
||||
|
||||
proxy(prox: 'uv' | 'sj') {}
|
||||
proxy(prox: 'uv' | 'sj') {
|
||||
this.#storageManager.setVal('proxy', prox);
|
||||
}
|
||||
|
||||
async *#init() {
|
||||
yield this.theme(this.#storageManager.getVal('theme') || 'default');
|
||||
|
||||
Reference in New Issue
Block a user