The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(ci): drop the CSP-blocked avatar from the chart SVGs
沨沄极客f8dfeffd5cce
diff --git a/.github/star-history/FONT-LICENSE.txt b/.github/star-history/FONT-LICENSE.txtindex 09fd662..116af2d 100644--- a/.github/star-history/FONT-LICENSE.txt+++ b/.github/star-history/FONT-LICENSE.txt@@ -6,7 +6,7 @@ http://scripts.sil.org/OFLhttps://fonts.google.com/specimen/Patrick+Handpatrick-hand.woff2 in this directory is that font, as served by Google Fonts-for the latin range, inlined into the star history SVGs by embed-font.py.+for the latin range, inlined into the star history SVGs by postprocess-svg.py.The OFL permits commercial use, embedding and redistribution, and requiresthat this notice travel with the font. The font is not sold on its own anddiff --git a/.github/star-history/embed-font.py b/.github/star-history/embed-font.pydeleted file mode 100755index c27bcb3..0000000--- a/.github/star-history/embed-font.py+++ /dev/null@@ -1,55 +0,0 @@-#!/usr/bin/env python3-"""Re-embed the chart font that star-history-action strips out.--The action removes the @font-face block on the assumption that GitHub drops it-from SVGs served via <img>. It does not. camo serves them with-- default-src 'none'; img-src data:; style-src 'unsafe-inline'--and a data:-URI font declared inside that inline style still loads (verified-against camo's exact header). Without this step the chart renders in the-browser's default sans-serif instead of the hand-drawn star-history look.--The font is Patrick Hand (SIL OFL), which reads as hand-drawn without the-non-commercial clause that star-history.com's own xkcd Script carries. To-switch faces, drop a new woff2 next to this script and point FONT at it.-"""-import base64-import pathlib-import sys--HERE = pathlib.Path(__file__).parent-FONT = HERE / "patrick-hand.woff2"-# The vendored star-history renderer asks for this family by name, so whatever-# face FONT points at has to be declared under it.-FAMILY = "xkcd"---def main(out_dir: str) -> int:- b64 = base64.b64encode(FONT.read_bytes()).decode("ascii")- face = (- '<defs><style type="text/css">'- f'@font-face{{font-family:"{FAMILY}";'- f"src:url(data:font/woff2;base64,{b64}) format('woff2');"- "font-weight:normal;font-style:normal;}</style></defs>"- )-- svgs = sorted(pathlib.Path(out_dir).glob("*.svg"))- if not svgs:- print(f"No SVGs in {out_dir}; nothing to do.")- return 0-- for svg in svgs:- text = svg.read_text(encoding="utf-8")- if "@font-face" in text:- print(f"{svg.name}: already has @font-face, skipping")- continue- # Insert immediately after the opening <svg ...> tag.- cut = text.index(">") + 1- svg.write_text(text[:cut] + face + text[cut:], encoding="utf-8")- print(f"{svg.name}: embedded {FONT.name} ({svg.stat().st_size // 1024} KB)")- return 0---if __name__ == "__main__":- sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "assets/star-history"))diff --git a/.github/star-history/postprocess-svg.py b/.github/star-history/postprocess-svg.pynew file mode 100755index 0000000..143df1d--- /dev/null+++ b/.github/star-history/postprocess-svg.py@@ -0,0 +1,86 @@+#!/usr/bin/env python3+"""Post-process the rendered star-history SVGs for GitHub's raw host.++Two fixes, both forced by the CSP raw.githubusercontent.com serves the chart+with:++ default-src 'none'; style-src 'unsafe-inline'; sandbox++strip_blocked_images() drops the repo-avatar <image> the renderer puts next to+the chart title. No img-src means no image source is permitted at all, data:+URIs included, so the avatar cannot load and the browser draws a broken-image+icon in its place. The title text is centred with text-anchor="middle"+independently of the avatar, so removing it leaves the heading correct.++embed_font() re-embeds the @font-face the renderer strips out, on the+assumption GitHub drops it. camo does allow it (its CSP names img-src data:+and style-src 'unsafe-inline'), which is the case the renderer had in mind.++The font is Patrick Hand (SIL OFL), which reads as hand-drawn without the+non-commercial clause that star-history.com's own xkcd Script carries. To+switch faces, drop a new woff2 next to this script and point FONT at it.+"""+import base64+import pathlib+import re+import sys++HERE = pathlib.Path(__file__).parent+FONT = HERE / "patrick-hand.woff2"+# The vendored star-history renderer asks for this family by name, so whatever+# face FONT points at has to be declared under it.+FAMILY = "xkcd"+++def strip_blocked_images(text: str) -> tuple[str, int]:+ """Remove every <image> element, plus any clip path left with no referent."""+ text, dropped = re.subn(r"<image\b[^>]*/>", "", text)+ if not dropped:+ return text, 0+ # The renderer wraps the avatar's clip path in its own <svg><defs>. Drop any+ # clip path nothing points at any more, then the container if it went empty.+ for clip in re.findall(r'<clipPath id="([^"]+)">.*?</clipPath>', text):+ if f"url(#{clip})" not in text:+ text = re.sub(+ r'<clipPath id="%s">.*?</clipPath>' % re.escape(clip), "", text+ )+ text = text.replace("<svg><defs></defs></svg>", "")+ return text, dropped+++def main(out_dir: str) -> int:+ b64 = base64.b64encode(FONT.read_bytes()).decode("ascii")+ face = (+ '<defs><style type="text/css">'+ f'@font-face{{font-family:"{FAMILY}";'+ f"src:url(data:font/woff2;base64,{b64}) format('woff2');"+ "font-weight:normal;font-style:normal;}</style></defs>"+ )++ svgs = sorted(pathlib.Path(out_dir).glob("*.svg"))+ if not svgs:+ print(f"No SVGs in {out_dir}; nothing to do.")+ return 0++ for svg in svgs:+ text = svg.read_text(encoding="utf-8")++ text, dropped = strip_blocked_images(text)+ if dropped:+ print(f"{svg.name}: dropped {dropped} CSP-blocked <image> element(s)")++ if "@font-face" in text:+ print(f"{svg.name}: already has @font-face, skipping font")+ else:+ # Insert immediately after the opening <svg ...> tag.+ cut = text.index(">") + 1+ text = text[:cut] + face + text[cut:]+ print(f"{svg.name}: embedded {FONT.name}")++ svg.write_text(text, encoding="utf-8")+ print(f"{svg.name}: {len(text.encode()) // 1024} KB")+ return 0+++if __name__ == "__main__":+ sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "assets/star-history"))diff --git a/.github/workflows/star-history.yml b/.github/workflows/star-history.ymlindex 6afc623..43a0baf 100644--- a/.github/workflows/star-history.yml+++ b/.github/workflows/star-history.yml@@ -5,6 +5,14 @@ on:# Daily at 04:17 UTC. Off the hour to avoid the top-of-hour Actions rush.- cron: '17 4 * * *'workflow_dispatch:+ inputs:+ force:+ # The publish is normally gated on the star data moving, so a change to+ # the SVG post-processing alone would not reach the branch until the+ # next new star. This republishes from the restored chart on demand.+ description: 'Republish even if the star data has not changed'+ type: boolean+ default: false# The stargazers API needs metadata:read + contents:write since GitHub's# 2026-06-30 restriction. The built-in token with contents:write covers both,@@ -62,25 +70,26 @@ jobs:output-dir: ${{ env.CHART_DIR }}type: Datethemes: light,dark- # Only reaches the PNG; the SVGs get their font from embed-font.py+ # Only reaches the PNG; the SVGs get their font from postprocess-svg.py# below. Set so the two do not drift apart.font-family: Patrick Handupdate-readme: falsecommit: false- # The action strips the @font-face, believing GitHub blocks it. It does- # not — see the note in embed-font.py. Without this the chart renders in- # the browser's fallback sans-serif instead of the star-history look.- - name: Embed chart font- if: steps.chart.outputs.changed == 'true'- run: python3 .github/star-history/embed-font.py "$CHART_DIR"+ # Drops the repo-avatar <image> the renderer adds beside the title, which+ # raw.githubusercontent.com's 'default-src none' CSP refuses to load at+ # all — it rendered as a broken-image icon — and re-embeds the @font-face+ # the renderer strips. See postprocess-svg.py for both.+ - name: Post-process chart SVGs+ if: steps.chart.outputs.changed == 'true' || inputs.force+ run: python3 .github/star-history/postprocess-svg.py "$CHART_DIR"# A fresh orphan commit force-pushed over CHART_BRANCH: the branch stays# one commit deep, so a daily 130 KB of regenerated binaries never turns# into a growing history. No rule guards a non-default branch, so this# needs no review and cannot be declined the way the old push to main was.- name: Publish chart to CHART_BRANCH- if: steps.chart.outputs.changed == 'true'+ if: steps.chart.outputs.changed == 'true' || inputs.forceenv:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: |