Skip to content

Commit

Permalink
feat: proxy url support
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Oct 17, 2024
1 parent a419d98 commit cbf6e02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Config {
pub unread_badge: Option<bool>,
pub client_plugins: Option<bool>,
pub tray_icon_enabled: Option<bool>,
pub proxy_uri: Option<String>,

pub keybinds: Option<HashMap<String, Vec<KeyStruct>>>,
pub keybinds_enabled: Option<bool>,
Expand Down Expand Up @@ -75,6 +76,7 @@ impl Config {
unread_badge: Option::from(true),
client_plugins: Option::from(true),
tray_icon_enabled: Option::from(true),
proxy_uri: Option::from("".to_string()),

keybinds: Option::from(HashMap::new()),
keybinds_enabled: Option::from(true),
Expand Down
15 changes: 11 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)]

use std::{env, time::Duration};
use tauri::{Manager, WebviewWindowBuilder};
use tauri::{Manager, Url, WebviewWindowBuilder};
use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt};

use config::{get_config, set_config, Config};
Expand Down Expand Up @@ -225,9 +225,11 @@ fn main() {
plugin::get_new_plugins();

let config = get_config();
let proxy_uri = config.proxy_uri.unwrap_or("".to_string());
let proxy_uri = Url::parse(&proxy_uri);
let preinject = PREINJECT.clone();
let title = format!("Dorion - v{}", app.package_info().version);
let win = WebviewWindowBuilder::new(app, "main", url_ext)
let mut win = WebviewWindowBuilder::new(app, "main", url_ext)
.title(title.as_str())
// Preinject is bundled with "use strict" so we put it in it's own function to prevent potential client mod issues
.initialization_script(format!("(() => {{ {preinject} }})();{client_mods}").as_str())
Expand All @@ -243,8 +245,13 @@ fn main() {
config.blur.unwrap_or("none".to_string()) != "none"
)
.zoom_hotkeys_enabled(true)
.browser_extensions_enabled(true)
.build()?;
.browser_extensions_enabled(true);

if let Ok(proxy_uri) = proxy_uri {
win = win.proxy_url(proxy_uri);
}

let win = win.build()?;

// Set the user agent to one that enables all normal Discord features
set_user_agent(&win);
Expand Down

0 comments on commit cbf6e02

Please sign in to comment.