{"id":23440674,"url":"https://github.com/wodepig/xxdl-youhou-init","last_synced_at":"2026-04-29T21:01:42.761Z","repository":{"id":269367455,"uuid":"872483970","full_name":"wodepig/xxdl-youhou-init","owner":"wodepig","description":"A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat","archived":false,"fork":false,"pushed_at":"2024-12-23T03:29:37.000Z","size":525,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T07:16:32.631Z","etag":null,"topics":["greasemonkey","rollupjs","scriptcat","tampermonkey","unocss","userscripts","violentmonkey","vite","vite-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wodepig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-14T14:12:22.000Z","updated_at":"2024-12-23T03:28:06.000Z","dependencies_parsed_at":"2024-12-23T04:27:13.549Z","dependency_job_id":"b285b92d-48a2-4dae-a901-86993dabd3e6","html_url":"https://github.com/wodepig/xxdl-youhou-init","commit_stats":null,"previous_names":["wodepig/xxdl-youhou-init"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wodepig/xxdl-youhou-init","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wodepig%2Fxxdl-youhou-init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wodepig%2Fxxdl-youhou-init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wodepig%2Fxxdl-youhou-init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wodepig%2Fxxdl-youhou-init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wodepig","download_url":"https://codeload.github.com/wodepig/xxdl-youhou-init/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wodepig%2Fxxdl-youhou-init/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32443576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T20:22:27.477Z","status":"ssl_error","status_checked_at":"2026-04-29T20:22:26.507Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["greasemonkey","rollupjs","scriptcat","tampermonkey","unocss","userscripts","violentmonkey","vite","vite-plugin"],"created_at":"2024-12-23T16:17:24.876Z","updated_at":"2026-04-29T21:01:42.741Z","avatar_url":"https://github.com/wodepig.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"一个 vite 插件，用来辅助开发 [Tampermonkey](https://www.tampermonkey.net/), [Violentmonkey](https://violentmonkey.github.io/), [Greasemonkey](https://www.greasespot.net/), [ScriptCat](https://docs.scriptcat.org/) 等脚本引擎 的脚本\n\n支持添加一个按钮到页面\n![](./src/public/btn.png)\n\n支持控制台功能, 有简单的demo\n![](./src/public/console.png)\n# 主要特性\n* 支持 Tampermonkey、Violentmonkey、Greasemonkey、ScriptCat 等脚本引擎的辅助开发\n* 打包自动注入脚本配置头部注释\n* 当第一次启动或脚本配置注释改变时自动在默认浏览器打开脚本安装\n* 利用 @require 配置库的 CDN 的方案，减少构建脚本大小\n* 利用 @resource 配置外部资源 CDN 的方案，额外减少构建脚本大小\n* 通过 ESM 导入的方式使用 GM_api，附带类型提示\n* 智能收集使用到的 GM_api，自动配置 @grant 注释\n* 支持 top level await 和单文件下的 dynamic import\n* 预览模式下自动打开浏览器安装构建好的脚本\n* 完全的 Typescript 和 Vite 的开发体验，比如模块热替换，秒启动\n# 介绍\n从[原项目](https://github.com/lisonge/vite-plugin-monkey)中扩展得到的,添加了常用的工具和库. 自己也会把用到的一些工具加进来,方便新脚本开发时的快速启动.\n\n原项目wiki: [https://github.com/lisonge/vite-plugin-monkey/blob/main/README_zh.md](https://github.com/lisonge/vite-plugin-monkey/blob/main/README_zh.md)\n\n扩展后使用到的技术:\n\nts\n\nvue3\n\njQuery\n\nElement-Plus\n\nunocss\n\n# 启动和发布\n## 启动\n\n```\n// node 版本\u003e18\n// 安装依赖\npnpm i\n// 启动\npnpm run dev\n```\n启动项目,并且会自动打开浏览器安装脚本\n## 发布\n先编译项目\n```\npnpm run build\n```\n会在**dist**中生成对应的脚本\n\u003e 如果手动指定了@require的版本,在打包后需要把最后一行中的对应的版本删除:\n\u003e ```vue\n\u003e/// 删除后面的@版本号\n\u003e})(Vue, jQuery@3.7.1, ElementPlus@2.8.5);\n\u003e/// 变成这样的\n\u003e})(Vue, jQuery, ElementPlus);\n\u003e```\n\n### 推送\u0026远程更新\n**安装 pnpm add -D ali-oss**\n\n**卸载 pnpm remove ali-oss**\n\n我用的是阿里云对象存储, 记得安装依赖\n\n可以开通个对象存储和云函数,将打包后的文件放进去, 然后在油猴设置里的更新地址填入云函数绑定的域名(不用自己买域名,云函数提供),就能实现自动更新了\n\n根目录下有个**upload_oss.js**,里面有对应的上传方法,执行**pnpm run push**也能自动上传\n\n\n里面有个方法repalceVersion是去除版本号的\n\n### 使用\n直接把dist中的js复制到油猴扩展里面就行\n然后打开[百度](https://www.baidu.com/)查看效果\n### 发布到greasyfork\n项目使用的库里面有个https://cdn.jsdelivr.net/npm/vue-demi@latest/lib/index.iife.js\n\n它并不在greasyfork的白名单里\n\n需要把他替换为https://cdn.jsdelivr.net/npm/vue-demi@0.14.10/lib/index.iife.min.js\n```\n// ==UserScript==\n...\n// @description  油猴快速开发\n...\n- // @require      https://cdn.jsdelivr.net/npm/vue-demi@latest/lib/index.iife.js\n+ // @require      https://cdn.jsdelivr.net/npm/vue-demi@0.14.10/lib/index.iife.min.js\n...\n// @grant        GM_getResourceText\n// ==/UserScript==\n```\n\u003e 查看引入的包在不在白名单:\n\u003e [https://greasyfork.org/zh-CN/help/cdns](https://greasyfork.org/zh-CN/help/cdns)\n### 编译失败\n由于使用了ts,编译时会进行类型检查,随着代码变多,\n\n或者在window下随意的挂载属性,变量没指定类型,脚本的报错/标红也会变多\n\n但这些运行时都没有问题,一打包就会被终止.\n\n解决方法:\n在报错文件中的script下方添加一行// @ts-nocheck,跳过这个文件的检查\n```vue\n\u003cscript setup lang=\"ts\"\u003e\n// @ts-nocheck\n...忽略代码...\n\u003c/script\u003e\n```\n# 分支说明\n**main**分支(推荐): 包含全部的功能,有简单的按钮和控制台/日志功能/常用工具, 能自动打包并去除额外的版本号\n\n**thin**分支: 简化版的,适合只添加1,2个按钮的情况\n\n# 用到的命令\n\n### 添加自动导入\n安装命令\n```\npnpm add -D unplugin-auto-import\n```\n配置参考: https://github.com/unplugin/unplugin-auto-import\n### 添加element-plus\n```\npnpm install element-plus\n```\n添加对应的@require\n\u003e 我也不知道为啥这样写,参考: https://github.com/lisonge/vite-plugin-monkey/issues/5\n\n```\n// vite.config.ts\n//monkey.build属性\nexternalGlobals:  [\n          [\n            'vue',\n            cdn\n                .jsdelivr('Vue', 'dist/vue.global.prod.js')\n                .concat(\n                    cdn.jsdelivr('', 'lib/index.iife.js')[1]('latest', 'vue-demi'),\n                )\n                .concat(util.dataUrl(';window.Vue=Vue;')),\n          ],\n          [\n            'element-plus',\n            cdn.jsdelivr('ElementPlus@2.8.5', 'dist/index.full.min.js'),\n          ],\n        ]\n```\n\nmain.js里使用element\n```\n...省略...\nimport ElementPlus from 'element-plus';\nimport 'element-plus/dist/index.css';\n...省略...\napp.use(ElementPlus);\n```\n### 添加unocss\n参考\nhttps://unocss.nodejs.cn/integrations/vite\n\nhttps://unocss.net/presets/rem-to-px\n\n\n安装\n```\npnpm add -D unocss\n```\n\n安装像素转换\n```\npnpm add -D @unocss/preset-rem-to-px\n```\nmain.ts中引入\n```\nimport 'virtual:uno.css'\n```\n\n### 添加jQuery\n\u003e jq的变量名和模板的$冲突,所以先设置模板的$为别的,看原wiki中的clientAlias属性\n\n添加jq\n```\npnpm add jquery\npnpm add -D @types/jquery\n```\n\n添加对应的@require\n```\n//externalGlobals再加一条\n  [\n            'jquery',\n            cdn.jsdelivr('jQuery@3.7.1','dist/jquery.min.js')\n        ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwodepig%2Fxxdl-youhou-init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwodepig%2Fxxdl-youhou-init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwodepig%2Fxxdl-youhou-init/lists"}