39 lines
891 B
Markdown
39 lines
891 B
Markdown
# Browser Tab Debugger
|
|
|
|
Execute JavaScript files on Chrome tabs via remote debugging.
|
|
|
|
## Setup
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Start Chrome with remote debugging enabled:
|
|
```bash
|
|
chrome.exe --remote-debugging-port=9222
|
|
```
|
|
|
|
Or on Windows, run from PowerShell:
|
|
```powershell
|
|
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Option 1: VS Code Debug Configuration
|
|
1. Open the JavaScript file you want to execute (e.g., `example.js`)
|
|
2. Press F5 or go to Run and Debug
|
|
3. Select "Execute Script on Current Tab"
|
|
4. The script will run on the currently active Chrome tab
|
|
|
|
### Option 2: Command Line
|
|
```bash
|
|
node run-script.js example.js
|
|
```
|
|
|
|
## How it works
|
|
|
|
The script connects to Chrome's DevTools Protocol on port 9222, finds the first active page tab, and executes your JavaScript code using `Runtime.evaluate`.
|
|
|