File size: 4,740 Bytes
02bb1da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- coding: utf-8 -*-
import asyncio
import os
import re
from fastapi import FastAPI
import uvicorn
from playwright.async_api import async_playwright
from playwright_stealth import Stealth

# --- βš™οΈ TITAN CONFIG ---
PULSE_DELAY = 100
TABS_PER_SPACE = 1
app = FastAPI()

# πŸ”± FIX: defining both GET and HEAD to ensure 200 OK for UptimeRobot
@app.api_route("/", methods=["GET", "HEAD"])
async def health_check():
    return {"status": "TITAN_ACTIVE", "monitoring": "ONLINE"}

STRIKE_SCRIPT = """
    (name, delay) => {
        const getBlock = () => {
            const emojis = ["πŸ’™", "❀️", "πŸ’š", "πŸ’›", "πŸ’œ", "πŸ–€", "🀍", "🀎", "🧑", "πŸ’–"];
            const currentEmoji = emojis[Math.floor(Math.random() * emojis.length)];
            const line = "α΄˜Κ€α΄€α΄›Ιͺα΄‹-ᴠᴇᴇʀ-κœ±α΄œΚ€α΄€α΄Š-Ι΄α΄‡α΄α΄‡κœ±Ιͺπ–˜ πšƒπ™Όπ™Ίπ™² " + currentEmoji + "ΰΌ‹ΰΌ˜ΰΏ";
            
            let text = "";
            for(let i = 0; i < 10; i++) { 
                text += line + "\\r\\n\\r\\n\\r\\n\\r\\n"; 
            }
            return text;
        }

        const pulse = () => {
            const box = document.querySelector('div[role="textbox"], [contenteditable="true"]');
            if (box) {
                const text = getBlock();
                
                // 1. Create a virtual clipboard event
                const dataTransfer = new DataTransfer();
                dataTransfer.setData('text/plain', text);
                
                const pasteEvent = new ClipboardEvent('paste', {
                    clipboardData: dataTransfer,
                    bubbles: true,
                    cancelable: true
                });
                
                // 2. Focus and inject via paste event
                box.focus();
                box.dispatchEvent(pasteEvent);
                
                // 3. Trigger input event to update React state
                box.dispatchEvent(new Event('input', { bubbles: true }));
                
                // 4. Trigger send button
                setTimeout(() => {
                    const sendBtn = Array.from(document.querySelectorAll('div[role="button"], button')).find(el => 
                        el.textContent === 'Send' || el.innerText === 'Send'
                    );
                    if (sendBtn) {
                        sendBtn.click();
                    } else {
                        const fallbackBtn = document.querySelector('form button[type="button"], div[aria-label="Send"]');
                        if (fallbackBtn) fallbackBtn.click();
                    }
                }, 300);
            }
            setTimeout(() => { requestAnimationFrame(pulse); }, delay);
        }
        pulse();
    }
"""

async def run_titan():
    cookie = os.environ.get("INSTA_COOKIE")
    target_id = os.environ.get("TARGET_THREAD_ID")
    target_name = os.environ.get("TARGET_NAME", "TITAN")

    if not cookie or not target_id:
        print("❌ MISSING SECRETS")
        return

    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True, args=[
            "--no-sandbox",
            "--disable-dev-shm-usage",
            "--disable-gpu",
            "--js-flags='--max-old-space-size=512'"
        ])
        
        context = await browser.new_context(user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")
        
        sid = re.search(r'sessionid=([^;]+)', cookie).group(1) if 'sessionid=' in cookie else cookie
        await context.add_cookies([{'name': 'sessionid', 'value': sid.strip(), 'domain': '.instagram.com', 'path': '/', 'secure': True, 'httpOnly': True}])

        while True:
            pg = await context.new_page()
            await Stealth().apply_stealth_async(pg)
            await pg.route("**/*.{png,jpg,jpeg,gif,webp,svg,mp4,woff,woff2,ttf,css}", lambda route: route.abort())
            try:
                await pg.goto("https://www.instagram.com/", wait_until="commit", timeout=30000)
                await asyncio.sleep(2)
                await pg.goto(f"https://www.instagram.com/direct/t/{target_id}/", wait_until="load", timeout=90000)
                await pg.evaluate(STRIKE_SCRIPT, [target_name, PULSE_DELAY])
                await asyncio.sleep(600) 
            except Exception as e:
                print(f"⚠️ Tab Error: {e}")
                await asyncio.sleep(10)
            finally:
                await pg.close()

async def start_cluster():
    asyncio.create_task(run_titan())
    config = uvicorn.Config(app, host="0.0.0.0", port=7860, log_level="info")
    server = uvicorn.Server(config)
    await server.serve()

if __name__ == "__main__":
    asyncio.run(start_cluster())