diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-03-27 14:21:49 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-03-27 14:25:45 +0530 |
| commit | 5955bd821303cffa35263c41286339fb28e7536b (patch) | |
| tree | 98344fe12d6fc4b6003ec1fdcafbc61fc613510c /src/shared | |
| parent | 84f86da2faab3af73e3a55ab576ca14a0d38259e (diff) | |
| download | banglar-bhumi-utils-5955bd821303cffa35263c41286339fb28e7536b.tar.gz banglar-bhumi-utils-5955bd821303cffa35263c41286339fb28e7536b.zip | |
Added auto fill otp for mutation application.
Scoping the outputs of all scripts in iife.
Using webpack-merge to merge configuration options.
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/autofill-otp.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/shared/autofill-otp.ts b/src/shared/autofill-otp.ts new file mode 100644 index 0000000..e05ea7c --- /dev/null +++ b/src/shared/autofill-otp.ts @@ -0,0 +1,31 @@ +type AutofillOTPRule = readonly [string, string] + +let otpAutofillList: AutofillOTPRule[] = []; + +document.addEventListener("DOMContentLoaded", () => { + const proxiedPost = $.post; + + $.post = function() { + for (const rule of otpAutofillList) { + if (arguments[0].endsWith(rule[0])) { + const element: HTMLInputElement | null = document.querySelector(rule[1]) as HTMLInputElement | null; + + if (element) { + const callback = arguments[2]; + arguments[2] = (data: any) => { + element!.value = data?.messageShow || ""; + callback(data); + }; + } + + break; + } + } + + return proxiedPost.apply(this, Array.from(arguments) as any); + }; +}); + +export const addAutofillOtps = (addedOTPAutofillList: AutofillOTPRule[]) => { + otpAutofillList = otpAutofillList.concat(addedOTPAutofillList); +}; |
