This contains code for a JSON endpoint returning info about your user scripts installation. It currently supports Greasy Fork and OpenUserJS. It runs on RunKit.
This endpoint can be referenced by badge generators like https://shields.io/ for display in places like GitHub readme files.
Simply use my endpoint here:
https://runkit.io/mysticflute/userscripts/branches/master
Create your own RunKit account and copy paste the contents of index.js into a new notebook. Click on the "endpoint" link to grab your URL.
Head over to https://shields.io/ and scroll down to the "Dynamic" section:
- Choose
json
for the "data type". - Enter the URL chosen above into "data url".
- Append to the URL the service you want (
/greasyfork
or/openuserjs
). - For Greasy Fork, append the script id which you can grab from the url on your user script page (for the URL https://greasyfork.org/en/scripts/12345-my-script", append
/12345
). - Your final URL for Greasy Fork should look something like this:
https://runkit.io/mysticflute/userscripts/branches/master/greasyfork/12345
. - For OpenUserJS, append the username and name (for the URL "https://openuserjs.org/scripts/mysticflute/myscript" append
/mysticflute/myscript
). - Your final URL for OpenUserJS should look something like this:
https://runkit.io/mysticflute/userscripts/branches/master/openuserjs/mysticflute/myscript
.
- Append to the URL the service you want (
- For the "query" field, choose the json field that you want, e.g.,
$.version
. - Fill out the rest of the fields like color and label as appropriate.
- Click "Make Badge".
- Don't forget you can also add the badge style you want to the generated URL.
For a badge in markdown it would be something like this:
[![OpenUserJS](https://img.shields.io/badge/dynamic/json?style=for-the-badge&color=blue&label=OpenUserJS&query=%24.version&url=https%3A%2F%2Frunkit.io%2Fmysticflute%2Fuserscripts%2Fbranches%2Fmaster%2Fopenuserjs%2Fsample%2Fsample)](https://openuserjs.org/scripts/yournamespace/yourname)
Here's a sample response for GreasyFork:
{
"version": "1.0.0",
"updatedDateTime": "2018-11-17T17:50:02+00:00",
"updated": "11/17/2018",
"totalInstalls": "151",
"dailyInstalls": "0"
}
Here's a sample response for OpenUserJS:
{
"version": "1.0.0",
"updatedDateTime": "2019-07-21T05:41:58.134Z",
"updated": "07/21/2019",
"totalInstalls": "254168"
}