TemuTools

Temu auto rob tools

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

/*
 * @Author: xx
 * @Date: 2023-08-25 14:41:40
 * @LastEditTime: 2023-08-26 15:32:04
 * @Description:
 */

// ==UserScript==
// @name       TemuTools
// @namespace  npm/vite-plugin-monkey
// @version    0.0.0
// @author     monkey
// @description Temu auto rob tools
// @license    MIT
// @icon       https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png
// @match      https://kuajing.pinduoduo.com/main/order-manage
// @grant      GM.addElement
// @grant      GM.addStyle
// @grant      GM.deleteValue
// @grant      GM.getResourceUrl
// @grant      GM.getValue
// @grant      GM.info
// @grant      GM.listValues
// @grant      GM.notification
// @grant      GM.openInTab
// @grant      GM.registerMenuCommand
// @grant      GM.setClipboard
// @grant      GM.setValue
// @grant      GM.xmlHttpRequest
// @grant      GM_addElement
// @grant      GM_addStyle
// @grant      GM_addValueChangeListener
// @grant      GM_cookie
// @grant      GM_deleteValue
// @grant      GM_download
// @grant      GM_getResourceText
// @grant      GM_getResourceURL
// @grant      GM_getTab
// @grant      GM_getTabs
// @grant      GM_getValue
// @grant      GM_info
// @grant      GM_listValues
// @grant      GM_log
// @grant      GM_notification
// @grant      GM_openInTab
// @grant      GM_registerMenuCommand
// @grant      GM_removeValueChangeListener
// @grant      GM_saveTab
// @grant      GM_setClipboard
// @grant      GM_setValue
// @grant      GM_unregisterMenuCommand
// @grant      GM_webRequest
// @grant      GM_xmlhttpRequest
// @run-at     document-start
// @grant      unsafeWindow
// @grant      window.close
// @grant      window.focus
// @grant      window.onurlchange
// ==/UserScript==

console.log("油猴脚本----");

let time_waitfor_ok = 3000;
let time_waitfor_next = 4000;

let clickIntervals = {}; // 使用对象来存储不同按钮的间隔器
let totalClickTimes = 0;
let adClickIndex = 0;
let adsElements = [];

window.onload = function () {
    console.log("页面加载完------- DOMContentLoaded");

    setTimeout(function () {
        console.log("增加按钮 ---- ");
        addButton();
    }, 2000);
};

function addButton() {
    const addToShippingLinks = document.querySelectorAll('a[data-testid="beast-core-button-link"] span');
    addToShippingLinks.forEach(link => {
        if (link.textContent === '加入发货台') {
            const parentDiv = link.closest('.order-manage_actions___xYyp');

            const autoAddButton = document.createElement('a');
            autoAddButton.className = 'BTN_outerWrapper_5-72-0 BTN_textPrimary_5-72-0 BTN_small_5-72-0 BTN_outerWrapperLink_5-72-0';
            autoAddButton.setAttribute('data-tracking-id', 'custom-autoAddToShipping');
            autoAddButton.innerHTML = '<span>自动加入发货台</span>';

            autoAddButton.addEventListener('click', () => {
                start(link);
            });

            parentDiv.appendChild(autoAddButton);
        }
    });
}

// 点击确定
function clickOK(link) {
    // 实现点击确定的逻辑
    console.log("点击确定-----");
    // 查找所有的按钮
    const buttons = document.querySelectorAll('button[data-testid="beast-core-button"]');

    // 遍历按钮,找到包含 "确认" 文本的按钮
    buttons.forEach(button => {
        const buttonText = button.querySelector('span').textContent;
        if (buttonText === '确认') {
            console.log('找到确认按钮:', button);
            button.click();
            //下一次点击
            start(link);
        }
    });
}

// 点击加入发货台
function clickRob(link) {

    // 判断是否已经不可点击 disable了
     // 判断是否已经不可点击,如果有 disabled 属性,则直接返回
     if (link.closest('a').hasAttribute('disabled')) {
        console.log('按钮已被禁用,无法继续点击。');
        return;
    }

    link.closest('a').click();

    setTimeout(() => {
        clickOK(link);
    }, time_waitfor_ok);
}

function start(link) {
    const buttonKey = link.textContent; // 以按钮的文本内容作为键值,用于区分不同按钮的间隔器
    clearInterval(clickIntervals[buttonKey]); // 清除之前的间隔器,以防止多次点击叠加

    // clickRob(link);

    time_waitfor_ok = Math.random() * (6000 - 2000) + 2000;
    time_waitfor_next = Math.random() * (6000 - 2500) + 2500;

    console.log("随机的okTime = " + time_waitfor_ok + " nextTime = " + time_waitfor_next);
    let time = time_waitfor_ok + time_waitfor_next;

    setTimeout(() => {
        clickRob(link);
    }, time);
}