feat: notify client on new tab

This commit is contained in:
karishmas6
2024-06-08 00:33:22 +05:30
parent 8e977900ab
commit 7e66cd81b6

View File

@@ -501,4 +501,17 @@ export class WorkflowGenerator {
}
}
}
public notifyOnNewTab = (page: Page, pageIndex: number) => {
if (this.socket) {
page.on('close', () => {
this.socket.emit('tabHasBeenClosed', pageIndex);
})
const parsedUrl = new URL(page.url());
const host = parsedUrl.hostname?.match(/\b(?!www\.)[a-zA-Z0-9]+/g)?.join('.');
this.socket.emit('newTab', host ? host : 'new tab')
}
}
}