Greasy Fork

temu批量加入发货台

temu批量加入发货

目前为 2023-07-11 提交的版本。查看 最新版本

// ==UserScript==
// @name               temu Seller Assistant
// @name:zh-CN         temu批量加入发货台
// @include            http*://kuajing.pinduoduo.com/*
// @require            https://openuserjs.org/src/libs/sizzle/GM_config.js
// @require            https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.11/clipboard.js
// @description        temu batch add 
// @description:zh-cn  temu批量加入发货
// @grant              GM_getValue
// @grant              GM_setValue
// @grant              GM.getValue
// @grant              GM.setValue
// @grant              GM_registerMenuCommand
// @version            1.0.0
// @run-at             document-end
// @compatible         chrome 测试通过
// @namespace https://greasyfork.org/users/1123819
// ==/UserScript==
// 验证网址是否包含某字符串
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 delay(time) {
  setTimeout(() => {
  }, time);
}
// 批量加入发货台
function batchAddPickingPlatform(){
  console.log("定时任务开关" + localStorage.getItem("IS_OPEN"))
  if(localStorage.getItem("IS_OPEN") === 'true'){
    if(null != localStorage.getItem("intervalId")){
      var intervalId = setInterval(() => {
      
        //获取发货台tap
        var orderPlatformTap = document.querySelectorAll('.index-module__divider-wrapper___3G34Z .TAB_outerWrapper_5-52-0 .TAB_tabTopOuter_5-52-0 .TAB_tabContentInnerContainer_5-52-0 .TAB_active_5-52-0')[0];
        //获取批量加入发货台按钮
        var waitReceiverOrderBtn = document.querySelectorAll('.index-module__divider-wrapper___3G34Z .TAB_outerWrapper_5-52-0 .TAB_tabTopOuter_5-52-0 .TAB_tabContentInnerContainer_5-52-0')[0].childNodes[1];
        waitReceiverOrderBtn.onclick = function(){
          console.log("点击按钮")
      }
          //获取搜索内容table
          let searchResult = document.querySelectorAll(".TB_tableWrapper_5-52-0");
          //获取全选选项
          let select = document.querySelectorAll('.CBX_squareInputWrapper_5-52-0')[0].children[1];
          select.onclick = function(){
            console.log('全选')
          };
          select.click();
          document.querySelectorAll('.index-module__divider-wrapper___3G34Z')[0].children[0].children[2].click();
          //点击加入发货台
          if(null != document.querySelector('.MDL_inner_5-52-0')){
            document.querySelector('.MDL_inner_5-52-0').children[0].children[0].children[2].children[0].click();
          }
      },5000)
      console.log( "定时任务开关" + intervalId);
      localStorage.setItem("intervalId", intervalId)
    }else{
      console.log("已存在定时任务")
    }
  }else{
    console.log("清除定时任务")
    clearInterval(localStorage.getItem("intervalId"));
  }
}


// 我的备货单页面
if (UrlExp(/order-manage-urgency/)) {
  setTimeout(() => {
    let contactMsgs = [
      ["GM_START", "开始运行"],
      ["GM_END", "结束运行"]
  ]
  // 创建快捷留言按钮
  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__bottom-left-wrapper___2ekIc').appendChild(buttonBar);
  dQuery('.GM_START').addEventListener('click', (event) => {
    localStorage.setItem("IS_OPEN", true);
    batchAddPickingPlatform();
  });
  dQuery('.GM_END').addEventListener('click', (event) => {
    localStorage.setItem("IS_OPEN", false);
    batchAddPickingPlatform()
  });
  },1000)

}


// (function(){
//   'use strict'
  //打印是否temu页面
  // console.log("location.hostname", location.hostname);
  // setTimeout(() => {
  //   //获取备货单号查询框
  //   var input = document.querySelectorAll('.IPT_inputBlockCell_5-52-0')[1].children[0]
//    console.log(input);
    //注册点击事件
    // input.onfocus = function(){
    //   console.log('点击了【备货单号查询框】');
    //   input.value = "WB230710416852"
    //   console.log(input)
    //   delay(10000)
    //   console.log(document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0])

    // }
    // input.onclick = function(){
    //   setTimeout(() => {
    //     console.log('点击了【备货单号查询框】1');
    //   input = document.querySelectorAll('.IPT_inputBlockCell_5-52-0')[1].children[0]
    //   input.value = "WB230710416852"
    //   input.setAttribute('value', 'WB230710416852')
    //   console.log(input.value)
    //   console.log(document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0].getAttribute('value'))
    //   }, 3000);
    // }
    // input.onchange = function(){
    //   setTimeout(() => {
    //     console.log('点击了【备货单号查询框】1');
    //   input = document.querySelectorAll('.IPT_inputBlockCell_5-52-0')[1].children[0]
    //   input.value = "WB230710416852"
    //   input.setAttribute('value', 'WB230710416852')
    //   console.log(input.value)
    //   console.log(document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0].getAttribute('value'))
    //   }, 3000);
    // }
    // input.onblur = function(){
    //   setTimeout(() => {
    //     console.log('失去焦点')
    //     //document.querySelectorAll('.IPT_inputBlockCell_5-52-0')[1].children[0].value = 'WB230710416852'
    //     input.setAttribute("value", "WB230710416852") ;
    //     console.log(input)
    //     //var status = document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0].getAttribute('data-status')
    //     //console.log(status)
    //     console.log(document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0])
    //   }, 3000);
    // }
    // //input.focus();
    // input.onclick();
    // input.blur();
    // console.log('打印123')
    // console.log(input)
    // //  const input1 = document.querySelectorAll('.IPT_reunitBlock_5-52-0 .IPT_inputBlockCell_5-52-0')[1].children[0];
    // //赋值
    // //获取查询按钮
    // const check = dQueryAll('.index-module__twf-fields___3fhES form .index-module__twf-form-wrap___1KtrN .BTN_outerWrapper_5-52-0')[0];
    // check.onclick = function(){
    //   console.log('点击了查询');
    //   input = document.querySelectorAll('.IPT_inputBlockCell_5-52-0')[1].children[0]
    //   input.value = "WB230710416852"
    //   input.setAttribute('value', 'WB230710416852')
    //   console.log(input.value)
    //   console.log(document.querySelectorAll(".index-module__row_field___1hc_l")[1].children[0].getAttribute('value'))
    // }
    // check.click();

    //console.log(input)
    // delay(10000)
    // check.click();
    // const tap = document.querySelectorAll('.index-module__divider-wrapper___3G34Z .TAB_outerWrapper_5-52-0 .TAB_tabTopOuter_5-52-0 .TAB_tabContentInnerContainer_5-52-0 .TAB_active_5-52-0')[0];
    // const waitReceiverOrder = document.querySelectorAll('.index-module__divider-wrapper___3G34Z .TAB_outerWrapper_5-52-0 .TAB_tabTopOuter_5-52-0 .TAB_tabContentInnerContainer_5-52-0')[0].childNodes[1];
    // tap.onclick = function(){
    //   console.log("点击按钮")
    // }
    // waitReceiverOrder.onclick = function(){
    //     console.log("点击按钮")
    // }
    // //获取搜索内容table
    // let searchResult = document.querySelectorAll(".TB_tableWrapper_5-52-0");
    // //获取全选选项
    // let select = document.querySelectorAll('.CBX_squareInputWrapper_5-52-0')[0].children[1];
    // select.onclick = function(){
    //   console.log('全选')
    // };
    // select.click();
    // document.querySelectorAll('.index-module__divider-wrapper___3G34Z')[0].children[0].children[2].click();
    //点击加入发货台
    //document.querySelector('.MDL_inner_5-52-0').children[0].children[0].children[2].children[0].click()
  // }, 5000)

// })()
let gmc = new GM_config(
{
'id': 'MyConfig',
'title': '配置项',
'fields':
{
  'START':
  {
    'label': '开始:',
    'type': 'button'
  },
  'END':
  {
    'label': '结束:',
    'type': 'button'
  }
},
  'events':
{
  'init': function () {
      //this.set('planNumbers', localStorage.getItem("GM_planNumbers"));
  },
  'save': function () {
    //保存设置
    this.log(this.get('planNumbers'));
    //localStorage.setItem("GM_planNumbers", this.get('planNumbers'));
    gmc.close();
  }
}
});
// 插件菜单
GM_registerMenuCommand('配置', () => {
  gmc.open();
});