Skip to content
Merged
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
4 changes: 2 additions & 2 deletions sources/en.comix/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
19 changes: 5 additions & 14 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 @@ -12,17 +12,15 @@ use aidoku::{
},
prelude::*,
};

use core::cell::RefCell;

mod helpers;
mod models;
mod settings;
mod web;

use crate::helpers::create_request_get;
use crate::settings::VERIFY_KEY;
use models::*;
use settings::VERIFY_KEY;
use web::*;

const BASE_URL: &str = "https://comix.to";
Expand Down Expand Up @@ -205,7 +203,7 @@ impl Source for Comix {
let response = web_view.build_request(&url)?.send()?;
let json: SingleMangaResponse = web_view.decode_json_owned(&response)?;

manga.copy_from(json.result.into());
manga.copy_from(json.result.into_detailed_manga());

if needs_chapters {
send_partial_result(&manga);
Expand Down Expand Up @@ -505,12 +503,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 +569,6 @@ register_source!(
Comix,
Home,
ListingProvider,
ImageRequestProvider,
NotificationHandler,
DeepLinkHandler,
WebLoginHandler
Expand Down
9 changes: 8 additions & 1 deletion sources/en.comix/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ impl From<ComixContentRating> for ContentRating {
}

impl ComixManga {
pub fn into_detailed_manga(mut self) -> Manga {
let description = self.synopsis.take();
let mut manga: Manga = self.into();
manga.description = description;
manga
}

pub fn is_hidden(&self, hidden_types: &[String], hidden_terms: &[i32]) -> bool {
if hidden_types.contains(&self.r#type) {
return true;
Expand Down Expand Up @@ -206,7 +213,7 @@ impl From<ComixManga> for Manga {
authors: value
.authors
.map(|v| v.into_iter().map(|t| t.title).collect()),
description: value.synopsis,
description: None,
url: Some(url),
tags: {
let mut tags = Vec::new();
Expand Down
43 changes: 27 additions & 16 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 Expand Up @@ -309,10 +323,7 @@ impl ComixWebView {
} else {
bail!("Response Error: {}", response.status_code())
}
} else if response
.get_header("x-enc")
.is_some_and(|value| value == "1")
{
} else if let Some(enc) = response.get_header("x-enc") {
let encoded_response = response
.get_string()?
.replace("\\", "\\\\")
Expand All @@ -325,7 +336,7 @@ impl ComixWebView {
data: JSON.parse('{encoded_response}'),
status: 200,
headers: {{
'x-enc': '1',
'x-enc': '{enc}',
}},
}});
return JSON.stringify({{ result: decoded && decoded.data }});
Expand Down
Loading