Skip to content

Commit

Permalink
feat: opera gx
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Sep 30, 2023
1 parent 37be98b commit 9112a82
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Browser | Linux | MacOS | Windows |
Chrome | 1/10/23 | - | 1/10/23 |
Firefox | 1/10/23 | - | 1/10/23 |
Opera | 1/10/23 | - | 1/10/23 |
Opera GX | - | - | 1/10/23 |
Edge | 1/10/23 | - | 1/10/23 |
Chromium | 1/10/23 | - | 1/10/23 |
Brave | 1/10/23 | - | 1/10/23 |
Expand Down
8 changes: 5 additions & 3 deletions bindings/python/rookiepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
chromium_based,
chromium,
opera,
vivaldi
vivaldi,
opera_gx
)
from typing import List, Any
import http.cookiejar
Expand All @@ -19,9 +20,10 @@
"chrome",
"chromium",
"opera",
"vivaldi"
"opera_gx",
"vivaldi",
"chromium_based",
"firefox_based"
"firefox_based",
"to_dict",
"to_cookiejar",
"create_cookie",
Expand Down
10 changes: 10 additions & 0 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ fn opera(_py: Python, domains: Option<Vec<&str>>) -> PyResult<Vec<PyCookie>> {
Ok(py_cookies)
}

#[pyfunction]
fn opera_gx(_py: Python, domains: Option<Vec<&str>>) -> PyResult<Vec<PyCookie>> {
let cookies = rookie::opera(domains).unwrap();

let py_cookies: Vec<PyCookie> = cookies.into_iter().map(|cookie| PyCookie { inner: cookie }).collect();

Ok(py_cookies)
}

#[pyfunction]
fn chromium(_py: Python, domains: Option<Vec<&str>>) -> PyResult<Vec<PyCookie>> {
let cookies = rookie::chromium(domains).unwrap();
Expand Down Expand Up @@ -153,6 +162,7 @@ fn rookiepy(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(brave, m)?)?;
m.add_function(wrap_pyfunction!(edge, m)?)?;
m.add_function(wrap_pyfunction!(opera, m)?)?;
m.add_function(wrap_pyfunction!(opera_gx, m)?)?;
m.add_function(wrap_pyfunction!(chromium, m)?)?;
m.add_function(wrap_pyfunction!(vivaldi, m)?)?;
m.add_function(wrap_pyfunction!(chromium_based, m)?)?;
Expand Down
26 changes: 26 additions & 0 deletions rookie-rs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ pub static CHROMIUM_CONFIG: BrowserConfig<'static> = BrowserConfig {
};


#[cfg(target_os = "windows")]
pub static OPERA_GX_CONFIG: BrowserConfig<'static> = BrowserConfig {
data_paths: &[
"%LOCALAPPDATA%/Opera Software/Opera GX {channel}/Cookies",
"%LOCALAPPDATA%/Opera Software/Opera GX {channel}/Network/Cookies",

"%APPDATA%/Opera Software/Opera GX {channel}/Cookies",
"%APPDATA%/Opera Software/Opera GX {channel}/Network/Cookies"
],
channels: &["Stable", ""],
};


/*
*********** LINUX **********
Expand Down Expand Up @@ -198,6 +210,13 @@ pub static FIREFOX_CONFIG: BrowserConfig<'static> = BrowserConfig {
channels: &[""],
};

#[cfg(target_os = "linux")]
pub static OPERA_GX_CONFIG: BrowserConfig<'static> = BrowserConfig {
data_paths: &[], // not available on Linux
channels: &["", ""],
};



/*
*********** MACOS **********
Expand Down Expand Up @@ -272,3 +291,10 @@ pub static CHROMIUM_CONFIG: BrowserConfig<'static> = BrowserConfig {
],
channels: &[""],
};

#[cfg(target_os = "macos")]
pub static OPERA_GX_CONFIG: BrowserConfig<'static> = BrowserConfig {
data_paths: &["~/Library/Application Support/com.operasoftware.OperaGX/Cookies"],
channels: &["Stable", ""],
};

21 changes: 21 additions & 0 deletions rookie-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,25 @@ pub fn vivaldi(domains: Option<Vec<&str>>) -> Result<Vec<Cookie>, Box<dyn Error>
pub fn opera(domains: Option<Vec<&str>>) -> Result<Vec<Cookie>, Box<dyn Error>> {
let (key, db_path) = paths::find_chrome_based_paths(&config::OPERA_CONFIG)?;
chromium_based(key, db_path, domains)
}

/// Returns cookies from opera gx
///
/// # Arguments
///
/// * `domains` - A optional list that for getting specific domains only
///
/// # Examples
///
/// ```
/// use rookie;
///
/// fn main() {
/// let domains = vec!["google.com"];
/// let cookies = rookie::opera_gx(Some(domains));
/// }
/// ```
pub fn opera_gx(domains: Option<Vec<&str>>) -> Result<Vec<Cookie>, Box<dyn Error>> {
let (key, db_path) = paths::find_chrome_based_paths(&config::OPERA_GX_CONFIG)?;
chromium_based(key, db_path, domains)
}

0 comments on commit 9112a82

Please sign in to comment.