Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -95,51 +95,56 @@ app.get('/headers', async (req, res) => {
|
|
| 95 |
}
|
| 96 |
});
|
| 97 |
|
| 98 |
-
app.get("/bypass", async (req, res) => {
|
| 99 |
-
const siteUrl = req.query.url;
|
| 100 |
-
if (!siteUrl) {
|
| 101 |
-
return res.status(400).json({ status: false, error: "Missing ?url param" });
|
| 102 |
-
}
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
try {
|
| 105 |
-
|
| 106 |
-
headless: true,
|
| 107 |
-
args: ["--no-sandbox", "--disable-setuid-sandbox"],
|
| 108 |
-
});
|
| 109 |
const page = await browser.newPage();
|
| 110 |
|
| 111 |
-
await page.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
)
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
await browser.close();
|
| 130 |
|
| 131 |
-
if (!
|
| 132 |
-
return res.status(
|
| 133 |
}
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
} catch (err) {
|
| 137 |
-
|
| 138 |
-
|
|
|
|
| 139 |
}
|
| 140 |
});
|
| 141 |
|
| 142 |
|
|
|
|
| 143 |
app.get('/moddl', async (req, res) => {
|
| 144 |
const apkUrl = req.query.url
|
| 145 |
|
|
|
|
| 95 |
}
|
| 96 |
});
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
app.get("/api/direct", async (req, res) => {
|
| 100 |
+
const { url } = req.query;
|
| 101 |
+
if (!url) return res.status(400).json({ status: false, error: "Missing url parameter" });
|
| 102 |
+
|
| 103 |
+
let browser;
|
| 104 |
try {
|
| 105 |
+
browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox"] });
|
|
|
|
|
|
|
|
|
|
| 106 |
const page = await browser.newPage();
|
| 107 |
|
| 108 |
+
await page.setUserAgent(
|
| 109 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
| 110 |
+
"(KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
// Step 1: open the main page
|
| 114 |
+
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
|
| 115 |
+
|
| 116 |
+
// Step 2: extract the onclick link
|
| 117 |
+
const intermediate = await page.evaluate(() => {
|
| 118 |
+
const btn = document.querySelector("span.wildbutton");
|
| 119 |
+
if (!btn) return null;
|
| 120 |
+
const onclickAttr = btn.getAttribute("onclick");
|
| 121 |
+
if (!onclickAttr) return null;
|
| 122 |
+
const match = onclickAttr.match(/'(https?:\/\/[^']+)'/);
|
| 123 |
+
return match ? match[1] : null;
|
| 124 |
+
});
|
|
|
|
|
|
|
| 125 |
|
| 126 |
+
if (!intermediate) {
|
| 127 |
+
return res.status(404).json({ status: false, error: "Download link not found" });
|
| 128 |
}
|
| 129 |
|
| 130 |
+
// Step 3: navigate to intermediate link and get final URL
|
| 131 |
+
const response = await page.goto(intermediate, { waitUntil: "networkidle2" });
|
| 132 |
+
const finalUrl = response.url();
|
| 133 |
+
|
| 134 |
+
res.json({
|
| 135 |
+
status: true,
|
| 136 |
+
intermediate,
|
| 137 |
+
direct: finalUrl
|
| 138 |
+
});
|
| 139 |
} catch (err) {
|
| 140 |
+
res.status(500).json({ status: false, error: err.message });
|
| 141 |
+
} finally {
|
| 142 |
+
if (browser) await browser.close();
|
| 143 |
}
|
| 144 |
});
|
| 145 |
|
| 146 |
|
| 147 |
+
|
| 148 |
app.get('/moddl', async (req, res) => {
|
| 149 |
const apkUrl = req.query.url
|
| 150 |
|