Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
Update 1.3.0 (Fix Ui bug add reset setting warp)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwldom committed Sep 11, 2024
1 parent 0c3eabc commit a76dde0
Show file tree
Hide file tree
Showing 59 changed files with 196 additions and 379 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
webui
tmp
out
dist
.vscode
Expand All @@ -14,4 +16,5 @@ current-config.json
reg.php
Users.txt
configsVibeLink.json
configsVibeName.json
configsVibeName.json
one.one
2 changes: 2 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Start Code
// #region Libraries
const ipc = require('electron').ipcRenderer;
const axios = require('axios');
Expand Down Expand Up @@ -261,3 +262,4 @@ setInterval(() => {
}, 10000);
testProxy();
trackEvent("start-browser");
// End Code
42 changes: 21 additions & 21 deletions connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ const offProxy = async (proxy) => {
if (err) console.log('Error setting ProxyEnable:', err);
});
};
function Onloading() {
try {
// Restore var settingWarp from json
settingWarp = JSON.parse(read_file("warp.json"));
}
catch {
saveSetting()
}
try {
settingVibe = JSON.parse(read_file("vibe.json")); // Load Setting From File.json
configsVibeName = JSON.parse(read_file("configsVibeName.json")); // Load Setting From File.json
configsVibeLink = JSON.parse(read_file("configsVibeLink.json")); // Load Setting From File.json
}
catch {
saveSetting();
}
if (settingVibe["config"] == "") {
settingVibe["config"] = "auto";
}
}
// #endregion
// #region Connection
function ConnectedVibe(stat = "normal") {
Expand Down Expand Up @@ -348,7 +368,7 @@ async function connectVibe(num = number) {
}
else {
var configs = [settingVibe["config"]];
if (settingVibe["config"].startsWith("vless") || settingVibe["config"].startsWith("vmess") || settingVibe["config"].startsWith("trojan") || settingVibe["config"].startsWith("shadowsocks") ) {
if (settingVibe["config"].startsWith("vless") || settingVibe["config"].startsWith("vmess") || settingVibe["config"].startsWith("trojan") || settingVibe["config"].startsWith("shadowsocks")) {
write_file(path.join(__dirname, "config", "config.txt"), btoa(unescape(encodeURIComponent(settingVibe["config"]))));
configs = [path.join(__dirname, "config", "config.txt")];
}
Expand Down Expand Up @@ -606,26 +626,6 @@ var links = {
}
}
//#endregion
function Onloading() {
try {
// Restore var settingWarp from json
settingWarp = JSON.parse(read_file("warp.json"));
}
catch {
saveSetting()
}
try {
settingVibe = JSON.parse(read_file("vibe.json")); // Load Setting From File.json
configsVibeName = JSON.parse(read_file("configsVibeName.json")); // Load Setting From File.json
configsVibeLink = JSON.parse(read_file("configsVibeLink.json")); // Load Setting From File.json
}
catch {
saveSetting();
}
if (settingVibe["config"] == "") {
settingVibe["config"] = "auto";
}
}
Onloading();
module.exports = {
connectVibe,
Expand Down
21 changes: 12 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ <h2 id="Status" title="false"></h2>
</button>
<button id="about"><i class='bx bxs-info-circle'></i></button>
</nav>
<b style="margin-top: 2vh;">IP Version</b>
<div id="ip-version">
<select name="" id="selector-ip-version">
<option value="IPV4">IP Version 4</option>
<option value="IPV6">IP Version 6</option>
</select>
</div>
<b>Config Freedom Guard for auto mode</b>
<div id="config-fg" class="form-control-c">
<input type="text" class="input input-alt" placeholder="https://links.json" id="config-fg-text"
Expand Down Expand Up @@ -122,11 +115,18 @@ <h2 id="Status" title="false"></h2>
<option value="IRANCELL">Irancell</option>
</select>
</div>
<b style="margin-top: 0.5vh;border-top: 2px solid white;padding-top: 2vh;">IP Version</b>
<div id="ip-version">
<select name="" id="selector-ip-version">
<option value="IPV4">IP Version 4</option>
<option value="IPV6">IP Version 6</option>
</select>
</div>
<b>Endpoint</b>
<div id="end-point" class="form-control-c">
<input placeholder="IP : 192.x.x.x" class="input input-alt" type="text" id="end-point-address">
<button class="btn btn-primary" id="find-best-endpoint">Find Best</button>
<span class="input-border input-border-alt"></span>
<button class="btn btn-primary" id="find-best-endpoint">Find Best Endpoint</button>
</div>
<b>Bind Address</b>
<div id="bind-address" class="form-control-c">
Expand Down Expand Up @@ -184,6 +184,9 @@ <h2 id="Status" title="false"></h2>
<span class="slider"></span>
</label>
</div>
<div id="reset-setting-warp">
<button id="reset-setting-warp-btn" class="btn">Reset setting Warp</button>
</div>
</div>
<div id="menu">
<div id="menu-dns">Set DNS</div>
Expand Down Expand Up @@ -288,7 +291,7 @@ <h2 id="Status" title="false"></h2>
<p> Freedom Guard 1.3.0 (Mahsa Version)</p>
<p> Developed By Fwldom 👩‍💻</p>
<p>👇 Acknowledgements 👇</p>
<p> <a href="https://github.com/hiddify/hiddify-core/">hiddify-core 2.1.5</a> from Hiddify</p>
<p> <a href="https://github.com/hiddify/hiddify-core/">hiddify-core 2.3.0</a> from Hiddify</p>
<p> <a href="https://github.com/bepass-org/warp-plus">warp-plus 1.2.4</a> from bepass-org</p>
<p> <a href="https://github.com/fwldom/Freedom-Guard">Freedom Browser 1.3</a> from fwldom</p>
<p> <a href="https://github.com/Ptechgithub/warp">Scanner Endpoint 1.2</a> from Ptechgithub</p>
Expand Down
142 changes: 81 additions & 61 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

// Start Code
// #region Libraries
;
const { app, BrowserWindow, ipcMain, Tray, Menu, nativeImage } = require('electron');
const { net, protocol, session, BrowserView } = require('electron')
const { dialog } = require('electron');
Expand All @@ -8,11 +12,17 @@ const { eventNames } = require('process');
const ipc = require('electron').ipcMain;
const { initialize } = require('@aptabase/electron/main');
const { setInterval } = require('timers/promises');

;
// #endregion
// #region Vars
initialize("A-EU-");
var currentURL = "";
var mainWindow = null
var ViewBrowser = null;
var pageTitle = "";
const gotTheLock = app.requestSingleInstanceLock()
// #endregion
// #region functions
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
Expand All @@ -35,12 +45,6 @@ function createWindow() {
catch { };
});
};
setInterval(() => {
try {
ViewBrowser.setBounds({ x: 0, y: mainWindow.getBounds().height / 6, width: mainWindow.getBounds().width / 1.3, height: mainWindow.getBounds().height / 1.3 });
}
catch { };
}, 5000)
function CreateViewBrowser(url) {
ViewBrowser = new BrowserView();
mainWindow.setBrowserView(ViewBrowser);
Expand All @@ -50,46 +54,16 @@ function CreateViewBrowser(url) {
setTimeout(() => {
mainWindow.setSize(800, 600);
}, 1000);
}
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('freedom-guard', process.execPath, [path.resolve(process.argv[1])])
}
} else {
app.setAsDefaultProtocolClient('freedom-guard')
};
ipc.on("load-main-app", (event) => {
mainWindow.loadFile("index.html");
mainWindow.removeBrowserView(ViewBrowser);
});
ipc.on('hide-browser', (event, url) => {
mainWindow.removeBrowserView(ViewBrowser);
});
ipc.on('show-browser', (event, url) => {
mainWindow.setBrowserView(ViewBrowser);
});
var pageTitle = "";
ipc.on('load-browser', (event) => {
CreateViewBrowser("https://fwldom.github.io/freedom-site-browser/index.html");
mainWindow.loadFile("browser.html");
ViewBrowser.webContents.on("did-finish-load", (event) => {
currentURL = ViewBrowser.webContents.getURL();
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-url', (currentURL));
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-title', (pageTitle));
});
ViewBrowser.webContents.on("did-navigate", (event, url) => {
currentURL = ViewBrowser.webContents.getURL();
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-url', (url));
});
mainWindow.maximize();
ViewBrowser.setBounds({ x: 10, y: mainWindow.getBounds().height / 6, width: mainWindow.getBounds().width, height: mainWindow.getBounds().height / 1.3 });
});
ipc.on('load-url-browser', (event, url) => {
ViewBrowser.webContents.loadURL(url);
});

// #endregion
// #region Interval
setInterval(() => { // Resize View Browser
try {
ViewBrowser.setBounds({ x: 0, y: mainWindow.getBounds().height / 6, width: mainWindow.getBounds().width / 1.3, height: mainWindow.getBounds().height / 1.3 });
}
catch { };
}, 5000)
setInterval(() => {
try {
if (currentURL != ViewBrowser.webContents.getURL()) {
Expand All @@ -101,8 +75,15 @@ setInterval(() => {
}
catch { };
}, 5000);
const gotTheLock = app.requestSingleInstanceLock()

// #endregion
// #region Startup
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('freedom-guard', process.execPath, [path.resolve(process.argv[1])])
}
} else {
app.setAsDefaultProtocolClient('freedom-guard')
};
if (!gotTheLock) {
app.quit()
} else {
Expand Down Expand Up @@ -211,13 +192,9 @@ app.whenReady().then(() => {
tray.setTitle('VPN (Warp, Vibe , Psiphon)')
})
app.on('ready', createWindow);

app.on('before-quit', () => {
exec("taskkill /IM " + "HiddifyCli.exe" + " /F");
exec('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /F');
exec("taskkill /IM " + "warp-plus.exe" + " /F");
if (process.platform !== 'darwin') {
app.quit();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
app.setUserTasks([
Expand All @@ -229,12 +206,53 @@ app.setUserTasks([
title: 'New Window',
description: 'Create a new window'
}
])
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
]);
// #endregion
// #region IPC
ipc.on("load-main-app", (event) => {
mainWindow.loadFile("index.html");
mainWindow.removeBrowserView(ViewBrowser);
});
ipc.on('hide-browser', (event, url) => {
mainWindow.removeBrowserView(ViewBrowser);
});
ipc.on('show-browser', (event, url) => {
mainWindow.setBrowserView(ViewBrowser);
});
ipc.on('load-browser', (event) => {
CreateViewBrowser("https://fwldom.github.io/freedom-site-browser/index.html");
mainWindow.loadFile("browser.html");
ViewBrowser.webContents.on("did-finish-load", (event) => {
currentURL = ViewBrowser.webContents.getURL();
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-url', (currentURL));
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-title', (pageTitle));
});
ViewBrowser.webContents.on("did-navigate", (event, url) => {
currentURL = ViewBrowser.webContents.getURL();
pageTitle = ViewBrowser.webContents.getTitle();
mainWindow.webContents.send('set-url', (url));
});
mainWindow.maximize();
ViewBrowser.setBounds({ x: 10, y: mainWindow.getBounds().height / 6, width: mainWindow.getBounds().width, height: mainWindow.getBounds().height / 1.3 });
});
ipc.on('load-url-browser', (event, url) => {
ViewBrowser.webContents.loadURL(url);
});
// #endregion
// #region Quit
app.on('before-quit', () => {
exec("taskkill /IM " + "HiddifyCli.exe" + " /F");
exec('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /F');
exec("taskkill /IM " + "warp-plus.exe" + " /F");
if (process.platform !== 'darwin') {
app.quit();
}
});
// #endregion Quit
// #region other
// Handle Write JSON file
ipcMain.handle('write-json', async (event, filePath, data) => {
return new Promise((resolve, reject) => {
fs.writeFile(filePath, JSON.stringify(data, null, 2), (err) => {
Expand All @@ -244,12 +262,14 @@ ipcMain.handle('write-json', async (event, filePath, data) => {
});
});

// Handle read JSON file
// Handle Read JSON file
ipcMain.handle('read-json', async (event, filePath) => {
return new Promise((resolve, reject) => {
fs.readFile(filePath, 'utf-8', (err, data) => {
if (err) reject(err);
else resolve(JSON.parse(data));
});
});
});
});
// #endregion
// End Code
32 changes: 30 additions & 2 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// start code
// Start code
// #region Libraries
;
const { open } = require("fs");
Expand Down Expand Up @@ -96,6 +96,34 @@ document.addEventListener("DOMContentLoaded", () => {
SetServiceWarp("configfg", document.getElementById("config-fg-text").value);
settingWarp["core"] = "auto";
};
document.getElementById("reset-setting-warp-btn").onclick = () => {
console.log("Reseting setting Warp ....")
settingWarp = {
proxy: "127.0.0.1:8086",
gool: false,
scan: false,
endpoint: "",
cfon: false,
cfonc: "IR",
ipver: 4,
warpver: "",
warpkey: "",
scanrtt: "",
verbose: false,
cache: "",
wgconf: "",
config: "",
reserved: "",
dns: "",
tun: false,
startup: "warp",
isp: "other",
core: "auto",
"configfg": "https://raw.githubusercontent.com/fwldom/Freedom-Guard/main/config/links.json"
};
saveSetting();
SetSettingWarp();
};
});
// #endregion
// #region For Connections Warp
Expand Down Expand Up @@ -644,4 +672,4 @@ setInterval(() => {
saveSetting();
}, 7500);
//#endregion
// end code
// End code
Loading

0 comments on commit a76dde0

Please sign in to comment.