Skip to content

Commit

Permalink
textcaptcha empty selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
j-w-yun committed Dec 2, 2022
1 parent aa9f7e7 commit 6d97479
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions textcaptcha.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
(async () => {
function is_present(settings) {
try {
const $image = document.querySelector(settings.textcaptcha_image_selector);
if (!$image) {
return false;
}
const $input = document.querySelector(settings.textcaptcha_input_selector);
if (!$input || $input.value) {
return false;
if (settings?.textcaptcha_image_selector && settings?.textcaptcha_input_selector) {
const $image = document.querySelector(settings.textcaptcha_image_selector);
if (!$image) {
return false;
}
const $input = document.querySelector(settings.textcaptcha_input_selector);
if (!$input || $input.value) {
return false;
}
return true;
}

return true;
} catch (e) {}
return false;
}
Expand Down Expand Up @@ -73,7 +74,7 @@
const $canvas = await get_canvas(selector);
return $canvas.toDataURL('image/jpeg').split(';base64,')[1];
} catch (e) {
console.error('failed to encode image data', e);
// console.error('failed to encode image data', e);
return null;
}
}
Expand Down

0 comments on commit 6d97479

Please sign in to comment.