Kyouka commited on
Commit
04cb189
·
verified ·
1 Parent(s): 7a4304a

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +8 -26
index.js CHANGED
@@ -229,17 +229,14 @@ app.all('/stablediff/illusion', async (req, res) => {
229
  })
230
 
231
  app.get('/dongo', async (req, res) => {
232
- const { url } = req.query;
233
- if (!url) return res.json({ success: false, message: 'Required parameter url' });
234
-
235
  const browser = await playwright.chromium.launch({
236
- headless: true,
237
- executablePath: '/usr/bin/chromium',
238
- args: ['--no-sandbox']
239
- });
240
-
241
  const context = await browser.newContext({
242
- viewport: null, // Use null to maximize viewport
243
  extraHTTPHeaders: {
244
  'accept': '*/*',
245
  'accept-language': 'en-US,en;q=0.9,id;q=0.8',
@@ -258,28 +255,13 @@ app.get('/dongo', async (req, res) => {
258
  });
259
 
260
  const page = await context.newPage();
261
-
262
- // Set to fullscreen by maximizing viewport
263
- const dimensions = await page.evaluate(() => ({ width: window.screen.width, height: window.screen.height }));
264
- await page.setViewportSize(dimensions);
265
-
266
  await page.goto(url);
267
 
268
- // Remove all elements except the video element
269
- await page.evaluate(() => {
270
- const videos = document.getElementsByTagName('video');
271
- if (videos.length > 0) {
272
- document.body.innerHTML = '';
273
- document.body.appendChild(videos[0]);
274
- videos[0].requestFullscreen().catch(err => console.error(err));
275
- }
276
- });
277
-
278
- const content = await page.content();
279
 
280
  await browser.close();
281
 
282
- res.send(content);
283
  });
284
 
285
  app.get('/fetch-page', async (req, res) => {
 
229
  })
230
 
231
  app.get('/dongo', async (req, res) => {
232
+ const { url } = req.query
233
+ if (!url) return res.json({ success: false, message: 'Required parameter url' })
 
234
  const browser = await playwright.chromium.launch({
235
+ headless: true,
236
+ executablePath: '/usr/bin/chromium',
237
+ args: ['--no-sandbox']
238
+ })
 
239
  const context = await browser.newContext({
 
240
  extraHTTPHeaders: {
241
  'accept': '*/*',
242
  'accept-language': 'en-US,en;q=0.9,id;q=0.8',
 
255
  });
256
 
257
  const page = await context.newPage();
 
 
 
 
 
258
  await page.goto(url);
259
 
260
+ const content = await page.content(); // Get the page content as HTML
 
 
 
 
 
 
 
 
 
 
261
 
262
  await browser.close();
263
 
264
+ res.send(content); // Send the page content as response
265
  });
266
 
267
  app.get('/fetch-page', async (req, res) => {