42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import { test } from '@playwright/test';
|
|
import path from 'path';
|
|
|
|
test.use({ storageState: path.resolve(__dirname, '.auth', 'ig-session.json') });
|
|
|
|
test('inspect IMAGES message shape', async ({ page }) => {
|
|
test.setTimeout(120_000);
|
|
|
|
const found = [];
|
|
|
|
page.on('response', async (response) => {
|
|
const url = response.url();
|
|
if (!url.includes('/api/graphql')) return;
|
|
const params = new URLSearchParams(response.request().postData() || '');
|
|
if (params.get('fb_api_req_friendly_name') !== 'IGDThreadDetailQuery') return;
|
|
try {
|
|
const json = await response.json();
|
|
const t = json?.data?.get_slide_thread_nullable?.as_ig_direct_thread;
|
|
if (!t) return;
|
|
for (const edge of t.slide_messages?.edges || []) {
|
|
if (edge.node?.content_type === 'IMAGES') {
|
|
found.push(edge.node);
|
|
}
|
|
}
|
|
} catch (e) { /* skip */ }
|
|
});
|
|
|
|
await page.goto('https://www.instagram.com/direct/inbox/');
|
|
await page.waitForTimeout(6000);
|
|
|
|
const threadHrefs = await page.$$eval('a[href*="/direct/t/"]', (els) => [
|
|
...new Set(els.map((el) => el.getAttribute('href'))),
|
|
]);
|
|
|
|
for (const href of threadHrefs) {
|
|
await page.goto(`https://www.instagram.com${href}`);
|
|
await page.waitForTimeout(3500);
|
|
}
|
|
|
|
console.log('[IMAGES MESSAGES]', JSON.stringify(found, null, 2));
|
|
});
|