aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2024-03-12 14:22:41 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2024-03-12 14:22:41 +0530
commit95becf369822cbb74f4cefb5658f3ff97e164d6e (patch)
treee00c49ed93744d4e97d9c9460baf2dc5fec84e86
parenta90f2e98c72ae2e04ba8b65e9a316eb08b5d6bea (diff)
downloadbanglar-bhumi-utils-95becf369822cbb74f4cefb5658f3ff97e164d6e.tar.gz
banglar-bhumi-utils-95becf369822cbb74f4cefb5658f3ff97e164d6e.zip
Using jquery for injected codes to maintain consistency.
-rw-r--r--src/scripts.json3
-rw-r--r--src/scripts/captcha/know-your-property.ts4
-rw-r--r--src/scripts/functionality/application-receipt.ts35
-rw-r--r--src/scripts/functionality/mutation-application.ts10
-rw-r--r--src/scripts/functionality/view-khatian/download-information-pdf-page-content.html15
-rw-r--r--src/scripts/functionality/view-khatian/index.ts85
-rw-r--r--src/scripts/login.ts26
-rw-r--r--src/scripts/stop-blocking.ts8
-rw-r--r--src/shared/generate-web-page.ts3
9 files changed, 97 insertions, 92 deletions
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 @@
<div id="content">
+ <style type="text/css" media="print">
+ @page {
+ size: A4;
+ margin: 0;
+ }
+ </style>
<style>
* {
box-sizing: border-box !important;
@@ -184,11 +190,6 @@
width: 50%;
}
- @page {
- size: A4;
- margin: 0 0 5rem 0;
- }
-
footer {
heigth: 5rem;
width: 100%;
@@ -202,10 +203,6 @@
bottom: 0;
}
- @page {
- size: A4;
- }
-
body {
width: 210mm !important;
height: 297mm !important;
diff --git a/src/scripts/functionality/view-khatian/index.ts b/src/scripts/functionality/view-khatian/index.ts
index 38e500b..1ca37c5 100644
--- a/src/scripts/functionality/view-khatian/index.ts
+++ b/src/scripts/functionality/view-khatian/index.ts
@@ -1,4 +1,5 @@
import { generateWebPage } from "@/shared/generate-web-page";
+import { interceptPost } from "@/shared/intercept-jquery-ajax";
import getDownloadInformationPDFPageContent from "@/scripts/functionality/view-khatian/download-information-pdf-page-content.html";
declare function load(): void;
@@ -6,14 +7,12 @@ declare function load(): void;
const sanghaFacilitationCentreBannerUrl = chrome.runtime.getURL("/assets/sangha-facilitation-centre-banner.jpg");
document.addEventListener("DOMContentLoaded", () => {
- const proxiedPost = $.post;
+ const submitButtonElement = $("#khbutton");
+ const separatorElement = $("#bodycover > div > form > hr:nth-child(2)");
+ const formElement = $("#bodycover > div > form");
+ let downloadPDFButton: JQuery<HTMLButtonElement> | null = null;
- const submitButtonElement = document.querySelector("#khbutton") as HTMLButtonElement;
- const separatorElement = document.querySelector("#bodycover > div > form > hr:nth-child(2)") as HTMLElement;
- const formElement = document.querySelector("#bodycover > div > form") as HTMLElement;
- let downloadPDFButton: HTMLButtonElement | null = null;
-
- const submitButtonElementComputedStyles = window.getComputedStyle(submitButtonElement);
+ const submitButtonElementComputedStyles = window.getComputedStyle(submitButtonElement[0]);
const styles = Array.from(submitButtonElementComputedStyles)
.reduce(
(str, property) => `${str}${property}:${submitButtonElementComputedStyles.getPropertyValue(property)};`,
@@ -21,60 +20,66 @@ document.addEventListener("DOMContentLoaded", () => {
);
const getValueOfSelectElement = (selector: string) => {
- const element = document.querySelector(selector) as HTMLSelectElement;
+ const element = document.querySelector<HTMLSelectElement>(selector)!;
return element.options[element.selectedIndex].text;
};
let isPlotInformation: boolean | null = null;
const downloadInformationPDF = () => {
- generateWebPage(getDownloadInformationPDFPageContent({
- sanghaFacilitationCentreBannerUrl,
- isPlotInformation: !!isPlotInformation,
- details: document.getElementById(isPlotInformation ? "plotdetails" : "khdetails")!.innerHTML,
- district: getValueOfSelectElement("#lstDistrictCode1"),
- block: getValueOfSelectElement("#lstBlockCode1"),
- mouza: getValueOfSelectElement("#lstMouzaList")
- }));
+ generateWebPage(
+ getDownloadInformationPDFPageContent({
+ sanghaFacilitationCentreBannerUrl,
+ isPlotInformation: !!isPlotInformation,
+ details: $(isPlotInformation ? "#plotdetails" : "#khdetails").html(),
+ district: getValueOfSelectElement("#lstDistrictCode1"),
+ block: getValueOfSelectElement("#lstBlockCode1"),
+ mouza: getValueOfSelectElement("#lstMouzaList")
+ }),
+ isPlotInformation
+ ? "Plot Details"
+ : "Khatian Details"
+ );
};
- $.post = function() {
- if (arguments[0].startsWith("plotDetailsAction_LandInfo.action")) {
- isPlotInformation = true;
- } else if (arguments[0].startsWith("khDetailsAction_LandInfo.action")) {
- isPlotInformation = false;
- }
-
+ const showDownloadButton = (args: any) => {
if (isPlotInformation !== null) {
- const callback = arguments[2];
- arguments[2] = (data: any) => {
+ const callback = args[2];
+ args[2] = (data: any) => {
callback(data);
- const tableElement = document.querySelector(isPlotInformation
+ const tableElement = $(isPlotInformation
? "#plotdetails > div:nth-child(1) > div:nth-child(4) > table > tbody"
: "#khdetails > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody"
- ) as HTMLElement | null;
+ );
- if (tableElement) {
- tableElement.style.height = "auto";
- tableElement.style.width = "100%";
+ if (tableElement.length > 0) {
+ tableElement.css("height", "auto");
+ tableElement.css("width", "100%");
if (!downloadPDFButton) {
- downloadPDFButton = document.createElement("button");
- downloadPDFButton.innerHTML = "Download PDF";
- downloadPDFButton.style.cssText = styles;
- downloadPDFButton.style.width = "auto";
- downloadPDFButton.style.marginBottom = "1rem";
- downloadPDFButton.addEventListener("click", downloadInformationPDF);
- formElement.insertBefore(downloadPDFButton, separatorElement);
+ downloadPDFButton = $(document.createElement("button"));
+ downloadPDFButton.html("Download PDF");
+ downloadPDFButton[0].style.cssText = styles;
+ downloadPDFButton.css("width", "auto");
+ downloadPDFButton.css("margin-bottom", "1rem");
+ downloadPDFButton.click(downloadInformationPDF);
+ formElement[0].insertBefore(downloadPDFButton[0], separatorElement[0]);
}
} else if (downloadPDFButton) {
- formElement.removeChild(downloadPDFButton);
+ $(downloadPDFButton).remove();
isPlotInformation = null;
downloadPDFButton = null;
}
}
}
+ };
- return proxiedPost.apply(this, Array.from(arguments) as any);
- }
+ interceptPost("plotDetailsAction_LandInfo.action", args => {
+ isPlotInformation = true;
+ showDownloadButton(args);
+ });
+ interceptPost("plotDetailsAction_LandInfo.action", args => {
+ isPlotInformation = false;
+ showDownloadButton(args);
+ });
});
diff --git a/src/scripts/login.ts b/src/scripts/login.ts
index 98720de..7bc6118 100644
--- a/src/scripts/login.ts
+++ b/src/scripts/login.ts
@@ -10,9 +10,9 @@ interceptPost("viewLoginAreaAction", args => {
captchaValueElement.val("FFFFFF");
(window as any).DrawLoginCaptcha = () => {};
(window as any).validateLoginCaptcha = () => true;
- captchaValueElement.css("display", "none");
- captchaInputElement.css("display", "none");
- $(".captcharefresh").css("display", "none");
+ captchaValueElement.hide();
+ captchaInputElement.hide();
+ $(".captcharefresh").hide();
}
});
interceptPost("viewPasswordRecoveryArea", args => {
@@ -24,9 +24,9 @@ interceptPost("viewPasswordRecoveryArea", args => {
captchaInputElement.val("FFFFFF");
captchaValueElement.val("FFFFFF");
(window as any).Captcha = () => {};
- captchaValueElement.css("display", "none");
- captchaInputElement.css("display", "none");
- $("#captchaRef").css("display", "none");
+ captchaValueElement.hide();
+ captchaInputElement.hide();
+ $("#captchaRef").hide();
}
});
interceptPost("login.action", args => {
@@ -39,7 +39,7 @@ interceptPost("login.action", args => {
callback(data);
$("#txtInput").val("FFFFFF");
- $("#beforeLoginDiv").css("display", "none");
+ $("#beforeLoginDiv").hide();
$("#afterLoginDiv").css("display", "block");
$("#afterLoginLabel").css("display", "block");
const username = atob(loginData.username.split("RGxycyMxMjM=")[1]);
@@ -61,9 +61,9 @@ interceptGet("viewRegistrationAreaAction", args => {
const captchaValueElement = $("#regCaptcha");
captchaInputElement.val("FFFFFF");
captchaValueElement.val("FFFFFF");
- $("#registrationForm > div > div:nth-child(5) > div:nth-child(3)").css("display", "none");
- $("#registrationForm > div > div:nth-child(5) > div:nth-child(4)").css("display", "none");
- $("#registrationForm > div > div:nth-child(5) > div:nth-child(5)").css("display", "none");
+ $("#registrationForm > div > div:nth-child(5) > div:nth-child(3)").hide();
+ $("#registrationForm > div > div:nth-child(5) > div:nth-child(4)").hide();
+ $("#registrationForm > div > div:nth-child(5) > div:nth-child(5)").hide();
(window as any).DrawRegistrationCaptcha = () => {};
(window as any).validateRegistrationCaptcha = () => true;
}
@@ -77,9 +77,9 @@ interceptGet("viewChangePasswordAction", args => {
captchaValueElement.val("FFFFFF");
captchaInputElement.val("FFFFFF");
(window as any).DrawLoginCaptcha = () => {};
- captchaValueElement.css("display", "none");
- captchaInputElement.css("display", "none");
- $(".captcharefresh").css("display", "none");
+ captchaValueElement.hide();
+ captchaInputElement.hide();
+ $(".captcharefresh").hide();
}
});
diff --git a/src/scripts/stop-blocking.ts b/src/scripts/stop-blocking.ts
index bf9ae4e..b8f4783 100644
--- a/src/scripts/stop-blocking.ts
+++ b/src/scripts/stop-blocking.ts
@@ -1,23 +1,21 @@
document.addEventListener("DOMContentLoaded", () => {
const proxiedBind = $.prototype.bind;
-
$.prototype.bind = function() {
if (arguments[0].trim() === "cut copy paste") {
- arguments[1] = (e: any) => {};
+ arguments[1] = (_: any) => {};
}
return proxiedBind.apply(this, Array.from(arguments) as any);
}
const proxiedKeydown = $.prototype.keydown;
-
$.prototype.keydown = function() {
- arguments[0] = (e: any) => true;
+ arguments[0] = (_: any) => true;
return proxiedKeydown.apply(this, Array.from(arguments) as any);
}
$.prototype.bind = proxiedBind;
$.prototype.keydown = proxiedKeydown;
- document.oncontextmenu = new Function("return true") as any;
+ document.oncontextmenu = () => true;
});
diff --git a/src/shared/generate-web-page.ts b/src/shared/generate-web-page.ts
index d7de655..1771e15 100644
--- a/src/shared/generate-web-page.ts
+++ b/src/shared/generate-web-page.ts
@@ -1,9 +1,10 @@
-export const generateWebPage = (content: string) => {
+export const generateWebPage = (content: string, title: string = "Banglar Bhumi") => {
const tab = window.open("about:blank", "_blank");
if (tab) {
tab.document.write(content);
tab.document.close();
+ tab.document.title = title;
tab.focus();
}
};