Skip to content

Commit

Permalink
abort requests to api.zitefy.com (#9)
Browse files Browse the repository at this point in the history
this is a temporary fix. doesn't close the issue.
  • Loading branch information
vishalkrishnads authored Aug 1, 2024
1 parent 9cff9ee commit 3341e8d
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions scripts/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,43 @@
During initial setup, run bun run puppeteer browsers install chrome, and copy the executable path to line 8
*/
const puppeteer = require('puppeteer');
const fs = require('fs');

(async () => {
const browser = await puppeteer.launch({executablePath: '/home/vishalds/.cache/puppeteer/chrome/linux-126.0.6478.182/chrome-linux64/chrome'});
const page = await browser.newPage();
await page.goto('file://' + process.argv[2]);
try {
const browser = await puppeteer.launch({
executablePath: '/home/vishalds/.cache/puppeteer/chrome/linux-126.0.6478.182/chrome-linux64/chrome',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});

// Mobile screenshot
await page.setViewport({ width: 412, height: 915 });
await page.screenshot({ path: process.argv[3] });
const page = await browser.newPage();
await page.setRequestInterception(true);

// Desktop screenshot
await page.setViewport({ width: 1280, height: 800 });
await page.screenshot({ path: process.argv[4] });
// Intercept requests to our own API & block them
// this is a temporary fix, has to be mitigated completely asap
page.on('request', (request) => {
if (request.url().includes('api.zitefy.com')) {
request.abort();
} else {
request.continue();
}
});

await browser.close();
await page.goto('file://' + process.argv[2], {
waitUntil: 'networkidle0',
timeout: 60000
});

await page.setViewport({ width: 412, height: 915 });
await page.screenshot({ path: process.argv[3] });

await page.setViewport({ width: 1280, height: 800 });
await page.screenshot({ path: process.argv[4] });

await browser.close();

} catch (error) {
fs.writeFileSync('screenshot_error.log', error.toString());
process.exit(1);
}
})();

0 comments on commit 3341e8d

Please sign in to comment.