# bensgith/userscripts architecture

> Architecture diagram of the GitHub repository bensgith/userscripts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bensgith/userscripts
- Repository: https://github.com/bensgith/userscripts

## Overview

##### Project type and purpose
- This is a personal “monorepo” of independent browser user-scripts (files ending in .user.js), each enhancing or theming a specific website or editor.
- It includes a GitHub Actions workflow to mirror the repo to GitLab, but contains no server, backend or database components.

##### File structure
- Top-level directories and files
– .github/workflows/sync-to-gitlab.yml: CI pipeline definition
– Several .user.js scripts in the root (e.g. clean-blog-articles.user.js, the-black-zhihu.user.js)
– A “vscode” folder containing more .user.js scripts targeting VS Code web or editor interfaces
- No “src” vs “dist” split, no package.json or build scripts – these are static files.
- No tests folder, no runtime server configs.

##### README
- Very high-level description: “Just a collection of user scripts for myself.”
- No further architectural notes or dependencies mentioned.

##### Main components
a. Repository hosting
– GitHub repo (this codebase, .github workflows)
– Mirror on GitLab (via CI)
b. CI/CD pipeline
– GitHub Actions job “sync-to-gitlab”
c. Artifact consumers
– Browser user script manager (Tampermonkey/Violentmonkey, etc.)
– Direct URL fetcher (users install scripts by browsing raw .user.js links)
d. User script files
– Root-scoped scripts (site-specific enhancements)
– vscode-scoped scripts (editor enhancements)

##### Relationships and interactions
- Developer pushes commits → triggers GitHub Actions → sync workflow runs → pushes mirror to GitLab
- End user points their user-script manager to the raw URL on GitHub (or GitLab) → downloads and runs the script in the browser/VS Code environment

##### Architectural patterns and design principles
- Monorepo pattern for grouping independent scripts
- CI as code (GitHub workflow for automatic mirroring)
- Static content distribution (no build step)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actors
    Developer["Developer"]:::external
    Tampermonkey["Tampermonkey/Browser"]:::external

    %% Hosting Platforms
    GitHubRepo["GitHub Repo"]:::hosting
    GitLabMirror["GitLab Mirror"]:::hosting

    %% CI Workflow
    subgraph "GitHub Repository"
        direction TB
        README["README.md"]:::code
        subgraph ".github/workflows"
            direction TB
            SyncJob["sync-to-gitlab.yml"]:::ci
        end
        subgraph "Root User Scripts"
            direction TB
            CleanBlog["clean-blog-articles.user.js"]:::script
            BlackZhihu["the-black-zhihu.user.js"]:::script
            Vocabulary["vocabulary.user.js"]:::script
            Weread["weread-portrait.user.js"]:::script
            WideWechat["wide-black-wechat.user.js"]:::script
        end
        subgraph "VSCode User Scripts"
            direction TB
            VSFeedly["feedly.user.js"]:::script
            VSInoreader["inoreader.user.js"]:::script
            VSTwitter["twitter.user.js"]:::script
            VSWechatArticle["wechat-article.user.js"]:::script
            VSWechatWeb["wechat-web.user.js"]:::script
            VSZhihu["zhihu.user.js"]:::script
        end
    end

    %% Connections
    Developer -->|"push commits"| GitHubRepo
    GitHubRepo -->|"trigger sync"| SyncJob
    SyncJob -->|"sync"| GitLabMirror
    Tampermonkey -->|"install via HTTP GET"| CleanBlog
    Tampermonkey -->|"install via HTTP GET"| BlackZhihu
    Tampermonkey -->|"install via HTTP GET"| Vocabulary
    Tampermonkey -->|"install via HTTP GET"| Weread
    Tampermonkey -->|"install via HTTP GET"| WideWechat
    Tampermonkey -->|"install via HTTP GET"| VSFeedly
    Tampermonkey -->|"install via HTTP GET"| VSInoreader
    Tampermonkey -->|"install via HTTP GET"| VSTwitter
    Tampermonkey -->|"install via HTTP GET"| VSWechatArticle
    Tampermonkey -->|"install via HTTP GET"| VSWechatWeb
    Tampermonkey -->|"install via HTTP GET"| VSZhihu

    %% Click Events
    click SyncJob "https://github.com/bensgith/userscripts/blob/main/.github/workflows/sync-to-gitlab.yml"
    click README "https://github.com/bensgith/userscripts/blob/main/README.md"
    click CleanBlog "https://github.com/bensgith/userscripts/blob/main/clean-blog-articles.user.js"
    click BlackZhihu "https://github.com/bensgith/userscripts/blob/main/the-black-zhihu.user.js"
    click Vocabulary "https://github.com/bensgith/userscripts/blob/main/vocabulary.user.js"
    click Weread "https://github.com/bensgith/userscripts/blob/main/weread-portrait.user.js"
    click WideWechat "https://github.com/bensgith/userscripts/blob/main/wide-black-wechat.user.js"
    click VSFeedly "https://github.com/bensgith/userscripts/blob/main/vscode/feedly.user.js"
    click VSInoreader "https://github.com/bensgith/userscripts/blob/main/vscode/inoreader.user.js"
    click VSTwitter "https://github.com/bensgith/userscripts/blob/main/vscode/twitter.user.js"
    click VSWechatArticle "https://github.com/bensgith/userscripts/blob/main/vscode/wechat-article.user.js"
    click VSWechatWeb "https://github.com/bensgith/userscripts/blob/main/vscode/wechat-web.user.js"
    click VSZhihu "https://github.com/bensgith/userscripts/blob/main/vscode/zhihu.user.js"

    %% Styles
    classDef hosting fill:#bbdefb,stroke:#2196f3,stroke-width:2px
    classDef ci fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px
    classDef script fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
    classDef code fill:#e1bee7,stroke:#8e24aa,stroke-width:2px
    classDef external fill:#f5f5f5,stroke:#9e9e9e,stroke-width:2px
```
