fix(grabcraft): extract model_id fallback for external voxel JS URL
All checks were successful
Deploy to Docker / deploy (push) Successful in 13s

The external myRenderObject script is loaded dynamically, not via a
static <script> tag. Add fallback patterns to extract model_id or
product_id from the page HTML and construct the JS URL from that.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-16 23:04:51 +00:00
parent f9e2b43d2b
commit 911471b564

View File

@@ -323,15 +323,41 @@ function extractRenderObject(html) {
* @returns {{ url: string, blueprintId: string } | null}
*/
function extractExternalScriptUrl(html) {
const regex = /<script[^>]+src=["']((?:https?:\/\/[^"']*)?\/js\/RenderObject\/myRenderObject_(\d+)\.js)["']/i;
const match = html.match(regex);
if (!match) return null;
let url = match[1];
if (url.startsWith('/')) {
url = GRABCRAFT_BASE + url;
// Pattern 1: explicit <script src="...myRenderObject_XXXX.js">
const scriptRegex = /<script[^>]+src=["']((?:https?:\/\/[^"']*)?\/js\/RenderObject\/myRenderObject_(\d+)\.js)["']/i;
const scriptMatch = html.match(scriptRegex);
if (scriptMatch) {
let url = scriptMatch[1];
if (url.startsWith('/')) {
url = GRABCRAFT_BASE + url;
}
return { url, blueprintId: scriptMatch[2] };
}
return { url, blueprintId: match[2] };
// Pattern 2: extract model_id from page and construct URL
// GrabCraft pages contain model_id in comment forms / AJAX calls
const modelIdRegex = /model_id\s*[:=]\s*["']?(\d+)["']?/;
const modelMatch = html.match(modelIdRegex);
if (modelMatch) {
const id = modelMatch[1];
return {
url: `${GRABCRAFT_BASE}/js/RenderObject/myRenderObject_${id}.js`,
blueprintId: id,
};
}
// Pattern 3: extract product_id
const productIdRegex = /product_id\s*[:=]\s*["']?(\d+)["']?/;
const productMatch = html.match(productIdRegex);
if (productMatch) {
const id = productMatch[1];
return {
url: `${GRABCRAFT_BASE}/js/RenderObject/myRenderObject_${id}.js`,
blueprintId: id,
};
}
return null;
}
/**