这是一个油猴脚本项目,使用typeScript + vue2 + rollup打包
local_build.js为默认配置打包名,可自定义
在项目文件夹下,打开终端根据实际情况选择对应的包输入命令
npm installyarn installpnpm install根据实际情况选择对应的包命令运行
npm run dev yarn run dev pnpm run dev根据实际情况选择对应的包命令运行打包
yarn run build npm run build pnpm run build- 假设已经按照了油猴插件
- 在插件拓展设置中勾选上
允许访问文件 URL - 插件中新建一个脚本,填写如下内容
// ==UserScript==
// @name twtter内容屏蔽器
// @namespace http://tampermonkey.net/
// @license Apache-2.0
// @version 1.0
// @author byhgz
// @icon https://static.hdslb.com/images/favicon.ico
// @noframes
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @match *://localhost/*
// @require https://unpkg.com/vue@2.7.16/dist/vue.min.js
// @require https://unpkg.com/element-ui@2.15.14/lib/index.js
// @require file://E:\Others\webStorm\project\tamper_monkey\mkTwtterContentShield\dist\local_build.js
// ==/UserScript==
/**
* 上面中的引用地址,根据项目本地实际路径进行修改,这里仅供参考
* file://E:\js\dist\local_build.js
*
*/- 如果在localhost本地地址测试时,不需要其他脚本干扰,可以在对应脚本头部配置中添加
@exclude http://localhost:3002/- 这里的端口可根据项目实际端口进行修改
- 如需本地测试,将rollup.config.js配置中serve函数取消注释掉,并运行
npm run dev