From 95becf369822cbb74f4cefb5658f3ff97e164d6e Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:22:41 +0530 Subject: Using jquery for injected codes to maintain consistency. --- src/scripts.json | 3 +- src/scripts/captcha/know-your-property.ts | 4 + src/scripts/functionality/application-receipt.ts | 35 +++++---- src/scripts/functionality/mutation-application.ts | 10 +-- .../download-information-pdf-page-content.html | 15 ++-- src/scripts/functionality/view-khatian/index.ts | 85 ++++++++++++---------- src/scripts/login.ts | 26 +++---- src/scripts/stop-blocking.ts | 8 +- src/shared/generate-web-page.ts | 3 +- 9 files changed, 97 insertions(+), 92 deletions(-) create mode 100644 src/scripts/captcha/know-your-property.ts (limited to 'src') diff --git a/src/scripts.json b/src/scripts.json index 8679f6f..ca5062c 100644 --- a/src/scripts.json +++ b/src/scripts.json @@ -8,7 +8,8 @@ "otps/mutation-application.ts": "MuteApplication.action", "otps/warish-application.ts": "WarishAppViewAction.action", "functionality/mutation-application.ts": "MuteApplication.action", - "functionality/view-khatian/index.ts": "KnowYourProperty.action" + "functionality/view-khatian/index.ts": "KnowYourProperty.action", + "captcha/know-your-property.ts": "KnowYourProperty.action" }, "loaded": { "functionality/application-receipt.ts": "Apprecrep.action" diff --git a/src/scripts/captcha/know-your-property.ts b/src/scripts/captcha/know-your-property.ts new file mode 100644 index 0000000..ae74b92 --- /dev/null +++ b/src/scripts/captcha/know-your-property.ts @@ -0,0 +1,4 @@ +document.addEventListener("DOMContentLoaded", () => { + (window as any).validateCaptcha = () => true; + $("#khatianPlotDiv > div:nth-child(6) > div").hide(); +}); diff --git a/src/scripts/functionality/application-receipt.ts b/src/scripts/functionality/application-receipt.ts index 878b910..704d865 100644 --- a/src/scripts/functionality/application-receipt.ts +++ b/src/scripts/functionality/application-receipt.ts @@ -1,21 +1,20 @@ -const receiptFormElement = document.getElementById("form_reprint_request") as HTMLElement; -receiptFormElement.removeAttribute("id"); -receiptFormElement.removeAttribute("name"); -receiptFormElement.removeAttribute("onsubmit"); -receiptFormElement.removeAttribute("target"); -receiptFormElement.removeAttribute("autocomplete"); -receiptFormElement.removeAttribute("rel"); +$("#form_reprint_request") + .removeAttr("id") + .removeAttr("name") + .removeAttr("onsubmit") + .removeAttr("target") + .removeAttr("autocomplete") + .removeAttr("rel"); -let captchaElement = document.querySelector("#werter > div > div:nth-child(4)") as HTMLElement; +const captchaElement = $("#werter > div > div:nth-child(4)"); -if (captchaElement) { - captchaElement = captchaElement!; - const captchaValueElement = document.getElementById("captchaText") as HTMLInputElement; - const captchaFieldElement = document.querySelector("[name=txtDrawText]") as HTMLInputElement; - const removeCaptcha = () => { - captchaFieldElement.value = captchaValueElement.value; - captchaElement.style.display = "none"; - setTimeout(removeCaptcha, 1000); - }; - removeCaptcha(); +if (captchaElement.length > 0) { + const captchaValueElement = $("#captchaText"); + const captchaFieldElement = $("[name=txtDrawText]"); + + setInterval(() => { + captchaFieldElement.val("FFFFFF"); + captchaValueElement.val("FFFFFF"); + captchaElement.hide(); + }, 1000); } diff --git a/src/scripts/functionality/mutation-application.ts b/src/scripts/functionality/mutation-application.ts index afc133f..c212823 100644 --- a/src/scripts/functionality/mutation-application.ts +++ b/src/scripts/functionality/mutation-application.ts @@ -5,11 +5,11 @@ const sanghaFacilitationCentreBannerUrl = chrome.runtime.getURL("/assets/sangha- document.addEventListener("DOMContentLoaded", () => { observeDOM(() => { - const formElement = document.querySelector("#form_MutationApplication > div > div:nth-child(14) > div.col-sm-2.btreset > form"); - const submitButtonElement = document.getElementById("btnDeclareForm"); - if (formElement && submitButtonElement) { - formElement.removeAttribute("action"); - submitButtonElement.addEventListener("click", e => { + const formElement = $("#form_MutationApplication > div > div:nth-child(14) > div.col-sm-2.btreset > form"); + const submitButtonElement = $("#btnDeclareForm"); + if (formElement.length > 0 && submitButtonElement.length > 0) { + formElement.removeAttr("action"); + submitButtonElement.click(e => { e.preventDefault(); (async () => { diff --git a/src/scripts/functionality/view-khatian/download-information-pdf-page-content.html b/src/scripts/functionality/view-khatian/download-information-pdf-page-content.html index e91c15e..44ced4f 100644 --- a/src/scripts/functionality/view-khatian/download-information-pdf-page-content.html +++ b/src/scripts/functionality/view-khatian/download-information-pdf-page-content.html @@ -1,4 +1,10 @@
+