pub enum BrowserType {
Chrome,
Edge,
Brave,
Chromium,
Vivaldi,
Comet,
Dia,
Atlas,
Firefox,
Safari,
}Variants§
Implementations§
Source§impl BrowserType
impl BrowserType
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
examples/test_copilot.rs (line 30)
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 match CookieReader::read_cookies(&prof, "github.com") {
14 Ok(cookies) => {
15 let has_user_session = cookies.iter().any(|c| {
16 c.name == "user_session" || c.name == "__Host-user_session_same_site"
17 });
18
19 if !has_user_session {
20 continue;
21 }
22
23 let dotcom_user = cookies
24 .iter()
25 .find(|c| c.name == "dotcom_user")
26 .map(|c| c.value.as_str())
27 .unwrap_or("unknown");
28 println!(
29 "Using {} - {} ({} cookies, user={})",
30 browser.name(),
31 prof.name,
32 cookies.len(),
33 dotcom_user
34 );
35
36 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
37 Ok(quota) => {
38 println!("\nSuccess! Copilot quota:");
39 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
40 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
41 println!(" reset_time: {:?}", quota.reset_time);
42 println!(" is_limited: {}", quota.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch Copilot quota: {}", e);
47 }
48 }
49 }
50 Err(_) => {}
51 }
52 }
53 }
54
55 println!("No github.com session with user_session cookie found");
56}Sourcepub fn is_chromium_based(&self) -> bool
pub fn is_chromium_based(&self) -> bool
Examples found in repository?
examples/test_copilot.rs (line 9)
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 match CookieReader::read_cookies(&prof, "github.com") {
14 Ok(cookies) => {
15 let has_user_session = cookies.iter().any(|c| {
16 c.name == "user_session" || c.name == "__Host-user_session_same_site"
17 });
18
19 if !has_user_session {
20 continue;
21 }
22
23 let dotcom_user = cookies
24 .iter()
25 .find(|c| c.name == "dotcom_user")
26 .map(|c| c.value.as_str())
27 .unwrap_or("unknown");
28 println!(
29 "Using {} - {} ({} cookies, user={})",
30 browser.name(),
31 prof.name,
32 cookies.len(),
33 dotcom_user
34 );
35
36 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
37 Ok(quota) => {
38 println!("\nSuccess! Copilot quota:");
39 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
40 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
41 println!(" reset_time: {:?}", quota.reset_time);
42 println!(" is_limited: {}", quota.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch Copilot quota: {}", e);
47 }
48 }
49 }
50 Err(_) => {}
51 }
52 }
53 }
54
55 println!("No github.com session with user_session cookie found");
56}Trait Implementations§
Source§impl Clone for BrowserType
impl Clone for BrowserType
Source§fn clone(&self) -> BrowserType
fn clone(&self) -> BrowserType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BrowserType
impl Debug for BrowserType
Source§impl FromStr for BrowserType
impl FromStr for BrowserType
Source§impl PartialEq for BrowserType
impl PartialEq for BrowserType
impl Copy for BrowserType
impl Eq for BrowserType
impl StructuralPartialEq for BrowserType
Auto Trait Implementations§
impl Freeze for BrowserType
impl RefUnwindSafe for BrowserType
impl Send for BrowserType
impl Sync for BrowserType
impl Unpin for BrowserType
impl UnsafeUnpin for BrowserType
impl UnwindSafe for BrowserType
Blanket Implementations§
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