chore: bootstrap Claude setup #1

Merged
dasemu merged 1 commits from chore/bootstrap into main 2026-10-18 19:20:44 +00:00
11 changed files with 255 additions and 0 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
2
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# PostToolUse hook (Edit/Write): quick syntax check on the file that was just changed.
# No linter/formatter is configured for this project, so this only catches
# JS syntax errors and invalid JSON.
set -euo pipefail
input=$(cat)
file_path=$(echo "$input" | node -e "
let d='';
process.stdin.on('data', c => d += c);
process.stdin.on('end', () => {
try {
const j = JSON.parse(d);
process.stdout.write(j.tool_input?.file_path || '');
} catch { process.stdout.write(''); }
});
" <<< "$input")
[ -z "$file_path" ] && exit 0
[ -f "$file_path" ] || exit 0
case "$file_path" in
*.js)
node --check "$file_path"
;;
*.json)
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$file_path"
;;
*)
exit 0
;;
esac
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Stop hook: quickest meaningful check for this repo. No test suite and no
# linter are configured, so this syntax-checks every tracked JS file and
# validates every tracked JSON file. Fails (blocking) on the first error.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
status=0
while IFS= read -r -d '' f; do
node --check "$f" || status=1
done < <(git ls-files -z -- '*.js')
while IFS= read -r -d '' f; do
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$f" || status=1
done < <(git ls-files -z -- '*.json')
exit $status
+19
View File
@@ -0,0 +1,19 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/lint-file.sh" }
]
}
],
"Stop": [
{
"hooks": [
{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/stop-check.sh" }
]
}
]
}
}
+5
View File
@@ -0,0 +1,5 @@
# This project is a static Firefox WebExtension with no backend and no build
# step. It does not read any environment variables.
#
# This file is kept only to match the repo standard and will be filled in if
# that ever changes.
+36
View File
@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
branches: [development]
push:
branches: [development, main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
# No linter/formatter is configured for this project yet (no package.json).
# This runs the same quick checks as the local Stop hook: JS syntax check
# and JSON validation on every tracked file.
- name: Syntax-check JS files
run: |
status=0
while IFS= read -r -d '' f; do
node --check "$f" || status=1
done < <(git ls-files -z -- '*.js')
exit $status
- name: Validate JSON files
run: |
status=0
while IFS= read -r -d '' f; do
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$f" || status=1
done < <(git ls-files -z -- '*.json')
exit $status
+65
View File
@@ -0,0 +1,65 @@
name: Version bump
on:
push:
branches: [development, main]
permissions:
contents: write
jobs:
bump:
# Never trigger on our own bump commits.
if: >-
github.actor != 'github-actions[bot]' &&
!contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
set -euo pipefail
read -r major minor patch < <(tr '.' ' ' < VERSION)
if [ "${GITHUB_REF_NAME}" = "development" ]; then
patch=$((patch + 1))
else
# main: a merge commit that brings in development's tip is the
# approved development -> main promotion (MINOR bump); anything
# else pushed directly to main is a hotfix (PATCH bump).
if git log -1 --pretty=%P | grep -qE '.+ .+' && \
git merge-base --is-ancestor HEAD^2 origin/development 2>/dev/null; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
fi
new_version="${major}.${minor}.${patch}"
echo "$new_version" > VERSION
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
- name: Commit and push version bump
run: |
git add VERSION
git commit -m "chore(release): v${{ steps.bump.outputs.new_version }} [skip ci]"
git push origin "HEAD:${GITHUB_REF_NAME}"
- name: Merge main back into development
if: github.ref_name == 'main'
run: |
git fetch origin development
git checkout development
git merge --no-edit origin/main
git push origin development
+42
View File
@@ -0,0 +1,42 @@
# CLAUDE.md
## Overview
Firefox WebExtension (Manifest V2) that bypasses paywalls on news sites. This repo is
a fork of the public `bypass-paywalls-firefox-clean` project (magnolia1234); upstream
updates are pulled in wholesale as single commits (see `changelog.txt`), so avoid
unrelated restructuring that would make future merges harder.
## Commands
Plain WebExtension, no build step and no package manager (no `package.json`).
- Syntax-check a JS file: `node --check <file>`
- Validate a JSON file: `node -e "JSON.parse(require('fs').readFileSync(process.argv[1]))" <file>`
- Load unpacked in Firefox: `about:debugging#/runtime/this-firefox` → "Load Temporary
Add-on" → select `manifest.json`.
- No test suite and no linter/formatter are configured.
## Architecture
See `docs/architecture.md` for the file layout (background script, content scripts,
options UI, site-rule data files).
## Conventions
- Site bypass rules live in `sites.js` (upstream) and `custom/sites_custom.json`
(local overrides, merged at runtime). Prefer adding overrides in the `custom/`
files rather than editing the upstream `sites.js` directly.
- `manifest.json` version (`4.2.8.2` style, 4 components) is upstream's own
versioning and is bumped by upstream syncs, not by this repo's release workflow.
This repo's own release version lives in the root `VERSION` file instead.
## Workflow quirks
- Upstream syncs replace large generated files (`sites.js`, `background.js`,
`contentScript*.js`, `README.md`/`README.html`, `changelog.txt`) wholesale —
keep local changes isolated to `custom/` where possible.
## Deployment
Not applicable — this is a browser extension loaded locally or published to the
Firefox Add-ons store manually; there is no server deployment.
## Gotchas
- There is no `development` branch yet; PRs target it once it exists, per the
global git workflow.
- No linter/test tooling exists in this repo; CI and hooks only run syntax/JSON
validation until real tooling is added.
+6
View File
@@ -0,0 +1,6 @@
# LESSONS.md
Recurring mistakes in this repo and how to avoid them.
(No recurring mistakes recorded yet. Add an entry here whenever the same mistake
happens more than once, with a short description and the fix/avoidance rule.)
+1
View File
@@ -0,0 +1 @@
0.1.0
+30
View File
@@ -0,0 +1,30 @@
# Architecture
Firefox Manifest V2 WebExtension with no build step; all files are loaded as-is.
## Layout
- `manifest.json` — extension manifest (background scripts, permissions, popup).
- `background.js` / `sites.js` — background scripts. `sites.js` holds the per-site
paywall bypass rules (cookie handling, regex blocks, DOM tweaks); `background.js`
implements the request interception and rule engine that applies them.
- `contentScript.js`, `contentScript_once.js`, `contentScript_once_var.js` —
content scripts injected into pages to apply DOM-level bypass logic.
- `options/` — options UI and popup (`options.html`, `popup.html`, their JS/CSS,
plus `clearCookies.js`, `version.js`, exclusion/custom-rule sub-pages).
- `custom/` — local override layer:
- `custom/sites_custom.json` — per-site rule overrides/additions, merged with
`sites.js` at runtime.
- `custom/manifest.json` — an alternate manifest (e.g. "limited permissions"
variant), not the one actually used to load the extension by default.
- `sites_updated.json`, `updates.json` — metadata used by the extension's
self-update check against the upstream project.
- `lib/` — small vendored libraries (`purify.min.js`, `empty.js`).
- `changelog.txt`, `README.md`, `README.html` — upstream-maintained docs; replaced
wholesale on each upstream sync, don't hand-edit beyond local notes.
## Data flow (high level)
1. `background.js` reads the merged site rules (`sites.js` + `custom/sites_custom.json`).
2. On matching requests/pages it applies cookie/header rules via the `webRequest` API.
3. Content scripts apply DOM-level rules (removing overlays, revealing hidden
content, injecting archive links, etc.) as instructed by the matched site rule.
4. The options/popup UI lets the user toggle sites, add custom rules, and view status.