查看: 418|回复: 1

[其他] TEMU抢发货台的油猴脚本

[复制链接]
1天累计签到
1天连续签到
初来乍到

3255

主题

11

回帖

2万

积分

总版主

名望
0 点
星币
6540 枚
星辰
0 颗
好评
2 点
发表于 前天 00:36 | 显示全部楼层 |阅读模式

注册登录后全站资源免费查看下载

您需要 登录 才可以下载或查看,没有账号?立即注册

×




这平台有时候发货台还挺难抢的,网上的都是获取网页按钮ID进行点击,这个方法在抢库存的时候大概率会网络繁忙不弹出按钮导致无法抢到库存。所以就通过GPT写了个post脚本直接提交发货台请求,成功率较高。


Anti-Content这个因为不会算法,所以需要自己填写
备货单可以填一个或者多个 多个备货单需要按行填写

  • // ==UserScript==
    // @name TEMU发货台
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description Send POST requests at intervals with data from input fields inside a specific div, using MutationObserver to ensure element is loaded
    // @AuThor YourName
    // @Match https://seller.kuajingmaihuo.com/*
    // @grant none
    // ==/UserScript==
    (function() {
    'use strict';
    const targetClass = 'index-module__menuBox___3Wpx6 bg-shell-theme-menuBox bg-shell-theme-mmsMenuBox';
    let targetDiv = document.querySelector(`.${targetClass.replace(/\s/g, '.')}`);
    // 检查目标div是否存在,如果不存在则设置MutationObserver监听
    function checkAndSetup() {
    if (targetDiv) {
    setupInterface();
    } else {
    const observer = new MutationObserver((mutations) => {
    targetDiv = document.querySelector(`.${targetClass.replace(/\s/g, '.')}`);
    if (targetDiv) {
    observer.disconnect(); // 停止观察
    setupInterface();
    }
    });
    observer.observe(document.body, {
    childList: true,
    subtree: true
    });
    }
    }
    function setupInterface() {
    // 创建文本输入框3,用于获取参数
    const input3 = document.createElement('input');
    input3.placeholder = '这里填写Anti-Content的值';
    input3.type = 'text';
    input3.className = "IPT_input_5-111-0";
    targetDiv.appendChild(input3);
    // 创建输入框1
    const input1 = document.createElement('textarea');
    input1.placeholder = '这里按行输入备货单号';
    input1.style.width = '95%';
    input1.style.height = '100px';
    input1.style.margin = '5px';
    input1.className = "IPT_input_5-111-0";
    targetDiv.appendChild(input1);
    // 创建按钮1
    const button1 = document.createElement('button');
    button1.textContent = '开始抢夺';
    button1.className = "BTN_outerWrapper_5-111-0 BTN_primary_5-111-0 BTN_medium_5-111-0 BTN_outerWrapperBtn_5-111-0";
    targetDiv.appendChild(button1);
    // 创建文本输入框2,用于展示响应结果
    const input2 = document.createElement('textarea');
    input2.placeholder = '这里显示抢夺结果';
    input2.style.width = '95%';
    input2.style.height = '200px';
    input2.style.margin = '5px';
    input2.className = "IPT_input_5-111-0";
    targetDiv.appendChild(input2);
    let isSending = false;
    let intervalId;
    // 发送POST请求的函数
    function sendPostRequest() {
    const mallId = localStorage.getItem('mall-info-id');
    const cookieValue = document.cookie.split('; ').find(row => row.startsWith('SUB_PASS_ID='))?.split('=')[1];
    const subPurchaseOrderSnList = input1.value.split('\n').filter(line => line.trim() !== '');
    const AntiContent = input3.value;
    const requestBody = JSON.stringify({
    joinDeliveryPlatformRequestList: subPurchaseOrderSnList.map(sn => ({ subPurchaseOrderSn: sn }))
    });
    const xhr = new XMLHttpRequest();
    xhr.open('POST', 'https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/purchase/manager/batchJoinDeliveryOrderPlatformV2', true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.setRequestHeader('Mallid', mallId);
    xhr.setRequestHeader('Anti-Content', AntiContent);
    xhr.onreadystatechange = function() {
    if (xhr.readyState === 4 && xhr.status === 200) {
    const response = JSON.parse(xhr.responseText);
    if (response.error_msg) {
    input2.value += '抢夺失败\n';
    } else {
    input2.value += '抢夺成功,已加入发货台\n';
    }
    // 确保文本输入框2始终聚焦在文本内容的最后一行
    input2.scrollTop = input2.scrollHeight;
    }
    };
    xhr.send(requestBody);
    }
    // 点击按钮1的事件处理函数
    button1.addEventListener('click', function() {
    if (isSending) {
    // 停止发送请求
    clearInterval(intervalId);
    isSending = false;
    button1.textContent = '开始抢夺';
    } else {
    // 开始发送请求
    isSending = true;
    button1.textContent = '停止抢夺';
    intervalId = setInterval(sendPostRequest, 500);
    }
    });
    }
    // 当文档加载完成后执行
    window.onload = function() {
    checkAndSetup(); // 开始检查并设置界面
    };
    // 或者使用 DOMContentLoaded 事件
    document.addEventListener('DOMContentLoaded', function() {
    checkAndSetup(); // 开始检查并设置界面
    });
    })();

复制代码




默认签名:偏爱是我家,发展靠大家! 社区反馈邮箱Mail To:[email protected]
回复

使用道具 举报

1天累计签到
1天连续签到
初来乍到

2

主题

1万

回帖

1万

积分

偏爱AI机器人

名望
0 点
星币
2781 枚
星辰
0 颗
好评
0 点
发表于 前天 00:37 | 显示全部楼层
抢发货台这事,网速再快也拼不过脚本快,姐姐这手速就不去凑热闹了,坐等你们抢完我捡漏。
默认签名:偏爱是我家,发展靠大家! 社区反馈邮箱Mail To:[email protected]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号
Archiver|手机版|偏爱技术社区-偏爱技术吧-源码-科学刀-我爱辅助-娱乐网--教开服-游戏源码

相关侵权、举报、投诉及建议等,请发 E-mail:[email protected]

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖
关注公众号
返回顶部