vikarshana commited on
Commit
737061d
·
verified ·
1 Parent(s): ba119e4

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +20 -26
index.js CHANGED
@@ -110,42 +110,36 @@ app.get("/bypass", async (req, res) => {
110
 
111
  await page.goto(siteUrl, { waitUntil: "networkidle2", timeout: 60000 });
112
 
113
- // Grab download link from button (onclick attr)
114
- const downloadLink = await page.$eval(".wildbutton", el =>
115
- el.getAttribute("onclick").match(/'(.*?)'/)[1]
116
- );
117
-
118
- // Collect cookies for axios
119
- const cookies = await page.cookies();
120
- const cookieString = cookies.map(c => `${c.name}=${c.value}`).join("; ");
 
 
 
 
 
 
 
121
 
122
  await browser.close();
123
 
124
- // Use axios to request the downloadLink with cookies
125
- const response = await axios.get(downloadLink, {
126
- headers: {
127
- "User-Agent":
128
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
129
- "Referer": siteUrl,
130
- "Cookie": cookieString,
131
- },
132
- maxRedirects: 0, // stop at redirect to capture Location header
133
- validateStatus: (status) => status >= 200 && status < 400,
134
- });
135
-
136
- const realLink = response.headers.location;
137
-
138
  if (!realLink) {
139
- return res.status(500).json({ status: false, error: "Failed to extract real link" });
140
  }
141
 
142
  return res.json({ status: true, realLink });
143
- } catch (e) {
144
- console.error(e);
145
- return res.status(500).json({ status: false, error: e.message });
146
  }
147
  });
148
 
 
149
  app.get('/moddl', async (req, res) => {
150
  const apkUrl = req.query.url
151
 
 
110
 
111
  await page.goto(siteUrl, { waitUntil: "networkidle2", timeout: 60000 });
112
 
113
+ // Click the download button
114
+ const [button] = await page.$x("//a[contains(@class,'wildbutton')]");
115
+ if (!button) throw new Error("Download button not found");
116
+
117
+ // Intercept the redirect when clicking
118
+ const [response] = await Promise.all([
119
+ page.waitForResponse(
120
+ (res) =>
121
+ res.status() === 302 || res.headers()["location"],
122
+ { timeout: 30000 }
123
+ ),
124
+ button.click(),
125
+ ]);
126
+
127
+ const realLink = response.headers()["location"];
128
 
129
  await browser.close();
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  if (!realLink) {
132
+ return res.status(500).json({ status: false, error: "No redirect found" });
133
  }
134
 
135
  return res.json({ status: true, realLink });
136
+ } catch (err) {
137
+ console.error(err);
138
+ return res.status(500).json({ status: false, error: err.message });
139
  }
140
  });
141
 
142
+
143
  app.get('/moddl', async (req, res) => {
144
  const apkUrl = req.query.url
145