mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
feat: support Linux. Refactor resources architecture. Create build script
Currently, themes are disabled and firefox notification too.
This commit is contained in:
@@ -22,7 +22,8 @@ const { logger } = require("../logger");
|
||||
* @returns {string} The detected browser identifier.
|
||||
*/
|
||||
function getUserBrowser() {
|
||||
const userProfile = os.homedir();
|
||||
//const userProfile = os.homedir();
|
||||
const firefoxPath = getFirefoxProfilePath();
|
||||
|
||||
/**
|
||||
* Browsers supported by yt-dlp cookie extraction.
|
||||
@@ -32,7 +33,7 @@ function getUserBrowser() {
|
||||
* once compatibility has been verified.
|
||||
*/
|
||||
const browsers = [
|
||||
{ name: "firefox", path: path.join(userProfile, "AppData", "Roaming", "Mozilla", "Firefox", "Profiles") },
|
||||
{ name: "firefox", path: firefoxPath },
|
||||
// { name: "chrome", path: path.join(userProfile, "AppData", "Local", "Google", "Chrome", "User Data", "Default") },
|
||||
// { name: "brave", path: path.join(userProfile, "AppData", "Local", "BraveSoftware", "Brave-Browser", "User Data", "Default") },
|
||||
// { name: "edge", path: path.join(userProfile, "AppData", "Local", "Microsoft", "Edge", "User Data", "Default") },
|
||||
@@ -44,7 +45,7 @@ function getUserBrowser() {
|
||||
|
||||
// Search for the first available browser profile.
|
||||
for (const browser of browsers) {
|
||||
if (fs.existsSync(browser.path)) {
|
||||
if (browser.path && fs.existsSync(browser.path)) {
|
||||
logger.info(`Browser found: ${browser.name}`);
|
||||
return browser.name;
|
||||
}
|
||||
@@ -52,11 +53,50 @@ function getUserBrowser() {
|
||||
|
||||
// No supported browser found => Notify User
|
||||
logger.warn("No supported browser found on the system");
|
||||
notify.notifyFirefoxBrowserMissing();
|
||||
|
||||
|
||||
// If you somehow managed to live without Firefox and need help installing it. - Don't applied to my Linux chad
|
||||
if (process.platform === "win32") {
|
||||
notify.notifyFirefoxBrowserMissing();
|
||||
}
|
||||
|
||||
// Fallback to Firefox and let yt-dlp handle the error gracefully.
|
||||
// This prevents the application from crashing
|
||||
return "firefox";
|
||||
}
|
||||
|
||||
function getFirefoxProfilePath() {
|
||||
const home = os.homedir();
|
||||
|
||||
if (process.platform === "win32") {
|
||||
return path.join(
|
||||
home,
|
||||
"AppData",
|
||||
"Roaming",
|
||||
"Mozilla",
|
||||
"Firefox",
|
||||
"Profiles"
|
||||
);
|
||||
}
|
||||
|
||||
if (process.platform === "linux") {
|
||||
return path.join(
|
||||
"usr",
|
||||
"bin",
|
||||
"firefox"
|
||||
);
|
||||
}
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
return path.join(
|
||||
home,
|
||||
"Library",
|
||||
"Application Support",
|
||||
"Firefox",
|
||||
"Profiles"
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = getUserBrowser
|
||||
Reference in New Issue
Block a user