diff --git a/plugins/vietnamese/LNHako.ts b/plugins/vietnamese/LNHako.ts index 042bdcf92..547e88f1c 100644 --- a/plugins/vietnamese/LNHako.ts +++ b/plugins/vietnamese/LNHako.ts @@ -1,5 +1,6 @@ import { fetchApi } from '@libs/fetch'; import { Parser } from 'htmlparser2'; +import { load as parseHTML } from 'cheerio'; import { HTMLParser2Util, Plugin } from '@/types/plugin'; import { NovelStatus } from '@libs/novelStatus'; import { FilterTypes, Filters } from '@libs/filterInputs'; @@ -19,7 +20,7 @@ class HakoPlugin implements Plugin.PluginBase { name = 'Hako'; icon = 'src/vi/hakolightnovel/icon.png'; site = 'https://ln.hako.vn'; - version = '1.1.0'; + version = '1.1.1'; parseNovels(url: string) { return fetchApi(url) .then(res => res.text()) @@ -223,7 +224,7 @@ class HakoPlugin implements Plugin.PluginBase { this.part++; } this.tempChapter = { - path: attribs['href'], + path: attribs['href']?.replace(/^(https?:\/\/[^/]+)/, ''), name: chapterName, page: this.currentVolume, chapterNumber: chapterNumber, @@ -401,12 +402,47 @@ class HakoPlugin implements Plugin.PluginBase { parseChapter(chapterPath: string): Promise { return fetchApi(this.site + chapterPath) .then(res => res.text()) - .then( - html => - html.match( - /(
[^]+)
[note]', + ); + + protectedEl.replaceWith(decryptedHtml); + } + } + + $('a[href^="/truyen/"]').has('img[src*="chapter-banners"]').remove(); + + return $('#chapter-content').html() || 'Không tìm thấy nội dung'; + }); } searchNovels( searchTerm: string, @@ -495,4 +531,24 @@ class HakoPlugin implements Plugin.PluginBase { } satisfies Filters; } +function decodeBase64(str: string): Uint8Array { + return Uint8Array.from(atob(str), c => c.charCodeAt(0)); +} + +function decryptXor(ciphertext: string, key: string): string { + const data = decodeBase64(ciphertext); + const keyLen = key.length; + const decrypted = data.map((byte, i) => byte ^ key.charCodeAt(i % keyLen)); + return new TextDecoder('utf-8').decode(decrypted); +} + +function decryptBase64Reverse(ciphertext: string): string { + const reversed = ciphertext.split('').reverse().join(''); + return new TextDecoder('utf-8').decode(decodeBase64(reversed)); +} + +function decryptNone(ciphertext: string): string { + return new TextDecoder('utf-8').decode(decodeBase64(ciphertext)); +} + export default new HakoPlugin();