diff --git a/main.js b/main.js index 0cc35d6..169b938 100644 --- a/main.js +++ b/main.js @@ -291,6 +291,11 @@ ipcMain.on("quit", () => { app.quit(); }); +ipcMain.handle('get-proxy', async (event, url) => { + const sess = event.sender.session; // get session from sender + const proxy = await sess.resolveProxy(url); + return proxy; +}); // Auto update let autoUpdate = false; diff --git a/src/renderer.js b/src/renderer.js index 8996061..65c4e18 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -89,6 +89,19 @@ function checkMaxDownloads() { } checkMaxDownloads(); +// Get system proxy +getSystemProxy("https://www.google.com").then(proxyInfo => { + if (proxyInfo != "DIRECT") { + try { + const proxyUrl = proxyInfo.split(" ")[1] + + proxy = proxyUrl + + console.log("System proxy: " + proxy) + } catch (_) {} + } +}) + // Check for auto updates let autoUpdate = true; const autoUpdateStatus = localStorage.getItem("autoUpdate"); @@ -345,6 +358,7 @@ async function getInfo(url) { proxy = getLocalStorageItem("proxy"); + // Whether to use browser cookies or not if (localStorage.getItem("browser")) { browser = localStorage.getItem("browser"); @@ -1408,6 +1422,11 @@ function afterSave(location, filename, progressId, thumbnail) { window.scrollTo(0, document.body.scrollHeight); } +async function getSystemProxy(url) { + const proxy = await ipcRenderer.invoke("get-proxy", url); + return proxy; +} + function showItem(location, filename) { shell.showItemInFolder(`${path.join(location, filename)}`); }