Are you experiencing an issue with...
shields.io
🐞 Description
Greasy Fork download badges currently work for normal userscripts, but not for library scripts.
Example library:
For libraries, /scripts/:id.json still reports:
{
"daily_installs": 0,
"total_installs": 0
}
But Greasy Fork now exposes library usage stats at /scripts/:id/stats.json, after greasyfork-org/greasyfork#1545.
The response shape is:
Array<[
scriptName: string,
dailyInstalls: number,
totalInstalls: number
]>
Example:
[
["Script 1", 0, 369],
["Script 2", 0, 8],
...
]
Expected behavior
For Greasy Fork library IDs, the existing download badge routes could aggregate /scripts/:id/stats.json:
dt: sum row[2], total installs of scripts requiring the library
dd: sum row[1], daily installs of scripts requiring the library
So this would make existing badge URLs work for libraries too.
🔗 Link to the badge
- https://img.shields.io/greasyfork/dt/470224?logo=greasyfork
- https://img.shields.io/greasyfork/dd/470224?logo=greasyfork
💡 Possible Solution
Greasy Fork does not currently expose an explicit script_type or library field in /scripts/:id.json.
A robust implementation could fetch /scripts/:id/stats.json when the normal install fields are zero, then detect library stats by response shape:
Array<[scriptName: string, dailyInstalls: number, totalInstalls: number]>
If the response is an array of 3-tuples, aggregate row[2] for dt and row[1] for dd. Otherwise, keep the existing normal-script behavior.
Are you experiencing an issue with...
shields.io
🐞 Description
Greasy Fork download badges currently work for normal userscripts, but not for library scripts.
Example library:
For libraries,
/scripts/:id.jsonstill reports:{ "daily_installs": 0, "total_installs": 0 }But Greasy Fork now exposes library usage stats at
/scripts/:id/stats.json, after greasyfork-org/greasyfork#1545.The response shape is:
Example:
Expected behavior
For Greasy Fork library IDs, the existing download badge routes could aggregate
/scripts/:id/stats.json:dt: sumrow[2], total installs of scripts requiring the librarydd: sumrow[1], daily installs of scripts requiring the librarySo this would make existing badge URLs work for libraries too.
🔗 Link to the badge
💡 Possible Solution
Greasy Fork does not currently expose an explicit
script_typeorlibraryfield in/scripts/:id.json.A robust implementation could fetch
/scripts/:id/stats.jsonwhen the normal install fields are zero, then detect library stats by response shape:If the response is an array of 3-tuples, aggregate
row[2]fordtandrow[1]fordd. Otherwise, keep the existing normal-script behavior.