Open screenshot-url in Script Kit
// Name: Screenshot URLimport "@johnlindquist/kit"const { chromium }: typeof import("playwright") = await npm("playwright")// get URL from userlet urlFromUser = await arg("Enter the URL to screenshot");if (!urlFromUser.match(/^https?:\/\//)) {urlFromUser = `http://${urlFromUser}`;}const pathObj = path.parse(urlFromUser);log(pathObj);// configlet timeout = 5_000;const FOLDER = 'Downloads/screenshot-url';const screenshotFolder = home(FOLDER);const filename = `${pathObj.name}${pathObj.ext}.png`const screenshotPath = home(FOLDER, filename);// Open the windowconst browser = await chromium.launch({ timeout, headless: false });const context = await browser.newContext({ colorScheme: "dark" });const page = await context.newPage();await page.setViewportSize({width: 800,height: 600,});page.setDefaultTimeout(timeout);try {// docs: https://playwright.dev/docs/api/class-pageawait page.goto(urlFromUser);await page.screenshot({ path: screenshotPath })// TODO: shrink the file to a thumbnailawait revealFile(screenshotFolder)log(`Done`)} catch (error) {warn('error', error);}await browser.close();