aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/autofill-otps.ts
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-13 22:49:42 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-13 22:49:42 +0530
commit34ad953c953a395ba3e51c8125034a6bb65b2a79 (patch)
tree253cc30047bb3963f387bd340d50938b3b727053 /src/scripts/autofill-otps.ts
parentaeeabaa0050ecb9e43b1a3fb309f314d92d3ca97 (diff)
downloadbanglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.tar.gz
banglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.zip
Fixed not being able to import modules in scripts.
Diffstat (limited to 'src/scripts/autofill-otps.ts')
-rw-r--r--src/scripts/autofill-otps.ts36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/scripts/autofill-otps.ts b/src/scripts/autofill-otps.ts
index f2c5650..140504c 100644
--- a/src/scripts/autofill-otps.ts
+++ b/src/scripts/autofill-otps.ts
@@ -1,20 +1,22 @@
-const proxiedPost = $.post;
+document.addEventListener("DOMContentLoaded", () => {
+ const proxiedPost = $.post;
-$.post = function() {
- let element: HTMLInputElement | null = null;
- if (arguments[0].endsWith("MISPetitionSmsSend.action")) {
- element = document.querySelector("input[name=mobile_Code]") as HTMLInputElement;
- } else if (arguments[0].endsWith("MISPetitionEmailSend.action")) {
- element = document.querySelector("input[name=txtemail_Code]") as HTMLInputElement;
- }
+ $.post = function() {
+ let element: HTMLInputElement | null = null;
+ if (arguments[0].endsWith("MISPetitionSmsSend.action")) {
+ element = document.querySelector("input[name=mobile_Code]") as HTMLInputElement;
+ } else if (arguments[0].endsWith("MISPetitionEmailSend.action")) {
+ element = document.querySelector("input[name=txtemail_Code]") as HTMLInputElement;
+ }
- if (element) {
- const callback = arguments[2];
- arguments[2] = (data: any) => {
- element!.value = data?.messageShow || "";
- callback(data);
- };
- }
+ if (element) {
+ const callback = arguments[2];
+ arguments[2] = (data: any) => {
+ element!.value = data?.messageShow || "";
+ callback(data);
+ };
+ }
- return proxiedPost.apply(this, Array.from(arguments) as any);
-};
+ return proxiedPost.apply(this, Array.from(arguments) as any);
+ };
+});