Greasy Fork API

Get information from Greasy Fork and do actions in it.

Dit script moet niet direct worden geïnstalleerd - het is een bibliotheek voor andere scripts om op te nemen met de meta-richtlijn // @require https://update.greasyfork.org/scripts/445697/1748148/Greasy%20Fork%20API.js

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

Maker
NotYou
Versie
3.1.0
Gemaakt op
29-05-2022
Bijgewerkt op
03-02-2026
Grootte
15,5 KB
Licentie
LGPL-3.0

Greasy Fork API

Description:

Get data from Greasy Fork, or/and do actions on Greasy Fork

Dependencies

  • Zod
  • GM.xmlHttpRequest
  • GM.openInTab

Docs

Getting started

Constructor only accepts one parameter, which determines if the hostname should be 'api.greasyfork.org' (pass down nothing since it is value by default or false to explicitly choose this one) or 'api.sleazyfork.org' (pass down true for this one)

const GF = new GreasyFork()

That's it for setting up the instance.

Schemas

These types are not real typescript types, but rather just their representation. (I used zod)

Id

Positive integer or numeric string that doesn't start with 0 (regex for the string: /^(?!0)\d+$/)

Query

An optional string

Page

An optional integer

FilterLocale

An optional boolean

ScriptsQuery

interface ScriptsQuery {
  q?: Query,
  page?: Page,
  filter_locale?: FilterLocale,
  sort?: "total_installs" | "ratings" | "created" | "updated" | "name",
  by?: Id,
  language: "js" | "css"
}

AdvancedScriptsQuery

interface AdvancedScriptsQuery extends ScriptsQuery {
  total_installs_operator?: "lt" | "gt" | "eq", // default gt
  total_installs?: number, // default 0
  daily_installs_operator?: "lt" | "gt" | "eq", // default gt
  daily_installs?: number, // default 0
  ratings_operator?: "lt" | "gt" | "eq", // default gt
  ratings?: number, // from 0 to 1, default 0
  created_operator?: "lt" | "gt" | "eq", // default gt
  created?: string, // datetime string, default blank
  updated_operator?: "lt" | "gt" | "eq", // default gt
  updated?: string, // datetime string, default blank
  entry_locales?: number[],
  tz?: string // is validated by that regex: /^[A-Za-z0-9_+-]+\/[A-Za-z0-9_+-]+(?:\/[A-Za-z0-9_+-]+)?$/
}

ScriptsBySiteQuery

interface ScriptsBySiteQuery extends ScriptsQuery {
  site: '*' | string // accepts only ip addesses, hostnames and * (for all sites)
}

ScriptSetQuery

Same as ScriptsQuery, but has property set and doesn't have property 'by'.

type ScriptSetQuery = Omit<ScriptsQuery & { set: Id }, 'by'>

LibrariesQuery

Same as ScriptsQuery, but doesn't have sorting by total_installs or ratings

interface LibrariesQuery {
  q?: Query,
  page?: Page,
  filter_locale?: FilterLocale,
  sort?: "created" | "updated" | "name",
  by?: Id
}

UsersQuery

interface UsersQuery {
  q?: Query,
  page?: Page,
  sort?: "name" | "daily_installs" | "total_installs" | "ratings" | "scripts" | "created_scripts" | "updated_scripts",
  authors?: boolean
}

Install

interface Install {
  id: Id,
  type?: "js" | "css" // "js" by default
}

Instance Properties

script

Contains methods to get particular script information. (for example script history)

Methods (of the script property):

getData(id: Id): Promise<object>

Gets info about the script

const data = await GF.script.getData(1)

/* Response Example:
{
    "id": 1,
    "daily_installs": 0,
    "total_installs": 311,
    "fan_score": "82.4",
    "good_ratings": 18,
    "ok_ratings": 0,
    "bad_ratings": 0,
    "created_at": "2014-02-18T19:51:43.000Z",
    "code_updated_at": "2023-11-22T00:50:37.000Z",
    "namespace": "http://userstyles.org",
    "support_url": null,
    "contribution_url": null,
    "contribution_amount": null,
    "users": [
        {
            "id": 1,
            "name": "JasonBarnabe",
            "created_at": "2014-02-18T19:49:27.000Z",
            "url": "https://greasyfork.org/users/1-jasonbarnabe"
        }
    ],
    "name": "Greasemonkey/Tampermonkey/Violentmonkey test style",
    "description": "If you install this and all text turns red, then things are working.",
    "url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style",
    "code_url": "https://update.greasyfork.org/scripts/1/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js",
    "code_size": 981,
    "license": null,
    "version": "20231121.2",
    "locale": "en"
}

getCode(id: Id): Promise<string>

Gets all the code of the user-script

const code = await GF.script.getCode(1)

/*
// ==UserScript==
// @name          Greasemonkey/Tampermonkey/Violentmonkey test style
// @namespace     http://userstyles.org
// @description   If you install this and all text turns red, then things are working.
// @author        JasonBarnabe
// @homepage      http://greasyfork.org/scripts/1
// @run-at        document-start
// @version       20231121.2
// @include       *

...

    var node = document.createElement("style");
    node.type = "text/css";
    node.appendChild(document.createTextNode(css));
    var heads = document.getElementsByTagName("head");
    if (heads.length > 0) {
        heads[0].appendChild(node); 
    } else {
        // no head yet, stick it whereever
        document.documentElement.appendChild(node);
    }
}
})();
*/

getMeta(id: Id): Promise<string>

Gets only the metadata of the user-script

const meta = await GF.script.getMeta(1)

/*
// ==UserScript==
// @name          Greasemonkey/Tampermonkey/Violentmonkey test style
// @namespace     http://userstyles.org
// @description   If you install this and all text turns red, then things are working.
// @author        JasonBarnabe
// @homepage      http://greasyfork.org/scripts/1
// @run-at        document-start
// @version       20231121.2
// @include       *
// ==/UserScript==
*/

getHistory(id: Id): Promise<object>

Gets version history of the user-script

const history = await GF.script.getHistory(1)

/*
[
    {
        "version": "20231121.2",
        "created_at": "2023-11-22T00:50:38.000Z",
        "url": "https://api.greasyfork.org/en/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style?version=1284072",
        "code_url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style/code/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js?version=1284072"
    },

    ...

    {
        "version": "1.20140218195143",
        "created_at": "2014-02-18T19:51:43.000Z",
        "url": "https://api.greasyfork.org/en/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style?version=1",
        "code_url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style/code/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js?version=1"
    }
]
*/

getStats(id: Id): Promise<object>

Gets stats of the user-script (installs, update checks)

/*
{
    "2014-02-18": {
        "installs": 1,
        "update_checks": null
    },
    "2014-02-19": {
        "installs": 5,
        "update_checks": null
    },

    ...


    "2026-02-02": {
        "installs": 0,
        "update_checks": 0
    },
    "2026-02-03": {
        "installs": 0,
        "update_checks": 0
    }
}
*/

getStatsCsv(id: Id): Promise<string>

Gets stats of the user-script (installs, update checks), but in csv format

const statsCsv = await GF.script.getStatsCsv(1)

/*
Response is too big to show
*/

Instance Methods

getScripts(options: ScriptsQuery): Promise<object[]>

Queries 100 scripts max at once using specified parameters

await GF.getScripts() // just get top scripts

await GF.getScripts({ q: 'test' }) // get scripts with relevant keyword


await GF.getScripts({
  q: 'test',
  page: 2 // pages start from 1, not from 0
})

await GF.getScripts({
  q: 'test',
  filter_locale: false, // show all results regardless of the language
  sort: 'name' // also, sort them by the name
})

await GF.getScripts({
  by: 1 // get scripts by user with id of 1
})

await GF.getScripts({
  language: "css" // get only user styles
})

getScriptsAdvanced(options: AdvancedScriptsQuery): Promise<object[]>

Queries 100 scripts max at once using specified parameters

await GF.getScriptsAdvanced({
  total_installs: 1000 // get scripts that have min of 1000 total installs
})

await GF.getScriptsAdvanced({
  daily_installs: 100 // get scripts that have min of 1000 daily installs
})

getScriptsBySite(options: ScriptsBySiteQuery): Promise<object[]>

Has same properties as getScripts, but itself requires site property.

Note: write '*' to get scripts that work at all of the sites

await GF.getScriptsBySite({
  site: 'youtube.com' // get scripts that work on 'youtube.com'
})

await GF.getScriptsBySite({
  site: '*' // get scripts work on all of the sites
})

getSitesPopularity(): Promise<Record>

await GF.getSitesPopularity()

/* Example:
{
  "example.com": 123,
  "example.org": 456,
  "example.net": 789
}
*/

getScriptSet(options: ScriptSetQuery): Promise<object[]>

Works same as getScripts, but just queries it from created sets.

GF.getScriptSet({
  set: 1,
  filter_locale: false,
  sort: 'created',
  page: 3
})

getLibraries(options: LibrariesQuery): Promise<object[]>

Queries the libraries.

The only real difference between script objects, is that value of code_url contains only the particular version of the library, not the always version.

await GF.getLibraries()

await GF.getLibraries({
  page: 2
})

await GF.getLibraries({
  q: 'GM',
  sort: 'name'
})

await GF.getLibraries({
  by: 1 // get libraries by user with id of 1
})

getUserData(id: Id): Promise<object>

await GF.getUserData(1)

/*
{
    "id": 1,
    "name": "JasonBarnabe",
    "created_at": "2014-02-18T19:49:27.000Z",
    "url": "https://greasyfork.org/users/1-jasonbarnabe",
    "scripts": [...]
}
*/

getUsers(options: UsersQuery): Promise<object[]>

Queries 100 users max per request

await GF.getUsers()

await GF.getUsers({
  q: 'john',
  page: 2,
  sort: 'name'
})

await GF.getUsers({
  author: true, // query script authors
  sort: 'created_scripts'
})

await GF.getUsers({
  author: false // unlike await GF.getUsers(), this query skips the script authors
})

/*
[
    {
        "id": 1567324,
        "name": "ambiel9687",
        "created_at": "2026-02-03T08:13:26.000Z",
        "url": "https://greasyfork.org/users/1567324-ambiel9687"
    },

    ...

    {
        "id": 1567224,
        "name": "Brandon Velasquez Morales",
        "created_at": "2026-02-03T01:45:59.000Z",
        "url": "https://greasyfork.org/users/1567224-brandon-velasquez-morales"
    }
]
*/

signOut(): Promise<void>

Signs out of the Greasy Fork account

await GF.signOut()

installUserScript(options: Install): void

Installs user-script.

Note: specifying "js" type for user-script doesn't do anything since this is default option

GF.installUserScript({
  id: 437291
})

GF.installUserScript({
  id: 439627,
  type: 'css' // you can specify "js" for user-styles
})