fix(route/pixiv): read NSFW novel data defined with Object.defineProperty

The app webview page defines its data with
Object.defineProperty(window, 'pixiv', { value: { novel, ... } }).
JSDOM ran that call, but the script data parser does not execute calls,
so window.pixiv was never set and the novel series route failed with
"Unsupported script data expression: CallExpression". Read the value from
the defineProperty call arguments instead.

Closes #23592
This commit is contained in:
pseudoyu
2026-10-16 14:36:46 +08:00
parent f515e234f5
commit 8aeca4cf73
+3 -2
View File
@@ -2,7 +2,7 @@ import { load } from 'cheerio';
import queryString from 'query-string';
import cache from '@/utils/cache';
import { evaluateScriptData } from '@/utils/evaluate-script';
import { evaluateScriptCallback } from '@/utils/evaluate-script';
import { parseDate } from '@/utils/parse-date';
import { maskHeader } from '../../constants';
@@ -32,7 +32,8 @@ export async function getNSFWNovelContent(novelId: string, token: string): Promi
if (!script) {
throw new Error('No novel data found');
}
const novelDetail = await evaluateScriptData<NSFWNovelDetail | undefined>(script, 'window.pixiv.novel');
// The page defines its data with Object.defineProperty(window, 'pixiv', { value: { novel } })
const novelDetail = (await evaluateScriptCallback<{ value?: { novel?: NSFWNovelDetail } }>(script, 'Object.defineProperty')).value?.novel;
if (!novelDetail) {
throw new Error('No novel data found');