Skip to content

Commit 4acc617

Browse files
authored
Enable chrome plugin (clearloop#124)
1 parent d26cb4e commit 4acc617

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/plugins/leetcode.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@ impl LeetCode {
3737
/// New LeetCode client
3838
pub fn new() -> Result<LeetCode, crate::Error> {
3939
let conf = config::Config::locate()?;
40-
let cookies = conf.cookies.clone();
40+
let (cookie, csrf) = if conf.cookies.csrf.is_empty() || conf.cookies.session.is_empty() {
41+
let cookies = super::chrome::cookies()?;
42+
(cookies.to_string(), cookies.csrf)
43+
} else {
44+
(
45+
conf.cookies.clone().to_string(),
46+
conf.cookies.clone().csrf,
47+
)
48+
};
4149
let default_headers = LeetCode::headers(
4250
HeaderMap::new(),
4351
vec![
44-
("Cookie", cookies.to_string().as_str()),
45-
("x-csrftoken", &cookies.csrf),
52+
("Cookie", &cookie),
53+
("x-csrftoken", &csrf),
4654
("x-requested-with", "XMLHttpRequest"),
4755
("Origin", &conf.sys.urls.base),
4856
],

src/plugins/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
//!
99
1010
// FIXME: Read cookies from local storage. (issue #122)
11-
// mod chrome;
11+
mod chrome;
1212
mod leetcode;
1313
pub use leetcode::LeetCode;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy