shot-scraper icon indicating copy to clipboard operation
shot-scraper copied to clipboard

Idea: plugins, packaging JavaScript to be injected into pages

Open simonw opened this issue 3 years ago • 2 comments

Tweet: https://twitter.com/simonw/status/1514657436287705119

I want to be able to use tricks like this one - where Readability.js is injected into a page - without relying on CDNs: https://til.simonwillison.net/shot-scraper/readability

One option would be to package things like this up as plugins using Pluggy (as seen in Datasette) - then serve the JavaScript assets using a /-/shot-scraper-xyz/plugins/... route configured using https://playwright.dev/python/docs/api/class-page#page-route

simonw avatar Apr 14 '22 17:04 simonw

Just to add an additional example — Playwright does a version of this behind the scenes itself. It "injects" helper scripts into every page.

rdmurphy avatar Apr 20 '22 18:04 rdmurphy

Plugins would be great. Especially if that makes it possible to detect if an image already exists or to not save a page if a 404 or other status code is detected.

jefftriplett avatar Jul 23 '22 16:07 jefftriplett