fix: inject cookie script on page load
This commit is contained in:
@@ -167,13 +167,16 @@ export class RemoteBrowser {
|
||||
this.context = await this.browser.newContext(contextOptions);
|
||||
this.currentPage = await this.context.newPage();
|
||||
|
||||
this.currentPage.on('framenavigated', (frame) => {
|
||||
this.currentPage.on('framenavigated', (frame) => {
|
||||
if (frame === this.currentPage?.mainFrame()) {
|
||||
this.currentPage.evaluate(getInjectableScript())
|
||||
this.socket.emit('urlChanged', this.currentPage.url());
|
||||
}
|
||||
});
|
||||
|
||||
this.currentPage.on('load', (page) => {
|
||||
page.evaluate(getInjectableScript())
|
||||
})
|
||||
|
||||
// await this.currentPage.setExtraHTTPHeaders({
|
||||
// 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
|
||||
// });
|
||||
@@ -374,11 +377,14 @@ export class RemoteBrowser {
|
||||
|
||||
this.currentPage.on('framenavigated', (frame) => {
|
||||
if (frame === this.currentPage?.mainFrame()) {
|
||||
this.currentPage.evaluate(getInjectableScript());
|
||||
this.socket.emit('urlChanged', this.currentPage.url());
|
||||
}
|
||||
});
|
||||
|
||||
this.currentPage.on('load', (page) => {
|
||||
page.evaluate(getInjectableScript())
|
||||
})
|
||||
|
||||
//await this.currentPage.setViewportSize({ height: 400, width: 900 })
|
||||
this.client = await this.currentPage.context().newCDPSession(this.currentPage);
|
||||
this.socket.emit('urlChanged', this.currentPage.url());
|
||||
@@ -407,10 +413,13 @@ export class RemoteBrowser {
|
||||
if (this.currentPage) {
|
||||
this.currentPage.on('framenavigated', (frame) => {
|
||||
if (frame === this.currentPage?.mainFrame()) {
|
||||
this.currentPage.evaluate(getInjectableScript());
|
||||
this.socket.emit('urlChanged', this.currentPage.url());
|
||||
}
|
||||
});
|
||||
|
||||
this.currentPage.on('load', (page) => {
|
||||
page.evaluate(getInjectableScript())
|
||||
})
|
||||
// this.currentPage.on('load', (page) => {
|
||||
// this.socket.emit('urlChanged', page.url());
|
||||
// })
|
||||
|
||||
Reference in New Issue
Block a user