@jackwener/opencli 0.9.8 → 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/CDP.md +1 -1
- package/CDP.zh-CN.md +1 -1
- package/CLI-ELECTRON.md +2 -2
- package/CLI-EXPLORER.md +4 -4
- package/README.md +15 -57
- package/README.zh-CN.md +16 -59
- package/SKILL.md +10 -8
- package/TESTING.md +7 -7
- package/dist/browser/daemon-client.d.ts +37 -0
- package/dist/browser/daemon-client.js +82 -0
- package/dist/browser/discover.d.ts +11 -34
- package/dist/browser/discover.js +15 -205
- package/dist/browser/errors.d.ts +6 -20
- package/dist/browser/errors.js +24 -63
- package/dist/browser/index.d.ts +2 -11
- package/dist/browser/index.js +5 -11
- package/dist/browser/mcp.d.ts +9 -18
- package/dist/browser/mcp.js +70 -284
- package/dist/browser/page.d.ts +28 -6
- package/dist/browser/page.js +210 -85
- package/dist/browser.test.js +4 -225
- package/dist/cli-manifest.json +167 -0
- package/dist/clis/neteasemusic/like.d.ts +1 -0
- package/dist/clis/neteasemusic/like.js +25 -0
- package/dist/clis/neteasemusic/lyrics.d.ts +1 -0
- package/dist/clis/neteasemusic/lyrics.js +47 -0
- package/dist/clis/neteasemusic/next.d.ts +1 -0
- package/dist/clis/neteasemusic/next.js +26 -0
- package/dist/clis/neteasemusic/play.d.ts +1 -0
- package/dist/clis/neteasemusic/play.js +26 -0
- package/dist/clis/neteasemusic/playing.d.ts +1 -0
- package/dist/clis/neteasemusic/playing.js +59 -0
- package/dist/clis/neteasemusic/playlist.d.ts +1 -0
- package/dist/clis/neteasemusic/playlist.js +46 -0
- package/dist/clis/neteasemusic/prev.d.ts +1 -0
- package/dist/clis/neteasemusic/prev.js +25 -0
- package/dist/clis/neteasemusic/search.d.ts +1 -0
- package/dist/clis/neteasemusic/search.js +52 -0
- package/dist/clis/neteasemusic/status.d.ts +1 -0
- package/dist/clis/neteasemusic/status.js +16 -0
- package/dist/clis/neteasemusic/volume.d.ts +1 -0
- package/dist/clis/neteasemusic/volume.js +54 -0
- package/dist/daemon.d.ts +13 -0
- package/dist/daemon.js +187 -0
- package/dist/doctor.d.ts +27 -61
- package/dist/doctor.js +70 -601
- package/dist/doctor.test.js +30 -170
- package/dist/main.js +6 -25
- package/dist/pipeline/executor.test.js +1 -0
- package/dist/pipeline/steps/browser.js +2 -2
- package/dist/pipeline/steps/intercept.js +1 -2
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +46 -160
- package/dist/types.d.ts +6 -0
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/manifest.json +31 -0
- package/extension/package.json +16 -0
- package/extension/src/background.ts +293 -0
- package/extension/src/cdp.ts +125 -0
- package/extension/src/protocol.ts +57 -0
- package/extension/store-assets/screenshot-1280x800.png +0 -0
- package/extension/tsconfig.json +15 -0
- package/extension/vite.config.ts +18 -0
- package/package.json +5 -5
- package/src/browser/daemon-client.ts +113 -0
- package/src/browser/discover.ts +18 -232
- package/src/browser/errors.ts +30 -100
- package/src/browser/index.ts +6 -12
- package/src/browser/mcp.ts +78 -278
- package/src/browser/page.ts +222 -88
- package/src/browser.test.ts +3 -233
- package/src/clis/chatgpt/README.md +1 -1
- package/src/clis/chatgpt/README.zh-CN.md +1 -1
- package/src/clis/neteasemusic/README.md +31 -0
- package/src/clis/neteasemusic/README.zh-CN.md +31 -0
- package/src/clis/neteasemusic/like.ts +28 -0
- package/src/clis/neteasemusic/lyrics.ts +53 -0
- package/src/clis/neteasemusic/next.ts +30 -0
- package/src/clis/neteasemusic/play.ts +30 -0
- package/src/clis/neteasemusic/playing.ts +62 -0
- package/src/clis/neteasemusic/playlist.ts +51 -0
- package/src/clis/neteasemusic/prev.ts +29 -0
- package/src/clis/neteasemusic/search.ts +58 -0
- package/src/clis/neteasemusic/status.ts +18 -0
- package/src/clis/neteasemusic/volume.ts +61 -0
- package/src/daemon.ts +217 -0
- package/src/doctor.test.ts +32 -193
- package/src/doctor.ts +74 -668
- package/src/main.ts +6 -23
- package/src/pipeline/executor.test.ts +1 -0
- package/src/pipeline/steps/browser.ts +2 -2
- package/src/pipeline/steps/intercept.ts +1 -2
- package/src/setup.ts +47 -183
- package/src/types.ts +1 -0
package/dist/cli-manifest.json
CHANGED
|
@@ -2514,6 +2514,173 @@
|
|
|
2514
2514
|
],
|
|
2515
2515
|
"type": "yaml"
|
|
2516
2516
|
},
|
|
2517
|
+
{
|
|
2518
|
+
"site": "neteasemusic",
|
|
2519
|
+
"name": "like",
|
|
2520
|
+
"description": "Like/unlike the currently playing song",
|
|
2521
|
+
"strategy": "ui",
|
|
2522
|
+
"browser": true,
|
|
2523
|
+
"args": [],
|
|
2524
|
+
"type": "ts",
|
|
2525
|
+
"modulePath": "neteasemusic/like.js",
|
|
2526
|
+
"domain": "localhost",
|
|
2527
|
+
"columns": [
|
|
2528
|
+
"Status"
|
|
2529
|
+
]
|
|
2530
|
+
},
|
|
2531
|
+
{
|
|
2532
|
+
"site": "neteasemusic",
|
|
2533
|
+
"name": "lyrics",
|
|
2534
|
+
"description": "Get the lyrics of the currently playing song",
|
|
2535
|
+
"strategy": "ui",
|
|
2536
|
+
"browser": true,
|
|
2537
|
+
"args": [],
|
|
2538
|
+
"type": "ts",
|
|
2539
|
+
"modulePath": "neteasemusic/lyrics.js",
|
|
2540
|
+
"domain": "localhost",
|
|
2541
|
+
"columns": [
|
|
2542
|
+
"Line"
|
|
2543
|
+
]
|
|
2544
|
+
},
|
|
2545
|
+
{
|
|
2546
|
+
"site": "neteasemusic",
|
|
2547
|
+
"name": "next",
|
|
2548
|
+
"description": "Skip to the next song",
|
|
2549
|
+
"strategy": "ui",
|
|
2550
|
+
"browser": true,
|
|
2551
|
+
"args": [],
|
|
2552
|
+
"type": "ts",
|
|
2553
|
+
"modulePath": "neteasemusic/next.js",
|
|
2554
|
+
"domain": "localhost",
|
|
2555
|
+
"columns": [
|
|
2556
|
+
"Status"
|
|
2557
|
+
]
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
"site": "neteasemusic",
|
|
2561
|
+
"name": "play",
|
|
2562
|
+
"description": "Toggle play/pause for the current song",
|
|
2563
|
+
"strategy": "ui",
|
|
2564
|
+
"browser": true,
|
|
2565
|
+
"args": [],
|
|
2566
|
+
"type": "ts",
|
|
2567
|
+
"modulePath": "neteasemusic/play.js",
|
|
2568
|
+
"domain": "localhost",
|
|
2569
|
+
"columns": [
|
|
2570
|
+
"Status"
|
|
2571
|
+
]
|
|
2572
|
+
},
|
|
2573
|
+
{
|
|
2574
|
+
"site": "neteasemusic",
|
|
2575
|
+
"name": "playing",
|
|
2576
|
+
"description": "Get the currently playing song info",
|
|
2577
|
+
"strategy": "ui",
|
|
2578
|
+
"browser": true,
|
|
2579
|
+
"args": [],
|
|
2580
|
+
"type": "ts",
|
|
2581
|
+
"modulePath": "neteasemusic/playing.js",
|
|
2582
|
+
"domain": "localhost",
|
|
2583
|
+
"columns": [
|
|
2584
|
+
"Title",
|
|
2585
|
+
"Artist",
|
|
2586
|
+
"Album",
|
|
2587
|
+
"Duration",
|
|
2588
|
+
"Progress"
|
|
2589
|
+
]
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
"site": "neteasemusic",
|
|
2593
|
+
"name": "playlist",
|
|
2594
|
+
"description": "Show the current playback queue / playlist",
|
|
2595
|
+
"strategy": "ui",
|
|
2596
|
+
"browser": true,
|
|
2597
|
+
"args": [],
|
|
2598
|
+
"type": "ts",
|
|
2599
|
+
"modulePath": "neteasemusic/playlist.js",
|
|
2600
|
+
"domain": "localhost",
|
|
2601
|
+
"columns": [
|
|
2602
|
+
"Index",
|
|
2603
|
+
"Title",
|
|
2604
|
+
"Artist"
|
|
2605
|
+
]
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
"site": "neteasemusic",
|
|
2609
|
+
"name": "prev",
|
|
2610
|
+
"description": "Go back to the previous song",
|
|
2611
|
+
"strategy": "ui",
|
|
2612
|
+
"browser": true,
|
|
2613
|
+
"args": [],
|
|
2614
|
+
"type": "ts",
|
|
2615
|
+
"modulePath": "neteasemusic/prev.js",
|
|
2616
|
+
"domain": "localhost",
|
|
2617
|
+
"columns": [
|
|
2618
|
+
"Status"
|
|
2619
|
+
]
|
|
2620
|
+
},
|
|
2621
|
+
{
|
|
2622
|
+
"site": "neteasemusic",
|
|
2623
|
+
"name": "search",
|
|
2624
|
+
"description": "Search for songs, artists, albums, or playlists",
|
|
2625
|
+
"strategy": "ui",
|
|
2626
|
+
"browser": true,
|
|
2627
|
+
"args": [
|
|
2628
|
+
{
|
|
2629
|
+
"name": "query",
|
|
2630
|
+
"type": "str",
|
|
2631
|
+
"required": true,
|
|
2632
|
+
"positional": true,
|
|
2633
|
+
"help": "Search query"
|
|
2634
|
+
}
|
|
2635
|
+
],
|
|
2636
|
+
"type": "ts",
|
|
2637
|
+
"modulePath": "neteasemusic/search.js",
|
|
2638
|
+
"domain": "localhost",
|
|
2639
|
+
"columns": [
|
|
2640
|
+
"Index",
|
|
2641
|
+
"Title",
|
|
2642
|
+
"Artist"
|
|
2643
|
+
]
|
|
2644
|
+
},
|
|
2645
|
+
{
|
|
2646
|
+
"site": "neteasemusic",
|
|
2647
|
+
"name": "status",
|
|
2648
|
+
"description": "Check CDP connection to NeteaseMusic Desktop",
|
|
2649
|
+
"strategy": "ui",
|
|
2650
|
+
"browser": true,
|
|
2651
|
+
"args": [],
|
|
2652
|
+
"type": "ts",
|
|
2653
|
+
"modulePath": "neteasemusic/status.js",
|
|
2654
|
+
"domain": "localhost",
|
|
2655
|
+
"columns": [
|
|
2656
|
+
"Status",
|
|
2657
|
+
"Url",
|
|
2658
|
+
"Title"
|
|
2659
|
+
]
|
|
2660
|
+
},
|
|
2661
|
+
{
|
|
2662
|
+
"site": "neteasemusic",
|
|
2663
|
+
"name": "volume",
|
|
2664
|
+
"description": "Get or set the volume level (0-100)",
|
|
2665
|
+
"strategy": "ui",
|
|
2666
|
+
"browser": true,
|
|
2667
|
+
"args": [
|
|
2668
|
+
{
|
|
2669
|
+
"name": "level",
|
|
2670
|
+
"type": "str",
|
|
2671
|
+
"required": false,
|
|
2672
|
+
"positional": true,
|
|
2673
|
+
"help": "Volume level 0-100 (omit to read current)"
|
|
2674
|
+
}
|
|
2675
|
+
],
|
|
2676
|
+
"type": "ts",
|
|
2677
|
+
"modulePath": "neteasemusic/volume.js",
|
|
2678
|
+
"domain": "localhost",
|
|
2679
|
+
"columns": [
|
|
2680
|
+
"Status",
|
|
2681
|
+
"Volume"
|
|
2682
|
+
]
|
|
2683
|
+
},
|
|
2517
2684
|
{
|
|
2518
2685
|
"site": "notion",
|
|
2519
2686
|
"name": "export",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const likeCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const likeCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'like',
|
|
5
|
+
description: 'Like/unlike the currently playing song',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Status'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
const result = await page.evaluate(`
|
|
13
|
+
(function() {
|
|
14
|
+
// The like/heart button in the player bar
|
|
15
|
+
const btn = document.querySelector('.m-playbar .icn-love, .m-playbar [class*="like"], .m-player [class*="love"], [data-action="like"]');
|
|
16
|
+
if (!btn) return 'Like button not found';
|
|
17
|
+
|
|
18
|
+
const wasLiked = btn.classList.contains('loved') || btn.classList.contains('active') || btn.getAttribute('data-liked') === 'true';
|
|
19
|
+
btn.click();
|
|
20
|
+
return wasLiked ? 'Unliked' : 'Liked';
|
|
21
|
+
})()
|
|
22
|
+
`);
|
|
23
|
+
return [{ Status: result }];
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const lyricsCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const lyricsCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'lyrics',
|
|
5
|
+
description: 'Get the lyrics of the currently playing song',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Line'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
// Try to open lyrics panel if not visible
|
|
13
|
+
await page.evaluate(`
|
|
14
|
+
(function() {
|
|
15
|
+
const btn = document.querySelector('.m-playbar .icn-lyric, [class*="lyric-btn"], [data-action="lyric"]');
|
|
16
|
+
if (btn) btn.click();
|
|
17
|
+
})()
|
|
18
|
+
`);
|
|
19
|
+
await page.wait(1);
|
|
20
|
+
const lyrics = await page.evaluate(`
|
|
21
|
+
(function() {
|
|
22
|
+
// Look for lyrics container
|
|
23
|
+
const selectors = [
|
|
24
|
+
'.m-lyric p, .m-lyric [class*="line"]',
|
|
25
|
+
'[class*="lyric-content"] p',
|
|
26
|
+
'.listlyric li',
|
|
27
|
+
'[class*="lyric"] [class*="line"]',
|
|
28
|
+
'.j-lyric p',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
for (const sel of selectors) {
|
|
32
|
+
const nodes = document.querySelectorAll(sel);
|
|
33
|
+
if (nodes.length > 0) {
|
|
34
|
+
return Array.from(nodes).map(n => (n.textContent || '').trim()).filter(l => l.length > 0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Fallback: try the body text for any lyrics-like content
|
|
39
|
+
return [];
|
|
40
|
+
})()
|
|
41
|
+
`);
|
|
42
|
+
if (lyrics.length === 0) {
|
|
43
|
+
return [{ Line: 'No lyrics found. Try opening the lyrics panel first.' }];
|
|
44
|
+
}
|
|
45
|
+
return lyrics.map((line) => ({ Line: line }));
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const nextCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const nextCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'next',
|
|
5
|
+
description: 'Skip to the next song',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Status'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
const clicked = await page.evaluate(`
|
|
13
|
+
(function() {
|
|
14
|
+
const btn = document.querySelector('.m-playbar .btnfwd, .m-playbar [class*="next"], .m-player .btn-next, [data-action="next"]');
|
|
15
|
+
if (btn) { btn.click(); return true; }
|
|
16
|
+
return false;
|
|
17
|
+
})()
|
|
18
|
+
`);
|
|
19
|
+
if (!clicked) {
|
|
20
|
+
// Fallback: Ctrl+Right is common next-track shortcut
|
|
21
|
+
await page.pressKey('Control+ArrowRight');
|
|
22
|
+
}
|
|
23
|
+
await page.wait(1);
|
|
24
|
+
return [{ Status: 'Skipped to next song' }];
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const playCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'play',
|
|
5
|
+
description: 'Toggle play/pause for the current song',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Status'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
// Click the play/pause button or use Space key
|
|
13
|
+
const clicked = await page.evaluate(`
|
|
14
|
+
(function() {
|
|
15
|
+
const btn = document.querySelector('.m-playbar .btnp, .m-playbar [class*="play"], .m-player .btn-play, [data-action="play"]');
|
|
16
|
+
if (btn) { btn.click(); return true; }
|
|
17
|
+
return false;
|
|
18
|
+
})()
|
|
19
|
+
`);
|
|
20
|
+
if (!clicked) {
|
|
21
|
+
// Fallback: use Space key which is the universal play/pause shortcut
|
|
22
|
+
await page.pressKey('Space');
|
|
23
|
+
}
|
|
24
|
+
return [{ Status: 'Play/Pause toggled' }];
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playingCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const playingCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'playing',
|
|
5
|
+
description: 'Get the currently playing song info',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Title', 'Artist', 'Album', 'Duration', 'Progress'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
const info = await page.evaluate(`
|
|
13
|
+
(function() {
|
|
14
|
+
// NeteaseMusic player bar is at the bottom
|
|
15
|
+
const selectors = {
|
|
16
|
+
title: '.m-playbar .j-song .name, .m-playbar .song .name, [class*="playing"] .name, .m-player .name',
|
|
17
|
+
artist: '.m-playbar .j-song .by, .m-playbar .song .by, [class*="playing"] .artist, .m-player .by',
|
|
18
|
+
album: '.m-playbar .j-song .album, [class*="playing"] .album',
|
|
19
|
+
time: '.m-playbar .j-dur, .m-playbar .time, .m-player .time',
|
|
20
|
+
progress: '.m-playbar .barbg .rng, .m-playbar [role="progressbar"], .m-player [class*="progress"]',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getText(sel) {
|
|
24
|
+
for (const s of sel.split(',')) {
|
|
25
|
+
const el = document.querySelector(s.trim());
|
|
26
|
+
if (el) return (el.textContent || el.innerText || '').trim();
|
|
27
|
+
}
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const title = getText(selectors.title);
|
|
32
|
+
const artist = getText(selectors.artist);
|
|
33
|
+
const album = getText(selectors.album);
|
|
34
|
+
const time = getText(selectors.time);
|
|
35
|
+
|
|
36
|
+
// Try to get playback progress from the progress bar width
|
|
37
|
+
let progress = '';
|
|
38
|
+
const bar = document.querySelector('.m-playbar .barbg .rng, [class*="progress"] [class*="played"]');
|
|
39
|
+
if (bar) {
|
|
40
|
+
const style = bar.getAttribute('style') || '';
|
|
41
|
+
const match = style.match(/width:\\s*(\\d+\\.?\\d*)%/);
|
|
42
|
+
if (match) progress = match[1] + '%';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!title) {
|
|
46
|
+
// Fallback: try document title which often contains "songName - NeteaseMusic"
|
|
47
|
+
const docTitle = document.title;
|
|
48
|
+
if (docTitle && !docTitle.includes('NeteaseMusic')) {
|
|
49
|
+
return { Title: docTitle, Artist: '', Album: '', Duration: '', Progress: '' };
|
|
50
|
+
}
|
|
51
|
+
return { Title: 'No song playing', Artist: '—', Album: '—', Duration: '—', Progress: '—' };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { Title: title, Artist: artist, Album: album, Duration: time, Progress: progress };
|
|
55
|
+
})()
|
|
56
|
+
`);
|
|
57
|
+
return [info];
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playlistCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const playlistCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'playlist',
|
|
5
|
+
description: 'Show the current playback queue / playlist',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Index', 'Title', 'Artist'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
// Open the playlist panel (usually a button at the bottom bar)
|
|
13
|
+
await page.evaluate(`
|
|
14
|
+
(function() {
|
|
15
|
+
const btn = document.querySelector('.m-playbar .icn-list, .m-playbar [class*="playlist"], [data-action="playlist"], .m-playbar .btnlist');
|
|
16
|
+
if (btn) btn.click();
|
|
17
|
+
})()
|
|
18
|
+
`);
|
|
19
|
+
await page.wait(1);
|
|
20
|
+
const items = await page.evaluate(`
|
|
21
|
+
(function() {
|
|
22
|
+
const results = [];
|
|
23
|
+
// Playlist panel items
|
|
24
|
+
const rows = document.querySelectorAll('.m-playlist li, [class*="playlist-panel"] li, .listlyric li, .j-playlist li');
|
|
25
|
+
|
|
26
|
+
rows.forEach((row, i) => {
|
|
27
|
+
const nameEl = row.querySelector('.name, [class*="name"], a, span:first-child');
|
|
28
|
+
const artistEl = row.querySelector('.by, [class*="artist"], .ar');
|
|
29
|
+
|
|
30
|
+
const title = nameEl ? (nameEl.getAttribute('title') || nameEl.textContent || '').trim() : (row.textContent || '').trim();
|
|
31
|
+
const artist = artistEl ? (artistEl.textContent || '').trim() : '';
|
|
32
|
+
|
|
33
|
+
if (title && title.length > 0) {
|
|
34
|
+
results.push({ Index: i + 1, Title: title.substring(0, 80), Artist: artist });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return results;
|
|
39
|
+
})()
|
|
40
|
+
`);
|
|
41
|
+
if (items.length === 0) {
|
|
42
|
+
return [{ Index: 0, Title: 'Playlist is empty or panel not open', Artist: '—' }];
|
|
43
|
+
}
|
|
44
|
+
return items;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prevCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const prevCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'prev',
|
|
5
|
+
description: 'Go back to the previous song',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Status'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
const clicked = await page.evaluate(`
|
|
13
|
+
(function() {
|
|
14
|
+
const btn = document.querySelector('.m-playbar .btnbak, .m-playbar [class*="prev"], .m-player .btn-prev, [data-action="prev"]');
|
|
15
|
+
if (btn) { btn.click(); return true; }
|
|
16
|
+
return false;
|
|
17
|
+
})()
|
|
18
|
+
`);
|
|
19
|
+
if (!clicked) {
|
|
20
|
+
await page.pressKey('Control+ArrowLeft');
|
|
21
|
+
}
|
|
22
|
+
await page.wait(1);
|
|
23
|
+
return [{ Status: 'Went to previous song' }];
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const searchCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const searchCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'search',
|
|
5
|
+
description: 'Search for songs, artists, albums, or playlists',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [{ name: 'query', required: true, positional: true, help: 'Search query' }],
|
|
10
|
+
columns: ['Index', 'Title', 'Artist'],
|
|
11
|
+
func: async (page, kwargs) => {
|
|
12
|
+
const query = kwargs.query;
|
|
13
|
+
// Focus and fill the search box
|
|
14
|
+
await page.evaluate(`
|
|
15
|
+
(function(q) {
|
|
16
|
+
const input = document.querySelector('.m-search input, #srch, [class*="search"] input, input[type="search"]');
|
|
17
|
+
if (!input) throw new Error('Search input not found');
|
|
18
|
+
input.focus();
|
|
19
|
+
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
20
|
+
setter.call(input, q);
|
|
21
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
22
|
+
})(${JSON.stringify(query)})
|
|
23
|
+
`);
|
|
24
|
+
await page.pressKey('Enter');
|
|
25
|
+
await page.wait(2);
|
|
26
|
+
// Scrape results
|
|
27
|
+
const results = await page.evaluate(`
|
|
28
|
+
(function() {
|
|
29
|
+
const items = [];
|
|
30
|
+
// Song list items in search results
|
|
31
|
+
const rows = document.querySelectorAll('.srchsongst li, .m-table tbody tr, [class*="songlist"] [class*="item"], table tbody tr');
|
|
32
|
+
|
|
33
|
+
rows.forEach((row, i) => {
|
|
34
|
+
if (i >= 20) return;
|
|
35
|
+
const nameEl = row.querySelector('.sn, .name a, [class*="songName"], td:nth-child(2) a, b[title]');
|
|
36
|
+
const artistEl = row.querySelector('.ar, .artist, [class*="artist"], td:nth-child(4) a, td:nth-child(3) a');
|
|
37
|
+
|
|
38
|
+
const title = nameEl ? (nameEl.getAttribute('title') || nameEl.textContent || '').trim() : '';
|
|
39
|
+
const artist = artistEl ? (artistEl.getAttribute('title') || artistEl.textContent || '').trim() : '';
|
|
40
|
+
|
|
41
|
+
if (title) items.push({ Index: i + 1, Title: title, Artist: artist });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return items;
|
|
45
|
+
})()
|
|
46
|
+
`);
|
|
47
|
+
if (results.length === 0) {
|
|
48
|
+
return [{ Index: 0, Title: `No results for "${query}"`, Artist: '—' }];
|
|
49
|
+
}
|
|
50
|
+
return results;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const statusCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const statusCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'status',
|
|
5
|
+
description: 'Check CDP connection to NeteaseMusic Desktop',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['Status', 'Url', 'Title'],
|
|
11
|
+
func: async (page) => {
|
|
12
|
+
const url = await page.evaluate('window.location.href');
|
|
13
|
+
const title = await page.evaluate('document.title');
|
|
14
|
+
return [{ Status: 'Connected', Url: url, Title: title }];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const volumeCommand: import("../../registry.js").CliCommand;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cli, Strategy } from '../../registry.js';
|
|
2
|
+
export const volumeCommand = cli({
|
|
3
|
+
site: 'neteasemusic',
|
|
4
|
+
name: 'volume',
|
|
5
|
+
description: 'Get or set the volume level (0-100)',
|
|
6
|
+
domain: 'localhost',
|
|
7
|
+
strategy: Strategy.UI,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'level', required: false, positional: true, help: 'Volume level 0-100 (omit to read current)' },
|
|
11
|
+
],
|
|
12
|
+
columns: ['Status', 'Volume'],
|
|
13
|
+
func: async (page, kwargs) => {
|
|
14
|
+
const level = kwargs.level;
|
|
15
|
+
if (!level) {
|
|
16
|
+
// Read current volume
|
|
17
|
+
const vol = await page.evaluate(`
|
|
18
|
+
(function() {
|
|
19
|
+
const bar = document.querySelector('.m-playbar .vol .barbg .rng, [class*="volume"] [class*="progress"], [class*="volume"] [class*="played"]');
|
|
20
|
+
if (bar) {
|
|
21
|
+
const style = bar.getAttribute('style') || '';
|
|
22
|
+
const match = style.match(/width:\\s*(\\d+\\.?\\d*)%/);
|
|
23
|
+
if (match) return match[1];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const vol = document.querySelector('.m-playbar .j-vol, [class*="volume-value"]');
|
|
27
|
+
if (vol) return vol.textContent.trim();
|
|
28
|
+
|
|
29
|
+
return 'Unknown';
|
|
30
|
+
})()
|
|
31
|
+
`);
|
|
32
|
+
return [{ Status: 'Current', Volume: vol + '%' }];
|
|
33
|
+
}
|
|
34
|
+
// Set volume by clicking on the volume bar at the right position
|
|
35
|
+
const targetVol = Math.max(0, Math.min(100, parseInt(level, 10)));
|
|
36
|
+
await page.evaluate(`
|
|
37
|
+
(function(target) {
|
|
38
|
+
const bar = document.querySelector('.m-playbar .vol .barbg, [class*="volume-bar"], [class*="volume"] [class*="track"]');
|
|
39
|
+
if (!bar) return;
|
|
40
|
+
|
|
41
|
+
const rect = bar.getBoundingClientRect();
|
|
42
|
+
const x = rect.left + (rect.width * target / 100);
|
|
43
|
+
const y = rect.top + rect.height / 2;
|
|
44
|
+
|
|
45
|
+
bar.dispatchEvent(new MouseEvent('click', {
|
|
46
|
+
clientX: x,
|
|
47
|
+
clientY: y,
|
|
48
|
+
bubbles: true,
|
|
49
|
+
}));
|
|
50
|
+
})(${targetVol})
|
|
51
|
+
`);
|
|
52
|
+
return [{ Status: 'Set', Volume: targetVol + '%' }];
|
|
53
|
+
},
|
|
54
|
+
});
|
package/dist/daemon.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opencli micro-daemon — HTTP + WebSocket bridge between CLI and Chrome Extension.
|
|
3
|
+
*
|
|
4
|
+
* Architecture:
|
|
5
|
+
* CLI → HTTP POST /command → daemon → WebSocket → Extension
|
|
6
|
+
* Extension → WebSocket result → daemon → HTTP response → CLI
|
|
7
|
+
*
|
|
8
|
+
* Lifecycle:
|
|
9
|
+
* - Auto-spawned by opencli on first browser command
|
|
10
|
+
* - Auto-exits after 5 minutes of idle
|
|
11
|
+
* - Listens on localhost:19825
|
|
12
|
+
*/
|
|
13
|
+
export {};
|