fix(grabcraft): extract model_id fallback for external voxel JS URL
All checks were successful
Deploy to Docker / deploy (push) Successful in 13s
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:
@@ -323,15 +323,41 @@ function extractRenderObject(html) {
|
|||||||
* @returns {{ url: string, blueprintId: string } | null}
|
* @returns {{ url: string, blueprintId: string } | null}
|
||||||
*/
|
*/
|
||||||
function extractExternalScriptUrl(html) {
|
function extractExternalScriptUrl(html) {
|
||||||
const regex = /<script[^>]+src=["']((?:https?:\/\/[^"']*)?\/js\/RenderObject\/myRenderObject_(\d+)\.js)["']/i;
|
// Pattern 1: explicit <script src="...myRenderObject_XXXX.js">
|
||||||
const match = html.match(regex);
|
const scriptRegex = /<script[^>]+src=["']((?:https?:\/\/[^"']*)?\/js\/RenderObject\/myRenderObject_(\d+)\.js)["']/i;
|
||||||
if (!match) return null;
|
const scriptMatch = html.match(scriptRegex);
|
||||||
|
if (scriptMatch) {
|
||||||
let url = match[1];
|
let url = scriptMatch[1];
|
||||||
if (url.startsWith('/')) {
|
if (url.startsWith('/')) {
|
||||||
url = GRABCRAFT_BASE + url;
|
url = GRABCRAFT_BASE + url;
|
||||||
}
|
}
|
||||||
return { url, blueprintId: match[2] };
|
return { url, blueprintId: scriptMatch[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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user