Code block test

I just installed the plugin Code Syntax Block and I wanted to test it out.

[
  {
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
  },
  {
    "userId": 1,
    "id": 2,
    "title": "quis ut nam facilis et officia qui",
    "completed": false
  },
  {
    "userId": 1,
    "id": 3,
    "title": "fugiat veniam minus",
    "completed": false
  }
]
import playwright from 'playwright';

export class Browser {
    #userAgent;
    #browserLocale;
    user;
    browser;
    context;
    page;

    constructor({ userAgent, browserLocale }) {
        this.#userAgent = userAgent;
        this.#browserLocale = browserLocale;
    }

    static async init({ userAgent, browserLocale }) {
        const instance = new Browser({ userAgent, browserLocale });
        instance.browser = await playwright.chromium.launch({
            headless: process.env.BROWSER_HEADLESS == 'true',
        });
        instance.context = await instance.browser.newContext({
            locale: this.browserLocale,
            userAgent: this.userAgent,
        });
        return instance;
    }

    async newPage() {
        this.page = await this.context.newPage();
        return this.page;
    }
}

Seems to be working fine! Great success!

By Rune Sum

This is my blog about all the stupid coding I do.

Leave a comment