agentleFS
NVIDIAKnown publisherNVIDIA/TensorRT/tools/Polygraphy/.agents/skills/headless-screenshots/SKILL.md

headless-screenshots

Skill13k starsChanged 5 months agoApache-2.0View on GitHub

Use this skill when asked to take browser screenshots of web pages or web-based tools in a headless/automated way — especially when the page uses HTML canvas (e.g. Cytoscape.js, WebGL, Chart.js) and the screenshots need to show canvas-rendered content like graph nodes, edge labels, or drawn shapes. Also use when asked to automate multi-step browser interactions (clicks, drags, form fills) before screenshotting.

  • Installs packages

Trending

Quiet this year.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the NVIDIA/TensorRT repository that our weekly crawl found: only 4 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    After wait_until="networkidle", add extra sleep for pages that run layout algorithms (e.g.

    line 55
  2. Distinctive:

    If a page displays the model/file path in its UI (e.g.

    line 100

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Headless Browser Screenshots with Playwright

Stack

  • Playwright (Python) — pip install playwright && python3 -m playwright install chromium
  • Chromium headless shell — installed by the command above

Critical: Canvas rendering requires software rendering

Headless Chromium GPU-composites canvas off-screen by default. canvas.getContext('2d').getImageData() returns all-zero pixels, and canvas-rendered content (text labels, shapes drawn via fillText/strokeRect, etc.) does not appear in page.screenshot().

Fix: always launch with --use-gl=swiftshader

browser = pw.chromium.launch(
    headless=True,
    args=["--disable-gpu", "--use-gl=swiftshader"],
)

This forces software rendering so canvas content is fully composited into screenshots.

How to tell you need this

  • DOM-rendered content (divs, HTML overlays) shows up fine in screenshots
  • Canvas-drawn content (graph edges, IO node labels, chart axes) is missing
  • canvas.getContext('2d').getImageData(x, y, 1, 1).data returns [0, 0, 0, 0] everywhere

Serving pages

Serve HTML via a local HTTP server — snap-confined browsers and sandboxed environments block file:// paths:

srv = subprocess.Popen(
    ["python3", "-m", "http.server", "8765"],
    cwd="/tmp/my_assets",
    stdout=subprocess.PIPE, stderr=subprocess.PIPE,
)
# wait for it to be ready
import socket, time
def wait_for_port(port, timeout=10):
    deadline = time.time() + timeout
    while time.time() < deadline:
        try: socket.create_connection(("127.0.0.1", port), 0.5).close(); return True
        except OSError: time.sleep(0.2)

Wait times for JS-heavy pages

After wait_until="networkidle", add extra sleep for pages that run layout algorithms (e.g. Cytoscape dagre, D3 force-directed):

page.goto(url, wait_until="networkidle")
time.sleep(3.5)   # let JS layout finish rendering

Accessing Cytoscape.js instances

window.cy is shadowed by the #cy DOM element (browser auto-creates globals from element IDs). Use the internal registry instead:

GET_CY = "document.getElementById('cy')._cyreg.cy"

# Get rendered node positions
positions = page.evaluate(f"""
    () => {{
        var cy = {GET_CY};
        var result = [];
        cy.nodes('.op').forEach(function(n) {{
            var pos = n.renderedPosition();
            result.push({{x: pos.x, y: pos.y}});
        }});
        return result;
    }}
""")

renderedPosition() returns pixel coordinates relative to the canvas container div (not the page).

Box-select / drag interactions

canvas_box = page.locator("#cy").bounding_box()
cx, cy_y = canvas_box["x"], canvas_box["y"]

page.mouse.move(cx + x1, cy_y + y1)
page.mouse.down()
page.mouse.move(cx + x2, cy_y + y2, steps=12)  # steps for smooth drag
page.mouse.up()
time.sleep(1.5)  # let selection + panel update

Avoiding identifying paths in screenshots

If a page displays the model/file path in its UI (e.g. in a command preview), copy the file to a neutral temp location before serving:

import shutil, pathlib
shutil.copy(src_model, "/tmp/polygraphy_docs/model.onnx")
# serve from /tmp/polygraphy_docs so displayed path is non-identifying

Full boilerplate

import subprocess, time, socket, glob, os
from pathlib import Path
from playwright.sync_api import sync_playwright

CHROMIUM_ARGS = ["--disable-gpu", "--use-gl=swiftshader"]
VIEWPORT = {"width": 1600, "height": 900}

def wait_for_server(port, timeout=15):
    deadline = time.time() + timeout
    while time.time() < deadline:
        try: socket.create_connection(("127.0.0.1", port), 0.5).close(); return True
        except OSError: time.sleep(0.2)
    return False

with sync_playwright() as pw:
    browser = pw.chromium.launch(headless=True, args=CHROMIUM_ARGS)
    page = browser.new_page(viewport=VIEWPORT)
    page.goto("http://127.0.0.1:PORT/", wait_until="networkidle")
    time.sleep(3.5)

    page.screenshot(path="output.png")
    browser.close()

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.