Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coverage/
test-results/
playwright-report/
playwright/.cache/
yt-storage.json

# IDE and editor files
.vscode/
Expand Down
288 changes: 152 additions & 136 deletions README.md

Large diffs are not rendered by default.

52 changes: 49 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,56 @@ copy_common_files() {
local target_dir=$1
cp "$PROJECT_ROOT/src/background.js" \
"$PROJECT_ROOT/src/content.js" \
"$PROJECT_ROOT/src/content-css.js" \
"$PROJECT_ROOT/src/content-url.js" \
"$PROJECT_ROOT/src/content-import.js" \
"$PROJECT_ROOT/src/content-playlists.js" \
"$PROJECT_ROOT/src/content-info.js" \
"$PROJECT_ROOT/src/content-thumbnails.js" \
"$PROJECT_ROOT/src/content-messages.js" \
"$PROJECT_ROOT/src/popup.html" \
"$PROJECT_ROOT/src/popup-core.js" \
"$PROJECT_ROOT/src/popup-utils.js" \
"$PROJECT_ROOT/src/popup-import.js" \
"$PROJECT_ROOT/src/popup-settings.js" \
"$PROJECT_ROOT/src/popup-search.js" \
"$PROJECT_ROOT/src/popup-data-pages.js" \
"$PROJECT_ROOT/src/popup-history-display.js" \
"$PROJECT_ROOT/src/popup-video-pagination.js" \
"$PROJECT_ROOT/src/popup-analytics-core.js" \
"$PROJECT_ROOT/src/popup-analytics-charts.js" \
"$PROJECT_ROOT/src/popup-analytics-extra.js" \
"$PROJECT_ROOT/src/popup-playlists.js" \
"$PROJECT_ROOT/src/popup-subscriptions.js" \
"$PROJECT_ROOT/src/popup-theme.js" \
"$PROJECT_ROOT/src/popup-shorts.js" \
"$PROJECT_ROOT/src/popup-localization.js" \
"$PROJECT_ROOT/src/popup.js" \
"$PROJECT_ROOT/src/import.html" \
"$PROJECT_ROOT/src/import.js" \
"$PROJECT_ROOT/src/feed.html" \
"$PROJECT_ROOT/src/feed-core.js" \
"$PROJECT_ROOT/src/feed-state-utils.js" \
"$PROJECT_ROOT/src/feed-cards.js" \
"$PROJECT_ROOT/src/feed-local-search.js" \
"$PROJECT_ROOT/src/feed-home.js" \
"$PROJECT_ROOT/src/feed-analytics.js" \
"$PROJECT_ROOT/src/feed-subscriptions-view.js" \
"$PROJECT_ROOT/src/feed-playlist-import.js" \
"$PROJECT_ROOT/src/feed-playlists-view.js" \
"$PROJECT_ROOT/src/feed-history-view.js" \
"$PROJECT_ROOT/src/feed-settings.js" \
"$PROJECT_ROOT/src/feed-localization.js" \
"$PROJECT_ROOT/src/feed-backup.js" \
"$PROJECT_ROOT/src/feed-data-pipeline.js" \
"$PROJECT_ROOT/src/feed-subscribe-results.js" \
"$PROJECT_ROOT/src/feed-youtube-search-core.js" \
"$PROJECT_ROOT/src/feed-youtube-search-render.js" \
"$PROJECT_ROOT/src/feed-channel-view.js" \
"$PROJECT_ROOT/src/feed-refresh.js" \
"$PROJECT_ROOT/src/feed.js" \
"$PROJECT_ROOT/src/storage.js" \
"$PROJECT_ROOT/src/sync-service.js" \
"$PROJECT_ROOT/src/content-subscriptions.js" \
"$PROJECT_ROOT/src/indexeddb-storage.js" \
"$target_dir/"
cp "$PROJECT_ROOT/src/icon"*.png "$target_dir/"
Expand Down Expand Up @@ -65,7 +111,7 @@ copy_common_files "$PROJECT_ROOT/build/firefox"
cp "$PROJECT_ROOT/src/manifest.firefox.json" "$PROJECT_ROOT/build/firefox/manifest.json"
cd "$PROJECT_ROOT/build/firefox"
# For Firefox, we need to zip the files directly, not the directory
zip -j "../../dist/youtube-local-history-firefox-v$VERSION.zip" manifest.json background.js content.js popup.html popup.js storage.js sync-service.js indexeddb-storage.js icon*.png -x ".*"
zip -j "../../dist/youtube-local-history-firefox-v$VERSION.zip" manifest.json background.js content.js content-css.js content-url.js content-import.js content-playlists.js content-info.js content-thumbnails.js content-messages.js popup.html popup-core.js popup-utils.js popup-import.js popup-settings.js popup-search.js popup-data-pages.js popup-history-display.js popup-video-pagination.js popup-analytics-core.js popup-analytics-charts.js popup-analytics-extra.js popup-playlists.js popup-subscriptions.js popup-theme.js popup-shorts.js popup-localization.js popup.js import.html import.js feed.html feed-core.js feed-state-utils.js feed-cards.js feed-local-search.js feed-home.js feed-analytics.js feed-subscriptions-view.js feed-playlist-import.js feed-playlists-view.js feed-history-view.js feed-settings.js feed-localization.js feed-backup.js feed-data-pipeline.js feed-subscribe-results.js feed-youtube-search-core.js feed-youtube-search-render.js feed-channel-view.js feed-refresh.js feed.js storage.js content-subscriptions.js indexeddb-storage.js icon*.png -x ".*"
# Include _locales in the Firefox zip if it exists
if [ -d _locales ]; then
zip -r "../../dist/youtube-local-history-firefox-v$VERSION.zip" _locales -x ".*"
Expand All @@ -77,4 +123,4 @@ echo "Chrome extension (ZIP): dist/youtube-local-history-chrome-v$VERSION.zip"
echo "Chrome extension (CRX): dist/youtube-local-history-chrome-v$VERSION.crx"
echo "Firefox extension: dist/youtube-local-history-firefox-v$VERSION.zip"
echo -e "\nPackage contents:"
ls -lh dist/
ls -lh dist/
File renamed without changes
176 changes: 78 additions & 98 deletions docs/build.md
Original file line number Diff line number Diff line change
@@ -1,146 +1,126 @@
# 🔨 Build Instructions
# Build Instructions

## 🛠️ Development Setup
This guide explains how to install dependencies, run checks, and load YT re:Watch for local browser testing.

This guide explains how to set up your development environment and build YT re:Watch extension for both Chrome and Firefox.
## Prerequisites

### Prerequisites
- **Node.js 14+** - [Download here](https://nodejs.org/)
- **NPM or Yarn** - Package manager (comes with Node.js)
- **Chrome/Firefox** - For testing the extension
- **Git** - For cloning the repository
- Node.js 18 or newer
- npm
- Git
- Firefox or Chrome/Chromium
- Git Bash, WSL, or another Bash-compatible shell if you want to run `build.sh`

### Local Development
## Install

#### 1. Clone the Repository
```bash
git clone https://github.com/EdinUser/YouTubeLocalHistory.git
cd YouTubeLocalHistory
npm install
```

#### 2. Install Dependencies
## Local Firefox Testing

This is the recommended development path on Windows.

```bash
npm install
npm run prepare:firefox
```

This will install all required dependencies including:
- **Jest** - For unit and integration testing
- **Playwright** - For end-to-end testing
- **ESLint** - For code linting
- **Babel** - For JavaScript transpilation
Then open Firefox:

#### 3. Build the Extension
```bash
# Build both Chrome and Firefox versions
./build.sh
1. Go to `about:debugging`.
2. Click `This Firefox`.
3. Click `Load Temporary Add-on`.
4. Select `build/firefox/manifest.json`.

# Or build specific browser
./build.sh chrome
./build.sh firefox
```
After code changes, run `npm run prepare:firefox` again, then reload the temporary add-on.

## Local Chrome Testing

#### 4. Load in Browser
After building, the extensions will be available in the `dist/` folder:
- **Chrome**: `dist/youtube-local-history-chrome-v{version}.zip`
- **Firefox**: `dist/youtube-local-history-firefox-v{version}.zip`
Use the release build script to prepare `build/chrome`, or copy the source files into a Chrome build folder using the same file list from `build.sh`.

**To load in browser:**
- **Chrome**: Go to `chrome://extensions/`, enable "Developer mode", click "Load unpacked" and select the `build/chrome` folder
- **Firefox**: Go to `about:debugging`, click "This Firefox", then "Load Temporary Add-on" and select the `build/firefox` folder
Then open Chrome:

### Testing
1. Go to `chrome://extensions/`.
2. Enable `Developer mode`.
3. Click `Load unpacked`.
4. Select `build/chrome`.

## Checks

Run these before opening a pull request:

#### Run All Tests
```bash
npm test
npm run lint
npm test -- --runInBand
npm run prepare:firefox
npx web-ext lint --source-dir=build/firefox
```

#### Run Specific Test Suites
Useful test commands:

```bash
# Unit tests only
npm test
npm run test:unit

# Integration tests only
npm run test:integration

# Memory tests only
npm run test:memory

# End-to-end tests (requires Playwright browsers)
npm run test:e2e

# Watch mode for development
npm run test:watch
npm run test:coverage
```

#### Test Coverage
`npm run test:e2e` uses Playwright. If browsers are missing, run:

```bash
npm run test:coverage
npx playwright install
```

This generates a coverage report in the `coverage/` folder.
## Release Packaging

### Building for Production
The release script builds browser folders and creates ZIP packages in `dist/`.

#### Build Both Browsers
```bash
./build.sh
npm run build
```

This will:
1. Clean previous builds
2. Merge locale files
3. Build Chrome extension (with signing if certificates are available)
4. Build Firefox extension
5. Create distribution packages in `dist/`
or directly:

#### Build Specific Browser
```bash
# Chrome only
./build.sh chrome

# Firefox only
./build.sh firefox
./build.sh
```

#### Output Files
After building, you'll find:
- **Chrome**: `dist/youtube-local-history-chrome-v{version}.zip` and `.crx` (if signed)
- **Firefox**: `dist/youtube-local-history-firefox-v{version}.zip`
Notes:

### Project Structure
- `build.sh` is a Bash script. On Windows, run it from Git Bash or WSL.
- Chrome CRX signing requires `google-chrome` and a private key at `certs/privatekey.pem`, or paths supplied through `CHROME_EXTENSION_DIR` and `PRIVATE_KEY_PATH`.
- If Chrome signing is not configured, the Chrome ZIP may still be useful, but CRX generation can warn or fail depending on your environment.

```
src/
├── _locales/ # Multi-language support files
│ ├── en/ # English translations
│ ├── de/ # German translations
│ └── ... # Other languages
├── manifest.chrome.json # Chrome extension manifest
├── manifest.firefox.json # Firefox extension manifest
├── background.js # Service worker/background script
├── content.js # Content script for YouTube pages
├── popup.html/js # Extension popup interface
├── storage.js # Local storage management
└── indexeddb-storage.js # IndexedDB wrapper for unlimited storage
```
Expected release outputs:

### Development Tips
- `dist/youtube-local-history-chrome-v{version}.zip`
- `dist/youtube-local-history-chrome-v{version}.crx` when signing succeeds
- `dist/youtube-local-history-firefox-v{version}.zip`

#### Hot Reloading
- The build script doesn't include hot reloading
- After making changes, run `./build.sh` and reload the extension in your browser
- Use the "Reload" button in `chrome://extensions/` or `about:debugging`
## Project Structure

```text
src/
_locales/ Translation files
manifest.chrome.json Chrome extension manifest
manifest.firefox.json Firefox extension manifest
background.js Extension background script
content*.js YouTube page content scripts
popup*.js Toolbar popup
feed*.js Full local feed page
import.html, import.js Import page
storage.js Browser storage wrapper
indexeddb-storage.js IndexedDB history storage
```

#### Debugging
- Enable "Debug Mode" in the extension settings for detailed logging
- Check browser console for errors
- Use `chrome://extensions/` or `about:debugging` for extension management
## Debugging

#### Common Issues
- **Build fails**: Ensure Node.js 14+ and all dependencies are installed
- **Extension not loading**: Check manifest permissions and browser compatibility
- **Tests failing**: Ensure Playwright browsers are installed (`npx playwright install`)
- Enable Debug Mode in Settings for extra logs.
- Use `about:debugging` in Firefox to inspect the temporary extension.
- Use `chrome://extensions/` in Chrome to inspect service worker/content script errors.
- If the local feed looks stale, reload the extension and click `Refresh` in the feed page.

---
*For more technical details, see [Technical Documentation](./technical.md)*
For more technical details, see [Technical Documentation](./technical.md).
Loading