Greasy Fork API

Get information from Greasy Fork and do actions in it.

< Обсуждения Greasy Fork API

Вопрос/комментарий

Here's a bug report.

GF.action throws Error 'Argument 1 install is not defined' during GF.action('install', {id: someGreasyforkScriptId})

Looking into the code, these ifs are missing else statement or return statement, which caused this bug:

    async action(action, options = {}) {
        let error = new GreasyFork().error,
            parser = new DOMParser()

        if(action === 'install') {
            error(options.id, 'Argument 2 { id } is not defined')
            setTimeout(() => {
                window.open(`https://greasyfork.org/scripts/${options.id}/code/source.user.${options.lang === 'css' ? 'css' : 'js'}`, '_top')
            }, options.timeout * 1e3 || 0)
        }
        if(action === 'signout') {
            setTimeout(() => {
                fetch('https://greasyfork.org/users/sign_out')
            }, options.timeout * 1e3 || 0)
        } if(action === 'list') {
            return [
                'install',
                'signout',
                'list'
            ]
        }
        else throw new Error(`Argument 1 ${action} is not defined`)
    }

I'd really appreciate if you could fix this code. But no worries if you can't get to it - I can also make the changes myself and redistribute to greasyfork (under LGPL). Thanks!

NotYouАвтор
§
Создано: 17.08.2023

I'm currently rewriting entire library because code right now really sucks, I'm almost done, I will publish code in 2–5 days.

NotYouАвтор
§
Создано: 21.08.2023

I already published the code 2 days ago, you can try new version. (Method name - installScript)

Ответить

Войдите, чтобы ответить.