Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNovak committed Aug 27, 2020
1 parent f92a349 commit 7300799
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
36 changes: 20 additions & 16 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const descriptions = config.bump.descriptions.list;

// Browser options
var browserOptions = {
headless: config.browser.hide
headless: config.browser.hide,
};

if (config.browser.custom.enabled) {
Expand Down Expand Up @@ -52,11 +52,13 @@ async function bumpServer() {

// Nagivate to "Edit Server" page
logger.log('Navigating to "Edit Server" page...');
await page.goto(`${urls.base}${urls.pages.edit}?${urls.queries.serverId}=${config.account.serverId}`);
await page.goto(
`${urls.base}${urls.pages.edit}?${urls.queries.serverId}=${config.account.serverId}`
);

// Check if editing is allowed
const selector = selectors.error;
const success = await page.evaluate((selector) => {
const success = await page.evaluate(selector => {
return document.querySelectorAll(selector).length === 0;
}, selector);

Expand All @@ -72,15 +74,15 @@ async function bumpServer() {
if (config.bump.descriptions.enabled) {
const selector = selectors.fields.description;
const description = getRandomDescription();
await page.evaluate(({
selector,
description
}) => {
document.querySelector(selector).value = description;
}, {
selector,
description
});
await page.evaluate(
({ selector, description }) => {
document.querySelector(selector).value = description;
},
{
selector,
description,
}
);
}

// Bump server
Expand Down Expand Up @@ -109,7 +111,9 @@ async function launchBrowser() {
});
return browser;
} catch (error) {
logger.error('Failed to launch browser. Please check if the executable path is correct or try changing the browser hide option.');
logger.error(
'Failed to launch browser. Please check if the executable path is correct or try changing the browser hide option.'
);
exit();
}
}
Expand All @@ -127,7 +131,7 @@ async function delay(page) {
if (delaysEnabled) {
const delay = generateRandomDelay();
const time = timer.format(timer.getTimeAfterMs(delay));
logger.log(`Waiting ${delay/1000} seconds, until "${time}"...`);
logger.log(`Waiting ${delay / 1000} seconds, until "${time}"...`);
await page.waitFor(delay);
}
}
Expand All @@ -153,5 +157,5 @@ if (!module.parent) {
}

module.exports = {
bumpServer
};
bumpServer,
};
2 changes: 1 addition & 1 deletion data/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"dashboard": "th.n1"
},
"error": "div.errormsg"
}
}
2 changes: 1 addition & 1 deletion data/urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"queries": {
"serverId": "server_id"
}
}
}
2 changes: 1 addition & 1 deletion scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ function logNextRun() {
}

logger.log('Started the built-in scheduler.');
logNextRun();
logNextRun();
4 changes: 2 additions & 2 deletions utilities/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ function now() {

module.exports = {
log,
error
};
error,
};
4 changes: 2 additions & 2 deletions utilities/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ function getTimeAfterMs(delay, date = Date.now()) {

module.exports = {
format,
getTimeAfterMs
};
getTimeAfterMs,
};

0 comments on commit 7300799

Please sign in to comment.