Skip to content

Commit

Permalink
remove unnecessary formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfigueiraacin committed Oct 16, 2023
1 parent 77a9d0a commit d081810
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions bin/browser.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const getOutput = async (request, page = null) => {
return output;
};

const callChrome = async (pup) => {
const callChrome = async pup => {
let browser;
let page;
let remoteInstance;
const puppet = pup || require('puppeteer');
const puppet = (pup || require('puppeteer'));

try {
if (request.options.remoteInstanceUrl || request.options.browserWSEndpoint ) {
Expand All @@ -81,7 +81,7 @@ const callChrome = async (pup) => {
}

try {
browser = await puppet.connect(options);
browser = await puppet.connect( options );

remoteInstance = true;
} catch (exception) { /** does nothing. fallbacks to launching a chromium instance */}
Expand Down Expand Up @@ -110,7 +110,7 @@ const callChrome = async (pup) => {
await page.setRequestInterception(true);

const contentUrl = request.options.contentUrl;
const parsedContentUrl = contentUrl ? contentUrl.replace(/\/$/, '') : undefined;
const parsedContentUrl = contentUrl ? contentUrl.replace(/\/$/, "") : undefined;
let pageContent;

if (contentUrl) {
Expand Down Expand Up @@ -140,8 +140,8 @@ const callChrome = async (pup) => {
url: response.request().url(),
status: response.status(),
reason: response.statusText(),
headers: response.headers(),
});
headers: response.headers()
})
}

if (response.status() >= 200 && response.status() <= 399) {
Expand All @@ -152,9 +152,9 @@ const callChrome = async (pup) => {
status: response.status(),
url: response.url(),
});
});
})

page.on('request', (interceptedRequest) => {
page.on('request', interceptedRequest => {
var headers = interceptedRequest.headers();

requestsList.push({
Expand Down Expand Up @@ -193,7 +193,7 @@ const callChrome = async (pup) => {
}

if (pageContent) {
const interceptedUrl = interceptedRequest.url().replace(/\/$/, '');
const interceptedUrl = interceptedRequest.url().replace(/\/$/, "");

// if content url matches the intercepted request url, will return the content fetched from the local file system
if (interceptedUrl === parsedContentUrl) {
Expand All @@ -211,11 +211,11 @@ const callChrome = async (pup) => {
.map(key => `${key}=${postParamsArray[key]}`)
.join('&');
interceptedRequest.continue({
method: 'POST',
method: "POST",
postData: queryString,
headers: {
...interceptedRequest.headers(),
'Content-Type': 'application/x-www-form-urlencoded',
"Content-Type": "application/x-www-form-urlencoded",
}
});
return;
Expand All @@ -225,7 +225,7 @@ const callChrome = async (pup) => {
});

if (request.options && request.options.dismissDialogs) {
page.on('dialog', async (dialog) => {
page.on('dialog', async dialog => {
await dialog.dismiss();
});
}
Expand Down Expand Up @@ -276,10 +276,10 @@ const callChrome = async (pup) => {
const response = await page.goto(request.url, requestOptions);

if (request.options.preventUnsuccessfulResponse) {
const status = response.status();
const status = response.status()

if (status >= 400 && status < 600) {
throw {type: 'UnsuccessfulResponse', status};
throw {type: "UnsuccessfulResponse", status};
}
}

Expand Down Expand Up @@ -337,13 +337,13 @@ const callChrome = async (pup) => {

const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.empty-page { page-break-after: always; visibility: hidden; }';
style.innerHTML = '.empty-page {page-break-after: always; visibility: hidden;}';
document.getElementsByTagName('head')[0].appendChild(style);

const emptyPages = Array.from({ length: window.pageStart }).map(() => {
const emptyPage = document.createElement('div');
emptyPage.className = 'empty-page';
emptyPage.textContent = 'empty';
emptyPage.className = "empty-page";
emptyPage.textContent = "empty";
return emptyPage;
});
document.body.prepend(...emptyPages);
Expand Down

0 comments on commit d081810

Please sign in to comment.