From 7285c82fb7d6ec3ce1a3c4fe8c85f98986b10a20 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Sun, 18 Oct 2026 11:42:15 +0200 Subject: [PATCH] chore: bootstrap Claude setup Add root CLAUDE.md, docs/, LESSONS.md, .env.example, .claude/settings.json hooks (syntax-check on edit and on stop), and CI workflows (lint via node --check, and a VERSION-based semver bump) for this plain-JS, no-build Chrome extension. Co-Authored-By: Claude Sonnet 5 --- .claude/bootstrap-version | 1 + .claude/settings.json | 25 +++++++++++++ .env.example | 4 +++ .github/workflows/ci.yml | 21 +++++++++++ .github/workflows/version.yml | 67 +++++++++++++++++++++++++++++++++++ CLAUDE.md | 44 +++++++++++++++++++++++ LESSONS.md | 6 ++++ VERSION | 1 + docs/development.md | 30 ++++++++++++++++ 9 files changed, 199 insertions(+) create mode 100644 .claude/bootstrap-version create mode 100644 .claude/settings.json create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/version.yml create mode 100644 CLAUDE.md create mode 100644 LESSONS.md create mode 100644 VERSION create mode 100644 docs/development.md diff --git a/.claude/bootstrap-version b/.claude/bootstrap-version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/.claude/bootstrap-version @@ -0,0 +1 @@ +2 diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..542483d --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,25 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "file=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.js) node --check \"$file\" ;; esac" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "cd \"$CLAUDE_PROJECT_DIR\" && find . -name '*.js' -not -path './.git/*' -print0 | xargs -0 -n1 node --check" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2364abc --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +# This project is a client-side browser extension with no backend and no +# build step, so it reads no environment variables at runtime or build time. +# This file is kept for consistency with the repo standard; add variables here +# (names only, no values) if the project ever needs any. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e52145b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +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 or test suite is configured for this plain-JS browser extension + # (no package.json/bundler). This runs a syntax check on every JS file. + - name: Syntax check (node --check) + run: | + find . -name "*.js" -not -path "./.git/*" -print0 | xargs -0 -n1 node --check diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..7d41643 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,67 @@ +name: Version bump + +on: + push: + branches: [development, main] + +permissions: + contents: write + +jobs: + bump: + 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 + 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 + current=$(cat VERSION) + IFS='.' read -r major minor patch <<< "$current" + + if [ "${{ github.ref_name }}" = "development" ]; then + patch=$((patch + 1)) + else + # push to main: MINOR bump only when this commit is already part of + # development's history (i.e. an approved development -> main merge + # PR); otherwise treat it as a direct hotfix push (PATCH bump). + if git fetch origin development >/dev/null 2>&1 && \ + git merge-base --is-ancestor "$(git rev-parse HEAD)" origin/development; 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 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: | + if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then + git fetch origin development + git checkout -B development origin/development + git merge --no-edit origin/main + git push origin development + else + echo "No development branch yet; skipping merge-back." + fi diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..a984d58 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,44 @@ +# CLAUDE.md + +## Overview +Bypass Paywalls Clean (BPC) — a Manifest V3 Chrome/Chromium extension that bypasses +paywalls on supported news sites. This is a tracked fork/mirror of the upstream +GitFlic project (`magnolia1234/bypass-paywalls-chrome-clean`); changes here are +mostly periodic syncs from upstream plus local tweaks. + +## Commands +Plain vanilla JS extension: no package.json, no bundler, no build step. +- Syntax check: `find . -name "*.js" -not -path "./.git/*" -print0 | xargs -0 -n1 node --check` +- No test suite and no linter are configured in this repo. +- Load locally: `chrome://extensions` → Developer Mode → *Load unpacked* → select this folder. + +## Architecture +- `manifest.json` — MV3 manifest (permissions, content scripts, service worker). +- `background.js` — service worker: request/header rewriting, site-rule dispatch. +- `contentScript.js`, `contentScript_once.js`, `contentScript_once_var.js` — injected page scripts. +- `sites.js` / `sites_updated.json` — per-site bypass rules (the bulk of upstream updates). +- `options/` — popup and options UI (HTML/CSS/JS). +- `custom/` — user-defined custom site manifest/rules. +- `lib/` — vendored third-party JS (e.g. `purify.min.js`). +- See `docs/` for anything not obvious from the code. + +## Conventions +- Keep edits minimal and localized; `sites.js`/`README.md` mirror upstream content — + avoid reformatting them so future upstream merges stay low-conflict. +- No build step: files run as-is in the browser, so keep syntax ES-compatible with + `minimum_chrome_version` in `manifest.json`. + +## Workflow quirks +- `manifest.json`'s `version` field tracks the upstream extension release (4-part, + e.g. `4.2.8.2`) and is NOT the repo's own semver — do not bump it by hand or via CI. + This repo's own release tracking uses the root `VERSION` file instead. +- `README.md` / `README.html` are upstream-authored docs (site list, install steps); + prefer syncing them from upstream over hand-editing. + +## Deployment +Not a deployed service — distributed as an unpacked folder or a `.crx` file. No +`web-deploy` setup applies. + +## Gotchas +- No `.env` / secrets: this is a client-side browser extension with no backend. +- `node --check` only validates syntax, not behavior — there is no real test coverage. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..621b835 --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,6 @@ +# Lessons + +Recurring mistakes in this repo and how to avoid them. Read before starting work; +add an entry whenever a mistake repeats. + +(No recurring mistakes recorded yet.) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..47dbbca --- /dev/null +++ b/docs/development.md @@ -0,0 +1,30 @@ +# Development notes + +This repo tracks the upstream [Bypass Paywalls Clean](https://gitflic.ru/project/magnolia1234/bypass-paywalls-chrome-clean) +project. Most changes are periodic syncs of `sites.js`, `background.js`, +`contentScript*.js` and `README.md`/`README.html` from upstream releases. + +## Local testing + +1. Open `chrome://extensions` in a Chromium-based browser. +2. Enable Developer Mode. +3. Click *Load unpacked* and select the repo root (it contains `manifest.json`). +4. Reload the extension after any file change. + +## Syntax checking + +There is no bundler or test suite. The quickest available check is a Node.js +syntax check on every JS file: + +```sh +find . -name "*.js" -not -path "./.git/*" -print0 | xargs -0 -n1 node --check +``` + +This only catches syntax errors, not logic bugs — there is no real lint or test +coverage configured. + +## Versioning + +`manifest.json`'s `version` field mirrors the upstream extension release and is +not touched by this repo's own CI. This repo's own release counter lives in the +root `VERSION` file, bumped automatically by `.github/workflows/version.yml`. -- 2.54.1