// ==UserScript==
// @name ktMallHelp
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 卡亭商城浏览器帮助工具
// @author dwb
// @match https://www.zhoujf.top/index.php/mobile/*
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
$(".ma-to-200 .fr a").attr("onclick", '');
$(".payit .fr a").click(function() {
let total = prompt("请输入下单次数", 10);
if (total) {
submit_order(total, 0);
}
});
// 提交订单
let ajax_return_status = 1; // 标识ajax 请求是否已经回来 可以进行下一次请求
function submit_order(total, current) {
if (current > total){
let r = confirm("查看我的订单");
if(r){
window.location.href = '/index.php/Mobile/Order/order_list/type/WAITPAY.html';
}
return;
}
console.log('总数total:', total, '当前current:', current);
$('.user_note_txt').each(function() {
var store_id = $(this).attr('data-store-id');
$("input[name='user_note[" + store_id + "]']").attr('value', $(this).val());
});
if (ajax_return_status == 0) return false;
ajax_return_status = 0;
$.ajax({
type: "POST",
url: "/index.php/Mobile/Cart/cart3.html",
data: $('#cart2_form').serialize() + "&act=submit_order",
dataType: "json",
success: function(data) {
if (data.status == 1) {} else {
// 登录超时
return false;
}
},
complete: function(XMLHttpRequest, textStatus) {
ajax_return_status = 1; // 上一次ajax 已经返回, 可以进行下一次 ajax请求
submit_order(total, ++current);
console.log('请求结束,现在第', current, '次');
}
});
}
// Your code here...
})();
console