上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖

大佬们帮我看看这个脚本为什么不会执行

[复制链接]
  • TA的每日心情

    2023-9-22 12:06
  • 签到天数: 1 天

    [LV.1]初来乍到

    1

    主题

    1

    回帖

    4

    积分

    助理工程师

    积分
    4
    发表于 2023-9-22 12:00:01 | 显示全部楼层 | 阅读模式
    悬赏2油猫币未解决
    // ==UserScript==
    // @name         达人自动邀约
    // @namespace    https://bbs.tampermonkey.net.cn/
    // @version      0.1.0
    // @description  try to take over the world!
    // @author       You
    // @match        {{https://buyin.jinritemai.com/dashboard/servicehall/daren-square}}
    // ==/UserScript==
    function showSuccessMessage() {
        console.log("执行成功!");
        // 可以在此处添加其他针对执行成功的处理逻辑
    }
    
    function showFailureMessage(reason) {
        console.log("执行失败:" + reason);
        // 可以在此处添加其他针对执行失败的处理逻辑
    }
    
    function handleYaoyue() {
        console.log("处理邀约");
        const iframeDocument = document.getElementById("gz").contentWindow.document;
    
        setTimeout(function() {
            const contactBtn = iframeDocument.querySelector(".contact-btn");
            if (contactBtn) {
                contactBtn.click();
    
                setTimeout(function() {
                    const addProductLastOperate = iframeDocument.querySelector(".text4.add-product-last-operate");
                    if (addProductLastOperate) {
                        addProductLastOperate.click();
    
                        setTimeout(function() {
                            const antBtns = iframeDocument.querySelectorAll(".ant-btn.ant-btn-primary");
                            if (antBtns && antBtns.length >= 2) {
                                antBtns[1].click();
                                showSuccessMessage();
                                goGoGo();
                            } else {
                                showFailureMessage("点击按钮失败");
                            }
                        }, 1500);
                    } else {
                        showFailureMessage("未找到添加商品按钮");
                    }
                }, 1000);
            } else {
                showFailureMessage("未找到联系按钮");
            }
        }, 0);
    }
    
    function goGoGo() {
        if (currentIndex >= userIds.length) {
            console.log("已经邀约完毕");
            return;
        }
    
        const currentUid = userIds[currentIndex];
        console.log("开始邀约[" + currentIndex + "] UID:" + currentUid);
    
        document.querySelector(".headerNav-item__text").textContent = "邀约进度: " + (currentIndex + 1) + "/" + userIds.length;
    
        document.getElementById("gz").src = "https://buyin.jinritemai.com/dashboard/servicehall/daren-profile?uid=" + currentUid;
        currentIndex++;
    
        setTimeout(function() {
            handleYaoyue();
        }, 5000);
    }
    
    function start() {
        userIds.length = 0;
        const domList = document.getElementsByClassName("daren-card");
    
        for (let i = 0; i < domList.length; i++) {
            const profileText = domList[i].innerText;
    
            if (!profileText.includes("已邀约") && !profileText.includes("同意合作") && !profileText.includes("拒绝合作")) {
                userIds.push(domList[i].getAttribute("data-item-uid"));
            }
        }
        window.onload = function() {
        // 在页面加载完成后执行的代码
        goGoGo();
    
    // 调用 start() 函数
    start();

  • TA的每日心情
    开心
    2024-3-13 10:14
  • 签到天数: 211 天

    [LV.7]常住居民III

    296

    主题

    3950

    回帖

    3858

    积分

    管理员

    积分
    3858

    管理员荣誉开发者油中2周年生态建设者喜迎中秋油中3周年挑战者 lv2

    发表于 2023-9-22 13:49:27 | 显示全部楼层
    match不对吧?没有{{的

    @match        {{https://buyin.jinritemai.com/dashboard/servicehall/daren-square}}
    上不慕古,下不肖俗。为疏为懒,不敢为狂。为拙为愚,不敢为恶。/ 微信公众号:一之哥哥
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2024-1-22 09:36
  • 签到天数: 92 天

    [LV.6]常住居民II

    1

    主题

    22

    回帖

    155

    积分

    荣誉开发者

    积分
    155

    荣誉开发者油中3周年挑战者 lv2

    发表于 2023-9-22 17:10:19 | 显示全部楼层
    start和window.onload都少了括号}
    回复

    使用道具 举报

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表