cli-browser 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -0
- package/bin/cli-browser.js +8 -0
- package/package.json +50 -0
- package/src/bangs.js +53 -0
- package/src/bookmarks.js +45 -0
- package/src/browser.js +1277 -0
- package/src/config.js +51 -0
- package/src/developer.js +246 -0
- package/src/download.js +80 -0
- package/src/history.js +58 -0
- package/src/index.js +45 -0
- package/src/network.js +56 -0
- package/src/plugins.js +74 -0
- package/src/renderer.js +259 -0
- package/src/search.js +113 -0
- package/src/sessions.js +37 -0
- package/src/stats.js +66 -0
- package/src/tabs.js +147 -0
- package/src/themes.js +137 -0
- package/src/ui.js +202 -0
package/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
██████╗██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗███████╗██████╗
|
|
5
|
+
██╔════╝██║ ██║ ██╔══██╗██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔════╝██╔══██╗
|
|
6
|
+
██║ ██║ ██║ ██████╔╝██████╔╝██║ ██║██║ █╗ ██║█████╗ █████╗ ██████╔╝
|
|
7
|
+
██║ ██║ ██║ ██╔══██╗██╔══██╗██║ ██║██║███╗██║██╔══╝ ██╔══╝ ██╔══██╗
|
|
8
|
+
╚██████╗███████╗██║ ██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝███████╗███████╗██║ ██║
|
|
9
|
+
╚═════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚══════╝╚═╝ ╚═╝
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### **Terminal Internet** — Browse the web entirely from your CLI
|
|
13
|
+
|
|
14
|
+
[](https://www.npmjs.com/package/cli-browser)
|
|
15
|
+
[](https://opensource.org/licenses/MIT)
|
|
16
|
+
[](https://nodejs.org)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Web Search** — Search via SearXNG with engine, category, and time filters
|
|
25
|
+
- **Page Browsing** — Render HTML pages as beautiful CLI text
|
|
26
|
+
- **Reader Mode** — Clean, distraction-free reading
|
|
27
|
+
- **Tab Management** — Multiple tabs with full navigation
|
|
28
|
+
- **History & Bookmarks** — Persistent across sessions
|
|
29
|
+
- **Bang Commands** — Quick access to YouTube, GitHub, Wikipedia, npm, etc.
|
|
30
|
+
- **Developer Tools** — Inspect frameworks, headers, cookies, security scan
|
|
31
|
+
- **Downloads** — Download files directly from the terminal
|
|
32
|
+
- **Themes** — Dark, Hacker, Minimal, Ocean, Sunset
|
|
33
|
+
- **Plugin System** — Extend with plugins
|
|
34
|
+
- **Statistics** — Track your browsing activity
|
|
35
|
+
- **Autocomplete** — Tab completion for all commands
|
|
36
|
+
- **Network Controls** — Proxy support, User-Agent switching
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install -g cli-browser
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or run directly:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx cli-browser
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Launch the browser
|
|
58
|
+
cli-browser
|
|
59
|
+
|
|
60
|
+
# Or use the short alias
|
|
61
|
+
cb
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
### Search
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
search cats # Basic web search
|
|
72
|
+
s cats # Shortcut
|
|
73
|
+
search cats --engine google # Use specific engine
|
|
74
|
+
search cats --engine duckduckgo # DuckDuckGo
|
|
75
|
+
search cats --type image # Image search
|
|
76
|
+
search cats --type video # Video search
|
|
77
|
+
search cats --type news # News search
|
|
78
|
+
search ai news --time day # Last 24 hours
|
|
79
|
+
search ai news --time week # Last week
|
|
80
|
+
search ai --multi # Multi-category search
|
|
81
|
+
image cats # Quick image search
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Browsing
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
open 1 # Open search result #1
|
|
88
|
+
open https://example.com # Open URL directly
|
|
89
|
+
link 3 # Follow link #3 on page
|
|
90
|
+
reader # Reader mode (clean view)
|
|
91
|
+
info # Page metadata
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Navigation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
back # Go back (or 'b')
|
|
98
|
+
forward # Go forward (or 'f')
|
|
99
|
+
home # Home screen
|
|
100
|
+
refresh # Reload current page
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Tabs
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
tab new # Create new tab
|
|
107
|
+
tab switch 2 # Switch to tab 2
|
|
108
|
+
tab close 2 # Close tab 2
|
|
109
|
+
tabs # List all tabs
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### History
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
history # View recent history
|
|
116
|
+
history open 2 # Revisit entry #2
|
|
117
|
+
history clear # Clear all history
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Bookmarks
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bookmark add # Bookmark current page
|
|
124
|
+
bookmark list # List all bookmarks
|
|
125
|
+
bookmark open 1 # Open bookmark #1
|
|
126
|
+
bookmark remove 1 # Remove bookmark #1
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Bang Commands
|
|
130
|
+
|
|
131
|
+
Quick-search specific sites:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
!yt cats # YouTube
|
|
135
|
+
!gh react # GitHub
|
|
136
|
+
!wiki javascript # Wikipedia
|
|
137
|
+
!npm express # npm
|
|
138
|
+
!so async await # Stack Overflow
|
|
139
|
+
!reddit programming # Reddit
|
|
140
|
+
!mdn fetch api # MDN Web Docs
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Developer Tools
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
inspect # Detect frameworks & technologies
|
|
147
|
+
headers # View HTTP response headers
|
|
148
|
+
cookies # View page cookies
|
|
149
|
+
scan example.com # Full security scan
|
|
150
|
+
robots # View robots.txt
|
|
151
|
+
sitemap # View sitemap.xml
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Downloads
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
download https://example.com/f.zip # Download a file
|
|
158
|
+
downloads # List all downloads
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### AI Features
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
summary # Summarize current page
|
|
165
|
+
ask what is this page about # Ask about page content
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Themes
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
theme # List available themes
|
|
172
|
+
theme dark # Dark theme (default)
|
|
173
|
+
theme hacker # Green hacker theme
|
|
174
|
+
theme minimal # Clean minimal theme
|
|
175
|
+
theme ocean # Blue ocean theme
|
|
176
|
+
theme sunset # Red sunset theme
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Network
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
proxy set 127.0.0.1:8080 # Set proxy
|
|
183
|
+
proxy clear # Remove proxy
|
|
184
|
+
ua chrome # Chrome user-agent
|
|
185
|
+
ua firefox # Firefox user-agent
|
|
186
|
+
ua mobile # Mobile user-agent
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Sessions
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
login example.com # Save session cookies
|
|
193
|
+
session list # List saved sessions
|
|
194
|
+
session clear # Clear all sessions
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Plugins
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
plugin list # List installed plugins
|
|
201
|
+
plugin install youtube # Install plugin
|
|
202
|
+
plugin remove youtube # Remove plugin
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Statistics
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
stats # View browsing statistics
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### General
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
help # Show all commands
|
|
215
|
+
help search # Help for search commands
|
|
216
|
+
help browse # Help for browsing
|
|
217
|
+
help dev # Help for developer tools
|
|
218
|
+
clear # Clear screen
|
|
219
|
+
exit # Exit browser
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Architecture
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
CLI Browser
|
|
228
|
+
↓
|
|
229
|
+
Search Engine (SearXNG)
|
|
230
|
+
↓
|
|
231
|
+
searxng.exe.xyz
|
|
232
|
+
↓
|
|
233
|
+
Web Pages → Rendered CLI Output
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Project Structure
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
cli-browser/
|
|
240
|
+
├── bin/
|
|
241
|
+
│ └── cli-browser.js # Entry point
|
|
242
|
+
├── src/
|
|
243
|
+
│ ├── index.js # Main app / REPL
|
|
244
|
+
│ ├── browser.js # Core browser engine
|
|
245
|
+
│ ├── search.js # SearXNG search client
|
|
246
|
+
│ ├── renderer.js # HTML → CLI renderer
|
|
247
|
+
│ ├── tabs.js # Tab management
|
|
248
|
+
│ ├── history.js # History management
|
|
249
|
+
│ ├── bookmarks.js # Bookmark management
|
|
250
|
+
│ ├── developer.js # Developer tools
|
|
251
|
+
│ ├── download.js # Download manager
|
|
252
|
+
│ ├── network.js # Proxy & UA manager
|
|
253
|
+
│ ├── themes.js # Theme engine
|
|
254
|
+
│ ├── stats.js # Statistics tracker
|
|
255
|
+
│ ├── bangs.js # Bang commands
|
|
256
|
+
│ ├── plugins.js # Plugin system
|
|
257
|
+
│ ├── sessions.js # Session/cookie manager
|
|
258
|
+
│ ├── config.js # Persistent configuration
|
|
259
|
+
│ └── ui.js # UI components
|
|
260
|
+
├── package.json
|
|
261
|
+
└── README.md
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Workflow Example
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
$ cli-browser
|
|
270
|
+
|
|
271
|
+
▸ search javascript frameworks
|
|
272
|
+
[1] React – A JavaScript library for building user interfaces
|
|
273
|
+
[2] Vue.js – The Progressive JavaScript Framework
|
|
274
|
+
[3] Angular – One framework for mobile & desktop
|
|
275
|
+
|
|
276
|
+
▸ open 1
|
|
277
|
+
══ React ══
|
|
278
|
+
React is a free and open-source JavaScript library...
|
|
279
|
+
Links:
|
|
280
|
+
[1] Getting Started
|
|
281
|
+
[2] Documentation
|
|
282
|
+
[3] GitHub
|
|
283
|
+
|
|
284
|
+
▸ link 2
|
|
285
|
+
══ React Documentation ══
|
|
286
|
+
...
|
|
287
|
+
|
|
288
|
+
▸ bookmark add
|
|
289
|
+
✓ Bookmarked: React Documentation
|
|
290
|
+
|
|
291
|
+
▸ back
|
|
292
|
+
▸ tab new
|
|
293
|
+
▸ search node.js
|
|
294
|
+
▸ !gh react
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Requirements
|
|
300
|
+
|
|
301
|
+
- **Node.js** >= 18.0.0
|
|
302
|
+
- Internet connection
|
|
303
|
+
- Terminal with Unicode support
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## License
|
|
308
|
+
|
|
309
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cli-browser",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A powerful Terminal Internet browser — search, browse, navigate, and explore the web entirely from your CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cli-browser": "./bin/cli-browser.js",
|
|
9
|
+
"cb": "./bin/cli-browser.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "node bin/cli-browser.js",
|
|
13
|
+
"dev": "node --watch bin/cli-browser.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cli",
|
|
17
|
+
"browser",
|
|
18
|
+
"terminal",
|
|
19
|
+
"web",
|
|
20
|
+
"search",
|
|
21
|
+
"searxng",
|
|
22
|
+
"terminal-browser",
|
|
23
|
+
"cli-browser",
|
|
24
|
+
"web-browser",
|
|
25
|
+
"text-browser"
|
|
26
|
+
],
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^1.7.0",
|
|
31
|
+
"chalk": "^5.3.0",
|
|
32
|
+
"cheerio": "^1.0.0",
|
|
33
|
+
"cli-table3": "^0.6.5",
|
|
34
|
+
"conf": "^13.0.0",
|
|
35
|
+
"ora": "^8.0.0",
|
|
36
|
+
"boxen": "^8.0.0",
|
|
37
|
+
"figures": "^6.0.0",
|
|
38
|
+
"wrap-ansi": "^9.0.0",
|
|
39
|
+
"string-width": "^7.0.0",
|
|
40
|
+
"cli-highlight": "^2.1.0"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"bin/",
|
|
47
|
+
"src/",
|
|
48
|
+
"README.md"
|
|
49
|
+
]
|
|
50
|
+
}
|
package/src/bangs.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import config from './config.js';
|
|
2
|
+
|
|
3
|
+
class BangCommands {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.commands = config.get('bangCommands');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
isBang(input) {
|
|
9
|
+
return input.startsWith('!');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
parse(input) {
|
|
13
|
+
const parts = input.split(/\s+/);
|
|
14
|
+
const bang = parts[0];
|
|
15
|
+
const query = parts.slice(1).join(' ');
|
|
16
|
+
return { bang, query };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getUrl(bang, query) {
|
|
20
|
+
const baseUrl = this.commands[bang];
|
|
21
|
+
if (!baseUrl) return null;
|
|
22
|
+
return baseUrl + encodeURIComponent(query);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
listBangs() {
|
|
26
|
+
const bangMap = {
|
|
27
|
+
'!yt': 'YouTube',
|
|
28
|
+
'!gh': 'GitHub',
|
|
29
|
+
'!wiki': 'Wikipedia',
|
|
30
|
+
'!npm': 'npm',
|
|
31
|
+
'!so': 'Stack Overflow',
|
|
32
|
+
'!reddit': 'Reddit',
|
|
33
|
+
'!mdn': 'MDN Web Docs',
|
|
34
|
+
'!twitter': 'Twitter/X',
|
|
35
|
+
'!amazon': 'Amazon',
|
|
36
|
+
'!maps': 'Google Maps',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return Object.entries(this.commands).map(([bang, url]) => ({
|
|
40
|
+
bang,
|
|
41
|
+
name: bangMap[bang] || url,
|
|
42
|
+
url,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
addBang(bang, url) {
|
|
47
|
+
if (!bang.startsWith('!')) bang = '!' + bang;
|
|
48
|
+
this.commands[bang] = url;
|
|
49
|
+
config.set('bangCommands', this.commands);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default new BangCommands();
|
package/src/bookmarks.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import config from './config.js';
|
|
2
|
+
|
|
3
|
+
class BookmarkManager {
|
|
4
|
+
add(title, url) {
|
|
5
|
+
const bookmarks = config.get('bookmarks') || [];
|
|
6
|
+
const exists = bookmarks.find(b => b.url === url);
|
|
7
|
+
if (exists) {
|
|
8
|
+
throw new Error('Already bookmarked');
|
|
9
|
+
}
|
|
10
|
+
const item = {
|
|
11
|
+
id: Date.now(),
|
|
12
|
+
title,
|
|
13
|
+
url,
|
|
14
|
+
createdAt: new Date().toISOString(),
|
|
15
|
+
};
|
|
16
|
+
bookmarks.push(item);
|
|
17
|
+
config.set('bookmarks', bookmarks);
|
|
18
|
+
return item;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getAll() {
|
|
22
|
+
return config.get('bookmarks') || [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getByIndex(idx) {
|
|
26
|
+
const bookmarks = this.getAll();
|
|
27
|
+
return bookmarks[idx - 1] || null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
remove(idx) {
|
|
31
|
+
const bookmarks = this.getAll();
|
|
32
|
+
if (idx < 1 || idx > bookmarks.length) {
|
|
33
|
+
throw new Error('Invalid bookmark index');
|
|
34
|
+
}
|
|
35
|
+
const removed = bookmarks.splice(idx - 1, 1);
|
|
36
|
+
config.set('bookmarks', bookmarks);
|
|
37
|
+
return removed[0];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
clear() {
|
|
41
|
+
config.set('bookmarks', []);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default new BookmarkManager();
|