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.1 (Add Freedom Plus Downloader and Runner)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwldom committed Sep 16, 2024
1 parent 6613134 commit d7feefb
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Users.txt
configsVibeLink.json
configsVibeName.json
one.one
plus/apps
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ <h2 id="Status" title="false"></h2>
<!-- #region Other All -->
<div id="about-app">
<button id="close-about"><i class='bx bx-exit-fullscreen'></i></button>
<p> Freedom Guard 1.3.0 (Mahsa Version)</p>
<p> Freedom Guard 1.3.1 (Hananeh Version)</p>
<p> Developed By Fwldom 👩‍💻</p>
<p>👇 Acknowledgements 👇</p>
<p> <a href="https://github.com/hiddify/hiddify-core/">hiddify-core 2.3.0</a> from Hiddify</p>
Expand Down
7 changes: 5 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,11 @@ ipc.on('load-browser', (event) => {
ipc.on('load-url-browser', (event, url) => {
ViewBrowser.webContents.loadURL(url);
});
ipc.on('load-file',(event,Pathfile) => {
mainWindow.loadFile(path.join(__dirname,Pathfile));
ipc.on('load-file', (event, Pathfile) => {
mainWindow.loadFile(path.join(__dirname, Pathfile));
});
ipc.on('load-file-plus', (event, Pathfile) => {
mainWindow.loadFile(path.join(Pathfile));
});
// #endregion
// #region Quit
Expand Down
28 changes: 28 additions & 0 deletions plus/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Freedom Plus</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<button id="back">Back To Warp</button>
<div class="container">
<h1>لیست برنامه‌ها</h1>
<input type="text" id="search" dir="rtl" placeholder="برنامه را جستجو کنید...">
<div id="apps-list"></div>
</div>
<div id="download-dialog" class="dialog" dir="rtl">
<div class="dialog-content">
<h2>دانلود فایل‌ها</h2>
<progress id="download-progress" value="0" max="100"></progress>
<p id="download-status">در حال دانلود...</p>
</div>
</div>
</body>
<script src="script.js"></script>

</html>
19 changes: 19 additions & 0 deletions plus/listapps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Calculator": {
"name": "Calculator",
"icon": "https://raw.githubusercontent.com/fwldom/Calculator_Web.github.io/main/icon.png",
"directory":"./apps/Calculator",
"type": "app",
"description": "A simple calculator app",
"version": "1.0.0",
"author": "Fwldom",
"website": "https://github.com/Fwldom/Calculator",
"license": "MIT",
"download":{
"index.js":"https://raw.githubusercontent.com/fwldom/Calculator_Web.github.io/main/index.js",
"index.html":"https://raw.githubusercontent.com/fwldom/Calculator_Web.github.io/main/index.html",
"style.css":"https://raw.githubusercontent.com/fwldom/Calculator_Web.github.io/main/style.css",
"icon.png":"https://raw.githubusercontent.com/fwldom/Calculator_Web.github.io/main/icon.png"
}
}
}
145 changes: 145 additions & 0 deletions plus/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
const fs = require('fs');
const axios = require('axios');
const path = require('path');
const ipc = require('electron').ipcRenderer;
__dirname = path.join(__dirname.replace("app.asar"));

fetch('listapps.json')
.then(response => response.json())
.then(data => {
const appsList = document.getElementById('apps-list');
const searchInput = document.getElementById('search');

function displayApps(filteredApps) {
appsList.innerHTML = '';
for (let key in filteredApps) {
const app = filteredApps[key];

const appCard = document.createElement('div');
appCard.classList.add('app-card');

appCard.innerHTML = `
<img src="${app.icon}" alt="${app.name} Icon">
<h2>${app.name}</h2>
<p>${app.description}</p>
`;
appCard.addEventListener('click', () => {
runApp(app);
});

appsList.appendChild(appCard);
}
}
displayApps(data);
searchInput.addEventListener('input', (e) => {
const searchTerm = e.target.value.toLowerCase();
const filteredApps = Object.keys(data)
.filter(key => data[key].name.toLowerCase().includes(searchTerm))
.reduce((res, key) => (res[key] = data[key], res), {});
displayApps(filteredApps);
});
function runApp(app) {
if (!fs.existsSync(path.join(__dirname, app.directory))) {
fs.mkdirSync(path.join(__dirname, app.directory));
};
if (!fs.existsSync(path.join(__dirname, './apps'))) {
fs.mkdirSync(path.join(__dirname, "./apps"));
};
downloadFiles([
{ "url": app["download"]["index.html"], "savePath": path.join(__dirname, app.directory, "index.html") },
{ "url": app["download"]["style.css"], "savePath": path.join(__dirname, app.directory, "style.css") },
{ "url": app["download"]["icon.png"], "savePath": path.join(__dirname, app.directory, "icon.png") },
{ "url": app["download"]["index.js"], "savePath": path.join(__dirname, app.directory, "index.js") },
], app = app)

}
})
.catch(error => console.error('Error loading apps:', error));


const downloadDialog = document.getElementById('download-dialog');
const downloadProgress = document.getElementById('download-progress');
const downloadStatus = document.getElementById('download-status');

function showDownloadDialog() {
downloadDialog.style.display = 'flex';
}

function hideDownloadDialog() {
downloadDialog.style.display = 'none';
}

async function checkAndDownloadFile(fileUrl, savePath) {
if (fs.existsSync(savePath)) {
console.log(`File already exists at ${savePath}`);
return;
}

try {
var Xhr = new XMLHttpRequest();
Xhr.open("GET", fileUrl, true);
Xhr.send();
Xhr.onreadystatechange = function () {
if (Xhr.readyState == 4 && Xhr.status == 200) {
write_file(savePath, Xhr.response);
console.log(savePath + " Downloaded");
return;
};
};
await sleep(15000);

} catch (error) {
console.error(`Error downloading file from ${fileUrl}:`, error);
}
};
async function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
read_file = function (path) {
return fs.readFileSync(path, 'utf8');
};
write_file = function (path, output) {
fs.writeFileSync(path, output);
};
async function downloadFiles(filesToDownload, app) {
showDownloadDialog();

let completed = 0;
const totalFiles = filesToDownload.length;

for (const file of filesToDownload) {
await checkAndDownloadFile(file.url, file.savePath);
completed++;
const progress = (completed / totalFiles) * 100;
downloadProgress.value = progress;
downloadStatus.innerText = `در حال دانلود: ${completed}/${totalFiles} فایل`;
if (!fs.existsSync(file.savePath)) {
alert("Error Download Files Try Again");
hideDownloadDialog();
return;

}
if (completed === totalFiles) {
downloadStatus.innerText = 'دانلود تکمیل شد!';
setTimeout(() => {
hideDownloadDialog();
runApp(app);
}, 1000);
}
}
}
function runApp(app) {
if (fs.existsSync(path.join(__dirname, app.directory, "index.html")))
ipc.send("load-file-plus", path.join(__dirname, app.directory, "index.html"));
else alert("Error RUN APP")

}
function CloseToPlus() {
try {
ipc.send("load-file", "./index.html");
}
catch { }
}
document.getElementById("back").addEventListener("click", function () {
CloseToPlus();
})
122 changes: 122 additions & 0 deletions plus/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
body {
font-family: 'Courier New', monospace;
background-color: #121212;
color: #fff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
width: 80%;
}

h1 {
text-align: center;
font-size: 2em;
margin-bottom: 20px;
}

input[type="text"] {
width: 100%;
padding: 10px;
font-size: 1.2em;
border: none;
margin-bottom: 20px;
background-color: #333;
color: #fff;
outline: none;
}

#apps-list {
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
}

.app-card {
background-color: #1e1e1e;
padding: 20px;
border-radius: 8px;
width: 200px;
text-align: center;
cursor: pointer;
transition: 0.3s ease;
}

.app-card:hover {
background-color: #333;
}

.app-card img {
width: 100px;
height: 100px;
}

.app-card h2 {
font-size: 1.5em;
margin: 10px 0;
}

.app-card p {
font-size: 0.9em;
color: #bbb;
}

.dialog {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
}

.dialog-content {
background-color: #1e1e1e;
padding: 20px;
border-radius: 8px;
text-align: center;
}

progress {
width: 100%;
height: 20px;
}

p {
margin-top: 10px;
}
#back {
position: absolute;
left: 10px;
top: 10px;
padding: 10px 20px;
font-size: 1.2em;
font-family: 'Courier New', monospace;
color: #fff;
background-color: #333;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#back:hover {
background-color: #555;
transform: translateY(-2px);
}

#back:active {
background-color: #111;
transform: translateY(0);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
2 changes: 1 addition & 1 deletion renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { readFile } = require("fs/promises");
const axios = require('axios'); // Import axios
const { type, platform } = require("os");
const geoip = require('geoip-lite');
const versionapp = "1.3.0";
const versionapp = "1.3.1";
const ipc = require('electron').ipcRenderer;
const { trackEvent } = require('@aptabase/electron/renderer');
var sect = "main";
Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ h2 {
position: absolute;
justify-content: center;
align-items: center;
backdrop-filter: blur(10px);
background-color: rgba(0, 0, 0, 1.0);
backdrop-filter: blur(20px);
background-color: rgba(30, 17, 104,0.3);
flex-direction: column;
z-index: 9;
border-radius: 15px;
Expand Down

0 comments on commit d7feefb

Please sign in to comment.