Initial Commit
This commit is contained in:
+11
-11
@@ -1,11 +1,12 @@
|
||||
import { test } from '@playwright/test';
|
||||
import path from 'path';
|
||||
|
||||
test.use({ storageState: '/home/pwuser/ig-session.json' });
|
||||
test.use({ storageState: path.resolve(__dirname, '.auth', 'ig-session.json') });
|
||||
|
||||
test('inspect non-text message shapes', async ({ page }) => {
|
||||
test('inspect IMAGES message shape', async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
|
||||
const interesting = [];
|
||||
const found = [];
|
||||
|
||||
page.on('response', async (response) => {
|
||||
const url = response.url();
|
||||
@@ -17,10 +18,8 @@ test('inspect non-text message shapes', async ({ page }) => {
|
||||
const t = json?.data?.get_slide_thread_nullable?.as_ig_direct_thread;
|
||||
if (!t) return;
|
||||
for (const edge of t.slide_messages?.edges || []) {
|
||||
const node = edge.node;
|
||||
const hasReactions = (node.reactions?.length || 0) > 0 || (node.msg_reactions?.length || 0) > 0;
|
||||
if (node.content_type !== 'TEXT' || hasReactions || node.replied_to_message) {
|
||||
interesting.push({ thread: t.thread_title, node });
|
||||
if (edge.node?.content_type === 'IMAGES') {
|
||||
found.push(edge.node);
|
||||
}
|
||||
}
|
||||
} catch (e) { /* skip */ }
|
||||
@@ -29,13 +28,14 @@ test('inspect non-text message shapes', async ({ page }) => {
|
||||
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')))]);
|
||||
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('[INTERESTING MESSAGES]', JSON.stringify(interesting, null, 2));
|
||||
});
|
||||
console.log('[IMAGES MESSAGES]', JSON.stringify(found, null, 2));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user