Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sources/en.comix/res/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"info": {
"id": "en.comix",
"name": "Comix",
"version": 24,
"version": 25,
"url": "https://comix.to",
"contentRating": 1,
"languages": ["en"],
Expand Down
14 changes: 3 additions & 11 deletions sources/en.comix/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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::*;
Expand Down Expand Up @@ -505,12 +504,6 @@ impl ListingProvider for Comix {
}
}

impl ImageRequestProvider for Comix {
fn get_image_request(&self, url: String, _context: Option<PageContext>) -> Result<Request> {
Ok(create_request_get(&url)?.header("Referer", &format!("{BASE_URL}/")))
}
}

impl NotificationHandler for Comix {
fn handle_notification(&self, notification: String) {
if notification == "resetFilters" {
Expand Down Expand Up @@ -577,7 +570,6 @@ register_source!(
Comix,
Home,
ListingProvider,
ImageRequestProvider,
NotificationHandler,
DeepLinkHandler,
WebLoginHandler
Expand Down
36 changes: 25 additions & 11 deletions sources/en.comix/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down