潇潇洒洒闯书界 改了下,貌似是不行,能在默认浏览器打开网页,但是不能像内置浏览器打开那样自动填充提取码。尴尬。
const matchs = ENTER.payload.match(/(https?:\/\/[a-z0-9-._~:/?=#]+)\s(?:(|()?(?:提取密?码?|访问密?码|密码)\s(?:😐:)?\s*([a-z0-9]{4,6})/i);
if (!matchs) {
throw new Error('无效文本');
}
// 使用电脑默认浏览器打开网页
const { exec } = require('child_process');
const url = matchs[1];
// 根据不同操作系统执行打开浏览器的命令
if (process.platform === 'win32') {
// Windows 系统
exec(start ${url}
);
} else if (process.platform === 'darwin') {
// macOS 系统
exec(open ${url}
);
} else if (process.platform === 'linux') {
// Linux 系统
exec(xdg-open ${url}
);
} else {
throw new Error('不支持的操作系统');
}
console.log(已使用默认浏览器打开:${url}
);