GM_HttpReq

获取提交参数方法

As of 2023-04-14. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/463963/1175558/GM_HttpReq.js

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 or Violentmonkey 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         GM_HttpReq
// @version      0.3
// @description  获取提交参数方法
// @license      All Rights Reserved
// @resource     priceOpen priceOpen
// @grant        GM_getResourceText
// ==/UserScript==

function priceOpen() {
    var open = XMLHttpRequest.prototype.open;
    var send = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.open = function () {
        var url = arguments[1];
        var method = arguments[0];
        if (method.toUpperCase() === 'GET' && url.indexOf('mtop.damai.cn/h5/mtop.alibaba.detail.subpage.getdetail') != -1) {
            this._url = url;  //保存请求的 URL
            console.log('获取到了GET request');
        }
        open.apply(this, arguments);
    };

    XMLHttpRequest.prototype.send = function () {
        this.addEventListener('readystatechange', function () {
            if (this.readyState === 4 && this.status === 200 && this._url && this._url.indexOf('mtop.damai.cn/h5/mtop.alibaba.detail.subpage.getdetail') != -1) {
                var responseText = JSON.parse(this.responseText);
                var result = JSON.parse(responseText.data.result);
                var skuList = result.perform.skuList;
                // 解析响应内容,获取相关信息
                console.log('获取到可选择的场次详情:', skuList);
                const skuIds = [];
                const itemIds = [];
                const priceNames = [];
                for (var k = 0; k < skuList.length; k++) {
                    skuIds.push(skuList[k].skuId);
                    itemIds.push(skuList[k].itemId);
                    priceNames.push(skuList[k].priceName);
                }
                sessionStorage.setItem('skuIds', skuIds);
                sessionStorage.setItem('itemIds', itemIds);

                let priceNameStr = "";
                for (let i = 0; i < priceNames.length; i++) {
                    priceNameStr += i + " : " + priceNames[i] + "\n";
                }
                alert("选择票价对应的序号输入: \n\n" + "当前选择场次:" + result.perform.performName + "\n\n" + priceNameStr);
            }
        });
        send.apply(this, arguments);
    };
}


function submit_phone_order() {
    console.log("提交订单中...");
    $("div[view-name='MColorFrameLayout']").attr("id", "myOrderSubmit");
    if ($("#myOrderSubmit")[0] == null) {
        sessionStorage.setItem("isStopped", "stop");
        return;
    }
    var submitBtn = $("#myOrderSubmit")[0].nextSibling;
    var myEvent = new Event('dx_tap');
    submitBtn.dispatchEvent(myEvent);
    setTimeout(check_phone_alert, 200);
    sessionStorage.setItem("isStopped", "start");
}