User Script Hosting: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(Remove a warning about an issue which no longer applies in the latest release.)
(hack url and using pastebin)
Line 28: Line 28:
For Greasemonkey, the only requirement is that the (entire) URL ends with <code>.user.js</code> and that it is not served with a <code>text/html</code> content type.
For Greasemonkey, the only requirement is that the (entire) URL ends with <code>.user.js</code> and that it is not served with a <code>text/html</code> content type.
Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.
Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.
=== Hack the URL ===
If you host your script on some websites that you can not custom url, you can append the url with '''query string''' or '''hash fragment''' ,
making it ending with <code>.user.js</code> , so greasemonkey could recognize it.
Most websites just skip unexpected query string in url, so it will not result in error in accessing webpage.
Because hash fragment only works in client side, adding hash fragment will not crash webpage, too.
(if website had not stored information in hash fragment for client side routing or what.)
For example, a webpage with url <code>https://pastebin.com/raw/zxASqw12</code> :
* Add <code>?somename.user.js</code> , so url become <code>https://pastebin.com/raw/zxASqw12?somename.user.js</code> .
* If you want to follow general query string style, you can add <code>?file=somename.user.js</code> or something else, and url become <code>https://pastebin.com/raw/zxASqw12?file=somename.user.js</code> .
* Add <code>&file=somename.user.js</code> if url already has query string, and make sure that it is at the end of url: <code>https://pastebin.com/raw/zxASqw12?download=0&file=somename.user.js</code>
* Add <code>#somename.user.js</code> , so url become <code>https://pastebin.com/raw/zxASqw12#somename.user.js</code> .
Therefore, url end with <code>*.user.js</code> , and greasemonkey will recognize it.
=== pastebin ===
https://pastebin.com/
The advantage of pastebin is that it does not require regist, allowing anonymous paste, so you can host user script anonymous.
When you make a paste on pastebin, you will get a url with hash, like <code>https://pastebin.com/zxASqw12</code>, which link to a webpage containing your code.
However, the page is a ''webpage'' but not responsed without <code>Content-Type: text/html</code> , and its url is not ending with <code>*.user.js</code>
To get a url responsed without <code>Content-Type: text/html</code> and containing only user script code,
you should click the ''raw'' button on the webpage, or add <code>/raw</code> to url, like <code>https://pastebin.com/raw/zxASqw12</code>
To make url end with <code>*.user.js</code> , you can add querystring or hash fragment.
Add query string: <code>https://pastebin.com/raw/zxASqw12?file=somename.user.js</code>

Revision as of 04:06, 12 December 2019

Greasy Fork

https://greasyfork.org/

Created by the maintainer of http://userstyles.org/. HTTPS is available and enforced by default. Open source, hosted on GitHub.

OpenUserJS.org

https://openuserjs.org/

"The home of FOSS user scripts." Only HTTPS is available. Open source, hosted on GitHub.

Gist

https://gist.github.com/

Gist is GitHub's "paste" service, where any set of simple files can be pasted into a web form and saved. Gist files may be named. If they are given the .user.js suffix, then the raw link for the gist will serve perfectly as an install. HTTPS is available and used by default.

The Whole Internet

Any server across the entire web may host user scripts. For Greasemonkey, the only requirement is that the (entire) URL ends with .user.js and that it is not served with a text/html content type. Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.

Hack the URL

If you host your script on some websites that you can not custom url, you can append the url with query string or hash fragment , making it ending with .user.js , so greasemonkey could recognize it. Most websites just skip unexpected query string in url, so it will not result in error in accessing webpage. Because hash fragment only works in client side, adding hash fragment will not crash webpage, too. (if website had not stored information in hash fragment for client side routing or what.)

For example, a webpage with url https://pastebin.com/raw/zxASqw12 :

Therefore, url end with *.user.js , and greasemonkey will recognize it.

pastebin

https://pastebin.com/

The advantage of pastebin is that it does not require regist, allowing anonymous paste, so you can host user script anonymous.

When you make a paste on pastebin, you will get a url with hash, like https://pastebin.com/zxASqw12, which link to a webpage containing your code. However, the page is a webpage but not responsed without Content-Type: text/html , and its url is not ending with *.user.js

To get a url responsed without Content-Type: text/html and containing only user script code, you should click the raw button on the webpage, or add /raw to url, like https://pastebin.com/raw/zxASqw12

To make url end with *.user.js , you can add querystring or hash fragment. Add query string: https://pastebin.com/raw/zxASqw12?file=somename.user.js