Spaces:
Paused
Paused
File size: 6,064 Bytes
95866b8 bf86a13 95866b8 1c7a737 95866b8 1c7a737 639ad9e 9eb9558 1c7a737 9eb9558 1c7a737 9eb9558 1c7a737 9eb9558 d87de1b 1c7a737 ba119e4 95866b8 9eb9558 bf86a13 0de470c 1c7a737 7444b38 0de470c 737061d 1c7a737 95866b8 |
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
const express = require('express');
const app = express();
const port = process.env.PORT || 7860
const cookieParser = require('cookie-parser')
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const fetch = require("node-fetch");
puppeteer.use(StealthPlugin());
const { exec } = require('child_process');
app.use(express.json());
app.use(cookieParser());
exec('node node_modules/puppeteer/install.mjs', (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error}`);
return;
}
});
app.get('/head', async (req, res) => {
const url = req.query.url;
if (!url) {
return res.send({ status: false, owner: 'pakaya', err: 'Need site URL!' });
}
let browser;
try {
browser = await puppeteer.launch({
headless: true,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--ignoreHTTPSErrors'],
});
const page = await browser.newPage(); // Create a new page
await page.setRequestInterception(true);
page.on('request', (request) => {
request.continue();
});
// Go to the specified URL
const response = await page.goto(url, { waitUntil: 'networkidle2' });
// Wait for a while to ensure all requests are completed
await new Promise(resolve => setTimeout(resolve, 60000));
// Get the response status and headers
const status = response.status();
const headers = response.headers();
console.log('Response Headers:', headers);
// Send the response back to the client
return res.status(200).json({ status: true, response: { status, headers } });
} catch (e) {
console.error(e);
return res.status(500).json({ status: false, error: e.message });
} finally {
if (browser) {
await browser.close();
}
}
});
app.get('/headers', async (req, res) => {
const url = req.query.url;
if (!url) return res.send({ status: false, owner: 'pakaya', err: 'Need site URL!' });
let downloadurl = ''; // Initialize redirectUrl variable
const browser = await puppeteer.launch({
headless: true,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--ignoreHTTPSErrors'],
});
const page = await browser.newPage(); // Create a new page
await page.setRequestInterception(true);
page.on('request', (request) => {
request.continue();
});
try {
let response = await page.goto(url, { waitUntil: 'networkidle2' });
await page.waitForTimeout(60000);
await browser.close();
return res.status(200).json({ status: response.status(),headers: response.headers() });
} catch (e) {
console.log(e);
res.status(200).json({ status: response.status(),headers: response.headers() });
}
});
app.get("/api/direct", async (req, res) => {
const { url } = req.query;
if (!url) return res.status(400).json({ status: false, error: "Missing url parameter" });
let browser;
try {
browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox"] });
const page = await browser.newPage();
// Set user agent
await page.setUserAgent(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
"(KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
);
// Step 1: Go to main page
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
// Step 2: Extract the onclick link
const intermediate = await page.$eval(".wildbutton", el =>
el.getAttribute("onclick").match(/'(.*?)'/)[1]
);
if (!intermediate) {
return res.status(404).json({ status: false, error: "Download link not found" });
}
const cookies = await page.cookies();
const cookieHeader = cookies.map(c => `${c.name}=${c.value}`).join("; ");
res.json({
status: true,
cookieHeader
});
} catch (err) {
res.status(500).json({ status: false, error: err.message });
} finally {
if (browser) await browser.close();
}
});
app.get('/moddl', async (req, res) => {
const apkUrl = req.query.url
if (!apkUrl) {
return res.status(400).send('APK URL is required');
}
try {
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--disable-gpu',
],
});
const page = await browser.newPage();
// Navigate to the APK URL
await page.goto(apkUrl, { waitUntil: 'networkidle2' });
// Wait for the download link to appear (adjust the selector as needed)
const downloadLinkSelector = 'a.download-link'; // Update this selector based on the actual link
await page.waitForSelector(downloadLinkSelector);
// Get the download link
const downloadLink = await page.$eval(downloadLinkSelector, el => el.href);
console.log('Download link:', downloadLink);
// Navigate to the download link
const response = await page.goto(downloadLink, { waitUntil: 'networkidle2' });
console.log(response);
// Get the APK file buffer
const buffer = await response.arraybuffer()
// Set the response headers for file download
res.set({
'Content-Type': 'application/vnd.android.package-archive',
'Content-Disposition': 'attachment; filename=downloaded.apk',
'Content-Length': buffer.length,
});
// Send the APK file buffer in the response
res.send(buffer);
await browser.close();
} catch (error) {
console.error('Error downloading APK:', error);
res.status(500).send(error);
}
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
module.exports = app |