INNER CODE UNIT · JavaScript

patchContext

bablosoft/puppeteer-with-fingerprints · src/utils.js:34

  function patchContext(ctx) {
    ctx.newPage = new Proxy(ctx.newPage, {
      async apply(fn, ctx, [opts]) {
        const page = await fn.call(ctx, resetOptions(opts));
        await hooks.onPageCreated?.(page);
        return patchPage(page);
      },
    });

    return ctx;
  }

  /** @param {import('puppeteer').Page} page */
  function patchPage(page) {
    page.setViewport = new Proxy(page.setViewport, {
      apply: async () => {
        console.warn('Warning: setting the viewport size is not allowed (limited by fingerprint).');
      },

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…