大佬,请教一个问题:pnpm run serve 是如何通知浏览器安装或更新用户脚本的呢? #74
-
运行 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
不是
vite-plugin-monkey 只是调用浏览器打开 浏览器扩展比如 tampermonkey 会自动识别 |
Beta Was this translation helpful? Give feedback.
-
谢谢@lisonge ,还是大佬厉害!
之前我真不知道,原来是油猴有识别 非常感谢,学习到新知识了!感谢! |
Beta Was this translation helpful? Give feedback.
-
大佬nb!我也仿造着大佬的思路使用 open 库 实现了自动打开浏览器安装脚本的功能 function installScript(url) {
const htmlContent = `<script>location.href = '${url}'; window.close()</script>`
const base64Content = Buffer.from(htmlContent).toString('base64')
const dataUrl = `data:text/html;base64,${base64Content}`
return open(dataUrl, {
app: { name: apps.browser },
})
} |
Beta Was this translation helpful? Give feedback.
不是
vite-plugin-monkey 只是调用浏览器打开
http://127.0.0.1:5173/__vite-plugin-monkey.install.user.js?origin=http://127.0.0.1:5173
浏览器扩展比如 tampermonkey 会自动识别
*.user.js
这种 url 然后打开它的安装页面vite-plugin-monkey/packages/vite-plugin-monkey/src/node/plugins/server.ts
Line 215 in 62c4bf2