Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from playwright.async_api import async_playwright
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
# Your personal 2026 Bearer Token
|
| 7 |
+
BEARER = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5M2NmYTBkMGU4YzlmMzdiZTA4Y2IyMCIsImlhdCI6MTczMjM5NTc5OSwiZXhwIjoxNzczMDAwNTk5fQ.Mc-LS_NMe0lpBQrQE4DEGs83iVBHIp8LvzBdeaUbmHo"
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
def home():
|
| 11 |
+
return {"status": "Silent Auto-React API is Running 🟢"}
|
| 12 |
+
|
| 13 |
+
@app.get("/api/react")
|
| 14 |
+
async def do_react(url: str, emojis: str):
|
| 15 |
+
try:
|
| 16 |
+
async with async_playwright() as p:
|
| 17 |
+
# Open invisible Chrome
|
| 18 |
+
browser = await p.chromium.launch(headless=True)
|
| 19 |
+
context = await browser.new_context(
|
| 20 |
+
# Inject your token into every request to bypass login
|
| 21 |
+
extra_http_headers={"Authorization": f"Bearer {BEARER}"},
|
| 22 |
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
page = await context.new_page()
|
| 26 |
+
|
| 27 |
+
# Go to the website
|
| 28 |
+
await page.goto("https://asitha.top/channel-react", wait_until="networkidle")
|
| 29 |
+
|
| 30 |
+
# Inject login into LocalStorage just in case and reload
|
| 31 |
+
await page.evaluate(f"window.localStorage.setItem('token', '{BEARER}');")
|
| 32 |
+
await page.reload(wait_until="networkidle")
|
| 33 |
+
await page.wait_for_timeout(2000)
|
| 34 |
+
|
| 35 |
+
# Find the input boxes and fill them
|
| 36 |
+
boxes = await page.get_by_role("textbox").all()
|
| 37 |
+
if len(boxes) >= 2:
|
| 38 |
+
await boxes[0].fill(url)
|
| 39 |
+
await page.wait_for_timeout(500)
|
| 40 |
+
await boxes[1].fill(emojis)
|
| 41 |
+
await page.wait_for_timeout(500)
|
| 42 |
+
|
| 43 |
+
# Click the yellow button!
|
| 44 |
+
await page.get_by_role("button", name="Pay 1 COIN & Send").click()
|
| 45 |
+
|
| 46 |
+
# Wait 4 seconds for the success message to register
|
| 47 |
+
await page.wait_for_timeout(4000)
|
| 48 |
+
|
| 49 |
+
await browser.close()
|
| 50 |
+
return {"success": True, "message": "Reaction injected successfully!"}
|
| 51 |
+
else:
|
| 52 |
+
await browser.close()
|
| 53 |
+
return {"success": False, "error": "Could not find text boxes."}
|
| 54 |
+
|
| 55 |
+
except Exception as e:
|
| 56 |
+
return {"success": False, "error": str(e)}
|