// ==UserScript== // @name 淘宝买家订单数据导出 // @namespace https://github.com/Sky-seeker/BuyerOrdersExport // @version 2.0.1 // @description “淘宝买家订单数据导出”最初基于“淘宝买家订单导出-颜色分类”添加了“商品主图”,修改和修复了一些细节问题,当前版本与之前已经有了较大的变动。导出的项目包括下单日期、订单编号、子订单编号、店铺名称、商品名称、快照商品名称、商品颜色分类名称、商品主图链接、商品链接、商品交易快照链接、单价、数量、商品退款状态、订单实付款、订单交易状态、订单详情链接。并支持添加额外的下单日期时间、快递物流公司、快递物流单号信息。导出的订单数据为CSV文件。在导出淘宝买家订单数据时,支持一些可选功能,如商品名称和店铺名称黑名单关键词过滤,快照商品名称获取以及获取时的随机延时,Excel 数据格式适配,订单详情链接一致化。支持项目标题次序自定义,支持图片链接尺寸选择,支持项目标题和黑名单列表的数据的本地存储。使用的过程中会有反馈,如按钮的可用状态和颜色变化,以及窗口右下角的气泡通知等。 // @author 梦幻之心星 // @match https://buyertrade.taobao.com/trade/* // @connect taobao.com // @connect tmall.com // @grant GM_xmlhttpRequest // @license MIT // @supportURL https://github.com/Sky-seeker/BuyerOrdersExport // @downloadURL none // ==/UserScript== var orderList = {}; var orderDetail = {}; var pageOrderList = {}; var orderHeaderList = []; var blackList = []; var imageDimensionsIndex = 0; var ToastTimeout = null; const fileNamePrefix = "淘宝买家订单数据导出_"; const fileNameSuffix = ""; const defaultOrderHeaderList = [ "下单日期", "订单编号", "子订单编号", "店铺名称", "商品名称", "快照名称", "分类名称", "主图链接", "商品链接", "快照链接", "单价", "数量", "商品退款状态", "订单实付款", "订单交易状态", "订单详情链接", ]; const defaultBlackList = ["保险服务", "增值服务", "买家秀"]; const imageDimensionsList = ["80x80", "100x100", "160x160", "200x200", "240x240", "300x300", "320x320", "400x400", "480x480", "560x560", "600x600", "640x640", "720x720", "800x800"]; var httpGetResult = { snapShotCount: 0, snapShotTotal: 0, isSnapShotFinish: true, orderDetailCount: 0, orderDetailTotal: 0, isOrderDetailFinish: true, isFinish: true, }; //通知气泡默认属性 function createToast() { const Toast = document.createElement("div"); const ToastText = document.createTextNode("通知气泡"); Toast.id = "Toast"; Toast.style.visibility = "hidden"; Toast.style.position = "fixed"; Toast.style.bottom = "0px"; Toast.style.fontSize = "17px"; Toast.style.minWidth = "200px"; Toast.style.backgroundColor = "#4CAF50"; Toast.style.color = "white"; Toast.style.textAlign = "center"; Toast.style.borderRadius = "10px"; Toast.style.padding = "10px"; Toast.style.zIndex = 1; Toast.style.right = "1%"; Toast.appendChild(ToastText); document.getElementById("page").appendChild(Toast); } //调用通知气泡 function Toast(toastTextContent, alwaysShow = false) { const Toast = document.getElementById("Toast"); Toast.style.visibility = "visible"; Toast.textContent = toastTextContent; if (alwaysShow === false) { ToastTimeout = setTimeout(function () { Toast.style.visibility = "hidden"; }, 3000); } else { clearTimeout(ToastTimeout); } } //文本区域默认属性 function createTextarea(element, onchangeFunc, text, id, width, rows) { const Textarea = document.createElement("TEXTAREA"); const TextareaTitle = document.createElement("p"); Textarea.id = id; Textarea.rows = rows; Textarea.cols = 30; Textarea.placeholder = "每行一条。"; Textarea.style.width = width; Textarea.style.height = "140px"; Textarea.style.padding = "5px"; TextareaTitle.textContent = text; TextareaTitle.style.fontSize = "15px"; TextareaTitle.style.fontWeight = "700"; Textarea.onchange = function () { onchangeFunc(); }; element.appendChild(TextareaTitle); element.appendChild(Textarea); } //单选按钮默认属性 function addRadio(element, onchangeFunc, name, text, id, value) { const radio = document.createElement("input"); const radioText = document.createTextNode(text); radio.id = id; radio.value = value; radio.type = "radio"; radio.name = name; radio.style.verticalAlign = "middle"; radio.style.marginLeft = "25px"; radio.style.marginRight = "5px"; radio.onchange = function () { onchangeFunc(); }; element.appendChild(radio); element.appendChild(radioText); } //复选框默认属性 function addCheckbox(element, onchangeFunc, text, id) { const checkbox = document.createElement("input"); const checkboxText = document.createTextNode(text); checkbox.id = id; checkbox.type = "checkbox"; checkbox.defaultChecked = true; checkbox.style.verticalAlign = "middle"; checkbox.style.marginLeft = "22px"; checkbox.style.marginRight = "5px"; checkbox.onchange = function () { onchangeFunc(); }; element.appendChild(checkbox); element.appendChild(checkboxText); } //按钮默认属性 function addButton(element, onclickFunc, text, id, width, marginLeft) { const button = document.createElement("input"); button.id = id; button.type = "button"; button.value = text; button.style.height = "50px"; button.style.width = width; button.style.align = "center"; button.style.marginLeft = marginLeft; //button.style.marginBottom = "20px"; button.style.color = "white"; button.style.background = "#409EFF"; button.style.border = "1px solid #409EFF"; button.style.fontSize = "16px"; button.onclick = function () { onclickFunc(); }; element.appendChild(button); } //图片尺寸选择默认属性 function createListSelect(element, name) { const ListTitle = document.createElement("p"); const ListSelect = document.createElement("select"); ListTitle.id = name + "ListTitle"; ListTitle.textContent = "图片尺寸:"; ListSelect.id = name + "ListSelect"; ListSelect.name = name; ListTitle.style.float = "left"; ListTitle.style.fontSize = "15px"; ListTitle.style.fontWeight = "700"; ListSelect.style.width = "85px"; ListSelect.style.marginLeft = "5px"; //添加下拉列表项 for (let imageDimension of imageDimensionsList) { const ListSelectOption = document.createElement("option"); ListSelectOption.text = imageDimension; ListSelectOption.value = imageDimension; ListSelect.add(ListSelectOption); } ListSelect.onchange = function () { choseImageDimensions(); }; element.appendChild(ListTitle); //添加单选项:常用值 addRadio(element, changeImageDimensions, name, "80x80", "80x80", "80x80"); addRadio(element, changeImageDimensions, name, "300x300", "300x300", "300x300"); addRadio(element, changeImageDimensions, name, "560x560", "560x560", "560x560"); addRadio(element, changeImageDimensions, name, "800x800", "800x800", "800x800"); addRadio(element, changeImageDimensions, name, "其它", "otherImageDimensions", "otherImageDimensions"); element.appendChild(ListSelect); } //在订单列表页面添加控件 const orderListPage = /https?:\/\/buyertrade\.taobao.*?\/trade/g; if (orderListPage.exec(document.URL)) { const orderListMain = document.getElementById("J_bought_main"); const userMain = document.createElement("div"); const userMainText = document.createElement("span"); const userMainList = document.createElement("ul"); const userMainTextCol1 = document.createElement("div"); const userMainTextCol2 = document.createElement("div"); const userMainListRow0 = document.createElement("li"); const userMainListRow1 = document.createElement("li"); const userMainListRow2 = document.createElement("li"); const userMainListRow3 = document.createElement("li"); const userMainListRow0Form = document.createElement("form"); const userMainListRow1Form = document.createElement("form"); userMain.id = "userMain"; userMainText.id = "userMainText"; userMainList.id = "userMainList"; userMainTextCol1.id = "userMainTextCol1"; userMainTextCol2.id = "userMainTextCol2"; userMainListRow0.id = "userMainListRow0"; userMainListRow1.id = "userMainListRow1"; userMainListRow2.id = "userMainListRow2"; userMainListRow3.id = "userMainListRow3"; userMainListRow0Form.id = "userMainListRow0Form"; userMainListRow1Form.id = "userMainListRow1Form"; orderListMain.insertBefore(userMain, orderListMain.childNodes[0]); userMain.appendChild(userMainText); userMain.appendChild(userMainList); userMainText.appendChild(userMainTextCol1); userMainText.appendChild(userMainTextCol2); userMainList.appendChild(userMainListRow0); userMainList.appendChild(userMainListRow1); userMainList.appendChild(userMainListRow2); userMainList.appendChild(userMainListRow3); userMainListRow0.appendChild(userMainListRow0Form); userMainListRow1.appendChild(userMainListRow1Form); createToast(); createTextarea(userMainTextCol1, changeOrderHeaderList, "订单项目标题", "orderHeaderList", "100px", 20); createTextarea(userMainTextCol2, changeBlackListKey, "黑名单关键词", "BlackListKey", "120px", 8); createListSelect(userMainListRow0Form, "imageDimensions"); addCheckbox(userMainListRow1Form, changeBlackListStatus, "黑名单过滤", "BlackListStatus"); addCheckbox(userMainListRow1Form, changeDelayStatus, "数据获取延时", "DelayStatus"); addCheckbox(userMainListRow1Form, changeSnapProductNameStatus, "快照名称获取", "SnapProductNameStatus"); addCheckbox(userMainListRow1Form, changeDataFormatAdaptationStatus, "Excel 格式适配", "DataFormatAdaptationStatus"); addCheckbox(userMainListRow1Form, changeUrlUniformizationStatus, "链接一致化", "UrlUniformizationStatus"); addButton(userMainListRow2, resetOrderHeader, "重置项目标题", "resetOrderHeader", "130px", "20px"); addButton(userMainListRow2, resetBlackList, "重置黑名单列表", "resetBlackList", "130px", "20px"); addButton(userMainListRow2, readLocalStorageData, "读取本地存储", "readLocalStorageData", "130px", "20px"); addButton(userMainListRow2, writeLocalStorageData, "写入本地存储", "writeLocalStorageData", "130px", "20px"); addButton(userMainListRow3, clearOrdersData, "清空订单数据", "clearOrdersData", "130px", "20px"); addButton(userMainListRow3, exportOrdersData, "导出订单数据", "exportOrdersData", "130px", "20px"); addButton(userMainListRow3, addOrdersToDetail, "添加订单详情", "addOrdersToDetail", "130px", "20px"); addButton(userMainListRow3, addPageOrdersToList, "添加本页订单", "addPageOrdersToList", "130px", "20px"); setOrderListPageElementStyle(); resetOrderHeader(); resetBlackList(); console.info("在订单列表页面添加控件!"); } //设置订单列表页面元素样式 function setOrderListPageElementStyle() { const userMain = document.getElementById("userMain"); const userMainText = document.getElementById("userMainText"); const userMainList = document.getElementById("userMainList"); const userMainTextCol1 = document.getElementById("userMainTextCol1"); const userMainTextCol2 = document.getElementById("userMainTextCol2"); const userMainListRow0 = document.getElementById("userMainListRow0"); const userMainListRow1 = document.getElementById("userMainListRow1"); const userMainListRow2 = document.getElementById("userMainListRow2"); const userMainListRow3 = document.getElementById("userMainListRow3"); userMain.style.height = "180px"; userMainText.style.float = "left"; userMainText.style.width = "260px"; userMainText.style.marginLeft = "0px"; userMainText.style.display = "inline-block"; userMainList.style.float = "left"; userMainList.style.width = "580px"; userMainList.style.marginLeft = "30px"; userMainTextCol1.style.float = "left"; userMainTextCol1.style.width = "110px"; userMainTextCol1.style.marginLeft = "0px"; userMainTextCol2.style.float = "left"; userMainTextCol2.style.width = "130px"; userMainTextCol2.style.marginLeft = "20px"; userMainListRow0.style.fontSize = "14px"; userMainListRow1.style.fontSize = "14px"; userMainListRow0.style.height = "20px"; userMainListRow1.style.height = "20px"; userMainListRow2.style.height = "70px"; userMainListRow3.style.height = "60px"; userMainListRow0.style.marginBottom = "5px"; userMainListRow1.style.marginBottom = "10px"; //设置首列元素左边距为零 document.getElementById("userMainListRow0Form").elements[0].style.marginLeft = "0"; document.getElementById("userMainListRow1Form").elements[0].style.marginLeft = "0"; userMainListRow2.children[0].style.marginLeft = "0"; userMainListRow3.children[0].style.marginLeft = "0"; //设置默认图片尺寸 document.getElementById("800x800").checked = true; imageDimensionsIndex = imageDimensionsList.indexOf("800x800"); } //重置按钮状态 function ResetButtonStatus() { document.getElementById("addPageOrdersToList").style.background = "#409EFF"; document.getElementById("addOrdersToDetail").style.background = "#409EFF"; document.getElementById("tp-bought-root").removeEventListener("click", ResetButtonStatus); } //添加本页订单数据 function addPageOrdersToList() { const mainOrders = document.getElementsByClassName("js-order-container"); document.getElementById("addPageOrdersToList").style.background = "#ff9800"; pageOrderList = {}; Toast("正在获取订单列表数据...", true); console.info("开始获取订单列表数据..."); console.time("processOrderList"); //遍历每条订单记录 for (let orders of mainOrders) { var ordersData = processOrderList(orders); if (!ordersData) { continue; } for (let orderItemIndex in ordersData) { orderList[orderItemIndex] = ordersData[orderItemIndex]; pageOrderList[orderItemIndex] = ordersData[orderItemIndex]; } //console.count("order count: "); //break; //订单列表数据-单条订单测试 } console.timeEnd("processOrderList"); console.info("获取订单列表数据结束!"); //通过交易快照获取商品信息 const isEnableSnapProductName = document.getElementById("SnapProductNameStatus").checked; var isAllEmptySnapUrl = false; if (isEnableSnapProductName === true) { Toast("正在获取快照商品名称...", true); console.info("开始获取快照商品名称..."); var emptySnapUrlCount = 0; const pageOrderListlength = Object.keys(pageOrderList).length; httpGetResult.isSnapShotFinish = false; for (let orderItemIndex in pageOrderList) { var snapUrl = pageOrderList[orderItemIndex]["snapURL"]; if (snapUrl !== "") { getDataFromSnapShot(orderItemIndex, "snapName", snapUrl); //break; //订单快照数据-单条快照测试 } else { console.info("子订单号[" + orderItemIndex + "]快照链接为空!"); emptySnapUrlCount++; if (emptySnapUrlCount === pageOrderListlength) { isAllEmptySnapUrl = true; console.info("当页订单列表的快照链接全为空!"); console.info("获取订单快照数据结束!"); } continue; } } } if (isEnableSnapProductName === false || isAllEmptySnapUrl === true) { document.getElementById("addPageOrdersToList").style.background = "#4CAF50"; document.getElementById("tp-bought-root").addEventListener("click", ResetButtonStatus); Toast("添加 " + Object.keys(pageOrderList).length + " 条子订单,已添加 " + Object.keys(orderList).length + " 条子订单。"); console.info("添加 " + Object.keys(pageOrderList).length + " 条子订单,已添加 " + Object.keys(orderList).length + " 条子订单。"); console.info("本页订单数据:"); console.info(pageOrderList); } } //导出订单数据 function exportOrdersData() { if (httpGetResult.isSnapShotFinish === false) { httpGetResult.isFinish = false; } else if (httpGetResult.isOrderDetailFinish === false) { httpGetResult.isFinish = false; } else { if (Object.keys(orderList).length === 0) { httpGetResult.isFinish = false; } else { httpGetResult.isFinish = true; } } if (httpGetResult.isFinish === false) { alert("请等待添加成功后再导出!"); return; } console.info("开始对订单列表数据进行可选功能处理和重定位!"); var orderListTemp = postprocessOrderList(orderList); var dateTimeStr = ""; var dateTime = new Date(); //获取当前日期 dateTime.setUTCHours(dateTime.getHours()); //修正本地时与世界时之间的时差 dateTimeStr = dateTime.toISOString(); //格式为: YYYY-MM-DDTHH:mm:ss.sssZ dateTimeStr = dateTimeStr.replace(/T/, "_"); dateTimeStr = dateTimeStr.replace(/:/g, "-"); dateTimeStr = dateTimeStr.replace(/\.\d{3}Z$/, ""); const fileName = fileNamePrefix + dateTimeStr + fileNameSuffix; dataToCsv(orderHeaderList, orderListTemp, fileName); } //清空订单数据 function clearOrdersData() { const count = Object.keys(orderList).length; orderList = {}; Toast("清空了: " + count + " 条子订单数据!"); console.info("清空了: " + count + " 条子订单数据!"); } //添加订单详情 function addOrdersToDetail() { var orderListTemp = {}; orderDetail = {}; if (Object.keys(orderList).length === 0) { alert("请先添加订单列表数据!"); return; } document.getElementById("addOrdersToDetail").style.background = "#ff9800"; httpGetResult.isOrderDetailFinish = false; console.info("开始对订单列表数据进行分类和去重"); orderListTemp = preprocessOrderList(orderList); Toast("正在获取订单详情数据...", true); console.info("开始获取订单详情数据..."); //orderList: ["taoBaoOrderList"];["tmallOrderList"];["archiveOrderList"]; for (let orderClassIndex in orderListTemp) { if (orderClassIndex === "archiveOrderList") { console.info("跳过存档的订单详情数据"); continue; } console.info("开始获取 " + orderClassIndex.replace("OrderList", "") + " 订单详情数据..."); for (let orderItemIndex in orderListTemp[orderClassIndex]) { var orderDetailURL = orderListTemp[orderClassIndex][orderItemIndex]["DetailURL"]; getDataFromOrderDetail(orderItemIndex, orderDetailURL); //break; //订单详情数据获取-单条测试 } } } //写入本地存储: 项目标题 + 黑名单列表 function writeLocalStorageData() { var orderHeaderListString = ""; var blackListString = ""; if (typeof Storage !== "undefined") { //localStorage.clear(); orderHeaderListString = orderHeaderList.join("\n"); blackListString = blackList.join("\n"); localStorage.setItem("orderHeaderList", orderHeaderListString); localStorage.setItem("blackList", blackListString); Toast("存储数据到本地!"); console.info("存储数据到本地!"); console.info("orderHeaderList" + "[" + orderHeaderList.length + "]:" + orderHeaderList); console.info("blackList" + "[" + blackList.length + "]:" + blackList); console.info("localStorage" + "[" + localStorage.length + "]:"); console.info(localStorage); } else { Toast("你的浏览器不支持网页存储!"); console.info("你的浏览器不支持网页存储!"); alert("你的浏览器不支持网页存储!"); } } //读取本地存储: 项目标题 + 黑名单列表 function readLocalStorageData() { if (typeof Storage !== "undefined") { var orderHeaderListString = ""; var blackListString = ""; orderHeaderListString = localStorage.getItem("orderHeaderList"); blackListString = localStorage.getItem("blackList"); if (orderHeaderListString !== null) { orderHeaderList = orderHeaderListString.split("\n"); document.getElementById("orderHeaderList").value = orderHeaderList.join("\n") + "\n"; } else { Toast("本地存储的项目标题为空!"); console.info("本地存储的项目标题为空!"); alert("本地存储的项目标题为空!"); } if (blackListString !== null) { blackList = blackListString.split("\n"); document.getElementById("BlackListKey").value = blackList.join("\n") + "\n"; } else { Toast("本地存储的黑名单列表为空!"); console.info("本地存储的黑名单列表为空!"); alert("本地存储的黑名单列表为空!"); } if (orderHeaderListString !== null || blackListString !== null) { Toast("读取数据到脚本!"); console.info("读取数据到脚本!"); console.info("orderHeaderList" + "[" + orderHeaderList.length + "]:" + orderHeaderList); console.info("blackList" + "[" + blackList.length + "]:" + blackList); console.info("localStorage" + "[" + localStorage.length + "]:"); console.info(localStorage); } } else { Toast("你的浏览器不支持网页存储!"); console.info("你的浏览器不支持网页存储!"); alert("你的浏览器不支持网页存储!"); } } //改变项目标题 function changeOrderHeaderList() { var textareaContent = document.getElementById("orderHeaderList").value; if (textareaContent.search(/\S+/) === -1) { textareaContent = orderHeaderList.join("\n") + "\n"; document.getElementById("orderHeaderList").value = textareaContent; Toast("项目标题不能为空!"); console.info("项目标题不能为空!"); alert("项目标题不能为空!"); } else { orderHeaderList = textareaContent.match(/\S+/g); textareaContent = orderHeaderList.join("\n") + "\n"; document.getElementById("orderHeaderList").value = textareaContent; Toast("设置项目标题!"); console.info("设置项目标题!"); console.info("orderHeaderList[" + orderHeaderList.length + "]:" + orderHeaderList); } } //重置项目标题 function resetOrderHeader() { var textareaContent = ""; orderHeaderList = defaultOrderHeaderList; textareaContent = orderHeaderList.join("\n") + "\n"; document.getElementById("orderHeaderList").value = textareaContent; Toast("重置项目标题!"); console.info("重置项目标题!"); console.info("orderHeaderList[" + orderHeaderList.length + "]:" + orderHeaderList); } //改变黑名单列表 function changeBlackListKey() { var textareaContent = document.getElementById("BlackListKey").value; if (textareaContent.search(/\S+/) === -1) { document.getElementById("BlackListKey").value = ""; blackList = []; Toast("清空黑名单列表!"); console.info("清空黑名单列表!"); console.info("blackList:" + blackList); } else { blackList = textareaContent.match(/\S+/g); textareaContent = blackList.join("\n") + "\n"; document.getElementById("BlackListKey").value = textareaContent; Toast("设置黑名单列表!"); console.info("设置黑名单列表!"); console.info("blackList[" + blackList.length + "]:" + blackList); } } //重置黑名单列表 function resetBlackList() { var textareaContent = ""; blackList = defaultBlackList; textareaContent = blackList.join("\n") + "\n"; document.getElementById("BlackListKey").value = textareaContent; Toast("重置黑名单列表!"); console.info("重置黑名单列表!"); console.info("blackList[" + blackList.length + "]:" + blackList); } //启用/禁用 商品名黑名单过滤 function changeBlackListStatus() { const isEnableBlackListStatus = document.getElementById("BlackListStatus").checked; if (isEnableBlackListStatus === true) { document.getElementById("resetBlackList").disabled = false; document.getElementById("resetBlackList").style.opacity = 1; Toast("启用商品名黑名单过滤!"); console.info("启用商品名黑名单过滤!"); } else { document.getElementById("resetBlackList").disabled = true; document.getElementById("resetBlackList").style.opacity = 0.6; Toast("禁用商品名黑名单过滤!"); console.info("禁用商品名黑名单过滤!"); } } //启用/禁用 快照获取随机延时 function changeDelayStatus() { const isEnableDelayStatus = document.getElementById("DelayStatus").checked; if (isEnableDelayStatus === true) { Toast("启用快照获取随机延时!"); console.info("启用快照获取随机延时!"); } else { Toast("禁用快照获取随机延时!"); console.info("禁用快照获取随机延时!"); } } //启用/禁用 快照商品名称获取 function changeSnapProductNameStatus() { const isEnableSnapProductNameStatus = document.getElementById("SnapProductNameStatus").checked; if (isEnableSnapProductNameStatus === true) { Toast("启用快照商品名称获取!"); console.info("启用快照商品名称获取!"); } else { Toast("禁用快照商品名称获取!"); console.info("禁用快照商品名称获取!"); } } //启用/禁用 Excel数据格式适配 function changeDataFormatAdaptationStatus() { const isEnableDataFormatAdaptationStatus = document.getElementById("DataFormatAdaptationStatus").checked; if (isEnableDataFormatAdaptationStatus === true) { Toast("启用Excel数据格式适配!"); console.info("启用Excel数据格式适配!"); } else { Toast("禁用Excel数据格式适配!"); console.info("禁用Excel数据格式适配!"); } } //启用/禁用 订单详情链接一致化 function changeUrlUniformizationStatus() { const isEnableUrlUniformizationStatus = document.getElementById("UrlUniformizationStatus").checked; if (isEnableUrlUniformizationStatus === true) { Toast("启用订单详情链接一致化!"); console.info("启用订单详情链接一致化!"); } else { Toast("禁用订单详情链接一致化!"); console.info("禁用订单详情链接一致化!"); } } // 改变图片尺寸大小 function changeImageDimensions() { const radios = document.getElementsByName("imageDimensions"); const ListSelect = document.getElementById("imageDimensionsListSelect"); var imageDimensionsTemp = null; for (let radio of radios) { if (radio.checked === true) { imageDimensionsTemp = radio; break; } } if (imageDimensionsTemp.value !== "otherImageDimensions") { const imageDimensionsIndexTemp = imageDimensionsList.indexOf(imageDimensionsTemp.value); if (imageDimensionsIndexTemp !== -1) { imageDimensionsIndex = imageDimensionsIndexTemp; } } else { imageDimensionsIndex = ListSelect.selectedIndex; } console.log("radios index: " + Array.from(radios).indexOf(imageDimensionsTemp) + "; radios value: " + imageDimensionsTemp.value); console.log("Selected Value: " + ListSelect.value + "; Selected Text: " + ListSelect.options[ListSelect.selectedIndex].text); console.log("imageDimensions index: " + imageDimensionsIndex + " image dimensions: " + imageDimensionsList[imageDimensionsIndex]); } // 监听下拉列表的变化,改变图片尺寸大小 function choseImageDimensions() { const ListSelect = document.getElementById("imageDimensionsListSelect"); if (document.getElementById("otherImageDimensions").checked === true) { imageDimensionsIndex = ListSelect.selectedIndex; } var selectedValue = ListSelect.value; // 获取选中的值 var selectedText = ListSelect.options[ListSelect.selectedIndex].text; // 获取选中的文本 console.log("Selected Value: " + selectedValue + "; Selected Text: " + selectedText); console.log("imageDimensions index: " + imageDimensionsIndex + " image dimensions: " + imageDimensionsList[imageDimensionsIndex]); } //数据转为csv文本文件 function dataToCsv(header, data, filename) { var rows = ""; var row = header.join(","); rows += row + "\n"; for (let key in data) { rows += data[key].join(",") + "\n"; } var blob = new Blob(["\ufeff" + rows], { type: "text/csv;charset=utf-8;" }); var encodedUrl = URL.createObjectURL(blob); var url = document.createElement("a"); url.setAttribute("href", encodedUrl); url.setAttribute("download", filename + ".csv"); document.body.appendChild(url); url.click(); } //获取交易快照数据 function getDataFromSnapShot(orderItemIndex, orderItemDataIndex, snapUrl) { const isenableDelay = document.getElementById("DelayStatus").checked; var randomTimeout = 0; if (httpGetResult.snapShotCount === 0) { httpGetResult.snapShotTotal = 0; console.time("getDataFromSnapShot"); } httpGetResult.snapShotCount++; httpGetResult.snapShotTotal = httpGetResult.snapShotCount; if (isenableDelay === true) { const min = 1000; //毫秒 const max = 3000; //毫秒 randomTimeout = Math.round(Math.random() * (max - min)) + min; } setTimeout(function () { const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var ShotProductName = null; var JSONString = null; var JSONData = {}; httpGetResult.snapShotCount--; //console.info("交易快照网页链接:" + snapUrl); var responseString = this.responseText; //console.info("交易快照网页响应文本:" + responseString); if (ShotProductName === null) { //在交易快照页面通过正则表达式获取HTML数据后获取标题 //