且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在网页上添加用户脚本安装按钮?

更新时间:2023-10-28 14:25:10

您的链接应类似于:

<a href="https://example.com/your_script.user.js">Click to install script X</a>
<small>(A userscript engine, like Tampermonkey, is required.)</small>


为了使您的安装链接正常工作,必须满足以下条件:


In order for your install link to work, the following conditions must be met:

  1. 文件名必须以.user.js结尾.示例:stack_exchange_edit_reasoner.user.js
  2. 浏览器必须正在运行兼容的用户脚本扩展.例如, Tampermonkey Greasemonkey .
  3. 该文件必须不提供text/html内容类型. (要解决此问题,您必须篡改服务器的默认设置.)
  1. The filename must end in .user.js. Example: stack_exchange_edit_reasoner.user.js
  2. The browser must be running a compatible userscript extension. For example, Tampermonkey or Greasemonkey.
  3. The file must NOT be served with text/html content type. (You would have to tamper with your server's default settings for this to be an issue.)

此外,如果您希望自动更新能够正常工作,则应通过https链接提供脚本(否则脚本会变得很复杂).

Also, if you wish for automatic updates to work, the script should be served via an https link (or it gets complicated).