Sync working tree before initial Gitea push

- File reorg: popup/options/bulk-check moved to src/ subdirs
- Shared modules: src/shared/id-extract.js, src/options/options-shared.js
- Host updates: rcjav-host.py + register/install scripts
- .gitignore expanded
This commit is contained in:
admin
2026-05-26 22:42:15 +02:00
parent 0e230320a9
commit 2d6a95682f
29 changed files with 2360 additions and 765 deletions
+8 -41
View File
@@ -11,40 +11,20 @@ if (!window.__rclonex_loaded__) {
window.__rclonex_loaded__ = true;
(() => {
// Optional single trailing letter (e.g. IBW-902z) is matched but discarded —
// rc-jav's index already drops trailing letters too, so query "IBW-902" finds the file.
const ID_RE_DASHED = /\b([A-Za-z][A-Za-z0-9]{1,})-(\d{2,7})[a-zA-Z]?\b/;
const ID_RE_UNDASHED = /\b([A-Za-z][A-Za-z0-9]{1,})(\d{3,5})[a-zA-Z]?\b/;
// Built-in studio normalizers — applied BEFORE generic ID regex.
// Each entry: { re: RegExp, fmt: string ($1, $2 = capture groups) }.
// User-added normalizers from settings are tried before these.
const BUILTIN_ID_NORMALIZERS = [
// FC2-PPV in any dash configuration: FC2PPV12345, FC2-PPV12345, FC2-PPV-12345
{ re: /\bFC2-?PPV-?(\d{4,})\b/i, fmt: "FC2-PPV-$1" },
// Some sites display FC2 IDs without the PPV segment: FC2-1841460.
{ re: /\bFC2-(\d{4,})\b/i, fmt: "FC2-PPV-$1" },
];
// ID-extraction primitives live in src/shared/id-extract.js (loaded by the
// manifest content_scripts[] entry before this file).
const { normalizeId: _normalizeId } = self.RCJAV_IDS;
const BUILTIN_SITE_ADAPTERS = [
{ host: "clearjav.com", selector: "div.meta-chip > h3.meta-chip__value" },
];
function applyNormalizers(text, userList) {
const all = [...(userList || []), ...BUILTIN_ID_NORMALIZERS];
for (const n of all) {
let re;
try { re = n.re instanceof RegExp ? n.re : new RegExp(n.re, "i"); } catch { continue; }
const m = text.match(re);
if (m) {
// Apply fmt with $1..$9 substitution
return n.fmt.replace(/\$(\d)/g, (_, i) => m[+i] || "");
}
}
return null;
}
let _userNormalizers = [];
// Thin wrapper so callers without an explicit list pick up the live settings.
function normalizeId(text, userNormalizers = _userNormalizers) {
return _normalizeId(text, userNormalizers);
}
async function loadUserNormalizers() {
try {
const { settings = {} } = await chrome.storage.sync.get("settings");
@@ -59,19 +39,6 @@ chrome.storage.onChanged?.addListener?.((changes, area) => {
});
loadUserNormalizers();
function normalizeId(text, userNormalizers = _userNormalizers) {
if (!text) return null;
// Try user-defined + built-in normalizers first (FC2-PPV-style oddballs).
const fromNormalizer = applyNormalizers(text, userNormalizers);
if (fromNormalizer) return fromNormalizer.toUpperCase();
let m = text.match(ID_RE_DASHED);
if (!m) m = text.match(ID_RE_UNDASHED);
if (!m) return null;
// Preserve the digits exactly as they appear (incl. leading zeros) — rc-jav --quick
// hands the glob "<ID>*" to rclone --include, which is literal, not numeric.
return `${m[1].toUpperCase()}-${m[2]}`;
}
function hostMatches(pattern, host) {
// Glob: '*' = any chars. Case-insensitive.
// Convenience: a bare domain (no '*.') ALSO matches any subdomain — and vice versa.