From 0334c891267d797e1528b2188ffac820c7a047e1 Mon Sep 17 00:00:00 2001 From: siritami <102145692+FiorenMas@users.noreply.github.com> Date: Sat, 23 May 2026 10:33:30 +0700 Subject: [PATCH 1/4] STV: Smooth cf captcha, change structure code --- .../SangTacViet/content-normalization.ts | 97 +++ .../vietnamese/SangTacViet/external-url.ts | 168 +++++ plugins/vietnamese/SangTacViet/filters.ts | 127 ++++ .../vietnamese/SangTacViet/glyph-decode.ts | 56 ++ plugins/vietnamese/SangTacViet/index.ts | 611 +++--------------- .../vietnamese/SangTacViet/webview/index.js | 360 +++++------ 6 files changed, 731 insertions(+), 688 deletions(-) create mode 100644 plugins/vietnamese/SangTacViet/content-normalization.ts create mode 100644 plugins/vietnamese/SangTacViet/external-url.ts create mode 100644 plugins/vietnamese/SangTacViet/filters.ts create mode 100644 plugins/vietnamese/SangTacViet/glyph-decode.ts diff --git a/plugins/vietnamese/SangTacViet/content-normalization.ts b/plugins/vietnamese/SangTacViet/content-normalization.ts new file mode 100644 index 00000000..34c249d7 --- /dev/null +++ b/plugins/vietnamese/SangTacViet/content-normalization.ts @@ -0,0 +1,97 @@ +import { decodeHtmlEntities, encodeHtmlEntities } from '@libs/utils'; +import { decodeGlyphs } from './glyph-decode'; + +// ── Content normalization ───────────────── +function looksLikeInterlinear(text: string): boolean { + return /]*\b(?:t|v|p)\s*=\s*['"][^'"]*['"][^>]*>/i.test(text); +} + +function normalizeInterlinear(raw: string): string { + let t = raw.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); + t = t.replace(/\s*/gi, '\n').replace(/<\/br\s*>/gi, '\n'); + t = t.replace( + /<\/i>\s*\n+\s*(?=[,.;:!?%\)\]\}\u3002\uff0c\u3001\uff01\uff1f\uff1b\uff1a\u201d\u2019\u300d\u300f\u3011\u300b])/gi, + '', + ); + const marker = '__STV_GAP__'; + t = t.replace(/<\/i>\s*' + marker + ']*>([\s\S]*?)<\/i>/gi, '$1'); + t = t.replace( + /<\/?(p|div|article|section|li|tr|h[1-6]|blockquote|ul|ol)[^>]*>/gi, + '\n', + ); + t = t.replace(/<[^>]+>/g, '').replace(/[<>]/g, ''); + t = decodeHtmlEntities(t); + t = t.replace(new RegExp(marker, 'g'), ' '); + t = t.replace(/[\t\f\v ]+/g, ' '); + t = t.replace( + / +([,.;:!?%\)\]\}\u3002\uff0c\u3001\uff01\uff1f\uff1b\uff1a\u201d\u2019\u300d\u300f\u3011\u300b])/g, + '$1', + ); + t = t.replace( + /\n+([,.;:!?%\)\]\}\u3002\uff0c\u3001\uff01\uff1f\uff1b\uff1a\u201d\u2019\u300d\u300f\u3011\u300b])/g, + '$1', + ); + t = t + .replace(/[ ]*\n[ ]*/g, '\n') + .replace(/\n{3,}/g, '\n\n') + .trim(); + return t ? t.replace(/\n/g, '') : ''; +} + +export function normalizeChapterHtml(host: string, raw: string): string { + let text = raw || ''; + if (!text) return ''; + const h = host.toLowerCase(); + + if (h === 'fanqie') { + text = text.replace(/]*>[\s\S]*?<\/header>/gi, ''); + text = text.replace(/