A Firefox browser extension that sends torrent/magnet links to qBittorrent via its Web API.
Fork of frogmech/send-to-qbittorrent
qbitload/
├── manifest.json # Extension manifest (v2)
├── background.js # Background script - main logic
├── leftclicksend.js # Content script for left-click magnet handling
├── config.html/js # Main popup - API configuration
├── settings.html/js # Settings page - dark mode, left-click, categories
├── category-picker.html/js # Category selection popup window
├── icons/ # Extension icons
└── LICENSE # GPL-3.0
- Browser Action Popup (
config.html) - Opens when clicking the extension icon - Context Menu - Right-click on links to send to qBittorrent
- Content Script (
leftclicksend.js) - Intercepts left-clicks on magnet links
User Action → Content Script/Context Menu → storage.local → Background Script → qBittorrent API
- Manifest v2 (Firefox-compatible)
- Permissions:
contextMenus,storage,http://*/*,https://*/* - Extension ID:
send2qbit@automa.gr - Content script runs on all URLs at
document_idle
Key Functions:
| Function | Purpose |
|---|---|
setBadge(text, color) |
Set browser action badge (status indicator) |
checkServerStatus() |
Check qBittorrent server connectivity, update badge |
getCredentials() |
Retrieve API credentials from storage |
login() |
Authenticate with qBittorrent API |
addTorrent(urls, credentials, category) |
Send torrent to qBittorrent |
getCategories() |
Fetch categories from qBittorrent |
createCategory(name, savePath) |
Create new category |
openQbit() |
Open qBittorrent Web UI in new tab |
regularLogin(tabId) |
Auto-fill login form in qBittorrent Web UI |
createContextMenu() |
Create right-click context menu items |
updateContextMenuTitle() |
Update menu title with default category |
Event Listeners:
runtime.onStartup/runtime.onInstalled- Initialize context menu and check statuscontextMenus.onClicked- Handle right-click menu actionsstorage.onChanged- React to magnet links (from content script), credential changesruntime.onMessage- Handle messages from popups/settingstabs.onUpdated- Handle CSRF disable flow
Badge Status Indicators:
- Gray
?- Not configured - Green (no text) - Connected
- Red
!- Server error or unreachable
Periodic Tasks:
- Server status check every 30 seconds
Runs on all pages when leftClickSend setting is enabled:
- Intercepts clicks on
a[href^="magnet:"]links - Stores magnet URL in
storage.local.magnetLink - Shows toast notification on success/failure
Toast Colors:
- Dark (
#222) - Success - Red (
#c62828) - Failure
Configuration form for qBittorrent API:
- Scheme (HTTP/HTTPS)
- Host
- Port
- Username
- Password
Also includes:
- "Open WebUI" button
- Link to settings page
- Dark mode support
Settings:
- Dark mode toggle
- Left-click sending toggle
- Default category selector
- Create new category form
- "Disable CSRF" button (opens qBittorrent and disables CSRF protection)
Popup window for "Send to qBittorrent (choose category...)" context menu:
- Lists existing categories
- Option to create new category with save path
- Send/Cancel buttons
| Key | Type | Description |
|---|---|---|
apiScheme |
string | "http" or "https" |
apiHost |
string | qBittorrent host |
apiPort |
string | qBittorrent port |
apiUsername |
string | Login username |
apiPassword |
string | Login password |
darkMode |
boolean | Dark mode enabled |
leftClickSend |
boolean | Left-click magnet sending enabled |
defaultCategory |
string | Default category for torrents |
magnetLink |
string | Temporary: magnet URL from content script |
pendingTorrentUrl |
string | Temporary: URL for category picker |
| Endpoint | Method | Purpose |
|---|---|---|
/api/v2/auth/login |
POST | Authenticate |
/api/v2/app/version |
GET | Health check |
/api/v2/torrents/add |
POST | Add torrent |
/api/v2/torrents/categories |
GET | List categories |
/api/v2/torrents/createCategory |
POST | Create category |
| Action | Sender | Handler |
|---|---|---|
openQbit |
config.js | background.js |
disableCSRF |
settings.js | background.js |
getCategories |
settings.js, category-picker.js | background.js |
createCategory |
settings.js, category-picker.js | background.js |
addTorrentWithCategory |
category-picker.js | background.js |
torrentAdded |
background.js | leftclicksend.js |
- "Send to qBittorrent [category]" (
sendToQbit) - Send with default category - "Send to qBittorrent (choose category...)" (
sendToQbitWithCategory) - Open category picker
Applied via CSS classes:
.dark-mode-body- Body background/text.dark-mode-others- Inputs, buttons, selects
Each page (config, settings, category-picker) has its own dark mode initialization.
- Added connection status badge with
setBadge()andcheckServerStatus() - Badge shows: gray
?(not configured), green (connected), red!(error) - Status checked on startup, periodically (30s), and on credential changes
addTorrent()now handles errors and sends success/failure messages- Toast notifications show success (dark) or failure (red with error message)