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
10 changes: 9 additions & 1 deletion electron/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ import { registerLnproxyProtocol } from './protocols/lnproxy.js';
app.commandLine.appendSwitch('disable-features', 'PartitionedCookies');

protocol.registerSchemesAsPrivileged([
{ scheme: 'lnproxy', privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true } }
{
scheme: 'lnproxy',
privileges: {
standard: true,
secure: true,
supportFetchAPI: true,
corsEnabled: true,
},
},
]);

const __filename = fileURLToPath(import.meta.url);
Expand Down
13 changes: 6 additions & 7 deletions electron/main/protocols/lnproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { performNetRequest } from '../ipc/fetch-handler.js';
import { customSession } from '../main.js';

export function registerLnproxyProtocol() {
customSession.protocol.handle('lnproxy', async (req) => {
customSession.protocol.handle('lnproxy', async req => {
// Handle OPTIONS request for preflight just in case, though Custom Protocol with corsEnabled shouldn't need it.
if (req.method === 'OPTIONS') {
return new Response(null, {
status: 204,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': '*'
}
'Access-Control-Allow-Headers': '*',
},
});
}

Expand Down Expand Up @@ -46,15 +46,15 @@ export function registerLnproxyProtocol() {
const responseData = await performNetRequest(targetUrl, {
method: req.method,
headers: headers,
body: bodyData
body: bodyData,
});

const resHeaders = new Headers(responseData.headers);

// Node fetch/net automatically decompresses but keeps original headers, causing issues when piped to Chromium
resHeaders.delete('content-encoding');
resHeaders.delete('content-length');

// Always allow CORS
resHeaders.set('Access-Control-Allow-Origin', '*');
resHeaders.set('Access-Control-Allow-Headers', '*');
Expand All @@ -67,7 +67,6 @@ export function registerLnproxyProtocol() {
statusText: responseData.statusMessage,
headers: resHeaders,
});

} catch (error) {
console.error('[lnproxy] Request error:', error);
return new Response(String(error), { status: 500 });
Expand Down
6 changes: 1 addition & 5 deletions plugins/vietnamese/ZumiNovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ZumiNovelPlugin implements Plugin.PluginBase {
name = 'ZumiNovel';
icon = 'src/vi/zuminovel/icon.png';
site = SITE;
version = '1.0.3';
version = '1.0.4';

pluginSettings: Plugin.PluginSettings = {
showRaw: {
Expand Down Expand Up @@ -181,10 +181,6 @@ class ZumiNovelPlugin implements Plugin.PluginBase {

if (opts.type) {
params.set('type', opts.type);
} else if (!opts.showRaw) {
params.append('type', 'original');
params.append('type', 'translated');
params.append('type', 'ai_translated');
}

params.set('includeDescription', 'false');
Expand Down
45 changes: 37 additions & 8 deletions plugins/vietnamese/jukanovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class JukaNovelPlugin implements Plugin.PluginBase {
name = 'JukaNovel';
icon = 'src/vi/jukanovel/icon.png';
site = 'https://jukaza.site';
version = '1.0.5';
version = '1.0.6';

pluginSettings: Plugin.PluginSettings = {
preferRaw: {
Expand Down Expand Up @@ -102,15 +102,43 @@ class JukaNovelPlugin implements Plugin.PluginBase {
};
}
async parseChapter(chapterPath: string): Promise<string> {
const chapterIdMatch = chapterPath.match(/\/(\d+)/);
if (!chapterIdMatch) {
throw new Error('Không thể tìm thấy ID chương.');
}
const chapterId = chapterIdMatch[1];
const response = await fetchText(`${this.site}${chapterPath}`);
const $ = loadCheerio(response);
this.checkLogin($);
const scriptContent = $('script:contains("__READER_DATA__")').html() || '';
const match = scriptContent.match(/window\.__READER_DATA__\s*=\s*(.*?});/);
if (!match) throw new Error('Không tìm thấy dữ liệu chương.');
const tokenMatch = scriptContent.match(
new RegExp(`"chapter_id":${chapterId},"token":"([^"]+)"`),
);
const token = tokenMatch ? tokenMatch[1] : null;

const cipherKeyMatch = scriptContent.match(/"cipherKey":"([^"]+)"/);
const cipherKey = cipherKeyMatch ? cipherKeyMatch[1] : '';

if (!token) throw new Error('Không tìm thấy token cho chương này.');

const getDataContent = await fetchText(
`${this.site}/api/reader/chapter/${chapterId}`,
{
headers: {
'accept': 'application/json',
'x-requested-with': 'XMLHttpRequest',
'referer': `${this.site}${chapterPath}`,
'x-reader-token': token,
},
},
);

try {
const readerData = JSON.parse(match[1]);
const chapterData = JSON.parse(getDataContent);
const readerData = {
cipherKey: cipherKey,
chapter: chapterData,
};
const chapterContent = this.decryptJukaNovel(readerData);
if (!chapterContent) throw new Error('chapterContent = null');
return chapterContent;
Expand Down Expand Up @@ -155,10 +183,11 @@ class JukaNovelPlugin implements Plugin.PluginBase {
if (this.preferRaw) {
content = contentCipher(chapter.raw_content);
} else {
content =
contentCipher(chapter.published_content) ||
contentCipher(chapter.translated_content) ||
contentCipher(chapter.raw_content);
content = contentCipher(
chapter.published_content ||
chapter.translated_content ||
chapter.raw_content,
);
}

if (!content) return '';
Expand Down
Loading