Skip to content

Commit 4b28997

Browse files
committed
fix: all concerns raised in PR review
1 parent 8b2a772 commit 4b28997

3 files changed

Lines changed: 50 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Breaking Changes
6+
- **Default AI Model Changed**: The default AI model has been switched from `gpt-4o` to `gemini-3-flash-preview` to make the CLI more accessible out of the box (Google provides a free tier for Gemini API keys). If you previously relied on the default `gpt-4o` and only had an `OPENAI_API_KEY` set, you may need to pass `--ai-model gpt-4o` explicitly.
7+
8+
### Changed
9+
- Improved `handleCookieConsent()` precision to avoid accidentally hiding non-banner layout elements.
10+
- Fixed an issue where the Adblocker plugin would register multiples times during `BrowserEngine` initialization.
11+
312
## 1.0.2 - 2025-08-18
413

514
### Added

README.md

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -104,60 +104,55 @@ npm install
104104
node src/cli.js https://example.com
105105
```
106106

107-
### OpenAI API Key Setup (Required for AI Features)
107+
### API Key Setup (Required for AI Features)
108108

109-
**🚨 IMPORTANT**: Users must set up their OpenAI API key in their terminal environment before using AI features. The package does NOT include pre-configured API keys.
109+
**🚨 IMPORTANT**: Users must set up an API key (Gemini or OpenAI) in their terminal environment before using AI features. The tool defaults to `gemini-3-flash-preview` as Google provides free API keys, making it more accessible.
110110

111-
#### **Step 1: Get OpenAI API Key**
111+
#### **Step 1: Get an API Key**
112112

113-
1. Visit [OpenAI Platform](https://platform.openai.com/api-keys)
114-
2. Create account and generate API key
115-
3. Copy your API key (starts with `sk-`)
113+
- **Gemini (Default)**: Get a free key from [Google AI Studio](https://aistudio.google.com/app/apikey)
114+
- **OpenAI (Alternative)**: Get a key from [OpenAI Platform](https://platform.openai.com/api-keys)
116115

117116
#### **Step 2: Set Environment Variable (REQUIRED)**
118117

119118
**Windows PowerShell:**
120119

121120
```powershell
122121
# Temporary (current session only)
123-
$env:OPENAI_API_KEY="sk-your-api-key-here"
122+
$env:GEMINI_API_KEY="AIzaSy..."
123+
# Or if using OpenAI:
124+
$env:OPENAI_API_KEY="sk-..."
124125
125126
# Permanent (recommended)
126-
[System.Environment]::SetEnvironmentVariable('OPENAI_API_KEY', 'sk-your-api-key-here', 'User')
127-
128-
# Verify setup
129-
echo $env:OPENAI_API_KEY
127+
[System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'AIzaSy...', 'User')
130128
```
131129

132130
**Windows Command Prompt:**
133131

134132
```cmd
135133
# Temporary (current session only)
136-
set OPENAI_API_KEY=sk-your-api-key-here
137-
138-
# Verify setup
139-
echo %OPENAI_API_KEY%
134+
set GEMINI_API_KEY=AIzaSy...
140135
```
141136

142137
**macOS/Linux (Bash/Zsh):**
143138

144139
```bash
145140
# Temporary (current session only)
146-
export OPENAI_API_KEY="sk-your-api-key-here"
141+
export GEMINI_API_KEY="AIzaSy..."
147142

148143
# Permanent (add to ~/.bashrc or ~/.zshrc)
149-
echo 'export OPENAI_API_KEY="sk-your-api-key-here"' >> ~/.bashrc
144+
echo 'export GEMINI_API_KEY="AIzaSy..."' >> ~/.bashrc
150145
source ~/.bashrc
151-
152-
# Verify setup
153-
echo $OPENAI_API_KEY
154146
```
155147

156148
#### **Alternative: Command Line Parameter**
157149

158150
```bash
159151
# Pass API key directly (not recommended for security)
160-
mirror-web-cli https://example.com --ai --openai-key "sk-your-key-here"
152+
# If using Gemini (default)
153+
mirror-web-cli https://example.com --ai --openai-key "AIzaSy..."
154+
# If using OpenAI
155+
mirror-web-cli https://example.com --ai --ai-model gpt-4o --openai-key "sk-..."
161156
```
162157

163158
#### **Step 3: Verify Setup**
@@ -172,9 +167,9 @@ mirror-web-cli https://example.com --ai --debug
172167

173168
**Requirements:**
174169

175-
-**OpenAI API keys only** (must start with `sk-`)
176-
-**GPT-4o model** for intelligent analysis
177-
-**Active OpenAI account** with billing setup
170+
-**Gemini AI API Key** (`AIzaSy...`) or **OpenAI API Key** (`sk-...`)
171+
-**gemini-3-flash-preview** (Default model) or **GPT-4o**
172+
-**Active account** with API access
178173
-**Terminal environment setup** (no pre-configured keys)
179174

180175
### Basic Usage (After Installation)
@@ -203,16 +198,17 @@ mirror-web-cli https://complex-site.com --debug
203198

204199
```bash
205200
# FIRST: Set up API key (see above section)
206-
export OPENAI_API_KEY="sk-your-api-key-here" # Linux/macOS
201+
export GEMINI_API_KEY="AIzaSy..." # Linux/macOS
207202
# or
208-
$env:OPENAI_API_KEY="sk-your-api-key-here" # Windows PowerShell
203+
$env:GEMINI_API_KEY="AIzaSy..." # Windows PowerShell
209204

210-
# THEN: Use AI features
205+
# THEN: Use AI features (defaults to gemini-3-flash-preview)
211206
mirror-web-cli https://example.com --ai
212207
# → Creates: ./example.com-ai-enhanced/
213208

214-
# AI + Clean mirroring
215-
mirror-web-cli https://complex-app.com --ai --clean
209+
# AI + Clean mirroring with OpenAI explicitly:
210+
export OPENAI_API_KEY="sk-..."
211+
mirror-web-cli https://complex-app.com --ai --ai-model gpt-4o --clean
216212
# → Creates: ./complex-app.com-ai-enhanced/
217213
```
218214

@@ -223,8 +219,8 @@ mirror-web-cli https://complex-app.com --ai --clean
223219
mirror-web-cli https://example.com --ai
224220

225221
# You'll see:
226-
# ⚠️ AI features requested but no OPENAI_API_KEY found
227-
# Add OPENAI_API_KEY to your environment...
222+
# ⚠️ AI analysis API key not found. AI analysis will be disabled.
223+
# Set GEMINI_API_KEY environment variable to enable AI features...
228224
# Continuing without AI features...
229225
```
230226

@@ -388,14 +384,13 @@ Options:
388384
-V, --version Show version number
389385
```
390386

391-
### OpenAI API Key Priority
387+
### API Key Priority
392388

393-
The tool checks for OpenAI API keys in this order:
389+
The tool checks for API keys in this order:
394390

395-
1. `--openai-key` command line parameter
396-
2. `OPENAI_API_KEY` environment variable
391+
1. `--openai-key` command line parameter (handles both Gemini and OpenAI keys)
392+
2. `GEMINI_API_KEY` (if default Gemini model is used) or `OPENAI_API_KEY` environment variable
397393
3. If neither is found, AI features are disabled with a helpful message
398-
4. Keys must start with `sk-` (validated automatically)
399394

400395
## 🏗️ Framework Support
401396

@@ -446,24 +441,24 @@ mirror-web-cli https://shop.example.com --debug --clean
446441
# → Creates: ./shop.example.com-standard/ with detailed logging, removes analytics
447442
```
448443

449-
### AI-Powered Analysis (OpenAI)
444+
### AI-Powered Analysis (Gemini/OpenAI)
450445

451446
**Windows PowerShell:**
452447

453448
```powershell
454449
# Set environment variable first
455-
$env:OPENAI_API_KEY="sk-proj-your-openai-key-here"
450+
$env:GEMINI_API_KEY="AIzaSy..."
456451
mirror-web-cli https://complex-app.com --ai --clean
457-
# → Creates: ./complex-app.com-ai-enhanced/ with OpenAI GPT-4o framework analysis
452+
# → Creates: ./complex-app.com-ai-enhanced/ with AI framework analysis
458453
```
459454

460455
**macOS/Linux:**
461456

462457
```bash
463458
# Set environment variable first
464-
export OPENAI_API_KEY="sk-proj-your-openai-key-here"
459+
export GEMINI_API_KEY="AIzaSy..."
465460
mirror-web-cli https://complex-app.com --ai --clean
466-
# → Creates: ./complex-app.com-ai-enhanced/ with OpenAI GPT-4o framework analysis
461+
# → Creates: ./complex-app.com-ai-enhanced/ with AI framework analysis
467462
```
468463

469464
**Cross-platform (using CLI parameter):**

src/core/browser-engine.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import puppeteer from 'puppeteer-extra';
22
import AdblockerPlugin from 'puppeteer-extra-plugin-adblocker';
33
import chalk from 'chalk';
44

5+
let isAdblockerRegistered = false;
6+
57
/**
68
* Browser Engine - Handles browser automation
79
*/
@@ -19,8 +21,9 @@ export class BrowserEngine {
1921
this.page = null;
2022

2123
// Use adblocker plugin if enabled
22-
if (this.options.blockAds) {
24+
if (this.options.blockAds && !isAdblockerRegistered) {
2325
puppeteer.use(AdblockerPlugin({ blockTrackers: true }));
26+
isAdblockerRegistered = true;
2427
}
2528
}
2629

@@ -193,7 +196,7 @@ export class BrowserEngine {
193196
document.querySelectorAll(selector).forEach(el => {
194197
// Only remove if it looks like a popup (likely fixed or absolute)
195198
const style = window.getComputedStyle(el);
196-
if (style.position === 'fixed' || style.position === 'absolute' || el.tagName === 'DIV') {
199+
if (style.position === 'fixed' || style.position === 'absolute') {
197200
el.style.display = 'none';
198201
el.setAttribute('aria-hidden', 'true');
199202
}

0 commit comments

Comments
 (0)