File size: 2,575 Bytes
156bdd3
7342047
ab4cc6b
 
39f5335
 
aba37f8
 
156bdd3
ab4cc6b
 
 
56679b0
 
ab4cc6b
7f355d5
cf275f8
ab4cc6b
cf275f8
 
 
 
 
 
 
aba37f8
 
56679b0
 
 
7342047
56679b0
7342047
 
 
0955560
 
56679b0
 
 
 
cf275f8
 
2bcf1c8
 
 
 
 
 
 
 
 
7f355d5
 
 
cf275f8
2bcf1c8
 
7f355d5
7342047
7f355d5
 
 
2bcf1c8
 
 
7f355d5
7342047
 
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
import os

# Paksa patcher undetected-chromedriver ke /tmp
os.environ["UCDP_DATA_PATH"] = "/tmp/ucdata"
os.environ["XDG_CACHE_HOME"] = "/tmp/.cache"
os.environ["XDG_CONFIG_HOME"] = "/tmp/.config"
os.environ["XDG_DATA_HOME"] = "/tmp/.local/share"
os.environ["HOME"] = "/tmp"

import time
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def bypass_shinigami(url: str) -> dict:
    options = uc.ChromeOptions()
    options.add_argument("--headless=new")
    options.add_argument("--disable-gpu")
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--disable-software-rasterizer")
    options.add_argument("--disable-dev-tools")
    options.add_argument("--disable-setuid-sandbox")
    options.add_argument("--remote-debugging-port=9222")
    options.add_argument("--user-data-dir=/tmp/chrome-user-data")
    options.add_argument("--disk-cache-dir=/tmp/.cache/chrome")
    options.add_argument(
        "--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"
    )

    driver = uc.Chrome(options=options, headless=True, user_data_dir="/tmp/chrome-user-data", data_path="/tmp/ucdata")

    try:
        driver.get(url)
        # Tunggu maksimal 5 detik sampai judul halaman bukan "Just a moment..."
        WebDriverWait(driver, 5).until(
            lambda d: "Just a moment" not in d.title
        )
        time.sleep(2)  # Tambahan delay agar benar-benar lolos

        link_elem = driver.find_elements(By.TAG_NAME, "a")
        link = link_elem[0].get_attribute("href") if link_elem else None
        title = driver.title
        meta_elements = driver.find_elements(By.XPATH, "//head/meta")
        headers = {}
        for meta in meta_elements:
            name = meta.get_attribute("name") or meta.get_attribute("property")
            content = meta.get_attribute("content")
            if name and content:
                headers[name] = content

        return {
            "status": "success",
            "message": "OK",
            "bypassed_url": link,
            "title": title,
            "headers": headers
        }
    except Exception as e:
        return {
            "status": "error",
            "message": f"Error: {e}",
            "bypassed_url": None,
            "title": None,
            "headers": {}
        }
    finally:
        driver.quit()