Skip to content

Support Greasy Fork library usage stats in download badges #11958

Description

@PRO-2684

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

dt - https://img.shields.io/greasyfork/dt/470224?logo=greasyfork

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    service-badgeNew or updated service badge

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions