pub mod cookies;
pub mod info;
use strum::{EnumProperty, IntoEnumIterator};
use strum_macros::{AsRefStr, Display, EnumIter, EnumString};
#[derive(Clone, Copy)]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
#[derive(Default)]
#[derive(Debug)]
#[derive(EnumIter, Display, EnumString, AsRefStr, strum_macros::EnumProperty)]
pub enum Browser {
#[default]
#[strum(ascii_case_insensitive, props(Based = "firefox"))]
Firefox,
#[strum(ascii_case_insensitive, props(Based = "firefox"))]
Librewolf,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Chrome,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Edge,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Chromium,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Brave,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Yandex,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Vivaldi,
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Opera,
#[cfg(not(target_os = "linux"))]
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
OperaGX,
#[cfg(not(target_os = "linux"))]
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
CocCoc,
#[cfg(target_os = "macos")]
#[strum(ascii_case_insensitive, props(Based = "chromium"))]
Arc,
#[cfg(target_os = "macos")]
#[strum(ascii_case_insensitive, props(Based = "safari"))]
Safari,
}
impl Browser {
pub fn is_chromium_base(self) -> bool {
self.get_str("Based")
.map_or(false, |base| base.eq_ignore_ascii_case("chromium"))
}
pub fn is_firefox_base(self) -> bool {
self.get_str("Based")
.map_or(false, |base| base.eq_ignore_ascii_case("firefox"))
}
pub fn chromiums() -> Vec<Self> {
Self::iter()
.filter(|v| {
v.get_str("Based")
.map_or(false, |base| base.eq_ignore_ascii_case("chromium"))
})
.collect()
}
pub fn firefoxs() -> Vec<Self> {
Self::iter()
.filter(|v| {
v.get_str("Based")
.map_or(false, |base| base.eq_ignore_ascii_case("firefox"))
})
.collect()
}
}
impl Browser {
#[cfg(target_os = "macos")]
pub const fn safe_name(&self) -> &str {
match self {
Self::Chromium => "Chromium",
Self::Chrome => "Chrome",
Self::Edge => "Microsoft Edge",
Self::Brave => "Brave",
Self::Yandex => "Yandex",
Self::Vivaldi => "Vivaldi",
Self::Opera => "Opera",
#[cfg(not(target_os = "linux"))]
Self::OperaGX => "Opera",
#[cfg(not(target_os = "linux"))]
Self::CocCoc => "CocCoc",
#[cfg(not(target_os = "linux"))]
Self::Arc => "Arc",
_ => "Chrome",
}
}
#[cfg(not(target_os = "windows"))]
pub const fn storage(&self) -> &str {
match self {
Self::Chromium => concat!("Chromium", " Safe Storage"),
Self::Chrome => concat!("Chrome", " Safe Storage"),
Self::Edge => concat!("Microsoft Edge", " Safe Storage"),
Self::Brave => concat!("Brave", " Safe Storage"),
Self::Yandex => concat!("Yandex", " Safe Storage"),
Self::Vivaldi => concat!("Vivaldi", " Safe Storage"),
Self::Opera => concat!("Opera", " Safe Storage"),
#[cfg(not(target_os = "linux"))]
Self::OperaGX => concat!("Opera", " Safe Storage"),
#[cfg(not(target_os = "linux"))]
Self::CocCoc => concat!("CocCoc", " Safe Storage"),
#[cfg(not(target_os = "linux"))]
Self::Arc => concat!("Arc", " Safe Storage"),
_ => concat!("Chrome", " Safe Storage"),
}
}
}