mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-18 23:35:57 +08:00
feat: expose setViewport to page script
This commit is contained in:
parent
696536c7f2
commit
d8ad1cb6a1
@ -4,7 +4,7 @@ import { container, singleton } from 'tsyringe';
|
|||||||
import { AsyncService, Defer, marshalErrorLike, AssertionFailureError, delay, Deferred, perNextTick, ParamValidationError } from 'civkit';
|
import { AsyncService, Defer, marshalErrorLike, AssertionFailureError, delay, Deferred, perNextTick, ParamValidationError } from 'civkit';
|
||||||
import { Logger } from '../shared/services/logger';
|
import { Logger } from '../shared/services/logger';
|
||||||
|
|
||||||
import type { Browser, CookieParam, GoToOptions, HTTPResponse, Page } from 'puppeteer';
|
import type { Browser, CookieParam, GoToOptions, HTTPResponse, Page, Viewport } from 'puppeteer';
|
||||||
import type { Cookie } from 'set-cookie-parser';
|
import type { Cookie } from 'set-cookie-parser';
|
||||||
import puppeteer from 'puppeteer-extra';
|
import puppeteer from 'puppeteer-extra';
|
||||||
|
|
||||||
@ -555,6 +555,9 @@ export class PuppeteerControl extends AsyncService {
|
|||||||
}
|
}
|
||||||
page.emit('snapshot', snapshot);
|
page.emit('snapshot', snapshot);
|
||||||
}));
|
}));
|
||||||
|
preparations.push(page.exposeFunction('setViewport', (viewport: Viewport | null) => {
|
||||||
|
page.setViewport(viewport).catch(() => undefined);
|
||||||
|
}));
|
||||||
preparations.push(page.evaluateOnNewDocument(SCRIPT_TO_INJECT_INTO_FRAME));
|
preparations.push(page.evaluateOnNewDocument(SCRIPT_TO_INJECT_INTO_FRAME));
|
||||||
preparations.push(page.setRequestInterception(true));
|
preparations.push(page.setRequestInterception(true));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user