The AniList manga to check
The original Kenmei manga entry
Object with skip and accept rule matches if applicable
export function getCustomRuleMatchInfo(
manga: AniListManga,
kenmeiManga: KenmeiManga,
): { skipMatch?: CustomRule; acceptMatch?: CustomRule } {
const customRules = getMatchConfig().customRules;
if (!customRules) {
return {};
}
// Normalize customRules arrays defensively to handle malformed storage
const skipRules = Array.isArray(customRules.skipRules)
? customRules.skipRules
: [];
const acceptRules = Array.isArray(customRules.acceptRules)
? customRules.acceptRules
: [];
const result: { skipMatch?: CustomRule; acceptMatch?: CustomRule } = {};
// Check skip rules
const enabledSkipRules = skipRules.filter((rule) => rule.enabled);
for (const rule of enabledSkipRules) {
if (testRuleAgainstMetadata(rule, manga, kenmeiManga)) {
result.skipMatch = rule;
break;
}
}
// Check accept rules
const enabledAcceptRules = acceptRules.filter((rule) => rule.enabled);
for (const rule of enabledAcceptRules) {
if (testRuleAgainstMetadata(rule, manga, kenmeiManga)) {
result.acceptMatch = rule;
break;
}
}
return result;
}
Gets custom rule match information for debugging and UI display.