aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scripts.json3
-rw-r--r--src/scripts/captcha.ts20
-rw-r--r--src/scripts/login.ts112
-rw-r--r--src/scripts/stop-blocking.ts26
-rw-r--r--src/shared/intercept-jquery-ajax.ts41
-rw-r--r--src/shared/script-injector.ts6
6 files changed, 138 insertions, 70 deletions
diff --git a/src/scripts.json b/src/scripts.json
index 1d7c084..8679f6f 100644
--- a/src/scripts.json
+++ b/src/scripts.json
@@ -2,7 +2,7 @@
"injected-before": {
"stop-blocking.ts": "*"
},
- "injected": {
+ "injected-after": {
"login.ts": "*",
"otps/grievance-application.ts": "GrievAppViewAction.action",
"otps/mutation-application.ts": "MuteApplication.action",
@@ -11,7 +11,6 @@
"functionality/view-khatian/index.ts": "KnowYourProperty.action"
},
"loaded": {
- "captcha.ts": "*",
"functionality/application-receipt.ts": "Apprecrep.action"
}
}
diff --git a/src/scripts/captcha.ts b/src/scripts/captcha.ts
deleted file mode 100644
index 453443c..0000000
--- a/src/scripts/captcha.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const autofillCaptcha = () => {
- const captchas = Array.from(document.querySelectorAll("#captchaText")) as HTMLInputElement[];
-
- for (const captcha of captchas) {
- const captchaParentElement = captcha.parentElement!;
-
- if (captchaParentElement.id === "drawTextSpan") {
- const captchaInput = captchaParentElement.parentElement!.querySelector("#drawText1") as HTMLInputElement | null;
-
- if (captchaInput) {
- captchaInput.value = captcha.value.replaceAll(" ", "");
- captchaParentElement.parentElement!.style.display = "none";
- }
- }
- }
-
- setTimeout(autofillCaptcha, 1000);
-};
-
-autofillCaptcha();
diff --git a/src/scripts/login.ts b/src/scripts/login.ts
index d2e7594..6302cd3 100644
--- a/src/scripts/login.ts
+++ b/src/scripts/login.ts
@@ -1,46 +1,88 @@
+import { interceptPost, interceptGet } from "@/shared/intercept-jquery-ajax";
+
document.addEventListener("DOMContentLoaded", () => {
const proxiedPost = $.post;
+ const proxiedGet = $.get;
- $.post = function() {
- if (arguments[0].endsWith("viewLoginAreaAction")) {
+ interceptPost("viewLoginAreaAction", args => {
+ const callback = args[1];
+ args[1] = (html: any) => {
+ callback(html);
+ const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement;
+ const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement;
+ captchaValueElement.value = "FFFFFF";
+ captchaInputElement.value = "FFFFFF";
(window as any).DrawLoginCaptcha = () => {};
- const callback = arguments[1];
- arguments[1] = (html: any) => {
- callback(html);
- const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement;
- const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement;
- captchaValueElement.value = "ffffff";
- captchaInputElement.value = "ffffff";
- captchaValueElement.style.display = "none";
- captchaInputElement.style.display = "none";
- (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none";
- }
- } else if (arguments[0].endsWith("viewPasswordRecoveryArea")) {
+ (window as any).validateLoginCaptcha = () => true;
+ captchaValueElement.style.display = "none";
+ captchaInputElement.style.display = "none";
+ (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none";
+ }
+ });
+ interceptPost("viewPasswordRecoveryArea", args => {
+ const callback = args[1];
+ args[1] = (html: any) => {
+ callback(html);
+ const captchaInputElement = document.getElementById("dText") as HTMLInputElement;
+ const captchaValueElement = document.getElementById("captaText") as HTMLInputElement;
+ captchaValueElement.value = "FFFFFF";
+ captchaInputElement.value = "FFFFFF";
(window as any).Captcha = () => {};
- const callback = arguments[1];
- arguments[1] = (html: any) => {
- callback(html);
- const captchaInputElement = document.getElementById("dText") as HTMLInputElement;
- const captchaValueElement = document.getElementById("captaText") as HTMLInputElement;
- captchaValueElement.value = "ffffff";
- captchaInputElement.value = "ffffff";
- captchaValueElement.style.display = "none";
- captchaInputElement.style.display = "none";
- (document.getElementById("captchaRef") as HTMLElement).style.display = "none";
+ captchaValueElement.style.display = "none";
+ captchaInputElement.style.display = "none";
+ (document.getElementById("captchaRef") as HTMLElement).style.display = "none";
+ }
+ });
+ interceptPost("login.action", args => {
+ const callback = args[2];
+ args[2] = (data: any) => {
+ if (!data.exception && data.checkmsg === "success") {
+ window.localStorage.setItem("loginData", btoa(JSON.stringify(args[1])));
}
- } else if (arguments[0].endsWith("login.action")) {
- const callback = arguments[2];
- arguments[2] = (data: any) => {
- if (!data.exception && data.checkmsg === "success") {
- window.localStorage.setItem("loginData", btoa(JSON.stringify(arguments[1])));
- }
- callback(data);
- };
+ callback(data);
+ (document.getElementById("txtInput") as HTMLInputElement).value = "FFFFFF";
+ };
+ });
+ interceptPost("changePassword.action", args => {
+ const callback = args[2];
+ args[2] = (data: any) => {
+ callback(data);
+ (document.getElementById("txtInput") as HTMLInputElement).value = "FFFFFF";
+ };
+ });
+ interceptGet("viewRegistrationAreaAction", args => {
+ const callback = args[1];
+ args[1] = (html: any) => {
+ callback(html);
+ const captchaInputElement = document.getElementById("regInputCaptcha") as HTMLInputElement;
+ const captchaValueElement = document.getElementById("regCaptcha") as HTMLInputElement;
+ captchaValueElement.value = "FFFFFF";
+ captchaInputElement.value = "FFFFFF";
+ (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(3)") as HTMLElement).style.display = "none";
+ (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(4)") as HTMLElement).style.display = "none";
+ (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(5)") as HTMLElement).style.display = "none";
+ (window as any).DrawRegistrationCaptcha = () => {};
+ (window as any).validateRegistrationCaptcha = () => true;
}
-
- return proxiedPost.apply(this, Array.from(arguments) as any);
- };
+ });
+ interceptGet("logout", args => {
+ window.localStorage.removeItem("loginData");
+ });
+ interceptGet("viewChangePasswordAction", args => {
+ const callback = args[1];
+ args[1] = (html: any) => {
+ callback(html);
+ const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement;
+ const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement;
+ captchaValueElement.value = "FFFFFF";
+ captchaInputElement.value = "FFFFFF";
+ (window as any).DrawLoginCaptcha = () => {};
+ captchaValueElement.style.display = "none";
+ captchaInputElement.style.display = "none";
+ (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none";
+ }
+ });
setInterval(() => {
let loginData = window.localStorage.getItem("loginData");
diff --git a/src/scripts/stop-blocking.ts b/src/scripts/stop-blocking.ts
index f418f66..bf9ae4e 100644
--- a/src/scripts/stop-blocking.ts
+++ b/src/scripts/stop-blocking.ts
@@ -1,22 +1,22 @@
-const proxiedBind = $.prototype.bind;
+document.addEventListener("DOMContentLoaded", () => {
+ const proxiedBind = $.prototype.bind;
-$.prototype.bind = function() {
- if (arguments[0].trim() === "cut copy paste") {
- arguments[1] = (e: any) => {};
- }
+ $.prototype.bind = function() {
+ if (arguments[0].trim() === "cut copy paste") {
+ arguments[1] = (e: any) => {};
+ }
- return proxiedBind.apply(this, Array.from(arguments) as any);
-}
+ return proxiedBind.apply(this, Array.from(arguments) as any);
+ }
-const proxiedKeydown = $.prototype.keydown;
+ const proxiedKeydown = $.prototype.keydown;
-$.prototype.keydown = function() {
- arguments[0] = (e: any) => true;
+ $.prototype.keydown = function() {
+ arguments[0] = (e: any) => true;
- return proxiedKeydown.apply(this, Array.from(arguments) as any);
-}
+ return proxiedKeydown.apply(this, Array.from(arguments) as any);
+ }
-document.addEventListener("DOMContentLoaded", () => {
$.prototype.bind = proxiedBind;
$.prototype.keydown = proxiedKeydown;
document.oncontextmenu = new Function("return true") as any;
diff --git a/src/shared/intercept-jquery-ajax.ts b/src/shared/intercept-jquery-ajax.ts
new file mode 100644
index 0000000..efcb555
--- /dev/null
+++ b/src/shared/intercept-jquery-ajax.ts
@@ -0,0 +1,41 @@
+type InterceptJqueryAjaxCallback = (args: any) => void;
+
+interface InterceptJqueryEntry {
+ url: string;
+ callback: InterceptJqueryAjaxCallback;
+};
+
+const postIntercepts: InterceptJqueryEntry[] = [];
+const getIntercepts: InterceptJqueryEntry[] = [];
+
+document.addEventListener("DOMContentLoaded", () => {
+ const proxiedPost = $.post;
+ const proxiedGet = $.get;
+
+ $.post = function() {
+ for (const { url, callback } of postIntercepts) {
+ if (arguments[0].endsWith(url)) {
+ callback(arguments);
+ }
+ }
+
+ return proxiedPost.apply(this, Array.from(arguments) as any);
+ };
+ $.get = function() {
+ for (const { url, callback } of getIntercepts) {
+ if (arguments[0].endsWith(url)) {
+ callback(arguments);
+ }
+ }
+
+ return proxiedGet.apply(this, Array.from(arguments) as any);
+ };
+});
+
+export const interceptPost = (url: string, callback: InterceptJqueryAjaxCallback) => {
+ postIntercepts.push({ url, callback });
+};
+
+export const interceptGet = (url: string, callback: InterceptJqueryAjaxCallback) => {
+ getIntercepts.push({ url, callback });
+};
diff --git a/src/shared/script-injector.ts b/src/shared/script-injector.ts
new file mode 100644
index 0000000..7abc510
--- /dev/null
+++ b/src/shared/script-injector.ts
@@ -0,0 +1,6 @@
+export const injectScriptHead = (src: string) => {
+ const s = document.createElement("script") as HTMLScriptElement;
+ s.src = chrome.runtime.getURL(src);
+ // s.onload = () => s.remove();
+ (document.head || document.documentElement).append(s);
+};