testdy

moklgy

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         testdy
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  moklgy
// @author       mok
// @match        https://www.douyin.com/user/*
// @grant        none
// @license      Apache
// ==/UserScript==

(function() {
    'use strict';

    const minInterval = 4000; // 最小间隔
    const maxInterval = 6000; // 最大间隔
    const simulateUsers = 3; // 模拟的用户数量

    const currentUrl = window.location.href; // 存储当前页面链接

    const playVideo = () => {
        const video = document.querySelector('video');
        if (video) {
            video.play().catch(error => {
                console.error('无法播放视频:', error);
            });
        }
    };

    const refreshPage = () => {
        location.reload();
    };

    const randomInterval = () => {
        return Math.floor(Math.random() * (maxInterval - minInterval)) + minInterval;
    };

    const skipLoginPopup = () => {
        const loginPopup = document.querySelector('.login-popup-selector'); // 替换为实际的弹窗选择器
        const closeButton = loginPopup ? loginPopup.querySelector('.close-button-selector') : null; // 替换为实际的关闭按钮选择器

        if (closeButton) {
            closeButton.click();
        }
    };

    const preventRedirection = () => {
        window.addEventListener('beforeunload', (event) => {
            event.preventDefault(); // 阻止页面卸载
            event.returnValue = ''; // Chrome 需要这个属性来显示确认框
        });

        const checkRedirection = () => {
            if (window.location.href !== currentUrl) {
                window.history.pushState(null, '', currentUrl); // 强制保持在当前链接
            }
        };
        setInterval(checkRedirection, 1000); // 每秒检查一次
    };

    const bypassDetection = () => {
        // 修改用户代理,防止检测
        Object.defineProperty(navigator, 'userAgent', {
            get: function() {
                return 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36';
            }
        });
    };

    const simulateUserActions = () => {
        setInterval(() => {
            skipLoginPopup(); // 尝试跳过登录弹窗
            playVideo(); // 播放视频(如果可用)
            refreshPage(); // 刷新页面
            simulateHumanLikeBehavior(); // 模拟人类行为
        }, randomInterval());
    };

    const simulateHumanLikeBehavior = () => {
        // 随机滚动页面
        window.scrollBy(0, Math.random() * 100);
    };

    // 启动跳过检测
    bypassDetection();
    // 启动防止跳转
   preventRedirection();
    // 启动多个用户模拟
    for (let i = 0; i < simulateUsers; i++) {
        simulateUserActions();
    }
})();