Greasy Fork is available in English.

temu Seller Assistant

temu batch add

// ==UserScript==
// @name               temu Seller Assistant
// @name:zh-CN         temu批量加入发货台
// @include            http*://seller.kuajingmaihuo.com/main/*
// @require            https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js
// @description        temu batch add
// @description:zh-cn  temu批量加入发货
// @grant              GM_getValue
// @grant              GM_setValue
// @version            3.1.7
// @run-at             document-end
// @compatible         chrome 测试通过
// @namespace          https://greasyfork.org/users/1123819
// @require https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js
// 验证网址是否包含某字符串
// ==/UserScript==
// 验证网址是否包含某字符串

var html = '';
var sheetName = '销售数据';
var tmp_case_num = '';
var total_num = 0;
var total_page = 0;
var case_count = 0;
var speed = 5;
var tempArr = []
const thead =
[['商品信息','SKU属性', '申报价格(USD)','SKU货号','开款价格状态','调价状态','缺货数量',
'近7日用户加购数量','用户累计加购数量','已订阅待提醒到货',
'销售数据-今日','销售数据-近7天','销售数据-近30天',
'生产建议信息-生产信息','生产建议信息-建议生产数','生产建议信息	-剩余件数',
'库存数据-仓内可用库存','库存数据-仓内暂不可用库存','库存数据-已发货库存','库存数据-已创建备货单待发货库存','库存数据-待审核备货库存',
'VMI备货单数-待发货','VMI备货单数-在途单数','VMI备货单数-发货延迟','VMI备货单数-到货延迟',
'非VMI备货单数-待发货','非VMI备货单数-在途单数','非VMI备货单数-发货延迟','非VMI备货单数-到货延迟',
'备货计划-备货逻辑','备货计划-建议备货量','备货计划-库存可售天数','备货计划-仓内库存可售天数','备货计划-可售天数',
'建议备货引导']]

const header = {
    spu: '商品信息', skuValue: 'SKU属性'
  }
function UrlExp(textStr) {
    return RegExp(textStr).test(window.location.href);
  }
  // 创建选择器的简化写法
  function dQuery(selector) {
    return document.querySelector(selector);
  }
  function dQueryAll(selector) {
    return document.querySelectorAll(selector);
  }
  //初始化参数
  function init(){
  //清除定时任务
  localStorage.removeItem("intervalId")
  // 我的备货单页面
  if (UrlExp(/order-manage-urgency|order-manage|shipping-desk|sale-manage/)) {
    setTimeout(() => {
      let contactMsgs = [
        ["GM_START_DELIVERY", "开始加入发货台"],
        ["GM_END_DELIVERY"  , "结束加入发货台"],
        ["COLLECT_SALE_DATA", "销售数据采集"]
    ]
    let button = dQuery('.GM_START');
    if(null === button){
      let buttonBar = document.createElement('div');
      contactMsgs.forEach((item) => {
          buttonBar.innerHTML += `<input class="${item[0]}" type="button" value="${item[1]}" style="margin: 20px;"/>`;
      });
      dQuery('.index-module__sidebarBox___K3GYq').appendChild(buttonBar);
      dQuery('.GM_START_DELIVERY').addEventListener('click', (event) => {
        startAddShippedTable();
      });
      dQuery('.GM_END_DELIVERY').addEventListener('click', (event) => {
        endAddShippedTable();
      });
      dQuery('.COLLECT_SALE_DATA').addEventListener('click', (event) => {
        collectSaleData();
      });
    }
    },3000)

    urlHasChange();
  }
  }

  //开始加入发货台
  function startAddShippedTable(){
  if(null !== localStorage.getItem("intervalId")){
    console.log("任务已存在");
    clearInterval(localStorage.getItem("intervalId"));
  }
  var intervalId = addDeliverTable();
  console.log( "定时任务开关" + intervalId);
  localStorage.setItem("intervalId", intervalId)
  }

  //结束加入发货台
  function endAddShippedTable(){
    if(null !== localStorage.getItem("intervalId")){
        console.log("清除已存在定时任务" + localStorage.getItem("intervalId"));
        clearInterval(localStorage.getItem("intervalId"));
        localStorage.removeItem("intervalId")
      }
  }

  //开始创建发货单
  function startCreateInvoice(){
    if(null !== localStorage.getItem("createInvoiceId")){
        console.log("任务已存在")
        clearInterval(localStorage.getItem("createInvoiceId"));
      }
      var intervalId = createInvoice();
      console.log( "定时任务开关" + intervalId);
      localStorage.setItem("createInvoiceId", intervalId);
  }

  //结束创建发货单
  function endCreateInvoice(){
    if(null !== localStorage.getItem("createInvoiceId")){
        console.log("清除已存在定时任务" + localStorage.getItem("createInvoiceId"));
        clearInterval(localStorage.getItem("createInvoiceId"));
        localStorage.removeItem("createInvoiceId")
      }
  }


  //加入发货台
  function addDeliverTable(){
    var intervalId = setInterval(() => {
        //获取加入发货台按钮
        let btnArr = $('a[data-tracking-id="custom-t3wO-KG-3BT_5xyK"]').filter( function( index , e) {
            var a = e.getAttribute("disabled");
            if(a == null){
                return true;
            }else{
                return false;
            }
        } );
        //点击加入发货台
        btnArr.each(function(index , e){
            e.click();
        });
        //获取确认按钮
        let comfirmArr = dQueryAll('.PP_popoverContent_5-113-0 .body-module__footer___iiLIw');
        //逐个点击
        comfirmArr.forEach(e =>{
            setTimeout(function(){
                let btn = e.querySelectorAll('button')[0]
                btn.click()
            },generateRandom(500, 1000, 300))
        })
        var failWindow = document.querySelector('div[data-testid="beast-core-modal"]');
        if(null !== failWindow){
          failWindow.parentNode.removeChild(failWindow)
        }
    },1500);
    return intervalId
  }
  //创建发货单
  function createInvoice(){
  var intervalId = setInterval(() => {
    console.log('创建发货单')
    if(UrlExp(/shipping-list/)){
      //返回发货台
      console.log('返回发货台')
      returnShippingDesk();
    }
    //点击查询按钮
    let button = $('button[data-tracking-id="xqVOakOmzZvI1RvU"]');
    button.each(function(index , e){
      e.click();
  });
    setTimeout(function() {}, 1000)
    let inputArr = dQueryAll('.CBX_squareInputWrapper_5-72-0');
    inputArr.forEach((element, index) => {
        if (index === 0) {
          return;
        }
          //点击创建发货单
          element.click();
        //console.log(element);
      });
      setTimeout(function(){
        //点击创建发货单
        let createInvoiceBtn = $('button[data-tracking-id="O2EwJMyrt0ciAraT"]');
        createInvoiceBtn.click();
      },2000);
      //点击确认创建发货单
      setTimeout(function(){
        let confirmsArr = document.querySelector('.body-module__footer___APhLF');
        let button = confirmsArr.querySelector('button');
        button.click();
      },1000);
      if(UrlExp(/create/)){
      //点击创建备货单
      let create = document.querySelector('.shipping-desk_nBarWrapper__bXfOf');
      let button = create.querySelector('button');
      button.click();
      }
  }, 20000)
  return intervalId;
  }
  //返回发货台
  function returnShippingDesk(){

  let shippingDeskMenu = $('a[data-tracking-id="menu-/main/order-manager/shipping-desk"]');
  shippingDeskMenu.each(function(index , e){
    e.click();
  });
  }

  //加入发货台
  function collectSaleData(){
    //获取表格数据
    var saleDataContent = document.querySelectorAll('.TB_tableWrapper_5-109-0')[1]
    //获取分页信息
    var pageInfo = document.evaluate('/html/body/div[1]/div/div/div[2]/div[2]/div[2]/div/div/div/div/div[2]/div[2]/div[2]/div[3]/ul/li[1]',document).iterateNext().innerText;
    //获取总条数
    total_num = pageInfo.slice(2, pageInfo.length - 1);
    console.log(total_num)
    //获取分页参数
    let pageSize = document.evaluate('/html/body/div[1]/div/div/div[2]/div[2]/div[2]/div/div/div/div/div[2]/div[2]/div[2]/div[3]/ul/li[2]/div/div/div/div/div/div/div/div[1]/input',document).iterateNext().value;
    loopNext(tmp_case_num, 1, saleDataContent, 1);
    return saleDataContent
  }

  function downloadExcel(tempArr) {
    // 创建一个新的工作簿对象
    const wb = XLSX.utils.book_new()
    // 将二维数组转换为工作表对象
    const ws = XLSX.utils.json_to_sheet(tempArr)
    XLSX.utils.sheet_add_aoa(ws, thead, { origin: "A1" });
    ws["!cols"] = [ { wch: 20 } ];
    // 将工作表对象添加到工作簿中,'Sheet1'为工作表的名称
    XLSX.utils.book_append_sheet(wb, ws, '销售数据')
    // 将工作簿数据写入文件,'exported_data.xlsx'为导出文件的名称
    XLSX.writeFile(wb, '销售数据.xlsx')
}

function loopNext(tmp_case_num, next_page, tableContent){
    let timer = setInterval(() =>{

            let case_num = Number(document.querySelector('.PGT_outerWrapper_5-109-0 .PGT_pagerItemActive_5-109-0').innerText)
            if (case_num != tmp_case_num ) {
                clearInterval(timer);
                tmp_case_num = case_num;
                console.log('Processing...');
                //console.log('Processing for page ' + next_page + '/' + total_page + ' ...');
                //获取表格数据
                tableContent = document.querySelectorAll('.TB_tableWrapper_5-109-0')[1]
                let tr = tableContent.children[1].children
                case_count += tr.length;
                addNewData(tr);
                var clickNum = Math.ceil(total_num / 10);
                console.log(clickNum)
                if (tmp_case_num < clickNum) {
                  document.querySelector('.PGT_next_5-109-0').click();
                    setTimeout(()=>{
                        loopNext(tmp_case_num, next_page + 1, tableContent);
                    }, 10000 / speed + 100);
                } else {
                    setTimeout(()=>{
                        downloadExcel(tempArr);
                        tempArr.length = 0
                        console.log("%c一共"+case_count+"/"+total_num+"份课程,请注意核对数量是否正确,内容是否重复!",'color:#ba0707;font-size:20px;font-weight: bold;');
                    }, 5000);
                }
            }
        },
        7 * 1000 / speed);
}

function addNewData(tr) {
    var spuValue = null;
    //遍历表格数据,分组
    tr.forEach((element, index) => {
      var jsonObj = {};
      var isMainInfo = false;
      var isEndInfo = false;
      element.children.forEach((el, index) => {
        //判断当前行是否为主信息行
        if(element.querySelector('.main_productInfo__1t8Sv') !== null){
          isMainInfo = true
        }else{
          isMainInfo = false
        }
        //设置生产信息
        if(spuValue !== null){
          jsonObj.spuValue = spuValue
        }
      if(isMainInfo == true && index > 0){
        //判断开头列,是否有主信息
        if(index == 1){
          if(el.querySelector('.main_productInfo__1t8Sv') !== null){
            //获取SPU
            if(null !== el.querySelector('.main_productInfo__1t8Sv').getElementsByTagName('p')[3].innerText){
              spuValue = el.querySelector('.main_productInfo__1t8Sv').getElementsByTagName('p')[3].innerText
            }
          }
        }else if(index == 2){
          //SKU属性
          var skuValue = el.getElementsByTagName('p')[0].innerText
          jsonObj.skuValue = skuValue;
        }else if(index == 3){
         try{
            //申报价格(USD)
            var declarePrice = el.getElementsByTagName('div')[0].innerText
            jsonObj.declarePrice = declarePrice
          }catch(err){
            console.log(el)
          }

        }else if(index == 4){
          //SKU货号
          var skuGoodNo = el.getElementsByTagName('div')[1].innerText
          jsonObj.skuGoodNo  = skuGoodNo
        }else if(index == 5){
          //开款价格状态
          var priceStatus = el.getElementsByTagName('div')[0].innerText
          jsonObj.priceStatus  = priceStatus
        }else if(index == 6){
          //调价状态
          var adjustmentStatus = el.getElementsByTagName('div')[0].innerText
          jsonObj.adjustmentStatus  = adjustmentStatus
        }else if(index == 7){
          //缺货数量
          var outOfSstockQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.outOfSstockQuantity  = outOfSstockQuantity
        }else if(index == 8){
          //近7日用户加购数量
          var lastSevenDayQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.lastSevenDayQuantity = lastSevenDayQuantity
        }else if(index == 9){
          //用户累计加购数量
          var userAccumulatedQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.userAccumulatedQuantity = userAccumulatedQuantity
        }else if(index == 10){
          //已订阅待提醒到货
          var arrivalQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.arrivalQuantity = arrivalQuantity
        }else if(index == 11){
          //销售数据-今天
          var todaySaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.todaySaleData = todaySaleData
        }else if(index == 12){
          //销售数据-近7天
          var lastSevenSaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.lastSevenSaleData = lastSevenSaleData
        }else if(index == 13){
          //销售数据-近30天
          var lastThirtySaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.lastThirtySaleData  = lastThirtySaleData
        }else if(index == 14){
          //生产建议信息-生产信息
          var productionInfo = el.getElementsByTagName('div')[0].innerText
          jsonObj.productionInfo = productionInfo
        }else if(index == 15){
          //生产建议信息-建议生产数
          var suggestProQuantity = el.getElementsByTagName('div')[0].innerText
          jsonObj.suggestProQuantity  = suggestProQuantity
        }else if(index == 16){
          //生产建议信息-剩余件数
          var remainQuantity = el.getElementsByTagName('div')[0].innerText
          jsonObj.remainQuantity  = remainQuantity
        }else if(index == 17){
          //库存数据-仓内暂不可用库存
          var noInvQuautity = el.getElementsByTagName('div')[0].innerText
          jsonObj.noInvQuautity = noInvQuautity
        }else if(index == 18){
          //库存数据-已发货库存
          var hasDeliveryInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasDeliveryInv = hasDeliveryInv
        }else if(index == 19){
          //库存数据-已创建备货单待发货库存
          var hasWaitDeliveryInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasWaitDeliveryInv = hasWaitDeliveryInv
        }else if(index == 20){
          //库存数据-待审核备货库存
          var waitAuditingInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.waitAuditingInv = waitAuditingInv
        }else if(index == 21){
          //VMI备货单数-待发货
          var hasWaitDeliveryNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasWaitDeliveryNum = hasWaitDeliveryNum
        }else if(index == 22){
          //VMI备货单数-在途单数
          var inTheWayNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.inTheWayNum = inTheWayNum
        }else if(index == 23){
          //VMI备货单数-发货延迟
          var deliveryDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.deliveryDelay = deliveryDelay
        }else if(index == 24){
          //VMI备货单数-到货延迟
          var arrivalDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.arrivalDelay = arrivalDelay
        }else if(index == 25){
          //非VMI备货单数-待发货
          var nohasWaitDeliveryNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.nohasWaitDeliveryNum = nohasWaitDeliveryNum
        }else if(index == 26){
          //非VMI备货单数-在途单数
          var noinTheWayNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.noinTheWayNum = noinTheWayNum
        }else if(index == 27){
          //非VMI备货单数-发货延迟
          var nodeliveryDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.nodeliveryDelay = nodeliveryDelay
        }else if(index == 28){
          //非VMI备货单数-到货延迟
          var noarrivalDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.noarrivalDelay = noarrivalDelay
        }else if(index == 29){
          //备货计划-备货逻辑
          var stockingLogic = el.getElementsByTagName('div')[0].innerText
          jsonObj.stockingLogic = stockingLogic
        }else if(index == 30){
          //备货计划-建议备货量
          var suggestStockingQuantity = el.getElementsByTagName('div')[0].innerText
          jsonObj.suggestStockingQuantity = suggestStockingQuantity
        }else if(index == 31){
          //备货计划-库存可售天数
          var invSaleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.invSaleDay = invSaleDay
        }else if(index == 32){
          //备货计划-仓内库存可售天数
          var warehouseSaleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.warehouseSaleDay = warehouseSaleDay
        }else if(index == 33){
          //备货计划-可售天数
          var saleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.saleDay = saleDay
        }else if(index == 34){
          //备货计划-建议备货引导
          var suggestStockingGuide = el.getElementsByTagName('div')[0].innerText
          jsonObj.suggestStockingGuide = suggestStockingGuide
        }else if(index == 35){
            //备货计划-建议备货引导
            var guide = el.getElementsByTagName('div')[0].innerText
            jsonObj.guide = guide
          }
      }else if(isMainInfo == false){
        if(index == 0){
          //SKU属性
          if(el.querySelector('.main_totalStyle__nm6Lq') == null){
            var skuValue = el.getElementsByTagName('p')[0].innerText
            jsonObj.skuValue = skuValue;
          }
        }else if(index == 1){
          //申报价格(USD)
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
            try{
              //申报价格(USD)
              var declarePrice = el.getElementsByTagName('div')[0].innerText
              jsonObj.declarePrice = declarePrice
            }catch(err){
              console.log(el)
            }
          }
        }else if(index == 2){
          //SKU货号
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
            var skuGoodNo = el.getElementsByTagName('div')[1].innerText
            jsonObj.skuGoodNo = skuGoodNo
          }
        }else if(index == 3){
          //开款价格状态
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
            var priceStatus = el.getElementsByTagName('div')[0].innerText
            jsonObj.priceStatus  = priceStatus
          }
        }else if(index == 4){
          //调价状态
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var adjustmentStatus = el.getElementsByTagName('div')[0].innerText
          jsonObj.adjustmentStatus  = adjustmentStatus
          }
        }else if(index == 5){
          //缺货数量
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var outOfSstockQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.outOfSstockQuantity  = outOfSstockQuantity
          }
        }else if(index == 6){
          //近7日用户加购数量
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var lastSevenDayQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.lastSevenDayQuantity = lastSevenDayQuantity
          }
        }else if(index == 7){
          //用户累计加购数量
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var userAccumulatedQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.userAccumulatedQuantity = userAccumulatedQuantity
          }
        }else if(index == 8){
          //已订阅待提醒到货
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var arrivalQuantity = el.getElementsByTagName('div')[1].innerText
          jsonObj.arrivalQuantity = arrivalQuantity
          }
        }else if(index == 9){
          //销售数据-今天
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var todaySaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.todaySaleData = todaySaleData
          }
        }else if(index == 10){
          //销售数据-近7天
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var lastSevenSaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.lastSevenSaleData = lastSevenSaleData
          }
        }else if(index == 11){
          //销售数据-近30天
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var lastThirtySaleData = el.getElementsByTagName('div')[0].innerText
          jsonObj.lastThirtySaleData  = lastThirtySaleData
          }
        }else if(index == 12){
          //生产建议信息-生产信息
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var productionInfo = el.getElementsByTagName('div')[0].innerText
          jsonObj.productionInfo = '-'

          //生产建议信息-建议生产数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
            var suggestProQuantity = el.getElementsByTagName('div')[0].innerText
            jsonObj.suggestProQuantity  = suggestProQuantity
            }
          }
        }else if(index == 13){
          //生产建议信息-剩余件数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var remainQuantity = el.getElementsByTagName('div')[0].innerText
          jsonObj.remainQuantity  = remainQuantity
          }
        }else if(index == 14){
          //库存数据-仓内暂不可用库存
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var noInvQuautity = el.getElementsByTagName('div')[0].innerText
          jsonObj.noInvQuautity = noInvQuautity
          }
        }else if(index == 15){
          //库存数据-已发货库存
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var hasDeliveryInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasDeliveryInv = hasDeliveryInv
          }
        }else if(index == 16){
          //库存数据-已创建备货单待发货库存
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var hasWaitDeliveryInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasWaitDeliveryInv = hasWaitDeliveryInv
          }
        }else if(index == 17){
          //库存数据-待审核备货库存
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var waitAuditingInv = el.getElementsByTagName('div')[0].innerText
          jsonObj.waitAuditingInv = waitAuditingInv
          }
        }else if(index == 18){
          //VMI备货单数-待发货
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var hasWaitDeliveryNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.hasWaitDeliveryNum = hasWaitDeliveryNum
          }
        }else if(index == 19){
          //VMI备货单数-在途单数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var inTheWayNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.inTheWayNum = inTheWayNum
          }
        }else if(index == 20){
          //VMI备货单数-发货延迟
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var deliveryDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.deliveryDelay = deliveryDelay
          }
        }else if(index == 21){
          //VMI备货单数-到货延迟
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var arrivalDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.arrivalDelay = arrivalDelay
          }
        }else if(index == 22){
          //非VMI备货单数-待发货
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var nohasWaitDeliveryNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.nohasWaitDeliveryNum = nohasWaitDeliveryNum
          }
        }else if(index == 23){
          //非VMI备货单数-在途单数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var noinTheWayNum = el.getElementsByTagName('div')[0].innerText
          jsonObj.noinTheWayNum = noinTheWayNum
          }
        }else if(index == 24){
          //非VMI备货单数-发货延迟
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var nodeliveryDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.nodeliveryDelay = nodeliveryDelay
          }
        }else if(index == 25){
          //非VMI备货单数-到货延迟
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var noarrivalDelay = el.getElementsByTagName('div')[0].innerText
          jsonObj.noarrivalDelay = noarrivalDelay
          }
        }else if(index == 26){
          //备货计划-备货逻辑
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var stockingLogic = el.getElementsByTagName('div')[0].innerText
          jsonObj.stockingLogic = stockingLogic
          }
        }else if(index == 27){
          //备货计划-建议备货量
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var suggestStockingQuantity = el.getElementsByTagName('div')[0].innerText
          jsonObj.suggestStockingQuantity = suggestStockingQuantity
          }
        }else if(index == 28){
          //备货计划-库存可售天数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var invSaleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.invSaleDay = invSaleDay
          }
        }else if(index == 29){
          //备货计划-仓内库存可售天数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var warehouseSaleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.warehouseSaleDay = warehouseSaleDay
          }
        }else if(index == 30){
          //备货计划-可售天数
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var saleDay = el.getElementsByTagName('div')[0].innerText
          jsonObj.saleDay = saleDay
          }
        }else if(index == 31){
          //备货计划-建议备货引导
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var suggestStockingGuide = el.getElementsByTagName('div')[0].innerText
          jsonObj.suggestStockingGuide = suggestStockingGuide
          }
        }else if(index == 32){
          //备货计划-建议备货引导
          if (el.querySelector('.main_totalStyle__nm6Lq') == null) {
          var guide = el.getElementsByTagName('div')[0].innerText
          jsonObj.guide = guide
          }
        }
      }


      if(isMainInfo == true && index == 2){
        var skuValue = el.getElementsByTagName('p')[0].innerText;
        jsonObj.skuValue = skuValue;
      }
      })
      tempArr.push(jsonObj);
      });
}

  (function(jQuery){
    'use strict';
    console.log('脚本开始执行');
    //初始化参数
    init();
  })();

  function urlHasChange(){
    // 获取当前URL
    var currentUrl = window.location.href;
    // 定时检测URL是否发生变化
    setInterval(function() {
        if (window.location.href !== currentUrl) {
            if (UrlExp(/order-manage-urgency|order-manage/)) {
                endAddShippedTable();
              }else if(UrlExp(/order-manage-urgency|order-manage/)){
                endCreateInvoice();
              }
              console.log('URL发生变化');
              currentUrl = window.location.href;
        }}, 1000);
  }
  function generateRandom(min, max, step) {
    const randomNum = min + Math.random() * (max - min);
    return Math.round(randomNum / step) * step;
  }

  var text = '';
  // 获取按钮元素
var input = document.querySelectorAll('#contactMobile')[0].children[0].children[0].querySelectorAll('input')[1];
//模拟输入事件
let inputEvent = new Event('input', { bubbles: true });
//模拟点击事件
const clickEvent = new Event('click', { bubbles: true });
//修改输入框的值
input.value= text
//触发输入事件
input.dispatchEvent(inputEvent);

// 为按钮添加点击事件监听器
button.addEventListener('click', function(event) {
  this.value = text;
});

// 为按钮添加点击事件监听器
button.addEventListener('mouseleave', function(event) {
  this.value = text;
});

var input = document.querySelectorAll('#contactMobile')[0].children[0].children[0].querySelectorAll('input')[1];

const event = document.createEvent('HTMLEvents')
event.initEvent('input', false, true)
input.dispatchEvent(event) // 手动触发输入框的input事件
var input1 = document.querySelectorAll('#contactMobile')[0].children[0].children[0].querySelectorAll('input')[1];
console.log(input1.parentNode)
input1.value = '' // 修改用户名输入框的值
input1.dispatchEvent(event) // 手动触发输入框的input事件


//触发输入事件
input.dispatchEvent(clickEvent);

//修改输入框的值
input.value= ''
//触发输入事件
input.dispatchEvent(inputEvent);