diff --git a/sources/en.comix/res/source.json b/sources/en.comix/res/source.json index 2775cdb90..a4390b916 100644 --- a/sources/en.comix/res/source.json +++ b/sources/en.comix/res/source.json @@ -2,7 +2,7 @@ "info": { "id": "en.comix", "name": "Comix", - "version": 24, + "version": 25, "url": "https://comix.to", "contentRating": 1, "languages": ["en"], diff --git a/sources/en.comix/src/lib.rs b/sources/en.comix/src/lib.rs index e7beb5e48..0d47b5ad7 100644 --- a/sources/en.comix/src/lib.rs +++ b/sources/en.comix/src/lib.rs @@ -1,9 +1,9 @@ #![no_std] use aidoku::{ Chapter, DeepLinkHandler, DeepLinkResult, FilterValue, HashMap, Home, HomeComponent, - HomeLayout, HomePartialResult, ImageRequestProvider, Link, LinkValue, Listing, ListingProvider, - Manga, MangaPageResult, MangaWithChapter, NotificationHandler, Page, PageContent, PageContext, - Result, Source, WebLoginHandler, + HomeLayout, HomePartialResult, Link, LinkValue, Listing, ListingProvider, Manga, + MangaPageResult, MangaWithChapter, NotificationHandler, Page, PageContent, Result, Source, + WebLoginHandler, alloc::{String, Vec, string::ToString, vec}, helpers::uri::{QueryParameters, encode_uri_component}, imports::{ @@ -20,7 +20,6 @@ mod models; mod settings; mod web; -use crate::helpers::create_request_get; use crate::settings::VERIFY_KEY; use models::*; use web::*; @@ -505,12 +504,6 @@ impl ListingProvider for Comix { } } -impl ImageRequestProvider for Comix { - fn get_image_request(&self, url: String, _context: Option) -> Result { - Ok(create_request_get(&url)?.header("Referer", &format!("{BASE_URL}/"))) - } -} - impl NotificationHandler for Comix { fn handle_notification(&self, notification: String) { if notification == "resetFilters" { @@ -577,7 +570,6 @@ register_source!( Comix, Home, ListingProvider, - ImageRequestProvider, NotificationHandler, DeepLinkHandler, WebLoginHandler diff --git a/sources/en.comix/src/web.rs b/sources/en.comix/src/web.rs index 9376d4ecb..db14066d2 100644 --- a/sources/en.comix/src/web.rs +++ b/sources/en.comix/src/web.rs @@ -93,24 +93,38 @@ impl ComixWebView { let js_asset_path = &main_module_src[0..js_asset_path_index + 1]; let secure_script_regex = Regex::new("(secure-[A-Za-z0-9-_]+?\\.js)").unwrap(); let main_module_contents = - Request::get(format!("{BASE_URL}{main_module_src}"))?.string()?; + create_request_get(&format!("{BASE_URL}{main_module_src}"))?.string()?; if let Some(secure_script_path) = secure_script_regex .captures(main_module_contents.as_str()) .and_then(|captures| captures.get(1).map(|m| m.as_str())) { - self.web_view.eval(&format!( + let secure_module_contents = + create_request_get(&format!("{BASE_URL}{js_asset_path}{secure_script_path}"))? + .string()?; + let Some(module_body) = secure_module_contents + .rfind("export") + .filter(|&index| { + secure_module_contents[index + "export".len()..] + .trim_start() + .starts_with('{') + }) + .map(|index| &secure_module_contents[..index]) + else { + bail!("Secure module exports not found"); + }; + let result = self.web_view.eval(&format!( "(() => {{ - import('{BASE_URL}{js_asset_path}{secure_script_path}') - .then((m) => window['vm'] = m) - .catch((e) => window['vm'] = {{}}); - return ''; + try {{ + {module_body} + return 'ok'; + }} catch (e) {{ + return 'error: ' + e; + }} }})()" ))?; - while self - .web_view - .eval("(() => { return window['vm'] == null ? 'true' : 'false'; })()")? - == "true" - {} + if result != "ok" { + bail!("Failed to load secure module: {result}"); + } Ok(()) } else { bail!("Secure module not found");