Greasy Fork镜像 API

Get information from Greasy Fork镜像 and do actions in it.

< 脚本Greasy Fork镜像 API的反馈

提问/评论

§
发表于:2023-08-13

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://gf.qytechs.cn/scripts/${options.id}/code/source.user.${options.lang === 'css' ? 'css' : 'js'}`, '_top')
            }, options.timeout * 1e3 || 0)
        }
        if(action === 'signout') {
            setTimeout(() => {
                fetch('https://gf.qytechs.cn/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作者
§
发表于:2023-08-17

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作者
§
发表于:2023-08-21

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

发表回复

登录(不可用)以发表回复。

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址