pub struct BrowserDetector { /* private fields */ }Implementations§
Source§impl BrowserDetector
impl BrowserDetector
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/test_opencode_go.rs (line 10)
9async fn main() {
10 let detector = BrowserDetector::new();
11 let browsers = detector.detect_browsers();
12
13 for browser in &browsers {
14 for prof in detector.list_profiles(*browser) {
15 let Ok(cookies) = CookieReader::read_cookies(&prof, "opencode.ai") else {
16 continue;
17 };
18 let has_auth = cookies
19 .iter()
20 .any(|c| c.name == "auth" || c.name == "__Host-auth");
21 if !has_auth {
22 continue;
23 }
24 println!(
25 "Using {} - {} ({} opencode.ai cookies)",
26 browser.name(),
27 prof.name,
28 cookies.len(),
29 );
30 match seher::opencode_go::fetch_remote_usage(&cookies).await {
31 Ok(usage) => {
32 println!("\nSuccess! OpenCode Go usage (hosted dashboard):");
33 for w in &usage.windows {
34 println!(
35 " {:<8} {:>6.1}% reset_in_sec={:?} limited={}",
36 w.name,
37 w.used_percent,
38 w.reset_in_sec,
39 w.is_limited()
40 );
41 }
42 println!(" => limited: {}", usage.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch OpenCode Go usage: {e}");
47 }
48 }
49 }
50 }
51
52 println!("No opencode.ai session cookie (auth / __Host-auth) found in any browser");
53}More examples
examples/test_copilot.rs (line 5)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "github.com") {
14 let has_user_session = cookies
15 .iter()
16 .any(|c| c.name == "user_session" || c.name == "__Host-user_session_same_site");
17
18 if !has_user_session {
19 continue;
20 }
21
22 let dotcom_user = cookies
23 .iter()
24 .find(|c| c.name == "dotcom_user")
25 .map_or("unknown", |c| c.value.as_str());
26 println!(
27 "Using {} - {} ({} cookies, user={})",
28 browser.name(),
29 prof.name,
30 cookies.len(),
31 dotcom_user
32 );
33
34 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
35 Ok(quota) => {
36 println!("\nSuccess! Copilot quota:");
37 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
38 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
39 println!(" reset_time: {:?}", quota.reset_time);
40 println!(" is_limited: {}", quota.is_limited());
41 return;
42 }
43 Err(e) => {
44 println!("\nFailed to fetch Copilot quota: {e}");
45 }
46 }
47 }
48 }
49 }
50
51 println!("No github.com session with user_session cookie found");
52}examples/test_codex.rs (line 5)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "chatgpt.com") {
14 let has_session = cookies
15 .iter()
16 .any(|c| c.name.starts_with("__Secure-next-auth.session-token"));
17
18 if !has_session {
19 continue;
20 }
21
22 println!(
23 "Using {} - {} ({} cookies)",
24 browser.name(),
25 prof.name,
26 cookies.len(),
27 );
28
29 match seher::codex::CodexClient::fetch_usage(&cookies).await {
30 Ok(usage) => {
31 println!("\nSuccess! Codex usage:");
32 println!(" plan_type: {}", usage.plan_type);
33 println!(" rate_limit limited: {}", usage.rate_limit.is_limited());
34 println!(
35 " rate_limit reset_time: {:?}",
36 usage.rate_limit.next_reset_time()
37 );
38 println!(
39 " code_review limited: {}",
40 usage
41 .code_review_rate_limit
42 .as_ref()
43 .is_some_and(seher::CodexRateLimit::is_limited)
44 );
45 return;
46 }
47 Err(e) => {
48 println!("\nFailed to fetch Codex usage: {e}");
49 }
50 }
51 }
52 }
53 }
54
55 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
56}Sourcepub fn detect_browsers(&self) -> Vec<BrowserType>
pub fn detect_browsers(&self) -> Vec<BrowserType>
Examples found in repository?
examples/test_opencode_go.rs (line 11)
9async fn main() {
10 let detector = BrowserDetector::new();
11 let browsers = detector.detect_browsers();
12
13 for browser in &browsers {
14 for prof in detector.list_profiles(*browser) {
15 let Ok(cookies) = CookieReader::read_cookies(&prof, "opencode.ai") else {
16 continue;
17 };
18 let has_auth = cookies
19 .iter()
20 .any(|c| c.name == "auth" || c.name == "__Host-auth");
21 if !has_auth {
22 continue;
23 }
24 println!(
25 "Using {} - {} ({} opencode.ai cookies)",
26 browser.name(),
27 prof.name,
28 cookies.len(),
29 );
30 match seher::opencode_go::fetch_remote_usage(&cookies).await {
31 Ok(usage) => {
32 println!("\nSuccess! OpenCode Go usage (hosted dashboard):");
33 for w in &usage.windows {
34 println!(
35 " {:<8} {:>6.1}% reset_in_sec={:?} limited={}",
36 w.name,
37 w.used_percent,
38 w.reset_in_sec,
39 w.is_limited()
40 );
41 }
42 println!(" => limited: {}", usage.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch OpenCode Go usage: {e}");
47 }
48 }
49 }
50 }
51
52 println!("No opencode.ai session cookie (auth / __Host-auth) found in any browser");
53}More examples
examples/test_copilot.rs (line 6)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "github.com") {
14 let has_user_session = cookies
15 .iter()
16 .any(|c| c.name == "user_session" || c.name == "__Host-user_session_same_site");
17
18 if !has_user_session {
19 continue;
20 }
21
22 let dotcom_user = cookies
23 .iter()
24 .find(|c| c.name == "dotcom_user")
25 .map_or("unknown", |c| c.value.as_str());
26 println!(
27 "Using {} - {} ({} cookies, user={})",
28 browser.name(),
29 prof.name,
30 cookies.len(),
31 dotcom_user
32 );
33
34 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
35 Ok(quota) => {
36 println!("\nSuccess! Copilot quota:");
37 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
38 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
39 println!(" reset_time: {:?}", quota.reset_time);
40 println!(" is_limited: {}", quota.is_limited());
41 return;
42 }
43 Err(e) => {
44 println!("\nFailed to fetch Copilot quota: {e}");
45 }
46 }
47 }
48 }
49 }
50
51 println!("No github.com session with user_session cookie found");
52}examples/test_codex.rs (line 6)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "chatgpt.com") {
14 let has_session = cookies
15 .iter()
16 .any(|c| c.name.starts_with("__Secure-next-auth.session-token"));
17
18 if !has_session {
19 continue;
20 }
21
22 println!(
23 "Using {} - {} ({} cookies)",
24 browser.name(),
25 prof.name,
26 cookies.len(),
27 );
28
29 match seher::codex::CodexClient::fetch_usage(&cookies).await {
30 Ok(usage) => {
31 println!("\nSuccess! Codex usage:");
32 println!(" plan_type: {}", usage.plan_type);
33 println!(" rate_limit limited: {}", usage.rate_limit.is_limited());
34 println!(
35 " rate_limit reset_time: {:?}",
36 usage.rate_limit.next_reset_time()
37 );
38 println!(
39 " code_review limited: {}",
40 usage
41 .code_review_rate_limit
42 .as_ref()
43 .is_some_and(seher::CodexRateLimit::is_limited)
44 );
45 return;
46 }
47 Err(e) => {
48 println!("\nFailed to fetch Codex usage: {e}");
49 }
50 }
51 }
52 }
53 }
54
55 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
56}pub fn get_browser_base_path( &self, browser_type: BrowserType, ) -> Option<PathBuf>
Sourcepub fn list_profiles(&self, browser_type: BrowserType) -> Vec<Profile>
pub fn list_profiles(&self, browser_type: BrowserType) -> Vec<Profile>
Examples found in repository?
examples/test_opencode_go.rs (line 14)
9async fn main() {
10 let detector = BrowserDetector::new();
11 let browsers = detector.detect_browsers();
12
13 for browser in &browsers {
14 for prof in detector.list_profiles(*browser) {
15 let Ok(cookies) = CookieReader::read_cookies(&prof, "opencode.ai") else {
16 continue;
17 };
18 let has_auth = cookies
19 .iter()
20 .any(|c| c.name == "auth" || c.name == "__Host-auth");
21 if !has_auth {
22 continue;
23 }
24 println!(
25 "Using {} - {} ({} opencode.ai cookies)",
26 browser.name(),
27 prof.name,
28 cookies.len(),
29 );
30 match seher::opencode_go::fetch_remote_usage(&cookies).await {
31 Ok(usage) => {
32 println!("\nSuccess! OpenCode Go usage (hosted dashboard):");
33 for w in &usage.windows {
34 println!(
35 " {:<8} {:>6.1}% reset_in_sec={:?} limited={}",
36 w.name,
37 w.used_percent,
38 w.reset_in_sec,
39 w.is_limited()
40 );
41 }
42 println!(" => limited: {}", usage.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch OpenCode Go usage: {e}");
47 }
48 }
49 }
50 }
51
52 println!("No opencode.ai session cookie (auth / __Host-auth) found in any browser");
53}More examples
examples/test_copilot.rs (line 12)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "github.com") {
14 let has_user_session = cookies
15 .iter()
16 .any(|c| c.name == "user_session" || c.name == "__Host-user_session_same_site");
17
18 if !has_user_session {
19 continue;
20 }
21
22 let dotcom_user = cookies
23 .iter()
24 .find(|c| c.name == "dotcom_user")
25 .map_or("unknown", |c| c.value.as_str());
26 println!(
27 "Using {} - {} ({} cookies, user={})",
28 browser.name(),
29 prof.name,
30 cookies.len(),
31 dotcom_user
32 );
33
34 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
35 Ok(quota) => {
36 println!("\nSuccess! Copilot quota:");
37 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
38 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
39 println!(" reset_time: {:?}", quota.reset_time);
40 println!(" is_limited: {}", quota.is_limited());
41 return;
42 }
43 Err(e) => {
44 println!("\nFailed to fetch Copilot quota: {e}");
45 }
46 }
47 }
48 }
49 }
50
51 println!("No github.com session with user_session cookie found");
52}examples/test_codex.rs (line 12)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "chatgpt.com") {
14 let has_session = cookies
15 .iter()
16 .any(|c| c.name.starts_with("__Secure-next-auth.session-token"));
17
18 if !has_session {
19 continue;
20 }
21
22 println!(
23 "Using {} - {} ({} cookies)",
24 browser.name(),
25 prof.name,
26 cookies.len(),
27 );
28
29 match seher::codex::CodexClient::fetch_usage(&cookies).await {
30 Ok(usage) => {
31 println!("\nSuccess! Codex usage:");
32 println!(" plan_type: {}", usage.plan_type);
33 println!(" rate_limit limited: {}", usage.rate_limit.is_limited());
34 println!(
35 " rate_limit reset_time: {:?}",
36 usage.rate_limit.next_reset_time()
37 );
38 println!(
39 " code_review limited: {}",
40 usage
41 .code_review_rate_limit
42 .as_ref()
43 .is_some_and(seher::CodexRateLimit::is_limited)
44 );
45 return;
46 }
47 Err(e) => {
48 println!("\nFailed to fetch Codex usage: {e}");
49 }
50 }
51 }
52 }
53 }
54
55 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
56}pub fn get_profile( &self, browser_type: BrowserType, profile_name: Option<&str>, ) -> Option<Profile>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BrowserDetector
impl RefUnwindSafe for BrowserDetector
impl Send for BrowserDetector
impl Sync for BrowserDetector
impl Unpin for BrowserDetector
impl UnsafeUnpin for BrowserDetector
impl UnwindSafe for BrowserDetector
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().