前提:需要有node环境
1.输入npm init 初始化项目
2.输入npm i tampermonkey-vscode-helper tampermonkey-vscode-helper-cli -s
3.新建一个脚本代码,暂且起名叫test.js
// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2024-04-21
// @description  try to take over the world!
// @author       You
// @match        https://www.baidu.com
// @icon         https://www.google.com/s2/favicons?sz=64&domain=juejin.cn
// @grant        none
// ==/UserScript==
alert('hello workd')
4.在当前目录新建tampermonkey.config.js文件,输入配置项
const path = require("path");
module.exports = {
  watch: path.join(__dirname, "./test.js"),  //监听文件
  autoRefresh: "all", //自动刷新
};
5 .输入npx tampermonkey_vscode_helper_cli唤起浏览器
6.正常更改test.js就行啦!