Greasy Fork 还支持 简体中文。

HPX Flutter Trigger

给 HPX 增加一个 Flutter 版本号变更入口

As of 2022-04-27. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         HPX Flutter Trigger
// @namespace    https://mtflutter.sankuai.com
// @version      1.0
// @description  给 HPX 增加一个 Flutter 版本号变更入口
// @author       [email protected]
// @match        http://hpx.sankuai.com/application/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=flutter.dev
// @grant        none
// @run-at       document-start
// @license    Commercial
// ==/UserScript==

(function() {
    'use strict';
    document.onreadystatechange = function () {
        if (document.readyState === "interactive") {
            const script = document.createElement('script')
            script.src = '//unpkg.sankuai.com/package/xhook@latest/dist/xhook.min.js'
            document.getElementsByTagName('head')[0].appendChild(script)
        } else if (document.readyState === 'complete') {
            xhook.after(function (request, response) {
                if (request.url.match(/api\/buildType\/detail/)) {
                    const resp = JSON.parse(response.text)
                    if (resp.status == 1) {
                        for (const buildTypeParam of resp.data.buildType.buildTypeParams) {
                            const { buildParams } = buildTypeParam
                            for (let i = 0; i < buildParams.length; i++) {
                                if (buildParams[i].paramKey === 'integrationList') {
                                    const { elementRules } = buildParams[i]
                                    const newParam = {
                                        paramKey: "mtflutterIntegrationList",
                                        paramName: "Flutter 模块变更列表",
                                        paramValue: [],
                                        paramDesc: "iOS填waimai_e_flutter,Android填com.sankuai.wme:waimai_e_flutter",
                                        valueDesc: "Flutter 模块变更列表",
                                        couldEdit: true,
                                        require: false,
                                        elementRules,
                                    }
                                    buildParams.splice(i + 1, 0, newParam)
                                    break
                                }
                            }
                        }
                        response.text = JSON.stringify(resp)
                    }
                }
            });
        }
    }
})();