decrypt_cookies/browser/
mod.rs1pub mod cookies;
2pub mod info;
3
4use strum::{AsRefStr, Display, EnumIter, EnumProperty, EnumString, IntoEnumIterator};
5
6#[derive(Clone, Copy)]
7#[derive(PartialEq, Eq, PartialOrd, Ord)]
8#[derive(Default)]
9#[derive(Debug)]
10#[derive(EnumIter, Display, EnumString, AsRefStr, strum::EnumProperty)]
11pub enum Browser {
12 #[default]
14 #[strum(ascii_case_insensitive, props(Based = "firefox"))]
15 Firefox,
16 #[strum(ascii_case_insensitive, props(Based = "firefox"))]
18 Librewolf,
19
20 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
22 Chrome,
23 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
25 Edge,
26 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
28 Chromium,
29 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
31 Brave,
32 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
34 Yandex,
35 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
37 Vivaldi,
38 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
40 Opera,
41 #[cfg(not(target_os = "linux"))]
43 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
44 OperaGX,
45 #[cfg(not(target_os = "linux"))]
47 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
48 CocCoc,
49 #[cfg(target_os = "macos")]
52 #[strum(ascii_case_insensitive, props(Based = "chromium"))]
53 Arc,
54
55 #[cfg(target_os = "macos")]
57 #[strum(ascii_case_insensitive, props(Based = "safari"))]
58 Safari,
59}
60
61impl Browser {
62 pub fn is_chromium_base(self) -> bool {
63 self.get_str("Based")
64 .map_or(false, |base| base.eq_ignore_ascii_case("chromium"))
65 }
66 pub fn is_firefox_base(self) -> bool {
67 self.get_str("Based")
68 .map_or(false, |base| base.eq_ignore_ascii_case("firefox"))
69 }
70 pub fn chromiums() -> impl Iterator<Item = Self> {
72 Self::iter().filter(|v| {
73 v.get_str("Based")
74 .map_or(false, |base| base.eq_ignore_ascii_case("chromium"))
75 })
76 }
77 pub fn firefoxs() -> impl Iterator<Item = Self> {
79 Self::iter().filter(|v| {
80 v.get_str("Based")
81 .map_or(false, |base| base.eq_ignore_ascii_case("firefox"))
82 })
83 }
84}
85
86impl Browser {
87 #[cfg(target_os = "macos")]
89 pub const fn safe_name(&self) -> &str {
90 match self {
91 Self::Chromium => "Chromium",
92 Self::Chrome => "Chrome",
93 Self::Edge => "Microsoft Edge",
94 Self::Brave => "Brave",
95 Self::Yandex => "Yandex",
96 Self::Vivaldi => "Vivaldi",
97 Self::Opera => "Opera",
98 #[cfg(not(target_os = "linux"))]
99 Self::OperaGX => "Opera",
100 #[cfg(not(target_os = "linux"))]
101 Self::CocCoc => "CocCoc",
102 #[cfg(not(target_os = "linux"))]
103 Self::Arc => "Arc",
104 _ => "Chrome",
105 }
106 }
107
108 #[cfg(not(target_os = "windows"))]
110 pub const fn storage(&self) -> &str {
111 match self {
112 Self::Chromium => concat!("Chromium", " Safe Storage"),
113 Self::Chrome => concat!("Chrome", " Safe Storage"),
114 Self::Edge => concat!("Microsoft Edge", " Safe Storage"),
115 Self::Brave => concat!("Brave", " Safe Storage"),
116 Self::Yandex => concat!("Yandex", " Safe Storage"),
117 Self::Vivaldi => concat!("Vivaldi", " Safe Storage"),
118 Self::Opera => concat!("Opera", " Safe Storage"),
119 #[cfg(not(target_os = "linux"))]
120 Self::OperaGX => concat!("Opera", " Safe Storage"),
121 #[cfg(not(target_os = "linux"))]
122 Self::CocCoc => concat!("CocCoc", " Safe Storage"),
123 #[cfg(not(target_os = "linux"))]
124 Self::Arc => concat!("Arc", " Safe Storage"),
125 _ => concat!("Chrome", " Safe Storage"),
126 }
127 }
128}