Skip to content

Commit

Permalink
chore: revert puppeteer, run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jef committed Jul 16, 2021
1 parent 1d08d4c commit 5e9b3db
Show file tree
Hide file tree
Showing 107 changed files with 2,395 additions and 4,724 deletions.
74 changes: 37 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"nodemailer": "^6.6.3",
"open": "8.2.1",
"play-sound": "^1.1.3",
"puppeteer": "^10.1.0",
"puppeteer": "^9.1.1",
"puppeteer-extra-plugin-adblocker": "^2.11.11",
"pushover-notifications": "^1.2.2",
"redis": "^3.1.2",
Expand Down
11 changes: 6 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ function envOrArray(
environment: string | undefined,
array?: string[]
): string[] {
return (environment
? environment.includes('\n')
? environment.split('\n')
: environment.split(',')
: array ?? []
return (
environment
? environment.includes('\n')
? environment.split('\n')
: environment.split(',')
: array ?? []
).map(s => s.trim());
}

Expand Down
9 changes: 6 additions & 3 deletions src/messaging/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,22 @@ function checkInsecureUsage(pass: string, address: string): boolean {
}

function isClassANet(address: string): boolean {
const classRegex = /^(10\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;
const classRegex =
/^(10\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;

return Boolean(classRegex.exec(address));
}

function isClassBNet(address: string): boolean {
const classRegex = /^(172\.(1[6-9]|2\d|3[01])\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;
const classRegex =
/^(172\.(1[6-9]|2\d|3[01])\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;

return Boolean(classRegex.exec(address));
}

function isClassCNet(address: string): boolean {
const classRegex = /^(192\.168\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;
const classRegex =
/^(192\.168\.(\d|[1-9]\d|[12][0-5]{2})\.(\d|[1-9]\d|[12][0-5]{2}))$/;

return Boolean(classRegex.exec(address));
}
Expand Down
7 changes: 3 additions & 4 deletions src/messaging/philips-hue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
.then((allLights: any[]) => {
allLights.forEach((light: any) => {
logger.debug('adjusting all hue lights');
(hueBridge.lights.setLightState(
light,
lightState
) as Promise<any>).catch((error: Error) => {
(
hueBridge.lights.setLightState(light, lightState) as Promise<any>
).catch((error: Error) => {
logger.error('Failed to adjust all lights.');
logger.error(error);
throw error;
Expand Down
12 changes: 5 additions & 7 deletions src/store/captcha-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function getCaptchaPayloadAsync(
break;
case 'link':
captchaPayload = {
content: await challengeElement?.evaluate(img => img.getAttribute("src")) ?? "",
content: await challengeElement?.evaluate(img => img.src),
type: 'text',
};
break;
Expand All @@ -115,14 +115,12 @@ async function enterCaptchaResponseAsync(
store.labels.captchaHandler?.submit || 'button[type="submit"]';
const result = await page.evaluate(
(inputSelector, submitSelector, response) => {
const inputElement = document.querySelector<HTMLInputElement>(
inputSelector
);
const inputElement =
document.querySelector<HTMLInputElement>(inputSelector);
if (!inputElement) return false;
inputElement.value = response;
const submitElement = document.querySelector<HTMLButtonElement>(
submitSelector
);
const submitElement =
document.querySelector<HTMLButtonElement>(submitSelector);
if (!submitElement) return false;
submitElement.click();
return true;
Expand Down
Loading

0 comments on commit 5e9b3db

Please sign in to comment.