前言

  • 油猴脚本有挺多用处,这玩意不用审核,可以做点效率工具。

文档

开发

  • 开发简单的就直接上面写就行。
  • 复杂的就用前面文章的脚手架。
  • 在本地启服务后,把下面脚本复制进去即可开发调试:
// ==UserScript==
// @name         MoveSearch
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  try to take over the world!
// @author
// @match        https://*/*
// @match        http://*/*

// ==/UserScript==

;(function () {
  'use strict'
  if (location.href === 'http://localhost:8080/') return
  var script = document.createElement('script')
  script.src = 'http://localhost:8080/app.bundle.js'
  document.body.appendChild(script)
})()
  • 如果有csp错误需要安装上面的谷歌插件。

发布

  • 代码大小问题,可以引入外部cdn,使用@require注释拉取:
// @require https://unpkg.com/react@17/umd/react.production.min.js
// @require https://unpkg.com/react-dom@17/umd/react-dom.production.min.js
  • 打包时可以把react和react-dom打出来:
	entry: {
		app: "/src/index.js",
		vendor: [
			"react",
			"react-dom",
		],
	},
  • 网站匹配,匹配所有生效直接:
// @include http://*
// @include https://*
  • 否则就用@match 具体看文档。
  • 发布需要登录,在商店里点击自己名字,然后选择发布即可。
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐