How do I add a userscript installation button to my web page?

后端 未结 1 1026
野的像风
野的像风 2021-01-07 04:32

I need to host a userscript on an internal company website. How do I build the href so that Greasemonkey will install the userscript when the link is clicked?

1条回答
  •  一生所求
    2021-01-07 05:35

    Your link should look like:

    Click to install script X
    (A userscript engine, like Tampermonkey, is required.)
    

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

    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.)

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

    0 讨论(0)
提交回复
热议问题