simonw / simonw/shot-scraper

--init-script support

Open
#147 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
2.6k
Forks
128
Avg merge
9d 15h
Merged PRs (30d)
2

Description

Init scripts are special JavaScript that gets run to prime the page before the URL is loaded:

https://playwright.dev/python/docs/api/class-page#page-add-init-script

Adds a script which would be evaluated in one of the following scenarios:

  • Whenever the page is navigated.
  • Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.

The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed Math.random.

This should be an option for shot and javascript and more.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the CLI handles the shot and javascript options, then review the linked Playwright page.add_init_script behavior. Confirm how an init script should be passed through for those commands and determine the additional commands covered by “and more”; done means the option works before page scripts run in each supported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
cli, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.