This repository was archived by the owner on Jun 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
3
const { firefox } = require ( 'playwright-firefox' ) ;
4
+
4
5
const url = 'https://www.perplexity.ai/search?focus=internet&copilot=false&q=' + process . argv [ 2 ] ;
5
- const buttonMenu = 'button [data-testid="thread-dropdown-menu "]' ;
6
- const buttonDelete = 'div [data-testid="thread-delete "]' ;
7
- const buttonConfirm = 'css=button:has-text("Confirm")' ;
8
- const buttonCopy = 'svg[data-icon="clipboard"]' ;
6
+ const buttonCopy = 'svg [data-icon="clipboard "]' ; // copy icon on answer
7
+ const buttonMenu = 'button [data-testid="thread-dropdown-menu "]' ; // "..." icon on top right
8
+ const buttonDelete = 'div[data-testid="thread-delete"]' ; // "Delete Thread" button
9
+ const buttonConfirm = 'css=button:has-text("Confirm")' ;
9
10
const textMessage = 'div[dir="auto"]' ;
10
11
11
12
firefox . launch ( { headless : true , timeout : 30000 } ) . then ( async browser => {
13
+ // start session
12
14
const page = await browser . newPage ( ) ;
13
15
await page . goto ( url , { waitUntil : 'domcontentloaded' } ) ;
14
- page . setDefaultTimeout ( 20000 ) ;
15
16
17
+ // get answer
16
18
await page . waitForSelector ( buttonCopy ) ;
17
19
const result = await page . locator ( textMessage ) . textContent ( ) ;
18
20
console . log ( result ) ;
19
21
22
+ // delete thread
20
23
await page . click ( buttonMenu , { focus : true } ) ;
21
24
await page . waitForTimeout ( 300 ) ;
22
25
await page . click ( buttonDelete ) ;
23
26
await page . waitForTimeout ( 300 ) ;
24
27
await page . click ( buttonConfirm ) ;
25
28
29
+ // close browser
26
30
await browser . close ( ) ;
27
31
} ) ;
You can’t perform that action at this time.
0 commit comments