Greasy Fork

Greasy Fork is available in English.

temu加入发货台

This script mainly solves the delivery problem of temu buyers

当前为 2023-08-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               temu Seller Assistant
// @name:zh-CN         temu加入发货台
// @include            http*://kuajing.pinduoduo.com/*
// @require            https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js
// @description        This script mainly solves the delivery problem of temu buyers
// @description:zh-cn  脚本主要解决temu买家发货问题
// @grant              GM_getValue
// @grant              GM_setValue
// @grant              GM.getValue
// @grant              GM.setValue
// @grant              GM_registerMenuCommand
// @version            3.0.7
// @run-at             document-end
// @compatible         chrome 测试通过
// @namespace http://greasyfork.icu/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);
}
const DATA_TEST_ID_1 = "beast-core-modal-mask";

const DATA_TEST_ID_2 = "beast-core-modal";
// 批量加入发货台
function batchAddPickingPlatform(){
  console.log("定时任务开关" + localStorage.getItem("IS_OPEN"))
  if(localStorage.getItem("IS_OPEN") === 'true'){
    if(null !== localStorage.getItem("intervalId")){
      console.log("清除已存在定时任务" + localStorage.getItem("intervalId"));
      clearInterval(localStorage.getItem("intervalId"));
    }
    var intervalId = setInterval(() => {
      setInterval(() => {}, 1000)
      //获取发货台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')[0].childNodes[0].childNodes[2];
        //获取搜索内容table
        let searchResult = document.querySelectorAll(".TB_tableWrapper_5-52-0");
        //获取全选选项
        let select = document.querySelectorAll('.CBX_squareInputWrapper_5-72-0')[0];
        select.click();
        window.onload  = add()
    },4000)
    console.log( "定时任务开关" + intervalId);
    localStorage.setItem("intervalId", intervalId)
  }else{
    console.log("清除定时任务")
    clearInterval(localStorage.getItem("intervalId"));
  }
}


// 我的备货单页面
if (UrlExp(/order-manage-urgency|order-manage/)) {
  setInterval(() => {
    console.log('定时检测页面是否刷新')
    let contactMsgs = [
      ["GM_START", "开始运行"],
      ["GM_END", "结束运行"]
  ]
  // 创建快捷留言按钮
  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___3W6IS').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()
    });
    endAddPickingPlatform();
  }
  },3000)

}

function endAddPickingPlatform(){
  document.addEventListener('keyup', (e) => {
    console.log("强制结束定时任务" + localStorage.getItem("intervalId"));
    if(e.key === 'h'){
      if(null !== localStorage.getItem("intervalId")){
        console.log("清除已存在定时任务" + localStorage.getItem("intervalId"));
        clearInterval(localStorage.getItem("intervalId"));
        //删除弹窗
        let length = document.body.children.length;
        console.log("关闭弹窗,当前body长度" + length);
        while(length >= 9){
          console.log("循环关闭弹窗" + length);
          document.body.children[length - 1].remove;
          length = length - 1;
        }
      }
    }
  })
}

function add(){
  document.querySelectorAll('.index-module__divider-wrapper___3G34Z')[0].children[0].children[2].click();
          //点击加入发货台
          if(document.querySelector('.MDL_innerWrapper_5-72-0')){
            document.querySelector('.MDL_innerWrapper_5-72-0').childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[0].click();
            for(let i = document.body.children.length - 1 ; i >= 0 ; i--){
              console.log(document.body.children[i].getAttribute("data-testid"));
              var data_test_id = document.body.children[i].getAttribute("data-testid");
              if(DATA_TEST_ID_1 === document.body.children[i].getAttribute("data-testid")){
                document.body.children[i].remove();
              }else if(DATA_TEST_ID_2 === document.body.children[i].getAttribute("data-testid") && "MDL_outerWrapper_5-72-0 MDL_alert_5-72-0 undefined" !== document.body.children[i].getAttribute("class")){
                document.body.children[i].remove();
              }else if("beast-core-toast" === document.body.children[i].getAttribute("data-testid") ){
                document.body.children[i].remove();
              }else if(!document.body.children[i].getAttribute("id")){
                console.log('删除空元素')
                document.body.children[i].remove();
              }
            }
          }

//加入发货台(单独点击)
function dddPickingPlatform(){
  console.log("定时任务开关" + localStorage.getItem("IS_OPEN"))
  if(localStorage.getItem("IS_OPEN") === 'true'){
    if(null !== localStorage.getItem("intervalId")){
      console.log("清除已存在定时任务" + localStorage.getItem("intervalId"));
      clearInterval(localStorage.getItem("intervalId"));
    }
    var intervalId = setInterval(() => {
      setInterval(() => {}, 1000);
      //获取当前发货台表格body
      let tableBody = dQuery(".TB_tableWrapper_5-72-0");

    },100)
    console.log( "定时任务开关" + intervalId);
    localStorage.setItem("intervalId", intervalId)
  }else{
    console.log("清除定时任务")
    clearInterval(localStorage.getItem("intervalId"));
  }
}
}