Files
cannaiq/backend/treez-intercept.js
Kelly 698995e46f chore: bump task worker version comment
Force new git SHA to avoid CI scientific notation bug.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 02:02:30 -07:00

99 lines
2.8 KiB
JavaScript

const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
// Collect all API requests
const apiRequests = [];
page.on('request', (request) => {
const url = request.url();
// Focus on API/data requests
if (url.includes('api') || url.includes('graphql') ||
url.includes('.json') || request.resourceType() === 'xhr' ||
request.resourceType() === 'fetch') {
apiRequests.push({
url: url,
method: request.method(),
headers: request.headers(),
type: request.resourceType()
});
}
});
page.on('response', async (response) => {
const url = response.url();
const status = response.status();
// Log API responses with content type
if (url.includes('api') || url.includes('graphql') ||
url.includes('.json') || url.includes('product')) {
const contentType = response.headers()['content-type'] || '';
console.log('[' + status + '] ' + url.substring(0, 120));
// Try to get JSON responses
if (contentType.includes('json') && status === 200) {
try {
const text = await response.text();
const preview = text.substring(0, 500);
console.log(' Preview: ' + preview);
} catch (e) {}
}
}
});
console.log('Loading https://best.treez.io/onlinemenu/...');
await page.goto('https://best.treez.io/onlinemenu/', {
waitUntil: 'networkidle2',
timeout: 60000
});
// Wait for any lazy-loaded content
await page.waitForTimeout(5000);
// Try scrolling to trigger more loads
await page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight / 2);
});
await page.waitForTimeout(2000);
console.log('\n=== ALL API REQUESTS ===');
apiRequests.forEach(req => {
console.log(req.method + ' ' + req.url);
if (req.headers['authorization']) {
console.log(' Auth: ' + req.headers['authorization'].substring(0, 50) + '...');
}
});
// Check page content
const content = await page.content();
console.log('\n=== PAGE TITLE ===');
console.log(await page.title());
// Look for product data in page
const productData = await page.evaluate(() => {
// Check for React state or window variables
const windowKeys = Object.keys(window).filter(k =>
k.includes('store') || k.includes('product') || k.includes('__')
);
return {
windowKeys: windowKeys.slice(0, 20),
bodyText: document.body.innerText.substring(0, 1000)
};
});
console.log('\n=== WINDOW KEYS ===');
console.log(productData.windowKeys);
console.log('\n=== PAGE TEXT PREVIEW ===');
console.log(productData.bodyText);
await browser.close();
})();