From 6d97479a82a9792b3b6741e751964867523d66a5 Mon Sep 17 00:00:00 2001 From: Jaewan Yun Date: Thu, 1 Dec 2022 16:03:23 -0800 Subject: [PATCH] textcaptcha empty selectors --- textcaptcha.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/textcaptcha.js b/textcaptcha.js index 690d049..190b274 100644 --- a/textcaptcha.js +++ b/textcaptcha.js @@ -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; } @@ -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; } }