# tomorrow505/auto_feed_js architecture

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

- Interactive diagram: https://gitdiagram.com/tomorrow505/auto_feed_js
- Repository: https://github.com/tomorrow505/auto_feed_js

## Overview

##### Project type and purpose
- This is neither a traditional multi-tier “backend + frontend + database” system nor a server-hosted web app. It’s a Tampermonkey/Greasemonkey userscript written in JavaScript (auto_feed.user.js) that runs entirely in the browser.
- Purpose: “one-click repost” (auto-filling forms, fetching metadata, handling images, torrent clean-up) across 100+ PT tracker sites and external sources (IMDb, Douban, public image hosts).

##### File structure
- Top-level script: auto_feed.user.js – core logic, site detection, HTTP requests, DOM injection & form filling.
- Helper script: iTS Upload Helper.js – utilities for torrent cleaning / uploading.
- Static HTMLs (bdc_faq.html, bluebird_rules.html, etc.) – offline documentation of per-site rules and FAQ, not part of runtime.
- temple_search_urls – likely a data file mapping site names to search endpoints.
- README.md & license.

##### README
- Confirms it’s a browser userscript with features like:
- Scraping the source page (magnet, title, description)
- Fetching IMDb ID → retrieving Douban metadata
- Uploading images to a public image bed to avoid hotlinking
- Cleaning torrent files automatically
- Filling target tracker forms & submitting
- Optional one-click multi-site repost, duplication check, custom site ordering, internationalization.

a. Main components:
1) User & Browser Environment (Chrome/Firefox) with the Userscript Manager (Tampermonkey)
2) auto_feed.user.js core module
3) iTS Upload Helper submodule
4) temple_search_urls data module
5) Source PT Tracker sites (Site A, Site B, …)
6) Destination PT Tracker sites (could be same as source or multiple)
7) External Metadata Services (IMDb, Douban APIs or web pages)
8) Public Image Hosting Service (for anti-hotlinking)
9) (Optional) Local storage/cache in the browser (for speed)

b. Relationships & data flows:
- User clicks “Repost” button injected into a source site page → auto_feed.user.js kicks in.
- Script scrapes page DOM for torrent/magnet and descriptive fields.
- Script calls external IMDb/Douban endpoints via GM_xmlhttpRequest (cross-domain).
- Script processes image tags, re-uploads to public CDN via its upload API.
- With all data assembled, script auto-fills the target site’s form fields and triggers submission.
- iTS Upload Helper may intercept and clean the .torrent before it’s attached.
- Data/config (temple_search_urls) guides which endpoints to scrape or submit to.

c. Architectural patterns & design principles
- Modular plugin pattern: core script + helper modules + data file
- Event-driven UI injection: detect page URL → initialize injection → bind UI controls
- Asynchronous HTTP pipeline: fetch → transform → fill → submit
- Single-page, client-side only—no server components

d. Key technologies & libraries
- JavaScript (ES6+)
- Greasemonkey/Tampermonkey APIs (GM_xmlhttpRequest, GM_setValue, GM_getValue)
- HTML templates for per-site UI injection
- temple_search_urls data structure (JSON or JS object)
- (Possibly) Promise libraries (e.g., bluebird if included)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser + Userscript Manager"
        BROWSER["Browser (Chrome/Firefox) + Tampermonkey"]:::runtime
        CORE["auto_feed.user.js (Core Module)"]:::module
        HELPER["iTS Upload Helper.js (Helper Module)"]:::module
        DATA["temple_search_urls (Data Module)"]:::module
    end

    subgraph "External Services"
        SOURCES["Source PT Tracker Sites"]:::external
        DEST["Destination PT Tracker Sites"]:::external
        IMDB["IMDb API"]:::external
        DOUBAN["Douban API"]:::external
        CDN["Public Image Hosting Service"]:::external
    end

    subgraph "Documentation"
        README["README.md"]:::docs
        LICENSE["license"]:::docs
        subgraph "Per-Site FAQ & Rules"
            BDC_FAQ["bdc_faq.html"]:::docs
            BDC_RULES["bdc_rules.html"]:::docs
            BLUE_FAQ["bluebird_faq.html"]:::docs
            BLUE_RULES["bluebird_rules.html"]:::docs
            BLUE_BONUS["bluebird_bonus.html"]:::docs
            FL_FAQ["fl_faq.html"]:::docs
            FL_RULES["fl_rules.html"]:::docs
            HDF_FAQ["hdf_faq.html"]:::docs
            HDF_RULES["hdf_rules.html"]:::docs
            XTHOR_FAQ["xthor_faq.html"]:::docs
            XTHOR_RULES["xthor_rules.html"]:::docs
        end
    end

    BROWSER -->|loads script| CORE
    CORE -->|uses helper| HELPER
    CORE -->|loads data| DATA
    CORE -->|scrape torrent & metadata| SOURCES
    CORE -->|fetch metadata| IMDB
    CORE -->|fetch metadata| DOUBAN
    CORE -->|upload images| CDN
    CORE -->|fill & submit form| DEST

    classDef runtime fill:#f9f,stroke:#333,stroke-width:1px
    classDef module fill:#bbf,stroke:#333,stroke-width:1px
    classDef external fill:#fbb,stroke:#333,stroke-width:1px
    classDef docs fill:#bfb,stroke:#333,stroke-width:1px

    click CORE "https://github.com/tomorrow505/auto_feed_js/blob/master/auto_feed.user.js"
    click HELPER "https://github.com/tomorrow505/auto_feed_js/blob/master/iTS Upload Helper.js"
    click DATA "https://github.com/tomorrow505/auto_feed_js/tree/master/temple_search_urls"
    click README "https://github.com/tomorrow505/auto_feed_js/blob/master/README.md"
    click LICENSE "https://github.com/tomorrow505/auto_feed_js/tree/master/license"
    click BDC_FAQ "https://github.com/tomorrow505/auto_feed_js/blob/master/bdc_faq.html"
    click BDC_RULES "https://github.com/tomorrow505/auto_feed_js/blob/master/bdc_rules.html"
    click BLUE_FAQ "https://github.com/tomorrow505/auto_feed_js/blob/master/bluebird_faq.html"
    click BLUE_RULES "https://github.com/tomorrow505/auto_feed_js/blob/master/bluebird_rules.html"
    click BLUE_BONUS "https://github.com/tomorrow505/auto_feed_js/blob/master/bluebird_bonus.html"
    click FL_FAQ "https://github.com/tomorrow505/auto_feed_js/blob/master/fl_faq.html"
    click FL_RULES "https://github.com/tomorrow505/auto_feed_js/blob/master/fl_rules.html"
    click HDF_FAQ "https://github.com/tomorrow505/auto_feed_js/blob/master/hdf_faq.html"
    click HDF_RULES "https://github.com/tomorrow505/auto_feed_js/blob/master/hdf_rules.html"
    click XTHOR_FAQ "https://github.com/tomorrow505/auto_feed_js/blob/master/xthor_faq.html"
    click XTHOR_RULES "https://github.com/tomorrow505/auto_feed_js/blob/master/xthor_rules.html"
```
